summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-07-13 10:05:26 (EDT)
committerpelder2006-07-13 10:05:26 (EDT)
commitf4e749d5e569666e07674fdc41420b1673fbbecd (patch)
treec996c7e27790eeec22a420e1c2ad6e1ded2c5614
parentca371fdcde2c62f9405cfa472a1b579b192e4d6f (diff)
downloadorg.eclipse.jet-f4e749d5e569666e07674fdc41420b1673fbbecd.zip
org.eclipse.jet-f4e749d5e569666e07674fdc41420b1673fbbecd.tar.gz
org.eclipse.jet-f4e749d5e569666e07674fdc41420b1673fbbecd.tar.bz2
[147036] Change file selection dialog in run configuration
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JETTransformMainTab.java50
1 files changed, 38 insertions, 12 deletions
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
index 83649f7..4d38ae7 100644
--- 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
@@ -23,6 +23,8 @@ 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.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@@ -52,9 +54,13 @@ 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.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ResourceSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* Main tab for JET Launch Configuraitons
@@ -231,22 +237,42 @@ public class JETTransformMainTab extends AbstractLaunchConfigurationTab {
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 = chooseResource(getShell());
+ if(resource != null) {
+ sourceField.setText(resource.getFullPath().makeRelative().toString());
}
- IResource resource = (IResource)results[0];
- sourceField.setText(resource.getFullPath().makeRelative().toString());
}
});
}
-
+
+ private static IResource chooseResource(Shell shell) {
+ IResource resource = null;
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ shell, new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
+
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setAllowMultiple(false);
+ dialog.setTitle(Messages.JETTransformMainTab_SelectResourceDialogTitle);
+ dialog.setMessage(Messages.JETTransformMainTab_SelectResourceDialogTitle);
+ dialog.setValidator(new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ if (selection.length > 0)
+ return new Status(IStatus.OK, Activator.getDefault().getBundle().getSymbolicName(),
+ IStatus.OK, "", null); //$NON-NLS-1$
+
+ return new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(),
+ IStatus.ERROR, "", null); //$NON-NLS-1$
+ }
+ });
+ if (dialog.open() == ElementTreeSelectionDialog.OK) {
+ resource = (IResource) dialog.getFirstResult();
+ }
+ return resource;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/