summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-04-06 04:22:01 (EDT)
committer pelder2006-04-06 04:22:01 (EDT)
commit0028d75de1c91afa30ee03e0eea94247739531ad (patch)
treedcd5e5fc068459bacd5041060dd1d4a6b34f79df
parente27e5303e86f576631b0c764b1aecb351277bb08 (diff)
downloadorg.eclipse.jet-0028d75de1c91afa30ee03e0eea94247739531ad.zip
org.eclipse.jet-0028d75de1c91afa30ee03e0eea94247739531ad.tar.gz
org.eclipse.jet-0028d75de1c91afa30ee03e0eea94247739531ad.tar.bz2
[131200] Revamp Main tab of JET Transform run dialog
-rw-r--r--plugins/org.eclipse.jet.ui/plugin.xml32
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java20
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties11
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java166
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java3
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JETTransformMainTab.java306
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java28
7 files changed, 388 insertions, 178 deletions
diff --git a/plugins/org.eclipse.jet.ui/plugin.xml b/plugins/org.eclipse.jet.ui/plugin.xml
index 2958e80..afa6095 100644
--- a/plugins/org.eclipse.jet.ui/plugin.xml
+++ b/plugins/org.eclipse.jet.ui/plugin.xml
@@ -93,5 +93,37 @@
</objectContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.editors.annotationTypes">
+ <type
+ markerSeverity="2"
+ markerType="org.eclipse.jet.runtimeProblem"
+ name="org.eclipse.jet.runtime.error"
+ super="org.eclipse.ui.workbench.texteditor.error"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.markerAnnotationSpecification">
+ <specification
+ annotationType="org.eclipse.jet.runtime.error"
+ colorPreferenceKey="jetErrorColor"
+ colorPreferenceValue="255,0,0"
+ icon="icons/JETRuntimeError.gif"
+ includeOnPreferencePage="true"
+ isGoToNextNavigationTarget="false"
+ isGoToNextNavigationTargetKey="jetErrorIsGoToNextNavigationTarget"
+ isGoToPreviousNavigationTarget="false"
+ isGoToPreviousNavigationTargetKey="jetErrorIsGoToPrevNavigationTarget"
+ label="JET Runtime Error"
+ overviewRulerPreferenceKey="jetErrorOverviewRuler"
+ overviewRulerPreferenceValue="true"
+ showInNextPrevDropdownToolbarAction="true"
+ showInNextPrevDropdownToolbarActionKey="jetErrorShowInNextPrevDowndownToolbarAction"
+ textPreferenceKey="jetErrorText"
+ textPreferenceValue="true"
+ textStylePreferenceKey="jetErrorTextStyle"
+ textStylePreferenceValue="SQUIGGLES"
+ verticalRulerPreferenceKey="jetErrorVerticalRuler"
+ verticalRulerPreferenceValue="true"/>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java
index 0f15ec2..9ba1121 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java
@@ -13,6 +13,22 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
+ public static String JETTransformMainTab_BrowseButtonLabel;
+
+ public static String JETTransformMainTab_DescriptionLabel;
+
+ public static String JETTransformMainTab_IdLabel;
+
+ public static String JETTransformMainTab_NameLabel;
+
+ public static String JETTransformMainTab_SelectResourceDialogTitle;
+
+ public static String JETTransformMainTab_TransformGroupLabel;
+
+ public static String JETTransformMainTab_TransformInputGroup;
+
+ public static String LaunchShortcut_DefaultLaunchName;
+
public static String NewProjectWizard_WindowTitle;
public static String NewProjectWizard_ErrorCreatingProject;
@@ -23,10 +39,6 @@ public class Messages extends NLS {
public static String NewProjectWizard_MainPageDescription;
- public static String LaunchWizard_MainTab_TransformIdText;
-
- public static String LaunchWizard_MainTab_SourceText;
-
public static String LaunchWizard_MainTab_Name;
public static String JET2TemplateAccess_ErrorLoadingTemplateStore;
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties
index 5028284..cc8d99e 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties
@@ -15,13 +15,20 @@ NewProjectWizard_MainPageTabText=Main
NewProjectWizard_MainPageTitle=JET Transform Project
NewProjectWizard_MainPageDescription=Create a JET Transform Project in the workspace.
-LaunchWizard_MainTab_TransformIdText=Transform id:
-LaunchWizard_MainTab_SourceText=Source:
+LaunchShortcut_DefaultLaunchName=JET Transform
LaunchWizard_MainTab_Name=Main
JET2TemplateAccess_ErrorLoadingTemplateStore=Error loading editor template store.
+JETTransformMainTab_SelectResourceDialogTitle=Select resource
UnloadAction_DialogTitle=Unload JET Transform
UnloadAction_UnloadSuccessful=Unloaded "{0}". Refresh the Plugins View to confirm success.
UnloadAction_UnloadFailed=Failed to unloaded "{0}". Reason: {1}.
UnloadAction_NotLoaded=Bundle is not loaded "{0}". No action was taken.
+
+JETTransformMainTab_TransformGroupLabel=Transform
+JETTransformMainTab_DescriptionLabel=Description:
+JETTransformMainTab_NameLabel=Name:
+JETTransformMainTab_IdLabel=ID:
+JETTransformMainTab_TransformInputGroup=Transform Input
+JETTransformMainTab_BrowseButtonLabel=Browse...
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java
deleted file mode 100644
index 94519a7..0000000
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *
- * </copyright>
- *
- * $Id$
- */
-
-package org.eclipse.jet.internal.ui.launch;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.jet.JET2Platform;
-import org.eclipse.jet.internal.launch.JET2TransformationDelegate;
-import org.eclipse.jet.internal.ui.l10n.Messages;
-import org.eclipse.jet.ui.Activator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Main tab for JET Transform Launch configuration
- *
- */
-public class JET2TransformMainTab extends AbstractLaunchConfigurationTab
- implements ILaunchConfigurationTab {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private Text idText;
- private Text sourceText;
- private Image tabImage = null;
-
- /**
- *
- */
- public JET2TransformMainTab() {
- super();
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
-
- IFile resource = null;
-
- if(selection instanceof IStructuredSelection) {
- IStructuredSelection iss = (IStructuredSelection) selection;
- Object firstElement = iss.getFirstElement();
- if(firstElement instanceof IFile) {
- resource = (IFile)firstElement;
- } else if (firstElement instanceof IAdaptable) {
- resource = (IFile) ((IAdaptable)firstElement).getAdapter(IFile.class);
- }
- }
- if(resource != null) {
- configuration.setAttribute(JET2TransformationDelegate.SOURCE,
- resource.getFullPath().toString());
-
- try {
- if(resource.getProject().hasNature(JET2Platform.JET2_NATURE_ID))
- {
- // XXX Slight hack. Should get the id, not the name.
- configuration.setAttribute(JET2TransformationDelegate.ID, resource.getProject().getName());
- }
- } catch (CoreException e) {
- // just ignore the error, we know the project exists and is open, we have a
- // file in it!
- }
- }
- configuration.setAttribute(JET2TransformationDelegate.ID, EMPTY_STRING);
- }
-
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(JET2TransformationDelegate.ID, idText.getText());
-
- configuration.setAttribute(JET2TransformationDelegate.SOURCE, sourceText.getText());
-
- }
-
- public void createControl(Composite parent) {
- Composite comp = new Composite(parent, SWT.NONE);
- setControl(comp);
- FormLayout formLayout = new FormLayout();
- formLayout.marginHeight = 3;
- formLayout.marginWidth = 3;
- comp.setLayout(formLayout);
-
- Label label = new Label(comp, SWT.NONE);
- label.setText(Messages.LaunchWizard_MainTab_TransformIdText);
- FormData data = new FormData();
-
- idText = new Text(comp, SWT.SINGLE|SWT.BORDER);
- data = new FormData();
- data.left = new FormAttachment(label);
- data.right = new FormAttachment(100,0);
- idText.setLayoutData(data);
-
- Label label2 = new Label(comp, SWT.NONE);
- label2.setText(Messages.LaunchWizard_MainTab_SourceText);
- data = new FormData();
- data.top = new FormAttachment(label);
- label2.setLayoutData(data);
-
- sourceText = new Text(comp, SWT.SINGLE|SWT.BORDER);
- data = new FormData();
- data.left = new FormAttachment(label2);
- data.top = new FormAttachment(idText);
- data.right = new FormAttachment(100,0);
- sourceText.setLayoutData(data);
- }
-
- public void initializeFrom(ILaunchConfiguration configuration) {
- try {
- idText.setText(configuration.getAttribute(JET2TransformationDelegate.ID, EMPTY_STRING));
- } catch (CoreException e) {
- idText.setText(EMPTY_STRING);
- }
- try {
- sourceText.setText(configuration.getAttribute(JET2TransformationDelegate.SOURCE, EMPTY_STRING));
- } catch (CoreException e) {
- sourceText.setText(EMPTY_STRING);
- }
-
- }
-
- public String getName() {
- return Messages.LaunchWizard_MainTab_Name;
- }
-
- public Image getImage() {
- if(tabImage == null) {
- ImageDescriptor imageDescriptor = Activator.getImageDescriptor("icons/JET2LaunchIcon.gif"); //$NON-NLS-1$
- tabImage = imageDescriptor.createImage();
- }
- return tabImage;
- }
-
- public void dispose() {
- if(tabImage != null) {
- tabImage.dispose();
- }
- super.dispose();
- }
-}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java
index ca81371..fe016db 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java
@@ -39,7 +39,8 @@ public class JET2TransformationTabGroup extends
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new JET2TransformMainTab(),
+// new JET2TransformMainTab(),
+ new JETTransformMainTab(),
new CommonTab(),
};
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JETTransformMainTab.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JETTransformMainTab.java
new file mode 100644
index 0000000..dbad366
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JETTransformMainTab.java
@@ -0,0 +1,306 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.internal.ui.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jet.internal.launch.JET2TransformationDelegate;
+import org.eclipse.jet.internal.ui.l10n.Messages;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
+import org.eclipse.jet.ui.Activator;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ResourceSelectionDialog;
+
+/**
+ * Main tab for JET Launch Configuraitons
+ *
+ */
+public class JETTransformMainTab extends AbstractLaunchConfigurationTab {
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ // input block controls
+ private Text sourceField;
+ private Button workspaceLocationButton;
+
+ private final Listener fListener = new Listener();;
+
+ private Image tabImage;
+ private Combo transformCombo;
+ private Text transformName;
+ private Text transformDescription;
+
+
+ private class Listener extends SelectionAdapter implements ModifyListener
+ {
+
+ public void widgetSelected(SelectionEvent e) {
+ setDirty(true);
+ final Object source = e.getSource();
+ if(source == transformCombo) {
+ handleTransformSelection();
+ }
+ updateLaunchConfigurationDialog();
+ }
+ public void modifyText(ModifyEvent e) {
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ /**
+ *
+ */
+ public JETTransformMainTab() {
+ super();
+ }
+
+ private void handleTransformSelection() {
+ String id = transformCombo.getText();
+ final IJETBundleDescriptor descriptor = JET2Platform.getJETBundleManager().getDescriptor(id);
+ transformName.setText(descriptor.getName());
+ transformDescription.setText(descriptor.getDescription().trim());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.verticalSpacing = 15;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ createInputBlock(composite);
+ createTransformBlock(composite);
+
+ setControl(composite);
+ Dialog.applyDialogFont(composite);
+ }
+
+ /**
+ * @param composite
+ */
+ private void createTransformBlock(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(Messages.JETTransformMainTab_TransformGroupLabel);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createTransformIdSection(group);
+ createTransformNameSection(group);
+ createTransformDescriptionSection(group);
+ }
+
+ private void createTransformDescriptionSection(Group parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(Messages.JETTransformMainTab_DescriptionLabel);
+
+ transformDescription = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 300;
+ gd.heightHint = 40;
+ transformDescription.setLayoutData(gd);
+ }
+
+ private void createTransformNameSection(Group parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(Messages.JETTransformMainTab_NameLabel);
+
+ transformName = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 300;
+ transformName.setLayoutData(gd);
+
+ }
+
+ private void createTransformIdSection(Group parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(Messages.JETTransformMainTab_IdLabel);
+
+ transformCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
+ transformCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ transformCombo.setItems(JET2Platform.getJETBundleManager().getAllTransformIds());
+ transformCombo.addSelectionListener(fListener);
+ }
+
+ private void createInputBlock(Composite parent)
+ {
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(Messages.JETTransformMainTab_TransformInputGroup);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ sourceField = new Text(group, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ sourceField.setLayoutData(gridData);
+ sourceField.addModifyListener(fListener);
+
+ Composite buttonComposite = new Composite(group, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 3;
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(gridData);
+ buttonComposite.setFont(parent.getFont());
+
+ workspaceLocationButton= createPushButton(buttonComposite, Messages.JETTransformMainTab_BrowseButtonLabel, null);
+ workspaceLocationButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ResourceSelectionDialog dialog;
+ dialog = new ResourceSelectionDialog(getShell(),
+ ResourcesPlugin.getWorkspace().getRoot(),
+ Messages.JETTransformMainTab_SelectResourceDialogTitle);
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if (results == null || results.length < 1) {
+ return;
+ }
+ IResource resource = (IResource)results[0];
+ sourceField.setText(resource.getFullPath().makeRelative().toString());
+ }
+ });
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return Messages.LaunchWizard_MainTab_Name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ final String id = configuration.getAttribute(JET2TransformationDelegate.ID, EMPTY_STRING);
+ transformCombo.setText(id);
+ final IJETBundleDescriptor descriptor = JET2Platform.getJETBundleManager().getDescriptor(id);
+ if(descriptor != null)
+ {
+ transformName.setText(descriptor.getName());
+ transformDescription.setText(descriptor.getDescription().trim());
+ }
+ } catch (CoreException e) {
+ transformCombo.setText(EMPTY_STRING);
+ }
+ try {
+ sourceField.setText(configuration.getAttribute(JET2TransformationDelegate.SOURCE, EMPTY_STRING));
+ } catch (CoreException e) {
+ sourceField.setText(EMPTY_STRING);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(JET2TransformationDelegate.ID, transformCombo.getText());
+
+ configuration.setAttribute(JET2TransformationDelegate.SOURCE, sourceField.getText());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
+
+ IFile resource = null;
+ String id = null;
+
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection iss = (IStructuredSelection) selection;
+ Object firstElement = iss.getFirstElement();
+ if(firstElement instanceof IFile) {
+ resource = (IFile)firstElement;
+ } else if (firstElement instanceof IAdaptable) {
+ resource = (IFile) ((IAdaptable)firstElement).getAdapter(IFile.class);
+ }
+ }
+ if(resource != null) {
+ configuration.setAttribute(JET2TransformationDelegate.SOURCE,
+ resource.getFullPath().makeRelative().toString());
+
+ final IProject project = resource.getProject();
+ final IJETBundleDescriptor descriptor = JET2Platform.getProjectDescription(project.getName());
+ if(descriptor != null) {
+ id = descriptor.getId();
+ configuration.setAttribute(JET2TransformationDelegate.ID, id);
+
+
+
+ }
+ }
+ configuration.rename(LaunchShortcut.generateLaunchName(id, resource));
+ }
+
+ public Image getImage() {
+ if(tabImage == null) {
+ ImageDescriptor imageDescriptor = Activator.getImageDescriptor("icons/JET2LaunchIcon.gif"); //$NON-NLS-1$
+ tabImage = imageDescriptor.createImage();
+ }
+ return tabImage;
+ }
+
+ public void dispose() {
+ if(tabImage != null) {
+ tabImage.dispose();
+ }
+ super.dispose();
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java
index 4a57a22..b191384 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java
@@ -28,6 +28,8 @@ import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.internal.launch.JET2TransformationDelegate;
+import org.eclipse.jet.internal.ui.l10n.Messages;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
@@ -75,14 +77,13 @@ public class LaunchShortcut implements ILaunchShortcut {
}
String id = ""; //$NON-NLS-1$
- if(resource.getProject().hasNature(JET2Platform.JET2_NATURE_ID)) {
- // XXX Hack should get project id.
- id = resource.getProject().getName();
+ final IJETBundleDescriptor descriptor = JET2Platform.getProjectDescription(resource.getProject().getName());
+ if(descriptor != null) {
+ id = descriptor.getId();
}
final ILaunchConfigurationWorkingCopy wConfig = configurationType
- .newInstance(null, lm
- .generateUniqueLaunchConfigurationNameFrom(id + " " + resource.getName())); //$NON-NLS-1$
+ .newInstance(null, generateLaunchName(id, resource));
wConfig.setAttribute(JET2TransformationDelegate.ID, id);
wConfig.setAttribute(JET2TransformationDelegate.SOURCE, resource.getFullPath().toString());
final ILaunchConfiguration config = wConfig.doSave();
@@ -109,4 +110,21 @@ public class LaunchShortcut implements ILaunchShortcut {
}
+ public static String generateLaunchName(String id, IResource input)
+ {
+ ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+ String prefix;
+ if (id == null && input == null) {
+ prefix = Messages.LaunchShortcut_DefaultLaunchName;
+ } else if(input == null) {
+ prefix = id;
+ } else if(id == null)
+ {
+ prefix = input.getName();
+ } else {
+ prefix = id + " (" + input.getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ return lm.generateUniqueLaunchConfigurationNameFrom(prefix);
+ }
}