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/03/25 18:08:46 UTC
svn commit: r640899 [2/2] - in /ant/ivy/ivyde/trunk: ./
src/java/org/apache/ivyde/eclipse/
src/java/org/apache/ivyde/eclipse/cpcontainer/
src/java/org/apache/ivyde/eclipse/ui/actions/
src/java/org/apache/ivyde/eclipse/ui/console/ src/java/org/apache/iv...
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java Tue Mar 25 10:08:30 2008
@@ -1,15 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.ivyde.eclipse.cpcontainer;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.apache.ivy.util.Message;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -138,11 +158,68 @@
IClasspathEntry[] cpe = javaProject.getRawClasspath();
for (int i = 0; i < cpe.length; i++) {
IClasspathEntry entry = cpe[i];
- if (IvyClasspathContainer.isIvyClasspathContainer(entry.getPath())) {
+ if (isIvyClasspathContainer(entry.getPath())) {
return (IvyClasspathContainer) JavaCore.getClasspathContainer(entry.getPath(),
javaProject);
}
}
return null;
}
+
+ public static boolean isIvyClasspathContainer(IPath containerPath) {
+ return containerPath.segment(0).equals(IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID);
+ }
+
+// public static void scheduleResolve(IJavaProject javaProject) {
+// IvyClasspathContainer cp = getIvyClasspathContainer(javaProject);
+// if (cp != null) {
+// cp.scheduleResolve();
+// }
+// }
+
+ public static IvyClasspathContainer getIvyClasspathContainer(IJavaProject javaProject) {
+ try {
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+ IPath path = entry.getPath();
+ if (isIvyClasspathContainer(path)) {
+ IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
+ if (cp instanceof IvyClasspathContainer) {
+ return (IvyClasspathContainer) cp;
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ Message.error(e.getMessage());
+ }
+ return null;
+ }
+
+ public static List split(String str) {
+ String[] terms = str.split(",");
+ List ret = new ArrayList();
+ for (int i = 0; i < terms.length; i++) {
+ String t = terms[i].trim();
+ if (t.length() > 0) {
+ ret.add(t);
+ }
+ }
+ return ret;
+ }
+
+ public static String concat(Collection/* <String> */list) {
+ StringBuffer b = new StringBuffer();
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ b.append(it.next());
+ if (it.hasNext()) {
+ b.append(",");
+ }
+ }
+ return b.toString();
+ }
+
}
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java Tue Mar 25 10:08:30 2008
@@ -7,36 +7,44 @@
package org.apache.ivyde.eclipse.cpcontainer;
import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
+import org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension;
import org.eclipse.jdt.ui.wizards.NewElementWizardPage;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
+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;
@@ -44,13 +52,18 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceSorter;
@@ -58,114 +71,160 @@
public class IvydeContainerPage extends NewElementWizardPage implements IClasspathContainerPage,
IClasspathContainerPageExtension {
- private IJavaProject _project;
+ IJavaProject project;
- private IClasspathEntry _entry;
+ Text ivyFilePathText;
- private Text _ivyFilePathText;
+ CheckboxTableViewer confTableViewer;
- private CheckboxTableViewer _confTableViewer;
+ Text settingsText;
+ Text acceptedTypesText;
+
+ Text sourcesTypesText;
+
+ Text sourcesSuffixesText;
+
+ Text javadocTypesText;
+
+ Text javadocSuffixesText;
+
+ Button doRetrieveButton;
+
+ Text retrievePatternText;
+
+ Button alphaOrderCheck;
+
+ Button projectSpecificButton;
+
+ Button browse;
+
+ Link generalSettingsLink;
+
+ Composite configComposite;
+
+ private IvyClasspathContainerConfiguration conf;
+
+ private IClasspathEntry entry;
+
+ /**
+ * Constructor
+ *
+ */
public IvydeContainerPage() {
super("IvyDE Container");
}
- public boolean isPageComplete() {
- return true;
+ void checkCompleted() {
+ String error;
+ if (ivyFilePathText.getText().length() == 0) {
+ error = "Choose a valid ivy file";
+ } else if (confTableViewer.getCheckedElements().length == 0) {
+ error = "Choose at least one configuration";
+ } else {
+ error = null;
+ }
+ setErrorMessage(error);
+ setPageComplete(error == null);
}
public boolean finish() {
- if (_ivyFilePathText.getText().length() > 0 && getConfigurationsText().length() > 0) {
- return true;
+ conf.ivyXmlPath = ivyFilePathText.getText();
+ conf.confs = getConfigurations();
+ if (projectSpecificButton.getSelection()) {
+ conf.ivySettingsPath = settingsText.getText();
+ conf.acceptedTypes = IvyClasspathUtil.split(acceptedTypesText.getText());
+ conf.sourceTypes = IvyClasspathUtil.split(sourcesTypesText.getText());
+ conf.javadocTypes = IvyClasspathUtil.split(javadocTypesText.getText());
+ conf.sourceSuffixes = IvyClasspathUtil.split(sourcesSuffixesText.getText());
+ conf.javadocSuffixes = IvyClasspathUtil.split(javadocSuffixesText.getText());
+ conf.doRetrieve = doRetrieveButton.getSelection();
+ conf.retrievePattern = retrievePatternText.getText();
+ conf.alphaOrder = alphaOrderCheck.getSelection();
+ } else {
+ conf.ivySettingsPath = null;
+ }
+ entry = JavaCore.newContainerEntry(conf.getPath());
+ try {
+ IClasspathContainer cp = JavaCore.getClasspathContainer(entry.getPath(), project);
+ if (cp instanceof IvyClasspathContainer) {
+ ((IvyClasspathContainer) cp).scheduleResolve();
+ }
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- MessageDialog.openWarning(_ivyFilePathText.getShell(), "Missing information",
- "Please select a valid file and choose at least one configuration");
- return false;
+ return true;
}
public IClasspathEntry getSelection() {
- return createEntry();
+ return entry;
}
public void setSelection(IClasspathEntry entry) {
- _entry = entry != null ? entry : createDefaultEntry();
- }
-
- private IClasspathEntry createEntry() {
- IClasspathEntry entry = JavaCore.newContainerEntry(new Path(
- IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID)
- .append(_ivyFilePathText.getText()).append(getConfigurationsText()));
- return entry;
+ if (entry == null) {
+ conf = new IvyClasspathContainerConfiguration("ivy.xml", Arrays
+ .asList(new String[] {"*"}));
+ } else {
+ conf = new IvyClasspathContainerConfiguration(entry.getPath());
+ }
}
- private String getConfigurationsText() {
- Object[] confs = _confTableViewer.getCheckedElements();
- int tot = _confTableViewer.getTable().getItemCount();
- if (confs != null && confs.length == tot) {
- return "*";
+ private List getConfigurations() {
+ Object[] confs = confTableViewer.getCheckedElements();
+ int total = confTableViewer.getTable().getItemCount();
+ if (confs.length == total) {
+ return Arrays.asList(new String[] {"*"});
}
- String text = "";
+ List confList = new ArrayList();
for (int i = 0; i < confs.length; i++) {
- Configuration conf = (Configuration) confs[i];
- text += conf.getName() + (i < confs.length ? "," : "");
+ Configuration c = (Configuration) confs[i];
+ confList.add(c.getName());
}
- return text;
- }
-
- private IClasspathEntry createDefaultEntry() {
- IClasspathEntry entry = JavaCore.newContainerEntry(new Path(
- IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID).append("ivy.xml/*"));
- return entry;
+ return confList;
}
public void createControl(Composite parent) {
setTitle("IvyDE Managed Libraries");
setDescription("Choose ivy file and its configurations.");
- Composite control = new Composite(parent, 0);
- GridLayout layout = new GridLayout(2, false);
- control.setLayout(layout);
- GridData data = new GridData(GridData.FILL);
- data.grabExcessHorizontalSpace = true;
- control.setLayoutData(data);
-
- addMainSection(control);
- setControl(control);
- }
-
- private Composite createDefaultComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- return composite;
+ TabFolder tabs = new TabFolder(parent, SWT.BORDER);
+ tabs.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+ TabItem mainTab = new TabItem(tabs, SWT.NONE);
+ mainTab.setText("Main");
+ mainTab.setControl(createMainTab(tabs));
+
+ TabItem advancedTab = new TabItem(tabs, SWT.NONE);
+ advancedTab.setText("Advanced");
+ advancedTab.setControl(createAdvancedTab(tabs));
+
+ setControl(tabs);
+
+ loadFromConf();
}
- private void addMainSection(Composite parent) {
- Composite composite = createDefaultComposite(parent);
+ private Control createMainTab(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
// Label for ivy file field
Label pathLabel = new Label(composite, SWT.NONE);
pathLabel.setText("Ivy File");
- _ivyFilePathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _ivyFilePathText.setText(IvyClasspathContainer.getIvyFilePath(_entry.getPath()));
- _ivyFilePathText.addFocusListener(new FocusAdapter() {
+ ivyFilePathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ ivyFilePathText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ ivyFilePathText.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
refreshConfigurationTable();
}
});
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- _ivyFilePathText.setLayoutData(gridData);
+ ivyFilePathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ checkCompleted();
+ }
+ });
Button btn = new Button(composite, SWT.NONE);
btn.setText("Browse");
@@ -176,7 +235,7 @@
new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
private final IStatus errorStatus = new Status(IStatus.ERROR, IvyPlugin.ID, 0,
- "", null); //$NON-NLS-1$
+ "", null);
public IStatus validate(Object[] selection) {
if (selection.length == 0) {
@@ -194,14 +253,14 @@
});
dialog.setTitle("choose ivy file");
dialog.setMessage("choose the ivy file to use to resolve dependencies");
- dialog.setInput(_project.getProject());
+ dialog.setInput(project.getProject());
dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
if (elements.length > 0 && elements[0] instanceof IFile) {
IPath p = ((IFile) elements[0]).getProjectRelativePath();
- _ivyFilePathText.setText(p.toString());
+ ivyFilePathText.setText(p.toString());
refreshConfigurationTable();
}
}
@@ -211,23 +270,21 @@
// Label for ivy configurations field
Label confLabel = new Label(composite, SWT.NONE);
confLabel.setText("Configurations");
- gridData = new GridData();
- gridData.verticalAlignment = GridData.BEGINNING;
- confLabel.setLayoutData(gridData);
+
// table for configuration selection
- _confTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL
+ confTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL);
- _confTableViewer.getTable().setHeaderVisible(true);
- TableColumn col1 = new TableColumn(_confTableViewer.getTable(), SWT.NONE);
+ confTableViewer.getTable().setHeaderVisible(true);
+ TableColumn col1 = new TableColumn(confTableViewer.getTable(), SWT.NONE);
col1.setText("Name");
col1.setWidth(100);
- TableColumn col2 = new TableColumn(_confTableViewer.getTable(), SWT.NONE);
+ TableColumn col2 = new TableColumn(confTableViewer.getTable(), SWT.NONE);
col2.setText("Description");
col2.setWidth(300);
- _confTableViewer.setColumnProperties(new String[] {"Name", "Description"});
- _confTableViewer.getTable().setLayoutData(
+ confTableViewer.setColumnProperties(new String[] {"Name", "Description"});
+ confTableViewer.getTable().setLayoutData(
new GridData(GridData.FILL, GridData.FILL, true, true));
- _confTableViewer.setContentProvider(new IStructuredContentProvider() {
+ confTableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
if (inputElement != null && !"".equals(inputElement)) {
return getConfigurations((String) inputElement);
@@ -236,118 +293,308 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // nothing to do
}
public void dispose() {
+ // nothing to do
+ }
+ });
+ confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
+ confTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ checkCompleted();
}
});
- _confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
- _confTableViewer.setInput(_ivyFilePathText.getText());
- initTableSelection(_ivyFilePathText.getText());
// refresh
Button refreshConf = new Button(composite, SWT.NONE);
- gridData = new GridData();
- gridData.verticalAlignment = GridData.BEGINNING;
- refreshConf.setLayoutData(gridData);
refreshConf.setText("Refresh");
refreshConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- _confTableViewer.setInput(_ivyFilePathText.getText());
+ confTableViewer.setInput(ivyFilePathText.getText());
}
});
- Composite spacer = new Composite(composite, SWT.NONE);
+
+ // some spacer
+ new Composite(composite, SWT.NONE);
+
Link select = new Link(composite, SWT.PUSH);
- gridData = new GridData();
- gridData.verticalAlignment = GridData.BEGINNING;
- select.setLayoutData(gridData);
select.setText("<A>All</A>/<A>None</A>");
select.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.text.equals("All")) {
- ;
- _confTableViewer.setCheckedElements(getConfigurations(_ivyFilePathText
- .getText()));
+ confTableViewer
+ .setCheckedElements(getConfigurations(ivyFilePathText.getText()));
} else {
- _confTableViewer.setCheckedElements(new Configuration[0]);
+ confTableViewer.setCheckedElements(new Configuration[0]);
}
}
});
+
+ return composite;
+ }
+
+ private Control createAdvancedTab(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+ Composite headerComposite = new Composite(composite, SWT.NONE);
+ headerComposite.setLayout(new GridLayout(2, false));
+ headerComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ projectSpecificButton = new Button(headerComposite, SWT.CHECK);
+ projectSpecificButton.setText("Enable project specific settings");
+ projectSpecificButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateFieldsStatus();
+ }
+ });
+
+ generalSettingsLink = new Link(headerComposite, SWT.NONE);
+ generalSettingsLink.setFont(composite.getFont());
+ generalSettingsLink.setText("<A>Configure Workspace Settings...</A>");
+ generalSettingsLink.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(),
+ IvyPreferencePage.PEREFERENCE_PAGE_ID, null, null);
+ dialog.open();
+ }
+ });
+ generalSettingsLink.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+
+ Label horizontalLine = new Label(headerComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+
+ configComposite = new Composite(composite, SWT.NONE);
+ configComposite.setLayout(new GridLayout(3, false));
+ configComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ Label label = new Label(configComposite, SWT.NONE);
+ label.setText("Ivy settings path:");
+
+ settingsText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ settingsText
+ .setToolTipText("The url where your ivysettings file can be found. \nUse 'default' to reference the default ivy settings. \nRelative paths are handled relative to the project. Example: 'file://./ivysettings.xml'.");
+ settingsText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ browse = new Button(configComposite, SWT.NONE);
+ browse.setText("Browse");
+ browse.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ File f = getFile(new File("/"));
+ if (f != null) {
+ try {
+ settingsText.setText(f.toURL().toExternalForm());
+ } catch (MalformedURLException ex) {
+ // this cannot happend
+ }
+ }
+ }
+ });
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Accepted types:");
+
+ acceptedTypesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ acceptedTypesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2,
+ 1));
+ acceptedTypesText
+ .setToolTipText("Comma separated list of artifact types to use in IvyDE Managed Dependencies Library.\nExample: jar, zip");
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Sources types:");
+
+ sourcesTypesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ sourcesTypesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false,
+ 2, 1));
+ sourcesTypesText
+ .setToolTipText("Comma separated list of artifact types to be used as sources.\nExample: source, src");
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Sources suffixes:");
+
+ sourcesSuffixesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ sourcesSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
+ 2, 1));
+ sourcesSuffixesText
+ .setToolTipText("Comma separated list of suffixes to match sources to artifacts.\nExample: -source, -src");
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Javadoc types:");
+
+ javadocTypesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ javadocTypesText
+ .setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+ javadocTypesText
+ .setToolTipText("Comma separated list of artifact types to be used as javadoc.\nExample: javadoc.");
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Javadoc suffixes:");
+
+ javadocSuffixesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ javadocSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
+ 2, 1));
+ javadocSuffixesText
+ .setToolTipText("Comma separated list of suffixes to match javadocs to artifacts.\nExample: -javadoc, -doc");
+
+ doRetrieveButton = new Button(configComposite, SWT.CHECK);
+ doRetrieveButton.setText("Do retrieve after resolve");
+ doRetrieveButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 3,
+ 1));
+
+ label = new Label(configComposite, SWT.NONE);
+ label.setText("Retrive pattern:");
+
+ retrievePatternText = new Text(configComposite, SWT.SINGLE | SWT.BORDER);
+ retrievePatternText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
+ 2, 1));
+ retrievePatternText.setEnabled(doRetrieveButton.getSelection());
+ retrievePatternText
+ .setToolTipText("Example: lib/[conf]/[artifact].[ext]\nTo copy artifacts in folder named lib without revision by folder named like configurations");
+
+ doRetrieveButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ retrievePatternText.setEnabled(doRetrieveButton.getSelection());
+ }
+ });
+
+ alphaOrderCheck = new Button(configComposite, SWT.CHECK);
+ alphaOrderCheck.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+ alphaOrderCheck.setText("Order alphabetically the classpath entries");
+ alphaOrderCheck.setToolTipText(
+ "Order alphabetically the artifacts in the classpath container");
+
+ return composite;
+ }
+
+ private void loadFromConf() {
+ ivyFilePathText.setText(conf.ivyXmlPath);
+
+ confTableViewer.setInput(conf.ivyXmlPath);
+ initTableSelection(conf.ivyXmlPath, conf.confs);
+
+ if (conf.isProjectSpecific()) {
+ projectSpecificButton.setSelection(true);
+ settingsText.setText(conf.ivySettingsPath);
+ acceptedTypesText.setText(IvyClasspathUtil.concat(conf.acceptedTypes));
+ sourcesTypesText.setText(IvyClasspathUtil.concat(conf.sourceTypes));
+ sourcesSuffixesText.setText(IvyClasspathUtil.concat(conf.sourceSuffixes));
+ javadocTypesText.setText(IvyClasspathUtil.concat(conf.javadocTypes));
+ javadocSuffixesText.setText(IvyClasspathUtil.concat(conf.javadocSuffixes));
+ doRetrieveButton.setSelection(conf.doRetrieve);
+ retrievePatternText.setText(conf.retrievePattern);
+ alphaOrderCheck.setSelection(conf.alphaOrder);
+ } else {
+ projectSpecificButton.setSelection(false);
+ IvyDEPreferenceStoreHelper helper = IvyPlugin.getPreferenceStoreHelper();
+ settingsText.setText(helper.getIvySettingsPath());
+ acceptedTypesText.setText(IvyClasspathUtil.concat(helper.getAcceptedTypes()));
+ sourcesTypesText.setText(IvyClasspathUtil.concat(helper.getSourceTypes()));
+ sourcesSuffixesText.setText(IvyClasspathUtil.concat(helper.getSourceSuffixes()));
+ javadocTypesText.setText(IvyClasspathUtil.concat(helper.getJavadocTypes()));
+ javadocSuffixesText.setText(IvyClasspathUtil.concat(helper.getJavadocSuffixes()));
+ doRetrieveButton.setSelection(helper.getDoRetrieve());
+ retrievePatternText.setText(helper.getRetrievePattern());
+ alphaOrderCheck.setSelection(helper.isAlphOrder());
+ }
+
+ updateFieldsStatus();
+ }
+
+ void updateFieldsStatus() {
+ boolean projectSpecific = projectSpecificButton.getSelection();
+ generalSettingsLink.setEnabled(!projectSpecific);
+ configComposite.setEnabled(projectSpecific);
+ settingsText.setEnabled(projectSpecific);
+ acceptedTypesText.setEnabled(projectSpecific);
+ sourcesTypesText.setEnabled(projectSpecific);
+ sourcesSuffixesText.setEnabled(projectSpecific);
+ javadocTypesText.setEnabled(projectSpecific);
+ javadocSuffixesText.setEnabled(projectSpecific);
+ doRetrieveButton.setEnabled(projectSpecific);
+ retrievePatternText.setEnabled(doRetrieveButton.getSelection() && projectSpecific);
+ alphaOrderCheck.setEnabled(projectSpecific);
+ }
+
+ File getFile(File startingDirectory) {
+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
+ if (startingDirectory != null) {
+ dialog.setFileName(startingDirectory.getPath());
+ }
+ dialog.setFilterExtensions(new String[] {"*.xml", "*"});
+ String file = dialog.open();
+ if (file != null) {
+ file = file.trim();
+ if (file.length() > 0) {
+ return new File(file);
+ }
+ }
+ return null;
}
/**
* @param ivyFile
*/
- private void initTableSelection(final String ivyFile) {
- String selectedConfsString = IvyClasspathContainer.getConfigurationsText(_entry.getPath());
- if ("*".equals(selectedConfsString)) {
- _confTableViewer.setCheckedElements(getConfigurations(ivyFile));
+ private void initTableSelection(final String ivyFile, List confs) {
+ if ("*".equals(confs.get(0))) {
+ confTableViewer.setCheckedElements(getConfigurations(ivyFile));
} else {
- String selectedConf[] = IvyClasspathContainer.getConfigurations(_entry.getPath());
- if (selectedConf != null) {
- ModuleDescriptor md = getModuleDescriptor(ivyFile);
- if (md != null) {
- for (int i = 0; i < selectedConf.length; i++) {
- String name = selectedConf[i];
- Configuration configuration = md.getConfiguration(name);
- if (configuration != null) {
- _confTableViewer.setChecked(configuration, true);
- }
+ ModuleDescriptor md = getModuleDescriptor(ivyFile);
+ if (md != null) {
+ for (int i = 0; i < confs.size(); i++) {
+ Configuration configuration = md.getConfiguration((String) confs.get(i));
+ if (configuration != null) {
+ confTableViewer.setChecked(configuration, true);
}
}
}
}
}
- public void initialize(IJavaProject project, IClasspathEntry currentEntries[]) {
- _project = project;
+ public void initialize(IJavaProject p, IClasspathEntry currentEntries[]) {
+ this.project = p;
}
- /**
- *
- */
- private void refreshConfigurationTable() {
- if (_confTableViewer.getInput() == null
- || !_confTableViewer.getInput().equals(_ivyFilePathText.getText())) {
- _confTableViewer.setInput(_ivyFilePathText.getText());
+ void refreshConfigurationTable() {
+ if (confTableViewer.getInput() == null
+ || !confTableViewer.getInput().equals(ivyFilePathText.getText())) {
+ confTableViewer.setInput(ivyFilePathText.getText());
}
}
- /**
- * @param ivyfile
- * @return
- */
- private Configuration[] getConfigurations(String ivyfile) {
+ Configuration[] getConfigurations(String ivyfile) {
try {
ModuleDescriptor moduleDescriptor = getModuleDescriptor(ivyfile);
if (moduleDescriptor != null) {
return moduleDescriptor.getConfigurations();
}
} catch (Exception e) {
+ // TODO handle it or log it
}
return new Configuration[0];
}
- /**
- * @param ivyfile
- * @return
- * @throws MalformedURLException
- * @throws ParseException
- * @throws IOException
- */
private ModuleDescriptor getModuleDescriptor(String ivyfile) {
try {
- IFile file = _project.getProject().getFile(ivyfile);
+ IFile file = project.getProject().getFile(ivyfile);
URL url = new File(file.getLocation().toOSString()).toURL();
+ String ivySettingsPath;
+ if (projectSpecificButton.getSelection()) {
+ ivySettingsPath = settingsText.getText();
+ } else {
+ ivySettingsPath = IvyPlugin.getPreferenceStoreHelper().getIvySettingsPath();
+ }
return ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
- IvyPlugin.getIvy(_project).getSettings(), url, false);
+ IvyPlugin.getIvy(project, ivySettingsPath).getSettings(), url, false);
} catch (Exception e) {
+ // TODO hanle it or log it
}
return null;
}
- private static class ConfigurationLabelProvider extends LabelProvider implements
- ITableLabelProvider {
+ static class ConfigurationLabelProvider extends LabelProvider implements ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {
return null;
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/RefreshAction.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/RefreshAction.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/RefreshAction.java Tue Mar 25 10:08:30 2008
@@ -34,7 +34,7 @@
return;
}
if (cp != null) {
- cp.refresh();
+ cp.scheduleRefresh(true);
}
}
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAction.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAction.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAction.java Tue Mar 25 10:08:30 2008
@@ -34,7 +34,7 @@
return;
}
if (cp != null) {
- cp.resolve();
+ cp.scheduleResolve();
}
}
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java Tue Mar 25 10:08:30 2008
@@ -1,15 +1,22 @@
package org.apache.ivyde.eclipse.ui.actions;
-import java.util.Collection;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
@@ -31,7 +38,21 @@
public void run(IAction action) {
Job resolveAllJob = new Job("Resolve all dependencies") {
protected IStatus run(IProgressMonitor monitor) {
- Collection containers = IvyPlugin.getDefault().getAllContainers();
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ IJavaProject[] projects;
+ try {
+ projects = model.getJavaProjects();
+ } catch (JavaModelException e) {
+ return new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+ "Unable to get the list of available java projects", e);
+ }
+ List containers = new ArrayList();
+ for (int i = 0; i < projects.length; i++) {
+ IvyClasspathContainer cp = IvyClasspathUtil.getIvyClasspathContainer(projects[i]);
+ if (cp != null) {
+ containers.add(cp);
+ }
+ }
monitor.beginTask("Resolve all dependencies", containers.size());
for (Iterator iter = containers.iterator(); iter.hasNext();) {
if (monitor.isCanceled()) {
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java Tue Mar 25 10:08:30 2008
@@ -28,6 +28,17 @@
* implementation
*/
public class IvyConsole extends MessageConsole implements MessageLogger {
+
+ public static final String PREF_CONSOLE_DEBUG_COLOR = IvyPlugin.ID + ".console.color.debug";
+
+ public static final String PREF_CONSOLE_VERBOSE_COLOR = IvyPlugin.ID + ".console.color.verbose";
+
+ public static final String PREF_CONSOLE_INFO_COLOR = IvyPlugin.ID + ".console.color.info";
+
+ public static final String PREF_CONSOLE_WARN_COLOR = IvyPlugin.ID + ".console.color.warn";
+
+ public static final String PREF_CONSOLE_ERROR_COLOR = IvyPlugin.ID + ".console.color.error";
+
private MessageConsoleStream[] streams = new MessageConsoleStream[5];
private ConsoleDocument document;
@@ -118,15 +129,15 @@
// install colors
Color color;
- color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_DEBUG_COLOR);
+ color = createColor(Display.getDefault(), PREF_CONSOLE_DEBUG_COLOR);
streams[Message.MSG_DEBUG].setColor(color);
- color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR);
+ color = createColor(Display.getDefault(), PREF_CONSOLE_VERBOSE_COLOR);
streams[Message.MSG_VERBOSE].setColor(color);
- color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_INFO_COLOR);
+ color = createColor(Display.getDefault(), PREF_CONSOLE_INFO_COLOR);
streams[Message.MSG_INFO].setColor(color);
- color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_WARN_COLOR);
+ color = createColor(Display.getDefault(), PREF_CONSOLE_WARN_COLOR);
streams[Message.MSG_WARN].setColor(color);
- color = createColor(Display.getDefault(), IvyPlugin.PREF_CONSOLE_ERROR_COLOR);
+ color = createColor(Display.getDefault(), PREF_CONSOLE_ERROR_COLOR);
streams[Message.MSG_ERR].setColor(color);
initialized = true;
@@ -168,13 +179,13 @@
RGB rgb = PreferenceConverter.getColor(IvyPlugin.getDefault().getPreferenceStore(),
preference);
if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
- if (IvyPlugin.PREF_CONSOLE_DEBUG_COLOR.equals(preference)) {
+ if (PREF_CONSOLE_DEBUG_COLOR.equals(preference)) {
rgb = new RGB(180, 180, 255);
- } else if (IvyPlugin.PREF_CONSOLE_VERBOSE_COLOR.equals(preference)) {
+ } else if (PREF_CONSOLE_VERBOSE_COLOR.equals(preference)) {
rgb = new RGB(50, 150, 50);
- } else if (IvyPlugin.PREF_CONSOLE_WARN_COLOR.equals(preference)) {
+ } else if (PREF_CONSOLE_WARN_COLOR.equals(preference)) {
rgb = new RGB(255, 80, 20);
- } else if (IvyPlugin.PREF_CONSOLE_ERROR_COLOR.equals(preference)) {
+ } else if (PREF_CONSOLE_ERROR_COLOR.equals(preference)) {
rgb = new RGB(255, 0, 0);
}
}
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/IvyEditor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/IvyEditor.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/IvyEditor.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/IvyEditor.java Tue Mar 25 10:08:30 2008
@@ -1,6 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.ivyde.eclipse.ui.editors;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import org.apache.ivyde.eclipse.ui.core.IvyFileEditorInput;
import org.apache.ivyde.eclipse.ui.editors.pages.OverviewFormPage;
import org.apache.ivyde.eclipse.ui.editors.xml.XMLEditor;
@@ -11,6 +29,8 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
@@ -113,7 +133,11 @@
public void doSave(IProgressMonitor monitor) {
xmlEditor.doSave(monitor);
IFile file = ((IvyFileEditorInput) getEditorInput()).getFile();
- IvyClasspathContainer.resolveIfNeeded(file);
+ IJavaProject project = JavaCore.create(file.getProject());
+ IvyClasspathContainer cp = IvyClasspathUtil.getIvyClasspathContainer(project);
+ if (cp.getConf().getIvyXmlPath().equals(file.getProjectRelativePath().toString())) {
+ cp.scheduleResolve();
+ }
}
/**
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/xml/IvyContentAssistProcessor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/xml/IvyContentAssistProcessor.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/xml/IvyContentAssistProcessor.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/xml/IvyContentAssistProcessor.java Tue Mar 25 10:08:30 2008
@@ -37,7 +37,7 @@
private IvyModel _model;
/**
- * Call by viewer to retreive a list of ICompletionProposal
+ * Call by viewer to retrieve a list of ICompletionProposal
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
// Retrieve current document
Added: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java?rev=640899&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (added)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java Tue Mar 25 10:08:30 2008
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui.preferences;
+
+import java.util.List;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class IvyDEPreferenceStoreHelper {
+
+ private final IPreferenceStore prefStore;
+
+ public IvyDEPreferenceStoreHelper(IPreferenceStore prefStore) {
+ this.prefStore = prefStore;
+ setDefault();
+ }
+
+ public void setDefault() {
+ prefStore.setDefault(PreferenceConstants.IVYSETTINGS_PATH, "");
+ prefStore.setDefault(PreferenceConstants.ORGANISATION, "");
+ prefStore.setDefault(PreferenceConstants.ORGANISATION_URL, "");
+ prefStore.setDefault(PreferenceConstants.ACCEPTED_TYPES, "jar");
+ 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.DO_RETRIEVE, false);
+ prefStore.setDefault(PreferenceConstants.RETRIEVE_PATTERN, "lib/[conf]/[artifact].[ext]");
+ prefStore.setDefault(PreferenceConstants.ALPHABETICAL_ORDER, false);
+ }
+
+ public String getIvyOrg() {
+ return prefStore.getString(PreferenceConstants.ORGANISATION);
+ }
+
+ public String getIvyOrgUrl() {
+ return prefStore.getString(PreferenceConstants.ORGANISATION_URL);
+ }
+
+ public String getIvySettingsPath() {
+ return prefStore.getString(PreferenceConstants.IVYSETTINGS_PATH);
+ }
+
+ public List getAcceptedTypes() {
+ return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.ACCEPTED_TYPES));
+ }
+
+ public List getSourceTypes() {
+ return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.SOURCES_TYPES));
+ }
+
+ public List getJavadocTypes() {
+ return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.JAVADOC_TYPES));
+ }
+
+ public List getSourceSuffixes() {
+ return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.SOURCES_SUFFIXES));
+ }
+
+ public List getJavadocSuffixes() {
+ return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.JAVADOC_SUFFIXES));
+ }
+
+ public boolean getDoRetrieve() {
+ return prefStore.getBoolean(PreferenceConstants.DO_RETRIEVE);
+ }
+
+ public String getRetrievePattern() {
+ return prefStore.getString(PreferenceConstants.RETRIEVE_PATTERN);
+ }
+
+ public boolean isAlphOrder() {
+ return prefStore.getBoolean(PreferenceConstants.ALPHABETICAL_ORDER);
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java Tue Mar 25 10:08:30 2008
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.ivyde.eclipse.ui.preferences;
import java.io.File;
@@ -33,6 +50,9 @@
public class IvyPreferencePage extends FieldEditorPreferencePage 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;
public IvyPreferencePage() {
@@ -62,7 +82,8 @@
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.IVYCONF_PATH, "&IvyConf URL:", fieldParent) {
+ 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();
@@ -87,8 +108,8 @@
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 ivyconf file can be found. \nUse default to reference the default ivy configuration.");
+ explanation.setText("The url where your ivyconf file can be found. \n"
+ + "Leave empty to reference the default ivy configuration.");
new Label(fieldParent, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
GridData.BEGINNING, false, false, 3, 1)); // space
@@ -116,7 +137,8 @@
explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2,
1));
explanation
- .setText("Pattern example: lib/[conf]/[artifact].[ext]\nTo copy artifacts in folder named lib without revision by folder named like configurations");
+ .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
@@ -128,7 +150,8 @@
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\nExample: jar, zip");
+ .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));
@@ -137,18 +160,18 @@
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. \nExample: source, src");
+ 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));
+ 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. \nExample: -source, -src");
+ 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));
@@ -157,18 +180,27 @@
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. \nExample: javadoc");
+ 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));
+ 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. \nExample: -javadoc, -doc");
+ 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);
+
+ BooleanFieldEditor alphaOrder = new BooleanFieldEditor(PreferenceConstants.ALPHABETICAL_ORDER,
+ "Order alphabetically the artifacts in the classpath container", fieldParent);
+ addField(alphaOrder);
spacer = new Label(fieldParent, SWT.NONE);
spacerData = new GridData();
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java Tue Mar 25 10:08:30 2008
@@ -5,7 +5,7 @@
*/
public class PreferenceConstants {
- public static final String IVYCONF_PATH = "ivy_conf_path";
+ public static final String IVYSETTINGS_PATH = "ivy_conf_path";
public static final String ORGANISATION = "ivy_org";
@@ -31,6 +31,6 @@
public static final String RETRIEVE_PATTERN = "retreive.pattern";
- public static final String APHABETICAL_ORDER = "order.alphabetical";
+ public static final String ALPHABETICAL_ORDER = "order.alphabetical";
}
Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/properties/IvyProjectPropertyPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/properties/IvyProjectPropertyPage.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/properties/IvyProjectPropertyPage.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/properties/IvyProjectPropertyPage.java Tue Mar 25 10:08:30 2008
@@ -1,337 +0,0 @@
-package org.apache.ivyde.eclipse.ui.properties;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.apache.ivyde.eclipse.IvyPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class IvyProjectPropertyPage extends PropertyPage {
-
- private static final String PATH_TITLE = "Ivy settings url:";
-
- private static final String ACCEPTED_TYPES_TITLE = "Accepted types:";
-
- private static final String SOURCES_TYPES_TITLE = "Sources types:";
-
- private static final String SOURCES_SUFFIXES_TITLE = "Sources suffixes:";
-
- private static final String JAVADOC_TYPES_TITLE = "Javadoc types:";
-
- private static final String JAVADOC_SUFFIXES_TITLE = "Javadoc suffixes:";
-
- private Text _pathValueText;
-
- private Button _retreiveB;
-
- private Text _patternT;
-
- private Text _acceptedTypesText;
-
- private Text _sourcesTypesText;
-
- private Text _javadocTypesText;
-
- private Text _sourcesSuffixesText;
-
- private Text _javadocSuffixesText;
-
- private Button _alphaOrder;
-
- public IvyProjectPropertyPage() {
- super();
- }
-
- private void addMainSection(Composite parent) {
- Composite composite = createDefaultComposite(parent);
-
- // Label for path field
- Label pathLabel = new Label(composite, SWT.NONE);
- pathLabel.setText(PATH_TITLE);
-
- _pathValueText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- String ivyconfURL = IvyPlugin.getStrictIvyconfURL(getJavaProject());
- if (ivyconfURL == null) {
- ivyconfURL = getDefaultIvyconfURLForDisplay();
- }
- _pathValueText.setText(ivyconfURL);
- _pathValueText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false,
- 2, 1));
-
- Button btn = new Button(composite, SWT.NONE);
- btn.setText("Browse");
- btn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- File f = getFile(new File("/"));
- if (f != null) {
- try {
- _pathValueText.setText(f.toURL().toExternalForm());
- } catch (MalformedURLException e1) {
- }
- }
- }
- });
-
- new Label(composite, SWT.NONE); // space
- Label explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation
- .setText("The url where your ivysettings file can be found. \nUse 'default' to reference the default ivy settings. \nUse '[inherited]' to use your general eclipse setting.\nRelative paths are handled relative to the project. Example: 'file://./ivysettings.xml'.");
- new Label(composite, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 4, 1)); // space
-
- Label acceptedTypesLabel = new Label(composite, SWT.NONE);
- acceptedTypesLabel.setText(ACCEPTED_TYPES_TITLE);
-
- _acceptedTypesText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _acceptedTypesText.setText(IvyPlugin.getAcceptedTypesString(getJavaProject()));
- _acceptedTypesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
- false, 3, 1));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation
- .setText("Comma separated list of artifact types to use in IvyDE Managed Dependencies Library.\nExample: jar, zip\nUse [inherited] to use your general eclise setting.");
-
- Label sourcesTypesLabel = new Label(composite, SWT.NONE);
- sourcesTypesLabel.setText(SOURCES_TYPES_TITLE);
-
- _sourcesTypesText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _sourcesTypesText.setText(IvyPlugin.getSourcesTypesString(getJavaProject()));
- _sourcesTypesText
- .setToolTipText("Example: source, src\nUse [inherited] to use your general eclise setting.");
- _sourcesTypesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
- false, 3, 1));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation.setText("Comma separated list of artifact types to be used as sources.");
-
- Label sourcesSuffixesLabel = new Label(composite, SWT.NONE);
- sourcesSuffixesLabel.setText(SOURCES_SUFFIXES_TITLE);
-
- _sourcesSuffixesText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _sourcesSuffixesText.setText(IvyPlugin.getSourcesSuffixesString(getJavaProject()));
- _sourcesSuffixesText
- .setToolTipText("Example: -source, -src\nUse [inherited] to use your general eclise setting.");
- _sourcesSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
- false, 3, 1));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation.setText("Comma separated list of suffixes to match sources to artifacts.");
-
- Label javadocTypesLabel = new Label(composite, SWT.NONE);
- javadocTypesLabel.setText(JAVADOC_TYPES_TITLE);
-
- _javadocTypesText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _javadocTypesText.setText(IvyPlugin.getJavadocTypesString(getJavaProject()));
- _javadocTypesText
- .setToolTipText("Example: javadoc\nUse [inherited] to use your general eclise setting.");
- _javadocTypesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
- false, 3, 1));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation.setText("Comma separated list of artifact types to be used as javadoc.");
-
- Label javadocSuffixesLabel = new Label(composite, SWT.NONE);
- javadocSuffixesLabel.setText(JAVADOC_TYPES_TITLE);
-
- _javadocSuffixesText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _javadocSuffixesText.setText(IvyPlugin.getJavadocSuffixesString(getJavaProject()));
- _javadocSuffixesText
- .setToolTipText("Example: -javadoc, -doc\nUse [inherited] to use your general eclise setting.");
- _javadocSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
- false, 3, 1));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation.setText("Comma separated list of suffixes to match javadocs to artifacts.");
-
- new Label(composite, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 4, 1)); // space
-
- _retreiveB = new Button(composite, SWT.CHECK);
- _retreiveB.setText("Do retrieve after resolve");
- _retreiveB
- .setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 4, 1));
-
- new Label(composite, SWT.NONE).setText("Pattern:");
- _patternT = new Text(composite, SWT.SINGLE | SWT.BORDER);
- _patternT.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 3, 1));
- _retreiveB.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- _patternT.setEnabled(_retreiveB.getSelection());
- }
- });
- _retreiveB.setSelection(IvyPlugin.shouldDoRetrieve(getJavaProject()));
- _patternT.setEnabled(_retreiveB.getSelection());
- _patternT.setText(IvyPlugin.getRetrievePatternHerited(getJavaProject()));
-
- new Label(composite, SWT.NONE); // space
- explanation = new Label(composite, SWT.NONE);
- explanation.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3,
- 1));
- explanation
- .setText("Example: lib/[conf]/[artifact].[ext]\nTo copy artifacts in folder named lib without revision by folder named like configurations\nUse [inherited] to use your general eclipse setting.");
-
- new Label(composite, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 4, 1)); // space
-
- _alphaOrder = new Button(composite, SWT.CHECK);
- _alphaOrder.setText("Order alphabetically the artifacts in the classpath container");
- _alphaOrder
- .setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 4, 1));
- _alphaOrder.setSelection(IvyPlugin.isAlphaOrder(getJavaProject()));
-
- new Label(composite, SWT.NONE).setLayoutData(new GridData(GridData.FILL,
- GridData.BEGINNING, false, false, 4, 1)); // space
- }
-
- /**
- * Try to get a JavaProject from the getElement() result. Throws a IllegalStateException if it
- * can't succeed.
- *
- * @return
- */
- private IJavaProject getJavaProject() {
- IAdaptable adaptable = getElement();
- IJavaProject project = null;
- if (adaptable instanceof IJavaProject) {
- project = (IJavaProject) adaptable;
- } else if (adaptable instanceof IProject) {
- project = JavaCore.create((IProject) adaptable);
- } else {
- throw new IllegalStateException("Attempting a IProject element ! Not "
- + adaptable.getClass().getName() + " element");
- }
- return project;
- }
-
- /**
- * Helper to open the file chooser dialog.
- *
- * @param startingDirectory
- * the directory to open the dialog on.
- * @return File The File the user selected or <code>null</code> if they do not.
- */
- private File getFile(File startingDirectory) {
-
- FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
- if (startingDirectory != null)
- dialog.setFileName(startingDirectory.getPath());
- dialog.setFilterExtensions(new String[] {"*.xml", "*"});
- String file = dialog.open();
- if (file != null) {
- file = file.trim();
- if (file.length() > 0)
- return new File(file);
- }
-
- return null;
- }
-
- /**
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, false);
- composite.setLayout(layout);
- GridData data = new GridData(GridData.FILL);
- data.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data);
-
- addMainSection(composite);
- return composite;
- }
-
- private Composite createDefaultComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 4;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- protected void performDefaults() {
- _pathValueText.setText(getDefaultIvyconfURLForDisplay());
- _retreiveB.setSelection(false);
- _alphaOrder.setSelection(false);
- _patternT.setText("");
- _acceptedTypesText.setText("[inherited]");
- _sourcesTypesText.setText("[inherited]");
- _sourcesSuffixesText.setText("[inherited]");
- _javadocTypesText.setText("[inherited]");
- _javadocSuffixesText.setText("[inherited]");
- }
-
- private String getDefaultIvyconfURLForDisplay() {
- return "[inherited] " + IvyPlugin.getIvyconfURL();
- }
-
- public boolean performOk() {
- IvyPlugin.beginChanges();
- try {
- // store the value in the owner text field
- String text = _pathValueText.getText();
- if (text.startsWith("[inherited] ") || text.trim().length() == 0) {
- text = null;
- }
- IvyPlugin.setIvyconfURL(getJavaProject(), text);
-
- // retreive per project
- if (_retreiveB.getSelection()) {
- IvyPlugin.setRetreivePattern(getJavaProject(), _patternT.getText());
- } else {
- IvyPlugin.setRetreivePattern(getJavaProject(), "");
- }
-
- IvyPlugin.setAlphaOrder(getJavaProject(), _alphaOrder.getSelection());
- IvyPlugin.setAcceptedTypes(getJavaProject(), _acceptedTypesText.getText());
- IvyPlugin.setSourcesTypes(getJavaProject(), _sourcesTypesText.getText());
- IvyPlugin.setSourcesSuffixes(getJavaProject(), _sourcesSuffixesText.getText());
- IvyPlugin.setJavadocTypes(getJavaProject(), _javadocTypesText.getText());
- IvyPlugin.setJavadocSuffixes(getJavaProject(), _javadocSuffixesText.getText());
- return true;
- } finally {
- IvyPlugin.commitChanges();
- }
- }
-
-}