diff options
author | Vincent Lorenzo | 2022-01-28 15:14:06 +0000 |
---|---|---|
committer | Vincent Lorenzo | 2022-01-28 15:25:18 +0000 |
commit | b34cdd3ffb5fe1dfda19365d9dac80e5ef01ac01 (patch) | |
tree | 785731fc640aa15c8513887b22852f5e336aa701 /plugins | |
parent | 73d4836c1f58dc3ed1d1f8e30715e73dac78dea5 (diff) | |
download | org.eclipse.papyrus-b34cdd3ffb5fe1dfda19365d9dac80e5ef01ac01.tar.gz org.eclipse.papyrus-b34cdd3ffb5fe1dfda19365d9dac80e5ef01ac01.tar.xz org.eclipse.papyrus-b34cdd3ffb5fe1dfda19365d9dac80e5ef01ac01.zip |
Bug 578434: [ProjectExplorer][Di View][Sirius] Delete action doesn't work on model containing an aird file.
Change-Id: I53a202dddcc40d017eebb8085f44b015f44b1b3d
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins')
6 files changed, 44 insertions, 21 deletions
diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF index 93887eadd92..6cfa26e36d7 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Require-Bundle: org.eclipse.emf.transaction;bundle-version="[1.9.0,2.0.0)", org.eclipse.papyrus.infra.internationalization;bundle-version="[2.0.0,3.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 3.0.0.qualifier +Bundle-Version: 3.1.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-Activator: org.eclipse.papyrus.infra.onefile.Activator diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/pom.xml b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/pom.xml index e0a755aee0c..e752ddc3ec0 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/pom.xml +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/pom.xml @@ -9,6 +9,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.infra.onefile</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java index bbffed52975..a3541907725 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2011, 2016 Atos Origin Integration, Christian W. Damus, and others. + * Copyright (c) 2011, 2016, 2022 Atos Origin Integration, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,11 +12,14 @@ * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation * Christian W. Damus - bug 485220 * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 578434 *****************************************************************************/ package org.eclipse.papyrus.infra.onefile.utils; import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -59,7 +62,7 @@ public class OneFileUtils { return null; } final String substring = getFileNameForDi(fileName, parent); - IFile file = parent.getFile(new Path(substring + "." + DiModel.DI_FILE_EXTENSION)); + IFile file = parent.getFile(new Path(substring + "." + DiModel.DI_FILE_EXTENSION)); //$NON-NLS-1$ if (file.exists()) { return file; } @@ -138,6 +141,24 @@ public class OneFileUtils { } /** + * @param resources + * a list of {@link IResource} + * @return <code>true</code> if the list contains a di file + * @since 3.1 + */ + public static boolean containsDi(final Collection<IResource> resources) { + final Iterator<IResource> iter = resources.iterator(); + while (iter.hasNext()) { + final IResource current = iter.next(); + if (isDi(current)) { + return true; + } + } + return false; + + } + + /** * Returns the name without the extension of the file * * @param res @@ -180,7 +201,7 @@ public class OneFileUtils { } public static IFile[] getAssociatedFiles(IPapyrusFile papyrusFile) { - ArrayList<IFile> files = new ArrayList<IFile>(); + List<IFile> files = new ArrayList<>(); for (IResource res : papyrusFile.getAssociatedResources()) { if (res instanceof IFile) { files.add((IFile) res); diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF index 2d0f4023a5c..a9ccaba3d3b 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF @@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.papyrus.infra.core.log;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.emf;bundle-version="[4.0.0,5.0.0)", org.eclipse.papyrus.infra.internationalization;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.infra.onefile;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.onefile;bundle-version="[3.1.0,4.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[3.0.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.17.0,4.0.0)", org.eclipse.ui.navigator;bundle-version="[3.9.0,4.0.0)", @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.uml2.types;bundle-version="[2.5.0,3.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.100.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-Activator: org.eclipse.papyrus.infra.onefile.internal.ui.Activator diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/pom.xml b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/pom.xml index ef52c3f380d..15abab788e3 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/pom.xml +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/pom.xml @@ -9,6 +9,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.infra.onefile.ui</artifactId> - <version>2.0.0-SNAPSHOT</version> + <version>2.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/providers/PapyrusModelActionProvider.java b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/providers/PapyrusModelActionProvider.java index fdddf7197bc..e6fcf4b4857 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/providers/PapyrusModelActionProvider.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/providers/PapyrusModelActionProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration - CEA LIST. + * Copyright (c) 2011, 2022 Atos Origin Integration - CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,6 +12,7 @@ * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Add copy Action + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 578434 *****************************************************************************/ package org.eclipse.papyrus.infra.onefile.internal.ui.providers; @@ -157,7 +158,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { if (getIFile() != null) { try { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - page.openEditor(new FileEditorInput(getIFile()), "org.eclipse.papyrus.infra.core.papyrusEditor", true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT); + page.openEditor(new FileEditorInput(getIFile()), "org.eclipse.papyrus.infra.core.papyrusEditor", true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT); //$NON-NLS-1$ } catch (WorkbenchException e) { Activator.log.error(e); } @@ -183,8 +184,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { @Override public boolean isEnabled() { - return getSelectedResources() != null && getSelectedResources().size() > 0 && OneFileUtils.isDi((IResource) getSelectedResources().get(0)); - + return getSelectedResources() != null && getSelectedResources().size() > 0 && OneFileUtils.containsDi(getSelectedResources()); } @Override @@ -193,7 +193,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { } @Override - protected List getSelectedResources() { + protected List<IResource> getSelectedResources() { return helper.getSelectedResources(getContext()); } }; @@ -206,7 +206,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { } @Override - protected List getSelectedResources() { + protected List<IResource> getSelectedResources() { return helper.getSelectedResources(getContext()); } }; @@ -219,7 +219,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { } @Override - protected List getSelectedResources() { + protected List<IResource> getSelectedResources() { return helper.getSelectedResources(getContext()); } @@ -326,6 +326,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); @@ -342,6 +343,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { fNameField.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); fNameField.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { validatePage(); } @@ -361,7 +363,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { } protected final void validatePage() { - String text = fNameField.getText() + ".di"; + String text = fNameField.getText() + ".di"; //$NON-NLS-1$ RefactoringStatus status = fRefactoringProcessor.validateNewElementName(text); setPageComplete(status); } @@ -394,7 +396,7 @@ public class PapyrusModelActionProvider extends CommonActionProvider { } private void initializeRefactoring() { - fRefactoringProcessor.setNewResourceName(fNameField.getText() + ".di"); + fRefactoringProcessor.setNewResourceName(fNameField.getText() + ".di"); //$NON-NLS-1$ } } } @@ -446,12 +448,12 @@ public class PapyrusModelActionProvider extends CommonActionProvider { return null; } - protected List getSelectedResources(ActionContext context) { + protected List<IResource> getSelectedResources(ActionContext context) { ISelection selec = context.getSelection(); - List<IResource> resources = new ArrayList<IResource>(); + List<IResource> resources = new ArrayList<>(); if (selec instanceof IStructuredSelection) { IStructuredSelection struc = (IStructuredSelection) selec; - for (Iterator<Object> i = struc.iterator(); i.hasNext();) { + for (Iterator<?> i = struc.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IPapyrusFile) { IPapyrusFile papy = (IPapyrusFile) o; |