summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Aubry2012-10-04 05:52:19 (EDT)
committer sbernard2012-10-04 05:59:16 (EDT)
commit4248ad87112a0bd0a7988daa60e8036b65bb059a (patch)
treebf7d0837b5193da1ba88239869c28594c6552bec
parent0c722faec6d02182b56d7a4334d8a37d05beb959 (diff)
downloadorg.eclipse.koneki.ldt-4248ad87112a0bd0a7988daa60e8036b65bb059a.zip
org.eclipse.koneki.ldt-4248ad87112a0bd0a7988daa60e8036b65bb059a.tar.gz
org.eclipse.koneki.ldt-4248ad87112a0bd0a7988daa60e8036b65bb059a.tar.bz2
bug 390674: [remote] Remote launch conf, enhance the script selection
-rw-r--r--plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java60
-rw-r--r--plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/Messages.java2
-rw-r--r--plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/messages.properties2
3 files changed, 29 insertions, 35 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
index 4e67ef4..02a7271 100644
--- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/LuaDialogUtil.java
@@ -16,16 +16,13 @@ import java.util.List;
import org.eclipse.core.resources.IContainer;
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.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.koneki.ldt.core.LuaUtils;
-import org.eclipse.koneki.ldt.ui.internal.Activator;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
@@ -61,41 +58,34 @@ public final class LuaDialogUtil {
}
public static final IFile openSelectScriptFromProjectDialog(Shell shell, IProject project) {
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new WorkbenchLabelProvider());
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider() {
+ @Override
+ public Object[] getElements(Object element) {
+ Object[] elements = super.getElements(element);
+ List<Object> newElementList = new ArrayList<Object>();
+
+ // filter to display only lua files
+ for (Object anElement : elements) {
+ if (anElement instanceof IFile) {
+ IFile file = (IFile) anElement;
+ if ("lua".equals(file.getFileExtension())) { //$NON-NLS-1$
+ newElementList.add(file);
+ }
+ } else if (anElement instanceof IContainer) {
+ newElementList.add(anElement);
+ }
+ }
- dialog.setElements(getContainerScript(project, shell).toArray());
- dialog.setMessage("Select a script file.");
- dialog.setTitle("Select Script");
+ return newElementList.toArray();
+ }
+ });
+ dialog.setInput(project);
+ dialog.setMessage(Messages.LuaDialogUtil_selectScript_message);
+ dialog.setTitle(Messages.LuaDialogUtil_selectScript_title);
if (dialog.open() == Window.OK) {
return (IFile) dialog.getResult()[0];
}
return null;
}
- private static List<IFile> getContainerScript(IContainer container, Shell shell) {
- ArrayList<IFile> list = new ArrayList<IFile>();
-
- try {
- if (container.exists()) {
- for (IResource child : container.members()) {
-
- if (child instanceof IFile) {
- IFile file = (IFile) child;
- if (file.getName().endsWith(".lua")) //$NON-NLS-1$
- list.add(file);
- } else if (child instanceof IContainer) {
- IContainer childContainer = (IContainer) child;
- list.addAll(getContainerScript(childContainer, shell));
- }
- }
- } else {
- MessageDialog.openError(shell, "Unable to browse script", "The given project doesn't exist.");
- }
- } catch (CoreException e) {
- String errorMessage = NLS.bind("Unable to find scripts files of {0}", container.getFullPath());
- Activator.logError(errorMessage, e);
- MessageDialog.openError(shell, "Unable to browse script", errorMessage);
- }
- return list;
- }
}
diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/Messages.java b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/Messages.java
index b134d5d..9229607 100644
--- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/Messages.java
+++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/Messages.java
@@ -16,6 +16,8 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.koneki.ldt.ui.messages"; //$NON-NLS-1$
public static String LuaDialogUtil_message;
+ public static String LuaDialogUtil_selectScript_message;
+ public static String LuaDialogUtil_selectScript_title;
public static String LuaDialogUtil_title;
static {
// initialize resource bundle
diff --git a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/messages.properties b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/messages.properties
index 7183fdc..30c083a 100644
--- a/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/messages.properties
+++ b/plugins/org.eclipse.koneki.ldt.ui/src/org/eclipse/koneki/ldt/ui/messages.properties
@@ -1,2 +1,4 @@
LuaDialogUtil_message=Select a project to constraint your choice
+LuaDialogUtil_selectScript_message=Select a script file.
+LuaDialogUtil_selectScript_title=Select Script
LuaDialogUtil_title=Project Selection