From notifications-return-8366-apmail-ant-notifications-archive=ant.apache.org@ant.apache.org Tue Jun 02 22:36:05 2009 Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 46875 invoked from network); 2 Jun 2009 22:36:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Jun 2009 22:36:05 -0000 Received: (qmail 87118 invoked by uid 500); 2 Jun 2009 22:36:17 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 87063 invoked by uid 500); 2 Jun 2009 22:36:17 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 87054 invoked by uid 99); 2 Jun 2009 22:36:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 22:36:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 22:36:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0248223888D6; Tue, 2 Jun 2009 22:35:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r781194 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: cpcontainer/IvydeContainerPage.java ui/ConfTableViewer.java ui/NewIvyDEContainerWizard.java ui/actions/CreateContainerAction.java Date: Tue, 02 Jun 2009 22:35:51 -0000 To: notifications@ant.apache.org From: hibou@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090602223552.0248223888D6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hibou Date: Tue Jun 2 22:35:51 2009 New Revision: 781194 URL: http://svn.apache.org/viewvc?rev=781194&view=rev Log: fix a bug introduced in the implementation of IVYDE-164: it was preventing from editing a classpath container Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=781194&r1=781193&r2=781194&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java Tue Jun 2 22:35:51 2009 @@ -30,12 +30,14 @@ import org.apache.ivyde.eclipse.ui.IvyFilePathText; import org.apache.ivyde.eclipse.ui.RetrieveComposite; import org.apache.ivyde.eclipse.ui.SettingsEditor; +import org.apache.ivyde.eclipse.ui.ConfTableViewer.ConfTableListener; import org.apache.ivyde.eclipse.ui.IvyFilePathText.IvyXmlPathListener; import org.apache.ivyde.eclipse.ui.SettingsEditor.SettingsEditorListener; import org.apache.ivyde.eclipse.ui.preferences.ClasspathPreferencePage; import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper; import org.apache.ivyde.eclipse.ui.preferences.RetrievePreferencePage; import org.apache.ivyde.eclipse.ui.preferences.SettingsPreferencePage; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; @@ -98,6 +100,12 @@ private boolean exported; + private boolean newContainer = false; + + private String oldIvyFile; + + private List oldConfs; + /** * Constructor */ @@ -106,31 +114,45 @@ } void checkCompleted() { - String error; + String error = null; if (ivyFilePathText.getIvyFilePath().length() == 0) { error = "Choose an ivy file"; } else { - error = null; - // check that the chosen configuration doesn't already exist - // the uniqueness is for xmlivyPath + conf - List/* */containers = IvyClasspathUtil - .getIvyClasspathContainers(project); - if (containers != null) { - Iterator/* */itContainers = containers.iterator(); - while (error == null && itContainers.hasNext()) { - IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainers.next(); - IvyClasspathContainerConfiguration cpc = ivycp.getConf(); - if (cpc.ivyXmlPath.equals(ivyFilePathText.getIvyFilePath())) { - List/* */selecteds = confTableViewer.getSelectedConfigurations(); - if (selecteds.isEmpty() || cpc.confs.contains("*")) { - error = "A container already exists for the selected conf of " - + "the module descriptor"; - } else { - ArrayList list = new ArrayList(cpc.confs); - list.retainAll(selecteds); - if (!list.isEmpty()) { + String ivyFilePath = ivyFilePathText.getIvyFilePath(); + List selectedConfigurations = confTableViewer.getSelectedConfigurations(); + + // we will check if there are duplicate if we are creating a new container + boolean checkDuplicate = newContainer; + if (!checkDuplicate) { + // or we are editing a classpath with different ivy and confs than the initial ones + checkDuplicate = !ivyFilePath.equals(oldIvyFile) + || (selectedConfigurations.size() != oldConfs.size() + || !oldConfs.containsAll(selectedConfigurations)); + } + + if (checkDuplicate) { + // check that the chosen configuration doesn't already exist + // the uniqueness is for xmlivyPath + conf + List/* */containers = IvyClasspathUtil + .getIvyClasspathContainers(project); + if (containers != null) { + Iterator/* */itContainers = containers.iterator(); + while (error == null && itContainers.hasNext()) { + IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainers.next(); + IvyClasspathContainerConfiguration cpc = ivycp.getConf(); + if (cpc.ivyXmlPath.equals(ivyFilePath)) { + if (selectedConfigurations.isEmpty() + || selectedConfigurations.contains("*") || cpc.confs.isEmpty() + || cpc.confs.contains("*")) { error = "A container already exists for the selected conf of " + "the module descriptor"; + } else { + ArrayList list = new ArrayList(cpc.confs); + list.retainAll(selectedConfigurations); + if (!list.isEmpty()) { + error = "A container already exists for the selected conf of " + + "the module descriptor"; + } } } } @@ -222,6 +244,17 @@ conf = new IvyClasspathContainerConfiguration(project, entry.getPath(), true); exported = entry.isExported(); } + oldIvyFile = conf.ivyXmlPath; + oldConfs = conf.confs; + } + + public void setSelection(IFile ivyfile) { + newContainer = true; + conf = new IvyClasspathContainerConfiguration(project, ivyfile.getProjectRelativePath() + .toString(), true); + exported = false; + oldIvyFile = conf.ivyXmlPath; + oldConfs = conf.confs; } public void createControl(Composite parent) { @@ -330,6 +363,11 @@ // table for configuration selection confTableViewer = new ConfTableViewer(configComposite, SWT.NONE); confTableViewer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); + confTableViewer.addListener(new ConfTableListener() { + public void confTableUpdated(List confs) { + checkCompleted(); + } + }); // refresh Button refreshConf = new Button(configComposite, SWT.NONE); Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java?rev=781194&r1=781193&r2=781194&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java Tue Jun 2 22:35:51 2009 @@ -19,14 +19,17 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import org.apache.ivy.core.module.descriptor.Configuration; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; 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.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -46,6 +49,8 @@ private Link select; + private final List listeners = new ArrayList(); + public ConfTableViewer(Composite parent, int style) { super(parent, style); GridLayout layout = new GridLayout(); @@ -84,6 +89,11 @@ } }); confTableViewer.setLabelProvider(new ConfigurationLabelProvider()); + confTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + confTableUpdated(); + } + }); select = new Link(this, SWT.PUSH); select.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); @@ -148,6 +158,31 @@ } } + public interface ConfTableListener { + void confTableUpdated(List confs); + } + + public void addListener(ConfTableListener listener) { + synchronized (listeners) { + listeners.add(listener); + } + } + + public void remodeListener(ConfTableListener listener) { + synchronized (listeners) { + listeners.remove(listener); + } + } + + void confTableUpdated() { + synchronized (listeners) { + Iterator it = listeners.iterator(); + while (it.hasNext()) { + ((ConfTableListener) it.next()).confTableUpdated(getSelectedConfigurations()); + } + } + } + public void setEnabled(boolean enabled) { super.setEnabled(enabled); confTableViewer.getTable().setEnabled(enabled); Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java?rev=781194&r1=781193&r2=781194&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java Tue Jun 2 22:35:51 2009 @@ -25,6 +25,7 @@ import org.apache.ivyde.eclipse.IvyPlugin; import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer; import org.apache.ivyde.eclipse.cpcontainer.IvydeContainerPage; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.core.IClasspathContainer; @@ -38,10 +39,10 @@ private IvydeContainerPage containerPage; - public NewIvyDEContainerWizard(IJavaProject project, IClasspathEntry entry) { + public NewIvyDEContainerWizard(IJavaProject project, IFile ivyfile) { containerPage = new IvydeContainerPage(); containerPage.initialize(project, null); - containerPage.setSelection(entry); + containerPage.setSelection(ivyfile); } public void addPages() { Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java?rev=781194&r1=781193&r2=781194&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java Tue Jun 2 22:35:51 2009 @@ -18,10 +18,8 @@ package org.apache.ivyde.eclipse.ui.actions; import org.apache.ivyde.eclipse.IvyPlugin; -import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration; import org.apache.ivyde.eclipse.ui.NewIvyDEContainerWizard; import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jface.action.IAction; @@ -33,13 +31,6 @@ import org.eclipse.ui.PlatformUI; public class CreateContainerAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - - /** - * The constructor. - */ - public CreateContainerAction() { - } public void run(IAction action) { ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() @@ -50,11 +41,8 @@ if (o instanceof IFile) { IFile f = (IFile) o; IJavaProject javaProject = JavaCore.create(f.getProject()); - IvyClasspathContainerConfiguration conf = new IvyClasspathContainerConfiguration( - javaProject, f.getProjectRelativePath().toString(), false); - IClasspathEntry entry = JavaCore.newContainerEntry(conf.getPath()); WizardDialog dialog = new WizardDialog(IvyPlugin.getActiveWorkbenchShell(), - new NewIvyDEContainerWizard(javaProject, entry)); + new NewIvyDEContainerWizard(javaProject, f)); dialog.open(); } } @@ -69,6 +57,6 @@ } public void init(IWorkbenchWindow window) { - this.window = window; + // nothing to initialize } }