You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2008/11/12 00:05:05 UTC
svn commit: r713216 - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui:
./ preferences/
Author: hibou
Date: Tue Nov 11 15:05:04 2008
New Revision: 713216
URL: http://svn.apache.org/viewvc?rev=713216&view=rev
Log:
IVYDE-119:
- refactor of the global preference page so it does use the same widgets as the project configuration panel, and use only Eclipse 3.2 API
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/RetrieveComposite.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java?rev=713216&r1=713215&r2=713216&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java Tue Nov 11 15:05:04 2008
@@ -30,6 +30,21 @@
public class AcceptedSuffixesTypesComposite extends Composite {
+ public static final String TOOLTIP_ACCEPTED_TYPES = "Comma separated list of artifact types"
+ + " to use in IvyDE Managed Dependencies Library.\n" + "Example: jar, zip";
+
+ public static final String TOOLTIP_SOURCE_TYPES = "Comma separated list of artifact types to be used as sources.\n"
+ + "Example: source, src";
+
+ public static final String TOOLTIP_JAVADOC_TYPES = "Comma separated list of artifact types to be used as javadoc.\n"
+ + "Example: javadoc.";
+
+ public static final String TOOLTIP_SOURCE_SUFFIXES = "Comma separated list of suffixes to match sources to artifacts.\n"
+ + "Example: -source, -src";
+
+ public static final String TOOLTIP_JAVADOC_SUFFIXES = "Comma separated list of suffixes to match javadocs to artifacts.\n"
+ + "Example: -javadoc, -doc";
+
private Text acceptedTypesText;
private Text sourcesTypesText;
@@ -52,8 +67,7 @@
acceptedTypesText = new Text(this, SWT.SINGLE | SWT.BORDER);
acceptedTypesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- acceptedTypesText.setToolTipText("Comma separated list of artifact types"
- + " to use in IvyDE Managed Dependencies Library.\n" + "Example: jar, zip");
+ acceptedTypesText.setToolTipText(TOOLTIP_ACCEPTED_TYPES);
label = new Label(this, SWT.NONE);
label.setText("Sources types:");
@@ -61,45 +75,44 @@
sourcesTypesText = new Text(this, SWT.SINGLE | SWT.BORDER);
sourcesTypesText
.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
- sourcesTypesText
- .setToolTipText("Comma separated list of artifact types to be used as sources.\n"
- + "Example: source, src");
+ sourcesTypesText.setToolTipText(TOOLTIP_SOURCE_TYPES);
label = new Label(this, SWT.NONE);
label.setText("Sources suffixes:");
sourcesSuffixesText = new Text(this, SWT.SINGLE | SWT.BORDER);
sourcesSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- sourcesSuffixesText
- .setToolTipText("Comma separated list of suffixes to match sources to artifacts.\n"
- + "Example: -source, -src");
+ sourcesSuffixesText.setToolTipText(TOOLTIP_SOURCE_SUFFIXES);
label = new Label(this, SWT.NONE);
label.setText("Javadoc types:");
javadocTypesText = new Text(this, SWT.SINGLE | SWT.BORDER);
javadocTypesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- javadocTypesText
- .setToolTipText("Comma separated list of artifact types to be used as javadoc.\n"
- + "Example: javadoc.");
+ javadocTypesText.setToolTipText(TOOLTIP_JAVADOC_TYPES);
label = new Label(this, SWT.NONE);
label.setText("Javadoc suffixes:");
javadocSuffixesText = new Text(this, SWT.SINGLE | SWT.BORDER);
javadocSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- javadocSuffixesText
- .setToolTipText("Comma separated list of suffixes to match javadocs to artifacts.\n"
- + "Example: -javadoc, -doc");
+ javadocSuffixesText.setToolTipText(TOOLTIP_JAVADOC_SUFFIXES);
}
public void init(Collection acceptedTypes, Collection sourceTypes, Collection sourceSuffixes,
Collection javadocTypes, Collection javadocSuffixes) {
- acceptedTypesText.setText(IvyClasspathUtil.concat(acceptedTypes));
- sourcesTypesText.setText(IvyClasspathUtil.concat(sourceTypes));
- sourcesSuffixesText.setText(IvyClasspathUtil.concat(sourceSuffixes));
- javadocTypesText.setText(IvyClasspathUtil.concat(javadocTypes));
- javadocSuffixesText.setText(IvyClasspathUtil.concat(javadocSuffixes));
+ init(IvyClasspathUtil.concat(acceptedTypes), IvyClasspathUtil.concat(sourceTypes),
+ IvyClasspathUtil.concat(sourceSuffixes), IvyClasspathUtil.concat(javadocTypes),
+ IvyClasspathUtil.concat(javadocSuffixes));
+ }
+
+ public void init(String acceptedTypes, String sourceTypes, String sourceSuffixes,
+ String javadocTypes, String javadocSuffixes) {
+ acceptedTypesText.setText(acceptedTypes);
+ sourcesTypesText.setText(sourceTypes);
+ sourcesSuffixesText.setText(sourceSuffixes);
+ javadocTypesText.setText(javadocTypes);
+ javadocSuffixesText.setText(javadocSuffixes);
}
public void setEnabled(boolean enabled) {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/RetrieveComposite.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/RetrieveComposite.java?rev=713216&r1=713215&r2=713216&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/RetrieveComposite.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/RetrieveComposite.java Tue Nov 11 15:05:04 2008
@@ -29,6 +29,10 @@
public class RetrieveComposite extends Composite {
+ public static final String TOOLTIP_RETRIEVE_PATTERN = "Example: lib/[conf]/[artifact].[ext]\n"
+ + "To copy artifacts in folder named lib without revision by folder"
+ + " named like configurations";
+
private Button doRetrieveButton;
private Text retrievePatternText;
@@ -53,9 +57,7 @@
retrievePatternText = new Text(this, SWT.SINGLE | SWT.BORDER);
retrievePatternText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
retrievePatternText.setEnabled(doRetrieveButton.getSelection());
- retrievePatternText.setToolTipText("Example: lib/[conf]/[artifact].[ext]\n"
- + "To copy artifacts in folder named lib without revision by folder"
- + " named like configurations");
+ retrievePatternText.setToolTipText(TOOLTIP_RETRIEVE_PATTERN);
retrieveSyncButton = new Button(this, SWT.CHECK);
retrieveSyncButton.setText("Delete old retrieved artifacts");
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java?rev=713216&r1=713215&r2=713216&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/SettingsPathText.java Tue Nov 11 15:05:04 2008
@@ -43,6 +43,11 @@
public class SettingsPathText extends Composite {
+ public static final String TOOLTIP_SETTINGS = "The url where your ivysettings file can be found. \n"
+ + "Leave it empty to reference the default ivy settings. \n"
+ + "Relative paths are handled relative to the project.\n"
+ + " Example: 'project:///ivysettings.xml' or 'project://myproject/ivysettings.xml'.";
+
private Text settingsText;
private ControlDecoration settingsTextDeco;
@@ -62,10 +67,7 @@
FieldDecorationRegistry.DEC_ERROR).getImage();
settingsText = new Text(this, SWT.SINGLE | SWT.BORDER);
- settingsText.setToolTipText("The url where your ivysettings file can be found. \n"
- + "Use 'default' to reference the default ivy settings. \n"
- + "Relative paths are handled relative to the project."
- + " Example: 'file://./ivysettings.xml'.");
+ settingsText.setToolTipText(TOOLTIP_SETTINGS);
settingsText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
settingsText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java?rev=713216&r1=713215&r2=713216&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java Tue Nov 11 15:05:04 2008
@@ -17,6 +17,7 @@
*/
package org.apache.ivyde.eclipse.ui.preferences;
+import java.util.Collection;
import java.util.List;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
@@ -24,6 +25,32 @@
public class IvyDEPreferenceStoreHelper {
+ public static final String DEFAULT_IVYSETTINGS_PATH = "";
+
+ public static final String DEFAULT_ORGANISATION = "";
+
+ public static final String DEFAULT_ORGANISATION_URL = "";
+
+ public static final String DEFAULT_ACCEPTED_TYPES = "jar,bundle,ejb,maven-plugin";
+
+ public static final String DEFAULT_SOURCES_TYPES = "source";
+
+ public static final String DEFAULT_JAVADOC_TYPES = "javadoc";
+
+ public static final String DEFAULT_SOURCES_SUFFIXES = "-source,-sources,-src";
+
+ public static final String DEFAULT_JAVADOC_SUFFIXES = "-javadoc,-javadocs,-doc,-docs";
+
+ public static final boolean DEFAULT_DO_RETRIEVE = false;
+
+ public static final String DEFAULT_RETRIEVE_PATTERN = "lib/[conf]/[artifact].[ext]";
+
+ public static final boolean DEFAULT_RETRIEVE_SYNC = false;
+
+ public static final boolean DEFAULT_ALPHABETICAL_ORDER = false;
+
+ public static final boolean DEFAULT_RESOLVE_IN_WORKSPACE = false;
+
private final IPreferenceStore prefStore;
public IvyDEPreferenceStoreHelper(IPreferenceStore prefStore) {
@@ -32,25 +59,25 @@
}
public void setDefault() {
- prefStore.setDefault(PreferenceConstants.IVYSETTINGS_PATH, "");
- prefStore.setDefault(PreferenceConstants.ORGANISATION, "");
- prefStore.setDefault(PreferenceConstants.ORGANISATION_URL, "");
- prefStore.setDefault(PreferenceConstants.ACCEPTED_TYPES, "jar,bundle,ejb,maven-plugin");
- prefStore.setDefault(PreferenceConstants.SOURCES_TYPES, "source");
- prefStore.setDefault(PreferenceConstants.JAVADOC_TYPES, "javadoc");
- prefStore.setDefault(PreferenceConstants.SOURCES_SUFFIXES, "-source,-sources,-src");
- prefStore.setDefault(PreferenceConstants.JAVADOC_SUFFIXES, "-javadoc,-javadocs,-doc,-docs");
+ prefStore.setDefault(PreferenceConstants.IVYSETTINGS_PATH, DEFAULT_IVYSETTINGS_PATH);
+ prefStore.setDefault(PreferenceConstants.ORGANISATION, DEFAULT_ORGANISATION);
+ prefStore.setDefault(PreferenceConstants.ORGANISATION_URL, DEFAULT_ORGANISATION_URL);
+ prefStore.setDefault(PreferenceConstants.ACCEPTED_TYPES, DEFAULT_ACCEPTED_TYPES);
+ prefStore.setDefault(PreferenceConstants.SOURCES_TYPES, DEFAULT_SOURCES_TYPES);
+ prefStore.setDefault(PreferenceConstants.JAVADOC_TYPES, DEFAULT_JAVADOC_TYPES);
+ prefStore.setDefault(PreferenceConstants.SOURCES_SUFFIXES, DEFAULT_SOURCES_SUFFIXES);
+ prefStore.setDefault(PreferenceConstants.JAVADOC_SUFFIXES, DEFAULT_JAVADOC_SUFFIXES);
- prefStore.setDefault(PreferenceConstants.DO_RETRIEVE, false);
+ prefStore.setDefault(PreferenceConstants.DO_RETRIEVE, DEFAULT_DO_RETRIEVE);
boolean b = prefStore.getBoolean(PreferenceConstants.DO_RETRIEVE_DEPRECATED);
if (b) {
// not the default value, so it has been set
// erase the deprecated preference and store the new one
prefStore.setValue(PreferenceConstants.DO_RETRIEVE_DEPRECATED, null);
- prefStore.setValue(PreferenceConstants.DO_RETRIEVE, true);
+ prefStore.setValue(PreferenceConstants.DO_RETRIEVE, b);
}
- prefStore.setDefault(PreferenceConstants.RETRIEVE_PATTERN, "lib/[conf]/[artifact].[ext]");
+ prefStore.setDefault(PreferenceConstants.RETRIEVE_PATTERN, DEFAULT_RETRIEVE_PATTERN);
String s = prefStore.getString(PreferenceConstants.RETRIEVE_PATTERN_DEPRECATED);
if (s != null && s.length() != 0) {
// not the default value, so it has been set
@@ -59,61 +86,130 @@
prefStore.setValue(PreferenceConstants.RETRIEVE_PATTERN, s);
}
- prefStore.setDefault(PreferenceConstants.RETRIEVE_SYNC, false);
- prefStore.setDefault(PreferenceConstants.ALPHABETICAL_ORDER, false);
- prefStore.setDefault(PreferenceConstants.RESOLVE_IN_WORKSPACE, false);
+ prefStore.setDefault(PreferenceConstants.RETRIEVE_SYNC, DEFAULT_RETRIEVE_SYNC);
+ prefStore.setDefault(PreferenceConstants.ALPHABETICAL_ORDER, DEFAULT_ALPHABETICAL_ORDER);
+ prefStore
+ .setDefault(PreferenceConstants.RESOLVE_IN_WORKSPACE, DEFAULT_RESOLVE_IN_WORKSPACE);
}
public String getIvyOrg() {
return prefStore.getString(PreferenceConstants.ORGANISATION);
}
+ public void setIvyOrg(String org) {
+ prefStore.setValue(PreferenceConstants.ORGANISATION, org);
+ }
+
public String getIvyOrgUrl() {
return prefStore.getString(PreferenceConstants.ORGANISATION_URL);
}
+ public void setIvyOrgUrl(String url) {
+ prefStore.setValue(PreferenceConstants.ORGANISATION_URL, url);
+ }
+
public String getIvySettingsPath() {
return prefStore.getString(PreferenceConstants.IVYSETTINGS_PATH);
}
+ public void setIvySettingsPath(String path) {
+ prefStore.setValue(PreferenceConstants.IVYSETTINGS_PATH, path);
+ }
+
public List getAcceptedTypes() {
return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.ACCEPTED_TYPES));
}
+ public void setAcceptedTypes(Collection acceptedTypes) {
+ prefStore.setValue(PreferenceConstants.ACCEPTED_TYPES, IvyClasspathUtil.concat(acceptedTypes));
+ }
+
public List getSourceTypes() {
return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.SOURCES_TYPES));
}
+ public void setSourceTypes(Collection sourceTypes) {
+ prefStore.setValue(PreferenceConstants.SOURCES_TYPES, IvyClasspathUtil.concat(sourceTypes));
+ }
+
public List getJavadocTypes() {
return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.JAVADOC_TYPES));
}
+ public void setJavadocTypes(Collection javadocTypes) {
+ prefStore.setValue(PreferenceConstants.JAVADOC_TYPES, IvyClasspathUtil.concat(javadocTypes));
+ }
+
public List getSourceSuffixes() {
return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.SOURCES_SUFFIXES));
}
+ public void setSourceSuffixes(Collection sourceSuffixes) {
+ prefStore.setValue(PreferenceConstants.SOURCES_SUFFIXES, IvyClasspathUtil.concat(sourceSuffixes));
+ }
+
public List getJavadocSuffixes() {
return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.JAVADOC_SUFFIXES));
}
+ public void setJavadocSuffixes(Collection javadocSuffixes) {
+ prefStore.setValue(PreferenceConstants.JAVADOC_SUFFIXES, IvyClasspathUtil.concat(javadocSuffixes));
+ }
+
public boolean getDoRetrieve() {
return prefStore.getBoolean(PreferenceConstants.DO_RETRIEVE);
}
+ public void setDoRetrieve(boolean doretrieve) {
+ prefStore.setValue(PreferenceConstants.DO_RETRIEVE, doretrieve);
+ }
+
public String getRetrievePattern() {
return prefStore.getString(PreferenceConstants.RETRIEVE_PATTERN);
}
+ public void setRetrievePattern(String pattern) {
+ prefStore.setValue(PreferenceConstants.RETRIEVE_PATTERN, pattern);
+ }
+
public boolean getRetrieveSync() {
return prefStore.getBoolean(PreferenceConstants.RETRIEVE_SYNC);
}
+ public void setRetrieveSync(boolean sync) {
+ prefStore.setValue(PreferenceConstants.RETRIEVE_SYNC, sync);
+ }
+
public boolean isAlphOrder() {
return prefStore.getBoolean(PreferenceConstants.ALPHABETICAL_ORDER);
}
+ public void setAlphOrder(boolean alpha) {
+ prefStore.setValue(PreferenceConstants.ALPHABETICAL_ORDER, alpha);
+ }
+
public boolean isResolveInWorkspace() {
return prefStore.getBoolean(PreferenceConstants.RESOLVE_IN_WORKSPACE);
}
+ public void setResolveInWorkspace(boolean inWorkspace) {
+ prefStore.setValue(PreferenceConstants.RESOLVE_IN_WORKSPACE, inWorkspace);
+ }
+
+ public String getOrganization() {
+ return prefStore.getString(PreferenceConstants.ORGANISATION);
+ }
+
+ public void setOrganization(String org) {
+ prefStore.setValue(PreferenceConstants.ORGANISATION, org);
+ }
+
+ public String getOrganizationUrl() {
+ return prefStore.getString(PreferenceConstants.ORGANISATION_URL);
+ }
+
+ public void setOrganizationUrl(String url) {
+ prefStore.setValue(PreferenceConstants.ORGANISATION_URL, url);
+ }
+
}
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java?rev=713216&r1=713215&r2=713216&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java Tue Nov 11 15:05:04 2008
@@ -17,26 +17,25 @@
*/
package org.apache.ivyde.eclipse.ui.preferences;
-import java.io.File;
-import java.net.MalformedURLException;
-
import org.apache.ivy.Ivy;
import org.apache.ivyde.eclipse.IvyPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.ComboFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FileFieldEditor;
-import org.eclipse.jface.preference.StringFieldEditor;
+import org.apache.ivyde.eclipse.ui.AcceptedSuffixesTypesComposite;
+import org.apache.ivyde.eclipse.ui.RetrieveComposite;
+import org.apache.ivyde.eclipse.ui.SettingsPathText;
+import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
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.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.osgi.framework.Constants;
/**
* This class represents a preference page that is contributed to the Preferences dialog. By
@@ -48,201 +47,158 @@
* preference store.
*/
-public class IvyPreferencePage extends FieldEditorPreferencePage implements
- IWorkbenchPreferencePage {
+public class IvyPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
/** the ID of the preference page */
public static final String PEREFERENCE_PAGE_ID = "org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage";
- private StringFieldEditor pattern;
+ private RetrieveComposite retrieveComposite;
+
+ private SettingsPathText settingsPathText;
+
+ private Button resolveInWorkspaceCheck;
+
+ private Combo alphaOrderCheck;
- private BooleanFieldEditor retreiveSync;
+ private AcceptedSuffixesTypesComposite acceptedSuffixesTypesComposite;
+
+ private Text organizationText;
+
+ private Text organizationUrlText;
public IvyPreferencePage() {
- super(GRID);
setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore());
- setDescription("");
+ Object ivydeVersion = IvyPlugin.getDefault().getBundle().getHeaders().get(
+ Constants.BUNDLE_VERSION);
+ setDescription("Ivy " + Ivy.getIvyVersion() + " (" + Ivy.getIvyDate() + ") -- IvyDE "
+ + ivydeVersion);
}
public void init(IWorkbench workbench) {
- // nothing to init
+ setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore());
}
- /**
- * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to
- * manipulate various types of preferences. Each field editor knows how to save and restore
- * itself.
- */
- public void createFieldEditors() {
- final Composite fieldParent = getFieldEditorParent();
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ composite.setLayout(new GridLayout());
- Label info = new Label(fieldParent, SWT.NONE);
// CheckStyle:MagicNumber| OFF
- info.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3, 1));
- info.setText("Apache Ivy version " + Ivy.getIvyVersion() + " - " + Ivy.getIvyDate());
- new Label(fieldParent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 3, 1)); // space
-
- Label spacer = new Label(fieldParent, SWT.NONE);
- GridData spacerData = new GridData();
- spacerData.horizontalSpan = 3;
- spacer.setLayoutData(spacerData);
- spacer.setText("Runtime option");
- spacer = new Label(fieldParent, SWT.SEPARATOR | SWT.HORIZONTAL);
- spacer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
- addField(new FileFieldEditor(PreferenceConstants.IVYSETTINGS_PATH, "&Ivy settings URL:",
- fieldParent) {
- /* Opens the file chooser dialog and returns the selected file as an url. */
- protected String changePressed() {
- String f = super.changePressed();
- if (f == null) {
- return null;
- }
- File d = new File(f);
- try {
- return d.toURL().toExternalForm();
- } catch (MalformedURLException e) {
- // should never happen
- IvyPlugin.log(IStatus.ERROR, "A file from the file chooser is not an URL", e);
- return null;
- }
- }
-
- protected boolean checkState() {
- return true;
- }
- });
-
- new Label(fieldParent, SWT.NONE); // space
- Label explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation.setText("The url where your ivysettings file can be found. \n"
- + "Leave empty to reference the default ivy settings.");
- new Label(fieldParent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 3, 1)); // space
-
- BooleanFieldEditor doR = new BooleanFieldEditor(PreferenceConstants.DO_RETRIEVE,
- "Do a retrieve after resolve", fieldParent) {
- protected void createControl(final Composite parent) {
- super.createControl(parent);
- final Button b = getChangeControl(parent);
- b.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- pattern.setEnabled(b.getSelection(), parent);
- retreiveSync.setEnabled(b.getSelection(), parent);
- }
- });
- }
- };
- pattern = new StringFieldEditor(PreferenceConstants.RETRIEVE_PATTERN, "Pattern",
- fieldParent);
- pattern.setEnabled(getPreferenceStore().getBoolean(PreferenceConstants.DO_RETRIEVE),
- fieldParent);
- retreiveSync = new BooleanFieldEditor(PreferenceConstants.RETRIEVE_SYNC,
- "Delete old retrieved artifacts", fieldParent);
- addField(doR);
- addField(pattern);
- addField(retreiveSync);
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation
- .setText("Pattern example: lib/[conf]/[artifact].[ext]\n"
- + "To copy artifacts in folder named lib without revision by folder named like configurations");
- new Label(fieldParent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 3, 1)); // space
-
- addField(new StringFieldEditor(PreferenceConstants.ACCEPTED_TYPES, "Accepted types",
- fieldParent));
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation
- .setText("Comma separated list of artifact types to use in IvyDE Managed Dependencies Library\n"
- + "Example: jar, zip");
-
- addField(new StringFieldEditor(PreferenceConstants.SOURCES_TYPES, "Sources types",
- fieldParent));
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation.setText("Comma separated list of artifact types to be used as sources. \n"
- + "Example: source, src");
-
- addField(new StringFieldEditor(PreferenceConstants.SOURCES_SUFFIXES, "Sources suffixes",
- fieldParent));
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation.setText("Comma separated list of suffixes to match sources and artifacts. \n"
- + "Example: -source, -src");
-
- addField(new StringFieldEditor(PreferenceConstants.JAVADOC_TYPES, "Javadoc types",
- fieldParent));
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation.setText("Comma separated list of artifact types to be used as javadoc. \n"
- + "Example: javadoc");
-
- addField(new StringFieldEditor(PreferenceConstants.JAVADOC_SUFFIXES, "Javadoc suffixes",
- fieldParent));
-
- new Label(fieldParent, SWT.NONE); // space
- explanation = new Label(fieldParent, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
- 1));
- explanation.setText("Comma separated list of suffixes to match javadocs and artifacts. \n"
- + "Example: -javadoc, -doc");
-
- spacer = new Label(fieldParent, SWT.NONE);
- spacerData = new GridData();
- spacerData.horizontalSpan = 3;
- spacer.setLayoutData(spacerData);
-
- ComboFieldEditor alphaOrder = new ComboFieldEditor(PreferenceConstants.ALPHABETICAL_ORDER,
- "Order in the classpath container", new String[][] {
- {"From the ivy.xml", "false"}, {"Lexical", "true"}}, fieldParent);
- addField(alphaOrder);
-
- spacer = new Label(fieldParent, SWT.NONE);
- spacerData = new GridData();
- spacerData.horizontalSpan = 3;
- spacer.setLayoutData(spacerData);
-
- BooleanFieldEditor resolveInWorkspace = new BooleanFieldEditor(
- PreferenceConstants.RESOLVE_IN_WORKSPACE,
- "Resolve dependencies to workspace projects", fieldParent);
- addField(resolveInWorkspace);
-
- spacer = new Label(fieldParent, SWT.NONE);
- spacerData = new GridData();
- spacerData.horizontalSpan = 3;
- spacer.setLayoutData(spacerData);
-
- spacer = new Label(fieldParent, SWT.NONE);
- spacerData = new GridData();
- spacerData.horizontalSpan = 3;
- spacer.setLayoutData(spacerData);
- spacer.setText("Editor information");
- spacer = new Label(fieldParent, SWT.SEPARATOR | SWT.HORIZONTAL);
- spacer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
- addField(new StringFieldEditor(PreferenceConstants.ORGANISATION, "&Organisation:",
- fieldParent));
- addField(new StringFieldEditor(PreferenceConstants.ORGANISATION_URL, "Organisation &URL:",
- fieldParent));
+
+ Label horizontalLine = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ Group settingsGroup = new Group(composite, SWT.NONE);
+ settingsGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ settingsGroup.setLayout(new GridLayout());
+ settingsGroup.setText("Global settings");
+
+ settingsPathText = new SettingsPathText(settingsGroup, SWT.NONE);
+ settingsPathText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ Group retrieveGroup = new Group(composite, SWT.NONE);
+ retrieveGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ retrieveGroup.setLayout(new GridLayout());
+ retrieveGroup.setText("Retrieve configuration");
+
+ retrieveComposite = new RetrieveComposite(retrieveGroup, SWT.NONE);
+ retrieveComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ Group containerGroup = new Group(composite, SWT.NONE);
+ containerGroup.setText("Classpath container configuration");
+ containerGroup.setLayout(new GridLayout(3, false));
+ containerGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ resolveInWorkspaceCheck = new Button(containerGroup, SWT.CHECK);
+ resolveInWorkspaceCheck.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
+ false, 3, 1));
+ resolveInWorkspaceCheck.setText("Resolve dependencies in workspace (EXPERIMENTAL)");
+ resolveInWorkspaceCheck
+ .setToolTipText("Will replace jars on the classpath with workspace projects");
+
+ Label label = new Label(containerGroup, SWT.NONE);
+ label.setText("Order of the classpath entries:");
+
+ alphaOrderCheck = new Combo(containerGroup, SWT.READ_ONLY);
+ alphaOrderCheck
+ .setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+ alphaOrderCheck.setToolTipText("Order of the artifacts in the classpath container");
+ alphaOrderCheck.add("From the ivy.xml");
+ alphaOrderCheck.add("Lexical");
+
+ acceptedSuffixesTypesComposite = new AcceptedSuffixesTypesComposite(containerGroup,
+ SWT.NONE);
+ acceptedSuffixesTypesComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+ true, false, 3, 1));
+
+ Group editorGroup = new Group(composite, SWT.NONE);
+ editorGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
+ editorGroup.setLayout(new GridLayout(2, false));
+ editorGroup.setText("Editor information");
+
+ label = new Label(editorGroup, SWT.NONE);
+ label.setText("Organisation:");
+ organizationText = new Text(editorGroup, SWT.SINGLE | SWT.BORDER);
+ organizationText
+ .setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+
+ label = new Label(editorGroup, SWT.NONE);
+ label.setText("Organisation URL:");
+ organizationUrlText = new Text(editorGroup, SWT.SINGLE | SWT.BORDER);
+ organizationUrlText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
+ false));
// CheckStyle:MagicNumber| ON
+
+ initPreferences();
+
+ return composite;
+ }
+
+ private void initPreferences() {
+ IvyDEPreferenceStoreHelper helper = IvyPlugin.getPreferenceStoreHelper();
+ settingsPathText.init(helper.getIvySettingsPath());
+ retrieveComposite.init(helper.getDoRetrieve(), helper.getRetrievePattern(), helper
+ .getRetrieveSync());
+ resolveInWorkspaceCheck.setSelection(helper.isResolveInWorkspace());
+ alphaOrderCheck.select(helper.isAlphOrder() ? 1 : 0);
+ acceptedSuffixesTypesComposite.init(helper.getAcceptedTypes(), helper.getSourceTypes(),
+ helper.getSourceSuffixes(), helper.getJavadocTypes(), helper.getJavadocSuffixes());
+ organizationText.setText(helper.getIvyOrg());
+ organizationUrlText.setText(helper.getIvyOrgUrl());
+ }
+
+ public boolean performOk() {
+ IvyDEPreferenceStoreHelper helper = IvyPlugin.getPreferenceStoreHelper();
+ helper.setIvySettingsPath(settingsPathText.getSettingsPath());
+ helper.setDoRetrieve(retrieveComposite.isRetrieveEnabled());
+ helper.setRetrievePattern(retrieveComposite.getRetrievePattern());
+ helper.setRetrieveSync(retrieveComposite.isSyncEnabled());
+ helper.setResolveInWorkspace(resolveInWorkspaceCheck.getSelection());
+ helper.setAlphOrder(alphaOrderCheck.getSelectionIndex() == 1);
+ helper.setAcceptedTypes(acceptedSuffixesTypesComposite.getAcceptedTypes());
+ helper.setSourceTypes(acceptedSuffixesTypesComposite.getSourcesTypes());
+ helper.setSourceSuffixes(acceptedSuffixesTypesComposite.getSourceSuffixes());
+ helper.setJavadocTypes(acceptedSuffixesTypesComposite.getJavadocTypes());
+ helper.setJavadocSuffixes(acceptedSuffixesTypesComposite.getJavadocSuffixes());
+ helper.setOrganization(organizationText.getText());
+ helper.setOrganizationUrl(organizationUrlText.getText());
+ return true;
}
+ protected void performDefaults() {
+ settingsPathText.init(IvyDEPreferenceStoreHelper.DEFAULT_IVYSETTINGS_PATH);
+ retrieveComposite.init(IvyDEPreferenceStoreHelper.DEFAULT_DO_RETRIEVE,
+ IvyDEPreferenceStoreHelper.DEFAULT_RETRIEVE_PATTERN,
+ IvyDEPreferenceStoreHelper.DEFAULT_RETRIEVE_SYNC);
+ resolveInWorkspaceCheck
+ .setSelection(IvyDEPreferenceStoreHelper.DEFAULT_RESOLVE_IN_WORKSPACE);
+ alphaOrderCheck.select(IvyDEPreferenceStoreHelper.DEFAULT_ALPHABETICAL_ORDER ? 1 : 0);
+ acceptedSuffixesTypesComposite.init(IvyDEPreferenceStoreHelper.DEFAULT_ACCEPTED_TYPES,
+ IvyDEPreferenceStoreHelper.DEFAULT_SOURCES_TYPES,
+ IvyDEPreferenceStoreHelper.DEFAULT_SOURCES_SUFFIXES,
+ IvyDEPreferenceStoreHelper.DEFAULT_JAVADOC_TYPES,
+ IvyDEPreferenceStoreHelper.DEFAULT_JAVADOC_SUFFIXES);
+ organizationText.setText(IvyDEPreferenceStoreHelper.DEFAULT_ORGANISATION);
+ organizationUrlText.setText(IvyDEPreferenceStoreHelper.DEFAULT_ORGANISATION_URL);
+ }
}