Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/Messages.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/messages.properties24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/GenModelHelper.java117
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/PapyrusProjectCreationPage.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/NewPapyrusProjectWizard.java19
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml2
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLElementTreeAxisManagerForEventList.java24
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java24
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/IGenerator.java88
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/ProfileGenerator.java41
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextMainPage.java35
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextWizard.java81
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/GeneratorPage.java33
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/widget/FileChooser.java40
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java30
19 files changed, 544 insertions, 105 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
index 4f378bc76e1..637908c3fc3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
@@ -64,7 +64,8 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)",
org.eclipse.papyrus.uml.tools.utils;bundle-version="[4.0.0,5.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.9.0,4.0.0)",
org.eclipse.ui.navigator.resources;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.uml2.uml.editor;bundle-version="[5.5.0,6.0.0)"
+ org.eclipse.uml2.uml.editor;bundle-version="[5.5.0,6.0.0)",
+ org.eclipse.emf.codegen.ecore;bundle-version="[2.26.0,3.0.0)";resolution:=optional
Bundle-Vendor: %providerName
Eclipse-LazyStart: true
Bundle-Version: 4.1.0.qualifier
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/Messages.java
index d4239365470..8ef25cdd3a4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/Messages.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2021 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 574592
*
*****************************************************************************/
@@ -24,10 +25,17 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.profile.custom.messages.messages"; //$NON-NLS-1$
public static String CustomSemanticCreateCommand_CreateCustomSemanticCommandForMetaclass;
-
public static String CustomSemanticCreateCommand_LabelProviderServiceNotFound;
-
public static String CustomSemanticCreateCommand_SelectMetaclass;
+ public static String PreSaveProfileListener_0;
+ public static String PreSaveProfileListener_1;
+ public static String PreSaveProfileListener_2;
+ public static String PreSaveProfileListener_3;
+ public static String PreSaveProfileListener_4;
+ public static String PreSaveProfileListener_5;
+ public static String PreSaveProfileListener_6;
+ public static String PreSaveProfileListener_7;
+ public static String PreSaveProfileListener_8;
static {
// initialize resource bundle
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/messages.properties
index 678e84ee1c8..1ba9c7a7c7d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/messages/messages.properties
@@ -1,4 +1,28 @@
+###############################################################################
+# Copyright (c) 2010, 2021 CEA LIST, 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
+# which accompanies this distribution, and is available at
+# https://www.eclipse.org/legal/epl-2.0/
+#
+# SPDX-License-Identifier: EPL-2.0
+#
+# Contributors:
+# Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+# Christian W. Damus - bug 574592
+#
+###############################################################################
CustomSemanticCreateCommand_CreateCustomSemanticCommandForMetaclass=Create Custom Semantic Command for Metaclass
CustomSemanticCreateCommand_LabelProviderServiceNotFound=Label Provider Service not found
CustomSemanticCreateCommand_SelectMetaclass=Select Metaclass
+PreSaveProfileListener_0=In order to be able to apply this profile to UML models, it needs a dynamic definition.\nWould you like to define it now?
+PreSaveProfileListener_1=The profile has been successfully defined.
+PreSaveProfileListener_2=Uncaught exception
+PreSaveProfileListener_3=An exception occurred during the profile definition:\n{0}
+PreSaveProfileListener_4=Invalid Profile
+PreSaveProfileListener_5=The profile cannot be defined because it is invalid.
+PreSaveProfileListener_6=Profile Definition Failed
+PreSaveProfileListener_7=The following errors occured during the profile definition
+PreSaveProfileListener_8=Profile Definition
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/GenModelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/GenModelHelper.java
new file mode 100644
index 00000000000..20a178cdddc
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/GenModelHelper.java
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.profile.service;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * Helper for access to the <em>EMF Generator Model</em> for an UML profile.
+ */
+class GenModelHelper {
+
+ private static final GenModelHelper INSTANCE;
+
+ static {
+ GenModelHelper instance;
+
+ try {
+ instance = new Default();
+ } catch (Exception | LinkageError e) {
+ // The Ecore codegen dependency is optional, so if it isn't installed, then
+ // obviously there is no genmodel for the profile.
+ instance = new GenModelHelper();
+ }
+
+ INSTANCE = instance;
+ }
+
+ private GenModelHelper() {
+ super();
+ }
+
+ /**
+ * Query whether an UML package has a generator model.
+ *
+ * @param package_
+ * an UML package
+ * @param resourceSet
+ * the resource context in which it is loaded
+ * @return whether the package has a generator model that imports it
+ */
+ public boolean hasGeneratorModel(Package package_, ResourceSet resourceSet) {
+ EObject generatorModel = getGeneratorModel(package_, resourceSet);
+
+ return generatorModel != null && isForeignModelOf(package_, generatorModel, resourceSet);
+ }
+
+ EObject getGeneratorModel(Package package_, ResourceSet resourceSet) {
+ return null;
+ }
+
+ boolean isForeignModelOf(Package package_, EObject generatorModel, ResourceSet context) {
+ return false;
+ }
+
+ public static GenModelHelper getInstance() {
+ return INSTANCE;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static final class Default extends GenModelHelper {
+
+ private static final String UML_IMPORTER_ID = "org.eclipse.uml2.uml.ecore.importer"; //$NON-NLS-1$
+ private static final String GENMODEL_EXTENSION = "genmodel"; //$NON-NLS-1$
+
+ @Override
+ GenModel getGeneratorModel(Package package_, ResourceSet resourceSet) {
+ URI genmodelURI = package_.eResource().getURI().trimFileExtension().appendFileExtension(GENMODEL_EXTENSION);
+ return UML2Util.load(resourceSet, genmodelURI, GenModelPackage.Literals.GEN_MODEL);
+ }
+
+ @Override
+ boolean isForeignModelOf(Package package_, EObject generatorModel, ResourceSet context) {
+ boolean result = false;
+
+ GenModel genmodel = (GenModel) generatorModel;
+ if (UML_IMPORTER_ID.equals(genmodel.getImporterID())) {
+ URIConverter converter = context.getURIConverter();
+ URI genmodelURI = converter.normalize(EcoreUtil.getURI(genmodel).trimFragment());
+ URI sourceURI = converter.normalize(EcoreUtil.getURI(package_).trimFragment());
+
+ for (Iterator<String> foreignModel = genmodel.getForeignModel().iterator(); !result && foreignModel.hasNext();) {
+ URI foreignModelURI = URI.createURI(foreignModel.next()).resolve(genmodelURI);
+ result = foreignModelURI.equals(sourceURI);
+ }
+ }
+
+ return result;
+ }
+
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
index 99c042e1b7b..bb76f8c2189 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2021 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 574592
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.profile.service;
@@ -18,6 +19,7 @@ package org.eclipse.papyrus.uml.diagram.profile.service;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -29,6 +31,7 @@ import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
@@ -36,7 +39,7 @@ import org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.commands.CheckedOperationHistory;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.core.resource.IModel;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -45,20 +48,20 @@ import org.eclipse.papyrus.infra.services.validation.ValidationTool;
import org.eclipse.papyrus.infra.ui.lifecycleevents.DoSaveEvent;
import org.eclipse.papyrus.infra.ui.lifecycleevents.ISaveEventListener;
import org.eclipse.papyrus.uml.diagram.profile.custom.commands.DefineProfileCommand;
+import org.eclipse.papyrus.uml.diagram.profile.custom.messages.Messages;
import org.eclipse.papyrus.uml.profile.Activator;
import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileDefinitionDialog;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.operations.IWorkbenchOperationSupport;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Profile;
/**
- * This class provides listeners
- *
- *
- * This class describes the actions to do just before the save action
+ * Handler of the pre-save event for <em>UML Profiles</em> that, if appropriate,
+ * prompts the user to create a new dynamic definition before saving.
*/
public class PreSaveProfileListener implements ISaveEventListener {
@@ -98,19 +101,21 @@ public class PreSaveProfileListener implements ISaveEventListener {
rootProfile = (Profile) profileEObject;
}
- if (rootProfile == null) {
- return; // We're not saving a profile model
+ if (rootProfile == null || isStaticallyGenerated(rootProfile, modelSet)) {
+ // We're not saving a profile model or it is statically generated and should not
+ // have dynamic definitions (bug 574592)
+ return;
}
/**
* Does the user want define the profile?
*/
- String DEFINE_MSG = "In order to apply this profile, it had to be defined.\nWould you like to define it?";
- String PAPYRUS_QUESTION = "Papyrus question"; //$NON-NLS-1$
+ String defineMsg = Messages.PreSaveProfileListener_0;
+ String defineTitle = Messages.PreSaveProfileListener_8;
Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- boolean result = MessageDialog.openQuestion(activeShell, PAPYRUS_QUESTION, DEFINE_MSG);
+ boolean result = MessageDialog.openQuestion(activeShell, defineTitle, defineMsg);
if (!result) {
return;
}
@@ -131,14 +136,15 @@ public class PreSaveProfileListener implements ISaveEventListener {
DefineProfileCommand cmd = new DefineProfileCommand(domain, papyrusAnnotation, rootProfile, dialog.saveConstraintInDefinition());
try {
- IStatus status = CheckedOperationHistory.getInstance().execute(cmd, new NullProgressMonitor(), null);
+ IOperationHistory history = event.getMultiDiagramEditor().getSite().getService(IWorkbenchOperationSupport.class).getOperationHistory();
+ IStatus status = history.execute(cmd, new NullProgressMonitor(), null);
switch (status.getSeverity()) {
case IStatus.OK:
- MessageDialog.openInformation(activeShell, "The profile has been defined", "The profile has been successfully defined");
+ MessageDialog.openInformation(activeShell, defineTitle, Messages.PreSaveProfileListener_1);
break;
case IStatus.WARNING:
Activator.log.warn(status.getMessage());
- MessageDialog.openWarning(activeShell, "The profile has been defined", status.getMessage());
+ MessageDialog.openWarning(activeShell, defineTitle, status.getMessage());
break;
case IStatus.ERROR:
notifyErrors(activeShell, cmd.getDiagnostic());
@@ -146,21 +152,21 @@ public class PreSaveProfileListener implements ISaveEventListener {
}
} catch (ExecutionException e) {
Activator.log.error(e);
- MessageDialog.openError(activeShell, "Uncaught exception", "An exception occurred during the profile definition: \n" + e.getMessage());
+ MessageDialog.openError(activeShell, Messages.PreSaveProfileListener_2, NLS.bind(Messages.PreSaveProfileListener_3, e.getMessage()));
}
} else {
handleDiagnostic(diagnostic, rootProfile);
- MessageDialog.openError(activeShell, "Profile not Valid", "The profile cannot be defined because it is invalid.");
+ MessageDialog.openError(activeShell, Messages.PreSaveProfileListener_4, Messages.PreSaveProfileListener_5);
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Activator.log.error("Uncaught exception in profile definition.", e); //$NON-NLS-1$
}
}
protected void notifyErrors(Shell activeShell, Diagnostic diagnostic) {
Activator.log.error(diagnostic.getMessage(), diagnostic.getException());
- DiagnosticDialog.openProblem(activeShell, "Profile definition failed", "The following errors occured during the profile definition", diagnostic);
+ DiagnosticDialog.openProblem(activeShell, Messages.PreSaveProfileListener_6, Messages.PreSaveProfileListener_7, diagnostic);
}
protected boolean canDefine(Diagnostic diagnostic) {
@@ -246,4 +252,19 @@ public class PreSaveProfileListener implements ISaveEventListener {
e.printStackTrace();
}
}
+
+ /**
+ * Query whether an UML {@code profile} is statically generated (imported into an EMF Generator Model).
+ *
+ * @param profile
+ * an UML profile
+ * @param resourceSet
+ * the resource set context in which it is loaded
+ *
+ * @return whether the {@code profile} appears to be statically generated
+ */
+ boolean isStaticallyGenerated(Profile profile, ResourceSet resourceSet) {
+ return GenModelHelper.getInstance().hasGeneratorModel(profile, resourceSet);
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/PapyrusProjectCreationPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/PapyrusProjectCreationPage.java
index e887b3b9dab..1830eb94bc1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/PapyrusProjectCreationPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/PapyrusProjectCreationPage.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2017, 2019 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2017, 2019. 2021 CEA LIST, 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
@@ -11,7 +11,7 @@
* Contributors:
* Thibault Le Ouay (Sherpa Engineering) t.leouay@sherpa-eng.com - Initial API and implementation
* Christian W. Damus - bug 471453
- * Ansgar Radermacher (CEA LIST) - bug 551952
+ * Ansgar Radermacher (CEA LIST) - support working sets (bug 572328), bug 551952
*
*****************************************************************************/
@@ -76,6 +76,11 @@ public class PapyrusProjectCreationPage extends WizardNewProjectCreationPage imp
fileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
fileName.addListener(SWT.Modify, fileNameModifyListener);
setPageComplete(false);
+
+ String[] workingSetIds = new String[] {
+ "org.eclipse.ui.resourceWorkingSetPage", //$NON-NLS-1$
+ "org.eclipse.jdt.ui.JavaWorkingSetPage" }; //$NON-NLS-1$
+ createWorkingSetGroup(composite, null, workingSetIds);
}
/**
@@ -143,7 +148,7 @@ public class PapyrusProjectCreationPage extends WizardNewProjectCreationPage imp
*
* @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
*
- * @return
+ * @return true, if user can flip to next page
*/
@Override
public boolean canFlipToNextPage() {
@@ -183,6 +188,5 @@ public class PapyrusProjectCreationPage extends WizardNewProjectCreationPage imp
@Override
public void performHelp() {
PlatformUI.getWorkbench().getHelpSystem().displayHelp("org.eclipse.papyrus.uml.diagram.wizards.NewProject"); //$NON-NLS-1$
-
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/NewPapyrusProjectWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/NewPapyrusProjectWizard.java
index a3ec7d428ed..7260ef64cbe 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/NewPapyrusProjectWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/NewPapyrusProjectWizard.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2013 CEA LIST.
+ * Copyright (c) 2010, 2013, 2021 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,8 @@
* Contributors:
* Tatiana Fesenko (CEA LIST) - Initial API and implementation
* Christian W. Damus (CEA) - Support creating models in repositories (CDO)
+ * Ansgar Radermacher (CEA) - Support working sets ((bug 572328), avoid deprecated SubProgressMonitor
+ *
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.wizards.wizards;
@@ -22,7 +24,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.uml.diagram.wizards.Activator;
@@ -30,6 +32,8 @@ import org.eclipse.papyrus.uml.diagram.wizards.messages.Messages;
import org.eclipse.papyrus.uml.diagram.wizards.pages.PapyrusProjectCreationPage;
import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectArchitectureContextPage;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
/**
@@ -130,13 +134,16 @@ public class NewPapyrusProjectWizard extends CreateModelWizard {
if (projectLocationURI != null) {
projectDescription.setLocationURI(projectLocationURI);
}
- project.create(projectDescription, new SubProgressMonitor(progressMonitor, 1));
- project.open(new SubProgressMonitor(progressMonitor, 1));
+ project.create(projectDescription, SubMonitor.convert(progressMonitor, 1));
+ project.open(SubMonitor.convert(progressMonitor, 1));
} else {
// projectDescription = project.getDescription();
- project.open(new SubProgressMonitor(progressMonitor, 1));
+ project.open(SubMonitor.convert(progressMonitor, 1));
+ }
+ IWorkingSet[] workingSets = getMyProjectPage().getSelectedWorkingSets();
+ if (workingSets.length > 0) {
+ PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(project, workingSets);
}
-
return project;
}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF
index e83828d849f..d5ba04f12d8 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF
@@ -39,7 +39,7 @@ Require-Bundle: ca.odell.glazedlists;bundle-version="[1.9.0,2.0.0)",
org.eclipse.uml2.uml;bundle-version="[5.5.0,6.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 6.0.0.qualifier
+Bundle-Version: 6.0.100.qualifier
Bundle-Name: %Bundle-Name
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.uml.nattable.Activator
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml
index fdb2c4256cd..6244547c5d3 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.nattable</artifactId>
- <version>6.0.0-SNAPSHOT</version>
+ <version>6.0.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLElementTreeAxisManagerForEventList.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLElementTreeAxisManagerForEventList.java
index eeb7eb6de14..5df52cd9235 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLElementTreeAxisManagerForEventList.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLElementTreeAxisManagerForEventList.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2021 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,11 +11,12 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 514620
*****************************************************************************/
package org.eclipse.papyrus.uml.nattable.manager.axis;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -72,7 +73,7 @@ public class UMLElementTreeAxisManagerForEventList extends EObjectTreeAxisManage
if (elementId == null) {
return false;
}
-
+
final IElementType types = ElementTypeRegistry.getInstance().getType(elementId);
if (types == null || (types instanceof SpecializationType && ((SpecializationType) types).getMetamodelType() == null)) {
return false;
@@ -143,7 +144,7 @@ public class UMLElementTreeAxisManagerForEventList extends EObjectTreeAxisManage
/**
* This method allows to add/remove elements from the table, according to values returned by {@link #getFilteredValueAsCollection(TreeFillingConfiguration, Object, int)},
* when the attribute base_metaclass_name is modified in a stereotype application
- *
+ *
* @param notification
* a notification which concern the feature base_ of a stereotype application
*/
@@ -194,7 +195,7 @@ public class UMLElementTreeAxisManagerForEventList extends EObjectTreeAxisManage
}
/**
- *
+ *
* @param semanticParent
* the {@link ITreeItemAxis} representing the semantic parent of the baseElement concerned by the stereotype application
* @param baseElement
@@ -215,8 +216,13 @@ public class UMLElementTreeAxisManagerForEventList extends EObjectTreeAxisManage
Collection<?> values = getFilteredValueAsCollection(curr, context, 0);
ITreeItemAxis confRep = null;
if (this.managedElements.containsKey(curr)) {
- // we are on the root, only null or 1 representation is possible
- confRep = this.managedElements.get(curr).iterator().next();
+ Iterator<ITreeItemAxis> iter = this.managedElements.get(curr).iterator();
+ while (iter.hasNext() && confRep == null) {
+ final ITreeItemAxis axis = iter.next();
+ if (axis.getParent() == semanticParent) {
+ confRep = axis;
+ }
+ }
}
if (values.isEmpty()) {
if (confRep != null) {
@@ -252,11 +258,11 @@ public class UMLElementTreeAxisManagerForEventList extends EObjectTreeAxisManage
}
/**
- *
+ *
* @param notification
* a notification
* @return
- * <code>true</code> if the notification concerns a stereotype application
+ * <code>true</code> if the notification concerns a stereotype application
*/
protected boolean isStereotypeApplicationNotification(final Notification notification) {
Object notifier = notification.getNotifier();
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/META-INF/MANIFEST.MF
index 053d6a71522..4a1aff57ecb 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/META-INF/MANIFEST.MF
@@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.core.databinding.property;bundle-version="[1.8.0,2.0
org.eclipse.papyrus.views.properties.toolsmiths;bundle-version="[3.0.0,4.0.0)",
org.eclipse.ui.views.properties.tabbed;bundle-version="[3.8.0,4.0.0)",
org.eclipse.uml2.uml;bundle-version="[5.5.0,6.0.0)",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.papyrus.infra.ui;bundle-version="[3.3.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
index 40cacd80a4c..712f9f0fb06 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2019 CEA LIST.
+ * Copyright (c) 2010, 2021 CEA LIST, 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,6 +12,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Strategy improvement of generated files
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 544869
+ * Christian W. Damus - bug 573987
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.generators;
@@ -25,6 +26,9 @@ import java.util.List;
import java.util.Set;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
@@ -36,6 +40,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ModelExtent;
@@ -68,7 +73,7 @@ public class EcoreGenerator extends AbstractQVTGenerator {
protected List<EPackage> listEPackages;
@Override
- public void createControls(Composite parent) {
+ public void createControls(Composite parent, IFile workbenchSelection) {
Composite root = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
@@ -86,6 +91,12 @@ public class EcoreGenerator extends AbstractQVTGenerator {
listEPackages = new ArrayList<>();
+ if (workbenchSelection != null) {
+ IFile suggestion = getSourceFile(workbenchSelection);
+ if (suggestion != null) {
+ sourceFileChooser.setFile(suggestion);
+ }
+ }
}
@Override
@@ -393,6 +404,15 @@ public class EcoreGenerator extends AbstractQVTGenerator {
}
+ @Override
+ public IFile getSourceFile(IFile file, IContentType contentType) {
+ if (contentType == null) {
+ return null; // Ecore content type is registered, so the file is not an Ecore model
+ }
+
+ IContentType ecore = Platform.getContentTypeManager().getContentType(EcorePackage.eCONTENT_TYPE);
+ return ecore != null && contentType.isKindOf(ecore) ? file : null;
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/IGenerator.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/IGenerator.java
index 38b3cd6b45a..80410535140 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/IGenerator.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/IGenerator.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2021 CEA LIST, 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,14 +12,21 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Strategy improvement of generated files
* Christian W. Damus (CEA) - bug 422257
+ * Christian W. Damus - bug 573987
*
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.generators;
import java.util.List;
+import java.util.Optional;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
import org.eclipse.papyrus.infra.properties.contexts.Property;
@@ -54,8 +61,29 @@ public interface IGenerator {
*
* @param parent
* The Composite in which the controls will be displayed
+ *
+ * @deprecated Implement the {@link #createControls(Composite, IFile)} method, instead
+ */
+ @Deprecated
+ public default void createControls(Composite parent) {
+ // Extant classes already override this. New ones should not
+ throw new AbstractMethodError("createControls(Composite)"); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates the controls for this Generator. The generator is responsible
+ * for displaying any Control useful for editing its options, and listening
+ * for changes on them.
+ *
+ * @param parent
+ * The Composite in which the controls will be displayed
+ * @param workbenchSelection
+ * the file currently selected in the workbench, if any.
+ * May be {@code null}
*/
- public void createControls(Composite parent);
+ public default void createControls(Composite parent, IFile workbenchSelection) {
+ createControls(parent);
+ }
/**
* Gets the description for this Generator
@@ -148,4 +176,60 @@ public interface IGenerator {
*/
public void dispose();
+ /**
+ * Query the preferred source model for generation of a <em>Properties Context</em> model based on
+ * the given file selection in the workbench.
+ *
+ * @param file
+ * the file selection in the workbench
+ * @param contentType
+ * the content type of the {@code file}. May be {@code null} if the content type cannot
+ * be determined or if the {@code file}'s content type is not registered in the platform
+ * @return the preferred file to use as input for the generation. This should be related in some way to
+ * the selected {@code file}, usually being that {@code file} itself. Or else {@code null} to indicate
+ * that the given {@code file} is not handled at all by this generator
+ *
+ * @see #getSourceFile(IFile, IContentType)
+ */
+ public default IFile getSourceFile(IFile file) {
+ try {
+ Optional<IContentType> contentType = Optional.ofNullable(file.getContentDescription()).map(IContentDescription::getContentType);
+ return getSourceFile(file, contentType.orElse(null));
+ } catch (CoreException e) {
+ Activator.log.error("Could not determine content type of " + file, e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Query the preferred source model for generation of a <em>Properties Context</em> model based on
+ * the given file selection in the workbench.
+ *
+ * @param file
+ * the file selection in the workbench
+ * @param contentType
+ * the content type of the {@code file}. May be {@code null} if the content type cannot
+ * be determined or if the {@code file}'s content type is not registered in the platform
+ * @return the preferred file to use as input for the generation. This should be related in some way to
+ * the selected {@code file}, usually being that {@code file} itself. Or else {@code null} to indicate
+ * that the given {@code file} is not handled at all by this generator
+ */
+ public default IFile getSourceFile(IFile file, IContentType contentType) {
+ return null;
+ }
+
+ /**
+ * Query whether I can generate a <em>Properties Context</em> model from the given file selected in the workbench.
+ *
+ * @param selectedFile
+ * the file currently selected in the workbench. Must not be {@code null}
+ * @param contentType
+ * the content type of the selected file. May be {@code null} if the content type cannot
+ * be determined or if the selected file's content type is not registered in the platform
+ * @return
+ */
+ public default boolean canGenerate(IFile selectedFile, IContentType contentType) {
+ return getSourceFile(selectedFile, contentType) != null;
+ }
+
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/ProfileGenerator.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/ProfileGenerator.java
index 9a894763f7e..4a6291a1d54 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/ProfileGenerator.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/ProfileGenerator.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2021 CEA LIST, 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
@@ -11,6 +11,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Strategy improvement of generated files
+ * Christian W. Damus - bug 573987
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.generators;
@@ -24,6 +25,9 @@ import java.util.List;
import java.util.Set;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -33,6 +37,7 @@ import org.eclipse.m2m.qvt.oml.ModelExtent;
import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.papyrus.customization.properties.generation.messages.Messages;
import org.eclipse.papyrus.customization.properties.generation.wizard.widget.FileChooser;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
import org.eclipse.papyrus.infra.properties.contexts.Property;
@@ -51,6 +56,8 @@ import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageImport;
import org.eclipse.uml2.uml.PrimitiveType;
import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.UMLResource;
/**
* An IGenerator for building Contexts from a UML Profile
@@ -71,7 +78,7 @@ public class ProfileGenerator extends AbstractQVTGenerator {
@Override
- public void createControls(Composite parent) {
+ public void createControls(Composite parent, IFile workbenchSelection) {
Composite root = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
@@ -87,6 +94,13 @@ public class ProfileGenerator extends AbstractQVTGenerator {
sourceFileChooser.setFilterExtensions(FileExtensions.umlProfileExtensions);
sourceFileChooser.addListener(this);
listEObject = new ArrayList<>();
+
+ if (workbenchSelection != null) {
+ IFile suggestion = getSourceFile(workbenchSelection);
+ if (suggestion != null) {
+ sourceFileChooser.setFile(suggestion);
+ }
+ }
}
@Override
@@ -371,4 +385,27 @@ public class ProfileGenerator extends AbstractQVTGenerator {
return null;
}
+
+ @Override
+ public IFile getSourceFile(IFile file, IContentType contentType) {
+ IFile result = null;
+
+ if (DiModel.DI_FILE_EXTENSION.equals(file.getFileExtension())) {
+ // Get the associated UML file, if it exists
+ IFile umlFile = file.getProject().getFile(file.getProjectRelativePath().removeFileExtension().addFileExtension(UMLResource.FILE_EXTENSION));
+ if (umlFile != null && umlFile.isAccessible()) {
+ result = getSourceFile(umlFile);
+ }
+ } else if (contentType != null) {
+ // The only other supported input is the UML file, itself, and the UML content type is registered
+ IContentType uml = Platform.getContentTypeManager().getContentType(UMLPackage.eCONTENT_TYPE);
+
+ if (uml != null && contentType.isKindOf(uml)) {
+ result = file;
+ }
+ }
+
+ return result;
+ }
+
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextMainPage.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextMainPage.java
index 1db719f14be..d049c4a1772 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextMainPage.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextMainPage.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2021 CEA LIST, 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,13 +12,19 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add SelectOutputPage
* Christian W. Damus (CEA) - bug 422257
+ * Christian W. Damus - bug 573987
*
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.wizard;
import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.papyrus.customization.properties.generation.extensionpoint.GeneratorExtensionPoint;
import org.eclipse.papyrus.customization.properties.generation.generators.IGenerator;
import org.eclipse.papyrus.customization.properties.generation.messages.Messages;
@@ -64,6 +70,7 @@ public class CreateContextMainPage extends AbstractCreateContextPage implements
}
}
+ @Override
public void createControl(Composite parent) {
Composite root = new Composite(parent, SWT.NONE);
root.setLayout(new GridLayout(1, false));
@@ -80,6 +87,8 @@ public class CreateContextMainPage extends AbstractCreateContextPage implements
setControl(root);
setDescription(Messages.CreateContextMainPage_description);
+
+ getWizard().getCurrentlySelectedFile().ifPresent(this::selectGenerator);
}
@Override
@@ -90,8 +99,32 @@ public class CreateContextMainPage extends AbstractCreateContextPage implements
return getWizard().generatorPage;
}
+ @Override
public void handleEvent(Event event) {
super.setPageComplete(true);
}
+ /**
+ * Select the best-fitting generator, if any, for the file currently selected
+ * in the workbench.
+ *
+ * @param selectedFile
+ * the currently selected file. Must not be {@code null}
+ */
+ private void selectGenerator(IFile selectedFile) {
+ IContentType contentType = null;
+
+ try {
+ IContentDescription description = selectedFile.getContentDescription();
+ contentType = (description != null) ? description.getContentType() : null;
+ } catch (CoreException e) {
+ Activator.log.error("Failed to determine content type of " + selectedFile, e); //$NON-NLS-1$
+ }
+
+ IContentType _contentType = contentType;
+ generators.stream().filter(gen -> gen.canGenerate(selectedFile, _contentType))
+ .findFirst()
+ .ifPresent(gen -> combo.select(generators.indexOf(gen)));
+ }
+
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextWizard.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextWizard.java
index 0c61bcc3f91..5b71bd56090 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextWizard.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/CreateContextWizard.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2015, 2017 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2010, 2021, 2017 CEA LIST, 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
@@ -11,11 +11,13 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 422257
- * Christian W. Damus - bug 482927
- * Vincent Lorenzo (CEA LIST) - bug 520271
+ * Christian W. Damus - bugs 482927, 573987
+ * Vincent Lorenzo (CEA LIST) - bug 520271
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.wizard;
+import static java.util.stream.StreamSupport.stream;
+
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -25,11 +27,16 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.Policy;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.papyrus.customization.properties.generation.Activator;
@@ -40,6 +47,7 @@ import org.eclipse.papyrus.customization.properties.generation.generators.IGener
import org.eclipse.papyrus.customization.properties.generation.layout.ILayoutGenerator;
import org.eclipse.papyrus.customization.properties.generation.messages.Messages;
import org.eclipse.papyrus.customization.properties.generation.wizard.widget.TernaryButton;
+import org.eclipse.papyrus.infra.emf.utils.ResourceUtils;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.contexts.ContextsFactory;
import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
@@ -52,8 +60,12 @@ import org.eclipse.papyrus.infra.properties.ui.UiFactory;
import org.eclipse.papyrus.infra.properties.ui.ValueAttribute;
import org.eclipse.papyrus.infra.properties.ui.runtime.IConfigurationManager;
import org.eclipse.papyrus.infra.properties.ui.runtime.PropertiesRuntime;
+import org.eclipse.papyrus.infra.ui.util.EditorHelper;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
/**
* A Wizard for generating Property view contexts
@@ -87,14 +99,20 @@ public class CreateContextWizard extends Wizard implements INewWizard {
*/
protected ILayoutGenerator layoutGenerator;
+ private IWorkbenchPage workbenchPage;
+
+ private Optional<IFile> currentlySelectedFile;
+
public CreateContextWizard() {
setDefaultPageImageDescriptor(Activator.getDefault().getImageDescriptor("/icons/wizban-custom.png")); //$NON-NLS-1$
}
@Override
public boolean performFinish() {
+ boolean result = false;
+
if (generator == null || contexts == null || contexts.isEmpty() || layoutGenerator == null) {
- return false;
+ return result;
}
IConfigurationManager configManager = PropertiesRuntime.getConfigurationManager();
@@ -124,9 +142,9 @@ public class CreateContextWizard extends Wizard implements INewWizard {
continue;
}
- List<PropertyEditor> editors = new LinkedList<PropertyEditor>();
+ List<PropertyEditor> editors = new LinkedList<>();
// the list of properties for the current view
- final List<Property> properties = new ArrayList<Property>();
+ final List<Property> properties = new ArrayList<>();
for (DataContextElement element : getAllContextElements(view.getDatacontexts())) {
for (Property property : element.getProperties()) {
if (isSelected(fieldSelection, property, view.getElementMultiplicity() != 1)) {
@@ -135,9 +153,9 @@ public class CreateContextWizard extends Wizard implements INewWizard {
}
}
- final List<Property> tmpProperties = new ArrayList<Property>(properties);
+ final List<Property> tmpProperties = new ArrayList<>(properties);
for (Property p1 : tmpProperties) {
- //Bug 519090
+ // Bug 519090
// we remove all redefined properties from the list
properties.removeAll(p1.getRedefinedProperties());
}
@@ -169,11 +187,12 @@ public class CreateContextWizard extends Wizard implements INewWizard {
setNeedsProgressMonitor(true);
final Context currentContext = context;
- final Map<String, Object> saveOptions = new HashMap<String, Object>();
+ final Map<String, Object> saveOptions = new HashMap<>();
saveOptions.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);
getContainer().run(true, true, new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.CreateContextWizard_propertyViewGenerationJobName + currentContext.getUserLabel(), numberOfSections + 1);
monitor.worked(1);
@@ -204,9 +223,24 @@ public class CreateContextWizard extends Wizard implements INewWizard {
Activator.log.error(ex);
}
+ result = true;
}
- return true;
+ if (result) {
+ // Open the "main" generated context file
+ URI uriToOpen = contexts.get(0).eResource().getURI();
+ if (uriToOpen.isPlatformResource()) {
+ IFile file = ResourceUtils.getFile(contexts.get(0).eResource());
+
+ try {
+ IDE.openEditor(workbenchPage, file);
+ } catch (PartInitException e) {
+ Policy.getStatusHandler().show(e.getStatus(), getWindowTitle());
+ }
+ }
+ }
+
+ return result;
}
private boolean isSelected(FieldSelection fieldSelection, Property property, boolean multiple) {
@@ -276,7 +310,7 @@ public class CreateContextWizard extends Wizard implements INewWizard {
protected List<String> getPropertyPath(DataContextElement element) {
List<String> result;
if (element.getPackage() == null) {
- result = new LinkedList<String>();
+ result = new LinkedList<>();
} else {
result = getPropertyPath(element.getPackage());
}
@@ -285,7 +319,7 @@ public class CreateContextWizard extends Wizard implements INewWizard {
}
private Set<DataContextElement> getAllContextElements(Collection<DataContextElement> source) {
- Set<DataContextElement> result = new HashSet<DataContextElement>();
+ Set<DataContextElement> result = new HashSet<>();
for (DataContextElement element : source) {
getAllContextElements(element, result);
}
@@ -303,21 +337,36 @@ public class CreateContextWizard extends Wizard implements INewWizard {
}
}
+ @Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
addPage(mainPage = new CreateContextMainPage());
addPage(generatorPage = new GeneratorPage());
addPage(selectOutputPage = new SelectOutputPage());
addPage(selectFieldsPage = new SelectFieldsPage());
- // addPage(layout = new LayoutPage());
setWindowTitle(Messages.CreateContextWizard_pageTitle);
+ workbenchPage = EditorHelper.getInstance(workbench).getActivePage();
+ currentlySelectedFile = stream(((Iterable<?>) selection).spliterator(), false)
+ .filter(IFile.class::isInstance).map(IFile.class::cast)
+ .findFirst();
+ }
+
+ /**
+ * Query the file that was selected in the workbench when the user launched the wizard.
+ *
+ * @return the currently selected file
+ */
+ Optional<IFile> getCurrentlySelectedFile() {
+ return currentlySelectedFile;
}
protected void setGenerator(IGenerator generator) {
- this.generator = generator;
- generatorPage.setGenerator(generator);
- generatorPage.doBinding();
+ if (!Objects.equals(this.generator, generator)) {
+ this.generator = generator;
+ generatorPage.setGenerator(generator);
+ generatorPage.doBinding();
+ }
}
protected void setContexts(List<Context> contexts) {
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/GeneratorPage.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/GeneratorPage.java
index 41423893f01..abe06fe6e7e 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/GeneratorPage.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/GeneratorPage.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2021 CEA LIST, 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,6 +12,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Strategy improvement of generated files
* Christian W. Damus (CEA) - bug 422257
+ * Christian W. Damus - bug 573987
*
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.wizard;
@@ -23,8 +24,6 @@ import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.databinding.wizard.WizardPageSupport;
@@ -110,7 +109,7 @@ public class GeneratorPage extends AbstractCreateContextPage implements Listener
setDescription(generator.getDescription());
this.generator = generator;
- generator.createControls(generatorControl);
+ generator.createControls(generatorControl, getWizard().getCurrentlySelectedFile().orElse(null));
generatorControl.layout();
srcTextObservable = this.generator.getObservableValue();
root.layout();
@@ -284,26 +283,26 @@ public class GeneratorPage extends AbstractCreateContextPage implements Listener
targetFieldStrategy.setAfterConvertValidator(srcValidator);
binding = ctx.bindValue(srcTextObservable, targetTextObservable, srcFieldStrategy, targetFieldStrategy);
- }
- }
-
- @Override
- public boolean canFlipToNextPage() {
- binding.getValidationStatus().addValueChangeListener(new IValueChangeListener() {
-
- @Override
- public void handleValueChange(ValueChangeEvent event) {
- IStatus status = (IStatus) event.diff.getNewValue();
+ binding.getValidationStatus().addValueChangeListener(event -> {
+ IStatus status = event.diff.getNewValue();
if (status.isOK() || status.getSeverity() == IStatus.WARNING) {
setNext(true);
} else {
setNext(false);
}
- }
-
- });
+ });
+ // The source file is the "target", which the binding would not normally update to the "model."
+ // But if the source file is already suggested, then we do want to initialize the output file
+ // from it, so update the "target" to the "model" in binding-speak
+ if (srcTextObservable.getValue() != null && !"".equals(srcTextObservable.getValue())) {
+ binding.updateTargetToModel();
+ }
+ }
+ }
+ @Override
+ public boolean canFlipToNextPage() {
return this.next;
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/widget/FileChooser.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/widget/FileChooser.java
index 39750946bbb..1c4767cabdd 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/widget/FileChooser.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/widget/FileChooser.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2021 CEA LIST, 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
@@ -10,6 +10,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 573987
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.wizard.widget;
@@ -18,13 +19,14 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
@@ -66,6 +68,8 @@ public class FileChooser extends Composite implements SelectionListener, Listene
private boolean newFile;
+ private IObservableValue<String> textObservable;
+
/**
* Constructs a new FileChooser in the given Composite
*
@@ -89,6 +93,9 @@ public class FileChooser extends Composite implements SelectionListener, Listene
browse.setText(Messages.FileChooser_browseWorkspace);
browse.addSelectionListener(this);
this.newFile = newFile;
+
+ IWidgetValueProperty<Text, String> prop = WidgetProperties.text(SWT.Modify);
+ textObservable = prop.observeDelayed(600, text);
}
/**
@@ -207,9 +214,7 @@ public class FileChooser extends Composite implements SelectionListener, Listene
if (result.length > 0) {
Object file = result[0];
if (file instanceof IFile) {
- this.currentFile = ((IFile) file);
- text.setText(currentFile.getFullPath().toString());
- notifyChange();
+ setFile((IFile) file);
}
}
}
@@ -226,11 +231,32 @@ public class FileChooser extends Composite implements SelectionListener, Listene
}
public IObservableValue getObservableValue() {
- IWidgetValueProperty prop = WidgetProperties.text(SWT.Modify);
- return prop.observeDelayed(600, text);
+ return textObservable;
}
public void setText(String s) {
text.setText(s);
}
+
+ /**
+ * Set the currently selected file.
+ *
+ * @param file
+ * the currently selected file. May be {@code null} to clear the selection
+ */
+ public void setFile(IFile file) {
+ if (!Objects.equals(file, currentFile) && !text.isDisposed()) {
+ currentFile = file;
+ if (file == null) {
+ text.setText(""); //$NON-NLS-1$
+ } else {
+ text.setText(file.getFullPath().toString());
+ }
+
+ // Trigger the update immediately
+ getObservableValue().getValue();
+
+ notifyChange();
+ }
+ }
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java
index 35eb5c74cc7..f54a72a6619 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java
@@ -10,15 +10,16 @@
*
* Contributors:
* CEA LIST - Initial API and implementation (Ansgar Radermacher)
- * Christian W. Damus - bug 572676
+ * Christian W. Damus - bugs 572676, 575220
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.utils;
+import java.util.ArrayList;
+
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
@@ -72,20 +73,21 @@ public class StaticProfileUtil {
nsURI = profile.getURI();
}
if (nsURI == null) {
- Resource profileResource = profile.eResource();
- String profileResourceBaseName = profileResource == null ? null : profileResource.getURI().lastSegment();
- if (profileResourceBaseName != null) {
- // trim extensions (e.g., ".profile.uml")
- int dot = profileResourceBaseName.indexOf('.');
- if (dot >= 0) {
- profileResourceBaseName = profileResourceBaseName.substring(0, dot);
+ // Use the algorithm employed by the EMF UML Importer to get the implied NS URI
+ EPackage ePackage = (EPackage) new org.eclipse.uml2.uml.util.UMLUtil.UML2EcoreConverter() {
+ {
+ // This would normally be created by the convert() API
+ this.packages = new ArrayList<>();
+ }
+
+ // Disable the recursive conversion because it is unnecessary for this purpose
+ @Override
+ public Object defaultCase(org.eclipse.emf.ecore.EObject eObject) {
+ return null;
}
- } else {
- profileResourceBaseName = profile.getName();
- }
- // As generated by the EMF Model Importer
- nsURI = String.format("http:///%s.ecore", profileResourceBaseName); //$NON-NLS-1$
+ }.casePackage(profile);
+ nsURI = ePackage.getNsURI();
}
definition.setNsURI(nsURI);
}

Back to the top