Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-07-09 14:08:42 +0000
committercletavernie2012-07-09 14:08:42 +0000
commit64868d5c559d5b631dadf122511d03302459d049 (patch)
tree1780dd6a82daf95bdd2a62a82252ca33cd88cbf9 /plugins/customization
parent36ced9622e91785ed03e5f18490a642e91e42098 (diff)
downloadorg.eclipse.papyrus-64868d5c559d5b631dadf122511d03302459d049.tar.gz
org.eclipse.papyrus-64868d5c559d5b631dadf122511d03302459d049.tar.xz
org.eclipse.papyrus-64868d5c559d5b631dadf122511d03302459d049.zip
384570: [CSS - Export] It should be possible to export a set of stylesheets to create a Theme plug-in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384570
Diffstat (limited to 'plugins/customization')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/plugin.xml1
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/schema/metamodel.exsd102
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/creation/CustomizationElementCreationFactory.java48
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/display/DisplayManager.java11
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/FileBasedExtensionFactory.java53
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/PropertyViewExtensionFactory.java8
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElement.java11
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElementFactory.java11
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/wizard/CreateNewCustomizationPluginWizard.java23
9 files changed, 133 insertions, 135 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization/plugin.xml b/plugins/customization/org.eclipse.papyrus.customization/plugin.xml
index 9b69cff3b10..09386e5da59 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/plugin.xml
+++ b/plugins/customization/org.eclipse.papyrus.customization/plugin.xml
@@ -10,7 +10,6 @@
<plugin>
<extension-point id="factory" name="factory" schema="schema/factory.exsd"/>
- <extension-point id="metamodel" name="metamodel" schema="schema/metamodel.exsd"/>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
diff --git a/plugins/customization/org.eclipse.papyrus.customization/schema/metamodel.exsd b/plugins/customization/org.eclipse.papyrus.customization/schema/metamodel.exsd
deleted file mode 100644
index abe6c35dcda..00000000000
--- a/plugins/customization/org.eclipse.papyrus.customization/schema/metamodel.exsd
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.customization" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.papyrus.customization" id="metamodel" name="metamodel"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="metamodel" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="metamodel">
- <complexType>
- <attribute name="package" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.EPackage"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/creation/CustomizationElementCreationFactory.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/creation/CustomizationElementCreationFactory.java
index 1253f08f310..92034df2299 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/creation/CustomizationElementCreationFactory.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/creation/CustomizationElementCreationFactory.java
@@ -1,12 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
package org.eclipse.papyrus.customization.creation;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
+import org.eclipse.papyrus.customization.Activator;
+import org.eclipse.papyrus.customization.factory.ExtensionFactory;
+import org.eclipse.papyrus.customization.factory.ExtensionFactoryRegistry;
import org.eclipse.papyrus.customization.model.customizationplugin.CustomizationPluginPackage;
import org.eclipse.papyrus.customization.model.customizationplugin.Profile;
import org.eclipse.papyrus.customization.model.customizationplugin.UMLModel;
import org.eclipse.papyrus.customization.wizard.CreateNewCustomizationPluginWizard;
+import org.eclipse.papyrus.infra.emf.utils.EClassNameComparator;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.views.properties.creation.EcorePropertyEditorFactory;
import org.eclipse.swt.widgets.Control;
@@ -20,6 +42,13 @@ public class CustomizationElementCreationFactory extends EcorePropertyEditorFact
}
@Override
+ protected List<EClass> getAvailableEClasses() {
+ List<EClass> availableEClasses = EMFHelper.getSubclassesOf(type, true, getContributedEPackages());
+ Collections.sort(availableEClasses, new EClassNameComparator());
+ return availableEClasses;
+ }
+
+ @Override
protected EObject simpleCreateObject(Control widget) {
EClass eClass = chooseEClass(widget);
if(eClass == null) {
@@ -35,4 +64,23 @@ public class CustomizationElementCreationFactory extends EcorePropertyEditorFact
return instance;
}
+ public static final String METAMODEL_EXTENSION = Activator.PLUGIN_ID;
+
+ protected static Set<EPackage> getContributedEPackages() {
+ if(contributedEPackages == null) {
+ contributedEPackages = new HashSet<EPackage>();
+ for(ExtensionFactory factory : ExtensionFactoryRegistry.instance.getFactories()) {
+ if(factory.getCustomizableElementClass() != null) {
+ if(factory.getCustomizableElementClass().getEPackage() != null) {
+ contributedEPackages.add(factory.getCustomizableElementClass().getEPackage());
+ }
+ }
+
+ }
+ }
+ return contributedEPackages;
+ }
+
+ protected static Set<EPackage> contributedEPackages;
+
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/display/DisplayManager.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/display/DisplayManager.java
index fba9493b385..c7709df2df3 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/display/DisplayManager.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/display/DisplayManager.java
@@ -1,3 +1,14 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
package org.eclipse.papyrus.customization.display;
import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/FileBasedExtensionFactory.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/FileBasedExtensionFactory.java
index b9777967d63..8326703dc6d 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/FileBasedExtensionFactory.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/FileBasedExtensionFactory.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.customization.factory;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -28,15 +29,15 @@ import org.w3c.dom.Element;
public abstract class FileBasedExtensionFactory implements ExtensionFactory {
- private final String extensionPoint;
+ protected final String extensionPoint;
- private final String fileAttributeName;
+ protected final String fileAttributeName;
- private final String fileElementName;
+ protected final String fileElementName;
- private final boolean allowMultiple;
+ protected final boolean allowMultiple;
- private final String name;
+ protected final String name;
public FileBasedExtensionFactory(String name, String extensionPoint, String fileAttributeName, String fileElementName, boolean allowMultiple) {
this.extensionPoint = extensionPoint;
@@ -48,7 +49,11 @@ public abstract class FileBasedExtensionFactory implements ExtensionFactory {
public void addElement(CustomizableElement element, PluginEditor editor) {
createExtension((FileBasedCustomizableElement)element, editor);
- copyFile((FileBasedCustomizableElement)element, editor);
+ try {
+ copyFile((FileBasedCustomizableElement)element, editor);
+ } catch (IOException ex) {
+ Activator.log.error(ex);
+ }
}
protected Element createExtension(FileBasedCustomizableElement element, PluginEditor editor) {
@@ -61,21 +66,29 @@ public abstract class FileBasedExtensionFactory implements ExtensionFactory {
return extensionElement;
}
- protected void copyFile(FileBasedCustomizableElement element, PluginEditor editor) {
- String path = element.getFile();
- File sourceFile = FileUtil.getFile(path);
- File targetFile = FileUtil.getWorkspaceFile("/" + editor.getProject().getName() + "/" + getTargetPath(element)); //$NON-NLS-1$ //$NON-NLS-2$
+ protected void copyFile(FileBasedCustomizableElement element, PluginEditor editor) throws FileNotFoundException, IOException {
+ copyFile(element.getFile(), getTargetPath(element), editor);
+ }
+
+ protected void copyFile(String sourcePath, String targetPath, PluginEditor editor) throws FileNotFoundException, IOException {
+ File sourceFile = FileUtil.getFile(sourcePath);
+ File targetFile = FileUtil.getWorkspaceFile("/" + editor.getProject().getName() + "/" + targetPath); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if(sourceFile == null) {
+ throw new IllegalArgumentException("The source path " + sourcePath + " is not valid");
+ }
+
+ if(targetFile == null) {
+ throw new IllegalArgumentException("The target path " + targetPath + " is not valid");
+ }
+
if(!targetFile.getParentFile().exists()) {
targetFile.getParentFile().mkdirs();
}
- try {
- copy(new FileInputStream(sourceFile), targetFile);
- } catch (IOException ex) {
- Activator.log.error(ex);
- }
+ copy(new FileInputStream(sourceFile), targetFile);
- editor.getBuildEditor().addToBuild(getTargetPath(element));
+ editor.getBuildEditor().addToBuild(targetPath);
}
protected String getTargetPath(FileBasedCustomizableElement element) {
@@ -83,7 +96,13 @@ public abstract class FileBasedExtensionFactory implements ExtensionFactory {
}
protected String getFileName(FileBasedCustomizableElement element) {
- String path = element.getFile();
+ return getFileName(element.getFile());
+ }
+
+ protected String getFileName(String path) {
+ if(path == null) {
+ throw new IllegalArgumentException("File path should not be null");
+ }
String fileName;
path = path.replace("\\", "/");
if(path.indexOf("/") < 0) { //$NON-NLS-1$
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/PropertyViewExtensionFactory.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/PropertyViewExtensionFactory.java
index b89ede75d6e..b6435982b31 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/PropertyViewExtensionFactory.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/factory/PropertyViewExtensionFactory.java
@@ -180,8 +180,12 @@ public class PropertyViewExtensionFactory extends FileBasedExtensionFactory {
@Override
protected String getTargetPath(FileBasedCustomizableElement element) {
String fileName = getFileName(element);
- String simpleName = fileName.substring(0, fileName.lastIndexOf(".")); //$NON-NLS-1$
- return "/propertyView/" + simpleName + "/" + fileName; //$NON-NLS-1$ //$NON-NLS-2$
+ if(fileName.indexOf(".") > -1) {
+ String simpleName = fileName.substring(0, fileName.lastIndexOf(".")); //$NON-NLS-1$
+ return "/propertyView/" + simpleName + "/" + fileName; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ return fileName;
+ }
//TODO : Copy the whole directory (.xwt files + model dependencies)
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElement.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElement.java
index 880ca952993..5f7f196814b 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElement.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElement.java
@@ -1,3 +1,14 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
package org.eclipse.papyrus.customization.modelelement;
import org.eclipse.emf.ecore.EObject;
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElementFactory.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElementFactory.java
index dd16c90c401..3de479e66d9 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElementFactory.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/modelelement/CustomizationModelElementFactory.java
@@ -1,3 +1,14 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
package org.eclipse.papyrus.customization.modelelement;
import org.eclipse.emf.ecore.EObject;
diff --git a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/wizard/CreateNewCustomizationPluginWizard.java b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/wizard/CreateNewCustomizationPluginWizard.java
index 6226a84c0a1..29fb3d58291 100644
--- a/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/wizard/CreateNewCustomizationPluginWizard.java
+++ b/plugins/customization/org.eclipse.papyrus.customization/src/org/eclipse/papyrus/customization/wizard/CreateNewCustomizationPluginWizard.java
@@ -11,12 +11,8 @@
*****************************************************************************/
package org.eclipse.papyrus.customization.wizard;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.papyrus.customization.Activator;
import org.eclipse.papyrus.customization.generator.PluginGenerator;
@@ -24,7 +20,6 @@ import org.eclipse.papyrus.customization.messages.Messages;
import org.eclipse.papyrus.customization.model.customizationplugin.CustomizationConfiguration;
import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
import org.eclipse.swt.graphics.Image;
-import org.xml.sax.SAXException;
public class CreateNewCustomizationPluginWizard extends NewPluginProjectWizard {
@@ -71,14 +66,16 @@ public class CreateNewCustomizationPluginWizard extends NewPluginProjectWizard {
try {
PluginGenerator.instance.generate(project, configuration);
project.refreshLocal(IProject.DEPTH_INFINITE, null);
- } catch (CoreException ex) {
- Activator.log.error(ex);
- } catch (IOException ex) {
- Activator.log.error(ex);
- } catch (SAXException ex) {
- Activator.log.error(ex);
- } catch (ParserConfigurationException ex) {
+ } catch (Exception ex) {
Activator.log.error(ex);
+ String errorMessage = "An error occured while generating the customization plug-in: " + ex.getClass().getName() + ": " + ex.getLocalizedMessage(); //$NON-NLS-1$
+ for(IWizardPage page : getPages()) {
+ if(page instanceof DialogPage) {
+ ((DialogPage)page).setErrorMessage(errorMessage);
+ }
+
+ }
+ return false;
}
}

Back to the top