Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Swanson2002-11-01 17:26:29 -0500
committerDarin Swanson2002-11-01 17:26:29 -0500
commit968048d13669c243741bc402127717da01860aa7 (patch)
tree3b31a71f453b4874cebfc248be6916574cc50dac
parent9f1cc7b4326017c45ffd936084c8e6168e630a56 (diff)
downloadeclipse.platform.debug-antview.tar.gz
eclipse.platform.debug-antview.tar.xz
eclipse.platform.debug-antview.zip
Bug 21809 - Let user specify installation directory of Antantview
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPage.java11
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencePage.java3
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencesMessages.properties2
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPropertiesPage.java83
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/IExternalToolsUIConstants.java9
5 files changed, 87 insertions, 21 deletions
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPage.java
index c815fa018..9a16a8185 100644
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPage.java
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPage.java
@@ -68,9 +68,10 @@ public abstract class AntPage {
/**
* Adds an object to the contents
*/
- protected final void addContent(Object o) {
- if (contentProvider != null)
+ protected void addContent(Object o) {
+ if (contentProvider != null) {
contentProvider.add(o);
+ }
}
/**
@@ -202,8 +203,9 @@ public abstract class AntPage {
protected void removeButtonPressed() {
IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
Iterator enum = sel.iterator();
- while (enum.hasNext())
+ while (enum.hasNext()) {
contentProvider.remove(enum.next());
+ }
}
/**
@@ -272,8 +274,9 @@ public abstract class AntPage {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.viewer = (TableViewer) viewer;
elements.clear();
- if (newInput != null)
+ if (newInput != null) {
elements.addAll((List) newInput);
+ }
}
public void remove(Object o) {
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencePage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencePage.java
index 0ce2d0f33..ecdf6d3c5 100644
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencePage.java
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencePage.java
@@ -127,6 +127,9 @@ public class AntPreferencePage extends PreferencePage implements IWorkbenchPrefe
prefs.setCustomProperties(properties);
}
+ String[] files = propertiesPage.getPropertyFiles();
+ prefs.setCustomPropertyFiles(files);
+
prefs.updatePluginPreferences();
return super.performOk();
}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencesMessages.properties b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencesMessages.properties
index 52d96efd0..da8707ee8 100644
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencesMessages.properties
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPreferencesMessages.properties
@@ -22,7 +22,7 @@ AddCustomDialog.name = &Name:
AddCustomDialog.class = &Class:
AddCustomDialog.library = &Library:
-AntPreferencePage.description = &Customize the classpath, tasks, types, and properties\nused when running Ant build files from Eclipse.
+AntPreferencePage.description = &Customize the classpath, tasks, types, properties and property files\nused when running Ant build files from Eclipse.
AntPropertiesPage.title = Properties
AntPropertiesPage.addButton = Add &Property...
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPropertiesPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPropertiesPage.java
index 29e532715..ae66c9e9b 100644
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPropertiesPage.java
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/preferences/AntPropertiesPage.java
@@ -1,12 +1,15 @@
package org.eclipse.ui.externaltools.internal.ant.preferences;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import org.eclipse.ant.core.AntCorePlugin;
import org.eclipse.ant.core.Property;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -22,6 +25,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
@@ -29,6 +33,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.ui.IExternalToolsUIConstants;
/**
* Preference page for setting global Ant user properties.
@@ -47,7 +52,6 @@ public class AntPropertiesPage extends AntPage {
private Button addButton;
private Button addFileButton;
- private Button editFileButton;
private Button removeFileButton;
private TableViewer fileTableViewer;
@@ -55,11 +59,14 @@ public class AntPropertiesPage extends AntPage {
private final AntPropertiesLabelProvider labelProvider = new AntPropertiesLabelProvider();
+ private IDialogSettings fDialogSettings;
+
/**
* Creates an instance.
*/
public AntPropertiesPage(AntPreferencePage preferencePage) {
super(preferencePage);
+ fDialogSettings= ExternalToolsPlugin.getDefault().getDialogSettings();
}
/* (non-Javadoc)
@@ -79,7 +86,6 @@ public class AntPropertiesPage extends AntPage {
removeButton= createButton(parent, "AntPropertiesPage.removeButton", REMOVE_BUTTON); //$NON-NLS-1$;
} else {
addFileButton= createButton(parent, "AntPropertiesPage.addFileButton", ADD_PROPERTY_FILE_BUTTON); //$NON-NLS-1$;
- editFileButton= createButton(parent, "AntPropertiesPage.editFileButton", EDIT_PROPERTY_FILE_BUTTON); //$NON-NLS-1$;
removeFileButton= createButton(parent, "AntPropertiesPage.removeButton", REMOVE_PROPERTY_FILE_BUTTON); //$NON-NLS-1$;
}
}
@@ -157,17 +163,22 @@ public class AntPropertiesPage extends AntPage {
removeButtonPressed();
break;
case ADD_PROPERTY_FILE_BUTTON :
- //addFile();
- break;
- case EDIT_PROPERTY_FILE_BUTTON :
- //editFile(getSelection());
+ addPropertyFile();
break;
case REMOVE_PROPERTY_FILE_BUTTON :
- //removeFile();
+ removePropertyFile();
break;
}
}
+ private void removePropertyFile() {
+ IStructuredSelection selection= ((IStructuredSelection)fileTableViewer.getSelection());
+ Iterator itr = selection.iterator();
+ while (itr.hasNext()) {
+ fileContentProvider.remove(itr.next());
+ }
+ }
+
/**
* Allows the user to enter a global user property
*/
@@ -284,9 +295,7 @@ public class AntPropertiesPage extends AntPage {
*/
protected void fileTableSelectionChanged(IStructuredSelection newSelection) {
int size = newSelection.size();
- editFileButton.setEnabled(size == 1);
removeFileButton.setEnabled(size > 0);
- addFileButton.setEnabled(false);
}
/**
@@ -295,8 +304,60 @@ public class AntPropertiesPage extends AntPage {
*/
public void initialize() {
getTableViewer().setInput(Arrays.asList(AntCorePlugin.getPlugin().getPreferences().getCustomProperties()));
- fileTableViewer.setInput(new ArrayList());
+ fileTableViewer.setInput(Arrays.asList(AntCorePlugin.getPlugin().getPreferences().getCustomPropertyFiles()));
tableSelectionChanged((IStructuredSelection) getTableViewer().getSelection());
fileTableSelectionChanged((IStructuredSelection)fileTableViewer.getSelection());
}
+
+ /**
+ * Allows the user to enter JARs to the classpath.
+ */
+ private void addPropertyFile() {
+ String lastUsedPath;
+ lastUsedPath= fDialogSettings.get(IExternalToolsUIConstants.DIALOGSTORE_LASTEXTFILE);
+ if (lastUsedPath == null) {
+ lastUsedPath= ""; //$NON-NLS-1$
+ }
+ FileDialog dialog = new FileDialog(getShell(), SWT.MULTI);
+ dialog.setFilterExtensions(new String[] { "*.properties" }); //$NON-NLS-1$;
+ dialog.setFilterPath(lastUsedPath);
+
+ String result = dialog.open();
+ if (result == null) {
+ return;
+ }
+ IPath filterPath= new Path(dialog.getFilterPath());
+ String[] results= dialog.getFileNames();
+ for (int i = 0; i < results.length; i++) {
+ String fileName = results[i];
+ IPath path= filterPath.append(fileName).makeAbsolute();
+ addContent(path.toOSString());
+ }
+
+ fDialogSettings.put(IExternalToolsUIConstants.DIALOGSTORE_LASTEXTFILE, filterPath.toOSString());
+ }
+ /**
+ * @see org.eclipse.ui.externaltools.internal.ant.preferences.AntPage#addContent(java.lang.Object)
+ */
+ protected void addContent(Object o) {
+ if (o instanceof String) {
+ fileContentProvider.add(o);
+ } else {
+ super.addContent(o);
+ }
+ }
+
+ /**
+ * Returns the specified property files
+ *
+ * @return String[]
+ */
+ public String[] getPropertyFiles() {
+ Object[] elements = fileContentProvider.getElements(null);
+ String[] files= new String[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ files[i] = (String)elements[i];
+ }
+ return files;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/IExternalToolsUIConstants.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/IExternalToolsUIConstants.java
index 4eb7ac3db..80142e1a1 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/IExternalToolsUIConstants.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/IExternalToolsUIConstants.java
@@ -1,18 +1,17 @@
package org.eclipse.ui.externaltools.internal.ui;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-
/**********************************************************************
Copyright (c) 2002 IBM Corp. and others. All rights reserved.
This file is made available under the terms of the Common Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
**********************************************************************/
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+
public interface IExternalToolsUIConstants {
public static final String DIALOGSTORE_LASTEXTJAR= IExternalToolConstants.PLUGIN_ID + ".lastextjar"; //$NON-NLS-1$
-
+ public static final String DIALOGSTORE_LASTEXTFILE= IExternalToolConstants.PLUGIN_ID + ".lastextfile"; //$NON-NLS-1$
}

Back to the top