### Eclipse Workspace Patch 1.0 #P org.apache.ivyde.eclipse Index: src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java (working copy) @@ -123,7 +123,7 @@ items = new ArrayList(); } else { menuManager = new MenuManager("Ivy", IvyPlugin - .getImageDescriptor("icons/logo16x16.gif"), "org.apache.ivyde.eclipse.menu"); + .getImageDescriptor("icons/logo16x16.gif"), "org.apache.ivyde.eclipse.menu"); items = Collections.singletonList(menuManager); } @@ -136,6 +136,7 @@ } // add retrieve + List retrieveOnResolveAllSetups = new ArrayList(); if (!retrieveSetups.isEmpty()) { boolean oneProject = retrieveSetups.size() == 1 && totalSelected == 1; Iterator itProject = retrieveSetups.entrySet().iterator(); @@ -150,8 +151,19 @@ action.setText("Retrieve '" + retrieveSetup.getName() + (oneProject ? "'" : "' of " + project.getName())); fillMenu(menuManager, items, new ActionContributionItem(action)); + if (retrieveSetup.isRetrieveOnResolveAll()) { + retrieveOnResolveAllSetups.add(retrieveSetup); + } } } + // add retrieve on resolve + if (!retrieveOnResolveAllSetups.isEmpty()) { + RetrieveOnResolveAllAction retrieveOnREesolve = new RetrieveOnResolveAllAction( + retrieveOnResolveAllSetups); + retrieveOnREesolve.setText("Retrieve all with 'on Resolve' enabled"); + fillMenu(menuManager, items, new ActionContributionItem(retrieveOnREesolve)); + } + fillMenu(menuManager, items, new IvyMenuSeparator()); } Index: src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveOnResolveAllAction.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveOnResolveAllAction.java (revision 0) +++ src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveOnResolveAllAction.java (working copy) @@ -0,0 +1,47 @@ +/* + * 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.internal.eclipse.ui.menu; + +import java.util.Iterator; +import java.util.List; + +import org.apache.ivyde.internal.eclipse.IvyDEMessage; +import org.apache.ivyde.internal.eclipse.retrieve.StandaloneRetrieveSetup; +import org.eclipse.jface.action.Action; + +/** + * @author reto.stadler + * + */ +public class RetrieveOnResolveAllAction extends Action { + + private List retrieveSetups; + + public RetrieveOnResolveAllAction(List /* */retrieveSetups) { + this.retrieveSetups = retrieveSetups; + } + + public void run() { + for (Iterator iterator = retrieveSetups.iterator(); iterator.hasNext();) { + StandaloneRetrieveSetup retrieveSetup = (StandaloneRetrieveSetup) iterator.next(); + IvyDEMessage.verbose("Retrieve dependencies for " + retrieveSetup.getName() + + " standalone setup on project " + retrieveSetup.getProject().getName()); + new RetrieveAction(retrieveSetup).run(); + } + } +} Index: src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java (working copy) @@ -17,40 +17,56 @@ */ package org.apache.ivyde.internal.eclipse.handlers; +import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; +import org.apache.ivyde.internal.eclipse.IvyDEMessage; +import org.apache.ivyde.internal.eclipse.IvyPlugin; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; +import org.apache.ivyde.internal.eclipse.retrieve.RetrieveSetupManager; +import org.apache.ivyde.internal.eclipse.retrieve.StandaloneRetrieveSetup; +import org.apache.ivyde.internal.eclipse.ui.menu.RetrieveOnResolveAllAction; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; public class ResolveAllHandler extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { - IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); - IJavaProject[] projects; - try { - projects = model.getJavaProjects(); - } catch (JavaModelException e) { - // TODO deal with it properly - return null; - } - + RetrieveSetupManager retrieveSetupManager = IvyPlugin.getDefault() + .getRetrieveSetupManager(); + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + List retrieveSetups = new ArrayList(); for (int i = 0; i < projects.length; i++) { - Iterator it = IvyClasspathContainerHelper.getContainers(projects[i]).iterator(); + IProject project = projects[i]; + Iterator it = IvyClasspathContainerHelper.getContainers(project).iterator(); while (it.hasNext()) { IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next(); - ivycp.launchResolve(false, null); + new ResolveHandler().handleContainer(project, ivycp); + } + try { + List setupList = retrieveSetupManager.getSetup(project); + if (!setupList.isEmpty()) { + for (Iterator iterator = setupList.iterator(); iterator.hasNext();) { + StandaloneRetrieveSetup retrieveSetup = (StandaloneRetrieveSetup) iterator + .next(); + if (retrieveSetup.isRetrieveOnResolveAll()) { + retrieveSetups.add(retrieveSetup); + } + } + } + } catch (IOException e) { + IvyDEMessage.warn( + "Unable to get the retrieve setup for project " + project.getName(), e); } } - + // execute all standalone retrieves after the classpath resolve + new RetrieveOnResolveAllAction(retrieveSetups).run(); return null; } - } Index: src/java/org/apache/ivyde/internal/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java (working copy) @@ -53,6 +53,8 @@ private Button resolveInWorkspaceCheck; + private Button retrieveOnResolveAllCheck; + protected EditStandaloneRetrieveDialog(Shell parentShell, IProject project, StandaloneRetrieveSetup retrieveSetup) { super(parentShell); @@ -79,6 +81,7 @@ ivyFilePathText.init(retrieveSetup.getIvyXmlPath()); retrieveComposite.init(retrieveSetup.getRetrieveSetup()); resolveInWorkspaceCheck.setSelection(retrieveSetup.isResolveInWorkspace()); + retrieveOnResolveAllCheck.setSelection(retrieveSetup.isRetrieveOnResolveAll()); return tabs; } @@ -114,8 +117,16 @@ retrieveComposite = new RetrieveComposite(body, SWT.NONE, true, project); retrieveComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); + retrieveOnResolveAllCheck = new Button(body, SWT.CHECK); + retrieveOnResolveAllCheck.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, + false, 2, 1)); + retrieveOnResolveAllCheck.setText("Retrieve on ResolveAll"); + retrieveOnResolveAllCheck + .setToolTipText("These retrieve configuration will execute on ResolveAll"); + return body; } + protected void okPressed() { setup = new StandaloneRetrieveSetup(); setup.setName(nameText.getText()); @@ -124,6 +135,7 @@ setup.setIvyXmlPath(ivyFilePathText.getIvyFilePath()); setup.setRetrieveSetup(retrieveComposite.getRetrieveSetup()); setup.setResolveInWorkspace(resolveInWorkspaceCheck.getSelection()); + setup.setRetrieveOnResolveAll(retrieveOnResolveAllCheck.getSelection()); super.okPressed(); } Index: src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetup.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetup.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetup.java (working copy) @@ -26,6 +26,8 @@ private boolean resolveInWorkspace; + private boolean retrieveOnResolveAll; + private String name = "dependencies"; private SettingsSetup settingsSetup = new SettingsSetup(); @@ -52,7 +54,6 @@ this.resolveInWorkspace = resolveInWorkspace; } - public String getName() { return name; } @@ -61,6 +62,14 @@ this.name = name; } + public boolean isRetrieveOnResolveAll() { + return retrieveOnResolveAll; + } + + public void setRetrieveOnResolveAll(boolean retrieveOnResolveAll) { + this.retrieveOnResolveAll = retrieveOnResolveAll; + } + public SettingsSetup getSettingsSetup() { return settingsSetup; } Index: src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java (working copy) @@ -93,8 +93,11 @@ TableColumn col4 = new TableColumn(table.getTable(), SWT.NONE); col4.setText("Types"); col4.setWidth(50); + TableColumn col5 = new TableColumn(table.getTable(), SWT.NONE); + col5.setText("on ResolveAll"); + col5.setWidth(50); // CheckStyle:MagicNumber| ON - table.setColumnProperties(new String[] {"Name", "Pattern", "Confs", "Types"}); + table.setColumnProperties(new String[] {"Name", "Pattern", "Confs", "Types", "On Resolve"}); Composite buttons = new Composite(composite, SWT.NONE); buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); @@ -193,11 +196,12 @@ return setup.getRetrieveSetup().getRetrieveConfs(); case 3: return setup.getRetrieveSetup().getRetrieveTypes(); + case 4: + return Boolean.toString(setup.isRetrieveOnResolveAll()); } // CheckStyle:MagicNumber| ON return null; } - } public boolean performOk() { Index: src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java =================================================================== --- src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java (revision 1587818) +++ src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java (working copy) @@ -81,6 +81,8 @@ private static final String RESOLVE_IN_WORKSPACE = "resolveInWorkspace"; + private static final String RETRIEVE_ON_RESOLVE_ALL = "retrieveOnResolveAll"; + public void write(OutputStream out, List/* */setuplist) throws IOException { try { @@ -107,6 +109,10 @@ attr.setValue(Boolean.toString(setup.isResolveInWorkspace())); attributes.setNamedItem(attr); + attr = document.createAttribute(RETRIEVE_ON_RESOLVE_ALL); + attr.setValue(Boolean.toString(setup.isRetrieveOnResolveAll())); + attributes.setNamedItem(attr); + if (setup.isSettingProjectSpecific()) { Node settingsNode = document.createElement(IVYSETTINGS); node.appendChild(settingsNode); @@ -225,6 +231,12 @@ setup.setResolveInWorkspace(Boolean.valueOf(attr.getNodeValue()).booleanValue()); } + attr = attributes.getNamedItem(RETRIEVE_ON_RESOLVE_ALL); + if (attr != null) { + setup.setRetrieveOnResolveAll(Boolean.valueOf(attr.getNodeValue()) + .booleanValue()); + } + NodeList children = node.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node item = children.item(j);