Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2015-04-10 09:37:38 +0000
committercbrun2015-04-10 09:37:38 +0000
commitac1d40c319eaf0e9d7967f7e707d47513a2fe7ac (patch)
treeadfacfc8f50d7cc3bb14b05b992f5595eca9f044
parent01058ed45ea13c8f4f73fe97e22e4db3691c822f (diff)
downloadorg.eclipse.ecoretools-ac1d40c319eaf0e9d7967f7e707d47513a2fe7ac.tar.gz
org.eclipse.ecoretools-ac1d40c319eaf0e9d7967f7e707d47513a2fe7ac.tar.xz
org.eclipse.ecoretools-ac1d40c319eaf0e9d7967f7e707d47513a2fe7ac.zip
[464268] Remove dependencies to ecore.editor plugin
-rw-r--r--org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelerWizard.java1066
-rw-r--r--org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelingProjectCreationOperation.java4
-rw-r--r--org.eclipse.emf.ecoretools.design/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java2
-rw-r--r--org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/DesignServices.java47
-rw-r--r--org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/EcoreToolsDesignPlugin.java122
6 files changed, 604 insertions, 640 deletions
diff --git a/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelerWizard.java b/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelerWizard.java
index b158707..cf770d6 100644
--- a/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelerWizard.java
+++ b/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelerWizard.java
@@ -83,563 +83,511 @@ import com.google.common.collect.Lists;
*/
public class EcoreModelerWizard extends BasicNewProjectResourceWizard {
- /** The name of the Design viewpoint. */
- private static final String DESIGN_VIEWPOINT_NAME = "Design"; //$NON-NLS-1$
-
- private EcoreModelSpecPage modelPage;
-
- private ViewpointsSelectionWizardPage viewpointsSelectionWizardPage;
-
- private WizardNewProjectCreationPage wizardNewProjectCreationPage;
-
- protected IWorkbench workbench;
- protected IPath genModelProjectLocation;
- protected IPath genModelContainerPath;
- protected String initialProjectName;
- protected IStructuredSelection selection;
-
- private IProject createdProject;
-
- /**
- * Constructor.
- */
- public EcoreModelerWizard() {
- super();
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- super.init(workbench, selection);
- this.workbench = workbench;
- this.selection = selection;
- setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE
- .getImageDescriptor(GenModelEditPlugin.INSTANCE
- .getImage("full/wizban/NewEmptyEMFProject")));
- setWindowTitle(GenModelEditPlugin.INSTANCE
- .getString("_UI_NewEmptyProject_title"));
- setWindowTitle("New Ecore Modeling Project"); //$NON-NLS-1$
- setDefaultPageImageDescriptor(AbstractUIPlugin
- .imageDescriptorFromPlugin(EcoreToolsDesignPlugin.PLUGIN_ID,
- "icons/full/wizban/EcoreModelingProject_wizban.png"));
- setNeedsProgressMonitor(true);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addPages() {
- wizardNewProjectCreationPage = new WizardNewProjectCreationPage(
- SiriusEditPlugin.getPlugin().getString(
- "_UI_ModelingProjectWizard_label")) {
-
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
-
- Composite control = (Composite) getControl();
- GridLayout layout = new GridLayout();
- control.setLayout(layout);
-
- createWorkingSetGroup(
- control,
- new StructuredSelection(),
- new String[] {
- "org.eclipse.jdt.ui.JavaWorkingSetPage", //$NON-NLS-1$
- "org.eclipse.pde.ui.pluginWorkingSet", "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$ //$NON-NLS-2$
-
- Dialog.applyDialogFont(control);
- }
-
- @Override
- protected boolean validatePage() {
- if (super.validatePage()) {
- IPath locationPath = getLocationPath();
- genModelProjectLocation = Platform.getLocation().equals(
- locationPath) ? null : locationPath;
- IPath projectPath = getProjectHandle().getFullPath();
- genModelContainerPath = projectPath.append("src"); //$NON-NLS-1$
-
- updateModelPagePackageName(getProjectName());
- return true;
- } else {
- return false;
- }
- }
-
- private void updateModelPagePackageName(String projectName) {
- if (!StringUtil.isEmpty(projectName)) {
- String packageName = getPackageName(projectName);
- if (!StringUtil.isEmpty(packageName)) {
- modelPage.setPackageNameSilently(packageName);
- }
- }
- }
-
- };
-
- wizardNewProjectCreationPage.setInitialProjectName(initialProjectName);
- wizardNewProjectCreationPage
- .setTitle("Create a new Ecore Modeling project"); //$NON-NLS-1$
- wizardNewProjectCreationPage.setDescription("Enter a project name"); //$NON-NLS-1$
-
- modelPage = new EcoreModelSpecPage("Ecore model parameters"); //$NON-NLS-1$
- modelPage.setTitle("Model settings"); //$NON-NLS-1$
- modelPage.setDescription("Define the model settings"); //$NON-NLS-1$
-
- viewpointsSelectionWizardPage = new ViewpointsSelectionWizardPage(null,
- Lists.newArrayList(DESIGN_VIEWPOINT_NAME)) {
- @Override
- protected Collection<String> computeSemanticFileExtensions(
- Session session) {
- Set<String> fileExtensions = new HashSet<String>();
- fileExtensions.add("ecore");
- return fileExtensions;
- }
- };
-
- // Fix for VP-3711 to avoid a NPE on 3.8
- ReflectionHelper.setFieldValueWithoutException(this,
- "newProjectCreationPage", wizardNewProjectCreationPage);
-
- addPage(wizardNewProjectCreationPage);
- addPage(modelPage);
- addPage(viewpointsSelectionWizardPage);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
- boolean finished = true;
-
- updatePerspective();
- final EcoreModelingProjectCreationOperation ecoreModelingProjectCreationOperation = new EcoreModelingProjectCreationOperation(
- modelPage.getEPackage(), modelPage.getEcoreFileName(),
- modelPage.getGenModelFileName(),
- modelPage.getRepresentationFileName(),
- new LinkedHashSet<Viewpoint>(viewpointsSelectionWizardPage
- .getViewpoints()), workbench, genModelContainerPath,
- genModelProjectLocation,
- wizardNewProjectCreationPage.getSelectedWorkingSets());
- try {
- getContainer().run(true, false,
- ecoreModelingProjectCreationOperation);
- } catch (InvocationTargetException e) {
- IStatus status = new Status(IStatus.ERROR,
- EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR,
- e.getMessage(), e);
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
- finished = false;
- } catch (InterruptedException e) {
- IStatus status = new Status(IStatus.ERROR,
- EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR,
- e.getMessage(), e);
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
- finished = false;
- }
- try {
- getContainer().run(false, false, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask("Open the diagram metamodel", 2);
-
- IFile ecoreModel = ecoreModelingProjectCreationOperation
- .getEcoreModel();
- createdProject = ecoreModelingProjectCreationOperation
- .getNewProject();
- if (ecoreModel != null && ecoreModel.exists()) {
- selectAndReveal(ecoreModel);
- } else {
- selectAndReveal(ecoreModelingProjectCreationOperation
- .getNewProject());
- }
- monitor.worked(1);
-
- // Open the entities diagram, of the root of the
- // ecore
- // file,
- // that is automatically created (because the
- // Entities
- // diagram has
- // the "initialization" to true).
- // This can fail if the user deselects the "Design"
- // viewpoint in the second page of the wizard.
- openFirstRepresentation(
- ecoreModelingProjectCreationOperation
- .getNewProject(),
- new SubProgressMonitor(monitor, 1));
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- IStatus status = new Status(IStatus.ERROR,
- EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR,
- e.getMessage(), e);
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
- finished = false;
- } catch (InterruptedException e) {
- IStatus status = new Status(IStatus.ERROR,
- EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR,
- e.getMessage(), e);
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
- finished = false;
- }
- return finished;
- }
-
- @Override
- public IProject getNewProject() {
- return createdProject;
- }
-
- /**
- * Selects and reveals the newly added resource in all parts of the active
- * workbench window's active page.
- *
- * @see ISetSelectionTarget
- */
- protected void selectAndReveal(IResource newResource) {
- BasicNewResourceWizard.selectAndReveal(newResource,
- workbench.getActiveWorkbenchWindow());
- EclipseUIUtil.expand(newResource, workbench.getActiveWorkbenchWindow());
- }
-
- /**
- * Open the first representation containing in the representation file of
- * this Modeling project.
- *
- * @param project
- * The modeling project containing the representations file.
- * @param monitor
- * a {@link IProgressMonitor} to show progression of first
- * {@link DRepresentation} opening
- */
- private void openFirstRepresentation(IProject project,
- IProgressMonitor monitor) {
- Option<ModelingProject> opionalModelingProject = ModelingProject
- .asModelingProject(project);
- if (opionalModelingProject.some()) {
- Session session = opionalModelingProject.get().getSession();
- if (session != null) {
- if (!session.getSelectedViews().isEmpty()) {
- DView view = session.getSelectedViews().iterator().next();
- if (!view.getOwnedRepresentations().isEmpty()) {
- DRepresentation representationToOpen = view
- .getOwnedRepresentations().get(0);
- DialectUIManager.INSTANCE.openEditor(session,
- representationToOpen, monitor);
- }
- }
- }
- }
- }
-
- public void setInitialProjectName(String value) {
- initialProjectName = value;
- }
-
- private String getPackageName(String projectName) {
- String packageName = projectName.substring(0, 1).toLowerCase()
- + projectName.substring(1);
- int index = packageName.lastIndexOf('.');
- if (index != -1) {
- packageName = packageName.substring(index + 1);
- }
- return packageName;
- }
-
- private class EcoreModelSpecPage extends WizardPage {
-
- private static final String NAMESPACE_GROUP_LABEL = "Namespace properties";//$NON-NLS-1$
-
- private static final String NS_PREFIX_FIELD_LABEL = "Ns Prefix"; //$NON-NLS-1$
-
- private static final String NS_URI_FIELD_LABEL = "Ns Uri"; //$NON-NLS-1$
-
- private static final String USE_DEFAULT_LABEL = "Use default namespace parameters"; //$NON-NLS-1$
-
- private static final String PACKAGE_FIELD_LABEL = "Main package name"; //$NON-NLS-1$
-
- private static final String DEFAULT_URI_BASE = "http://www.example.org/"; //$NON-NLS-1$
-
- private static final String DEFAULT_COMMON_FILE_NAME = "model"; //$NON-NLS-1$
-
- // widgets
- private Text packageNameField;
-
- private Text nsPrefixField;
-
- private Text nsUriField;
-
- private Button useDefaultsButton;
-
- private EPackage ePackage;
-
- private boolean silentModificationEnabled = true;
-
- private final ModifyListener nsModifyListener = new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- if (!(useDefaultsButton != null && useDefaultsButton
- .getSelection())) {
- setPageComplete(validatePage());
- }
- }
- };
-
- public EcoreModelSpecPage(String name) {
- super(name);
- }
-
- /**
- * Allow an other page to set the package name until the user manualy
- * modify it.
- *
- * @param packageName
- * the package name to set.
- */
- public void setPackageNameSilently(String packageName) {
- if (packageNameField != null && silentModificationEnabled) {
- packageNameField.setText(packageName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createModelGroup(composite);
- createNamespaceGroup(composite, false);
-
- setPageComplete(validatePage());
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- }
-
- private void createModelGroup(Composite parent) {
- packageNameField = createLabelAndText(parent, PACKAGE_FIELD_LABEL,
- getPackageName());
- packageNameField.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- if (packageNameField.isVisible()) {
- silentModificationEnabled = false;
- }
- updateNamespaceValues();
- setPageComplete(validatePage());
- }
- });
-
- }
-
- private void createNamespaceGroup(Composite composite, boolean custom) {
- Group nsGroup = new Group(composite, SWT.NONE);
- nsGroup.setFont(composite.getFont());
- nsGroup.setText(NAMESPACE_GROUP_LABEL);
- nsGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- nsGroup.setLayout(new GridLayout(1, false));
-
- useDefaultsButton = new Button(nsGroup, SWT.CHECK | SWT.RIGHT);
- useDefaultsButton.setText(USE_DEFAULT_LABEL);
-
- GridData buttonData = new GridData();
- buttonData.horizontalSpan = 4;
- useDefaultsButton.setLayoutData(buttonData);
- useDefaultsButton.setSelection(!custom);
-
- nsUriField = createLabelAndText(nsGroup, NS_URI_FIELD_LABEL,
- getNsUri());
- nsPrefixField = createLabelAndText(nsGroup, NS_PREFIX_FIELD_LABEL,
- getNsPRefix());
-
- nsUriField.addModifyListener(nsModifyListener);
- nsPrefixField.addModifyListener(nsModifyListener);
- setNameSpaceGroupActivation(custom);
-
- useDefaultsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- boolean useDefault = useDefaultsButton.getSelection();
- if (useDefault) {
- updateNamespaceValues();
- }
- setNameSpaceGroupActivation(!useDefault);
- setPageComplete(validatePage());
- }
- });
- }
-
- private void setNameSpaceGroupActivation(boolean enabled) {
- if (nsUriField != null) {
- nsUriField.setEnabled(enabled);
- }
-
- if (nsPrefixField != null) {
- nsPrefixField.setEnabled(enabled);
- }
- }
-
- private void updateNamespaceValues() {
- if (useDefaultsButton != null && useDefaultsButton.getSelection()) {
- String packageName = getPackageName();
- if (nsPrefixField != null) {
- nsPrefixField.setText(packageName);
- }
-
- if (nsUriField != null) {
- nsUriField.setText(getDefaultNsUri(packageName));
- }
- }
- }
-
- private Text createLabelAndText(Composite parent, String label,
- String initialValue) {
- Composite group = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // label
- Label labelField = new Label(group, SWT.NONE);
- labelField.setText(label);
- labelField.setFont(parent.getFont());
-
- // text
- Text textField = new Text(group, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = 250;
- textField.setLayoutData(data);
- textField.setFont(parent.getFont());
- if (initialValue != null) {
- textField.setText(initialValue);
- }
- return textField;
- }
-
- public EPackage getEPackage() {
- if (ePackage == null) {
- initEPackage();
- }
- return ePackage;
- }
-
- private void initEPackage() {
- EClass eClass = (EClass) EcorePackage.eINSTANCE
- .getEClassifier("EPackage");
- EObject rootObject = EcoreFactory.eINSTANCE.create(eClass);
-
- if (rootObject instanceof EPackage) {
- ePackage = (EPackage) rootObject;
- updateEPackage(ePackage);
- }
- }
-
- private void updateEPackage(EPackage p) {
- p.setName(getPackageName());
- p.setNsPrefix(getNsPRefix());
- p.setNsURI(getNsUri());
- }
-
- /**
- * Returns whether this page's controls currently all contain valid
- * values.
- *
- * @return <code>true</code> if all controls are valid, and
- * <code>false</code> if at least one is invalid
- */
- protected boolean validatePage() {
- if (ePackage == null) {
- initEPackage();
- } else {
- updateEPackage(ePackage);
- }
-
- EcoreValidator validator = new EcoreValidator();
- BasicDiagnostic diagnostic = new BasicDiagnostic();
- boolean validName = validator.validateENamedElement_WellFormedName(
- ePackage, diagnostic, null);
- boolean validNsUri = validator.validateEPackage_WellFormedNsURI(
- ePackage, diagnostic, null);
- boolean validNsPrefix = validator
- .validateEPackage_WellFormedNsPrefix(ePackage, diagnostic,
- null);
-
- boolean validEPackage = validName && validNsUri && validNsPrefix;
- if (validEPackage) {
- setErrorMessage(null);
- } else {
- StringBuilder sb = new StringBuilder();
- buildCompoundMessage(sb, diagnostic);
- setErrorMessage(sb.toString());
- }
- return validEPackage;
- }
-
- private void buildCompoundMessage(StringBuilder sb,
- Diagnostic diagnostic) {
- if (!StringUtil.isEmpty(diagnostic.getMessage())
- && diagnostic.getSeverity() != Diagnostic.OK) {
- sb.append(diagnostic.getMessage());
- sb.append("\n");
- }
-
- for (Diagnostic child : diagnostic.getChildren()) {
- buildCompoundMessage(sb, child);
- }
- }
-
- private String getPackageName() {
- if (packageNameField == null) {
- return DEFAULT_COMMON_FILE_NAME;
- }
-
- return packageNameField.getText().trim();
- }
-
- private String getNsUri() {
- if (nsUriField == null) {
- return getDefaultNsUri(getPackageName());
- }
-
- return nsUriField.getText().trim();
- }
-
- private String getDefaultNsUri(String packageName) {
- return DEFAULT_URI_BASE + packageName;
- }
-
- private String getNsPRefix() {
- if (nsPrefixField == null) {
- return getPackageName();
- }
-
- return nsPrefixField.getText().trim();
- }
-
- public String getRepresentationFileName() {
- return getPackageName()
- + "." + SiriusUtil.SESSION_RESOURCE_EXTENSION; //$NON-NLS-1$
- }
-
- public String getEcoreFileName() {
- return getPackageName() + ".ecore"; //$NON-NLS-1$
- }
-
- public String getGenModelFileName() {
- return getPackageName() + ".genmodel"; //$NON-NLS-1$
- }
- }
+ /** The name of the Design viewpoint. */
+ private static final String DESIGN_VIEWPOINT_NAME = "Design"; //$NON-NLS-1$
+
+ private EcoreModelSpecPage modelPage;
+
+ private ViewpointsSelectionWizardPage viewpointsSelectionWizardPage;
+
+ private WizardNewProjectCreationPage wizardNewProjectCreationPage;
+
+ protected IWorkbench workbench;
+
+ protected IPath genModelProjectLocation;
+
+ protected IPath genModelContainerPath;
+
+ protected String initialProjectName;
+
+ protected IStructuredSelection selection;
+
+ private IProject createdProject;
+
+ /**
+ * Constructor.
+ */
+ public EcoreModelerWizard() {
+ super();
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ this.workbench = workbench;
+ this.selection = selection;
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(GenModelEditPlugin.INSTANCE.getImage("full/wizban/NewEmptyEMFProject")));
+ setWindowTitle(GenModelEditPlugin.INSTANCE.getString("_UI_NewEmptyProject_title"));
+ setWindowTitle("New Ecore Modeling Project"); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(EcoreToolsDesignPlugin.PLUGIN_ID, "icons/full/wizban/EcoreModelingProject_wizban.png"));
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addPages() {
+ wizardNewProjectCreationPage = new WizardNewProjectCreationPage(SiriusEditPlugin.getPlugin().getString("_UI_ModelingProjectWizard_label")) {
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ Composite control = (Composite) getControl();
+ GridLayout layout = new GridLayout();
+ control.setLayout(layout);
+
+ createWorkingSetGroup(control, new StructuredSelection(), new String[] { "org.eclipse.jdt.ui.JavaWorkingSetPage", //$NON-NLS-1$
+ "org.eclipse.pde.ui.pluginWorkingSet", "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Dialog.applyDialogFont(control);
+ }
+
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ IPath locationPath = getLocationPath();
+ genModelProjectLocation = Platform.getLocation().equals(locationPath) ? null : locationPath;
+ IPath projectPath = getProjectHandle().getFullPath();
+ genModelContainerPath = projectPath.append("src"); //$NON-NLS-1$
+
+ updateModelPagePackageName(getProjectName());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void updateModelPagePackageName(String projectName) {
+ if (!StringUtil.isEmpty(projectName)) {
+ String packageName = getPackageName(projectName);
+ if (!StringUtil.isEmpty(packageName)) {
+ modelPage.setPackageNameSilently(packageName);
+ }
+ }
+ }
+
+ };
+
+ wizardNewProjectCreationPage.setInitialProjectName(initialProjectName);
+ wizardNewProjectCreationPage.setTitle("Create a new Ecore Modeling project"); //$NON-NLS-1$
+ wizardNewProjectCreationPage.setDescription("Enter a project name"); //$NON-NLS-1$
+
+ modelPage = new EcoreModelSpecPage("Ecore model parameters"); //$NON-NLS-1$
+ modelPage.setTitle("Model settings"); //$NON-NLS-1$
+ modelPage.setDescription("Define the model settings"); //$NON-NLS-1$
+
+ viewpointsSelectionWizardPage = new ViewpointsSelectionWizardPage(null, Lists.newArrayList(DESIGN_VIEWPOINT_NAME)) {
+ @Override
+ protected Collection<String> computeSemanticFileExtensions(Session session) {
+ Set<String> fileExtensions = new HashSet<String>();
+ fileExtensions.add("ecore");
+ return fileExtensions;
+ }
+ };
+
+ // Fix for VP-3711 to avoid a NPE on 3.8
+ ReflectionHelper.setFieldValueWithoutException(this, "newProjectCreationPage", wizardNewProjectCreationPage);
+
+ addPage(wizardNewProjectCreationPage);
+ addPage(modelPage);
+ addPage(viewpointsSelectionWizardPage);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ boolean finished = true;
+
+ updatePerspective();
+ final EcoreModelingProjectCreationOperation ecoreModelingProjectCreationOperation = new EcoreModelingProjectCreationOperation(modelPage.getEPackage(), modelPage.getEcoreFileName(),
+ modelPage.getGenModelFileName(), modelPage.getRepresentationFileName(), new LinkedHashSet<Viewpoint>(viewpointsSelectionWizardPage.getViewpoints()), workbench, genModelContainerPath,
+ genModelProjectLocation, wizardNewProjectCreationPage.getSelectedWorkingSets());
+ try {
+ getContainer().run(true, false, ecoreModelingProjectCreationOperation);
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
+ finished = false;
+ } catch (InterruptedException e) {
+ IStatus status = new Status(IStatus.ERROR, EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
+ finished = false;
+ }
+ try {
+ getContainer().run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ monitor.beginTask("Open the diagram metamodel", 2);
+
+ IFile ecoreModel = ecoreModelingProjectCreationOperation.getEcoreModel();
+ createdProject = ecoreModelingProjectCreationOperation.getNewProject();
+ if (ecoreModel != null && ecoreModel.exists()) {
+ selectAndReveal(ecoreModel);
+ } else {
+ selectAndReveal(ecoreModelingProjectCreationOperation.getNewProject());
+ }
+ monitor.worked(1);
+
+ // Open the entities diagram, of the root of the
+ // ecore
+ // file,
+ // that is automatically created (because the
+ // Entities
+ // diagram has
+ // the "initialization" to true).
+ // This can fail if the user deselects the "Design"
+ // viewpoint in the second page of the wizard.
+ openFirstRepresentation(ecoreModelingProjectCreationOperation.getNewProject(), new SubProgressMonitor(monitor, 1));
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
+ finished = false;
+ } catch (InterruptedException e) {
+ IStatus status = new Status(IStatus.ERROR, EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
+ finished = false;
+ }
+ return finished;
+ }
+
+ @Override
+ public IProject getNewProject() {
+ return createdProject;
+ }
+
+ /**
+ * Selects and reveals the newly added resource in all parts of the active
+ * workbench window's active page.
+ *
+ * @see ISetSelectionTarget
+ */
+ protected void selectAndReveal(IResource newResource) {
+ BasicNewResourceWizard.selectAndReveal(newResource, workbench.getActiveWorkbenchWindow());
+ EclipseUIUtil.expand(newResource, workbench.getActiveWorkbenchWindow());
+ }
+
+ /**
+ * Open the first representation containing in the representation file of
+ * this Modeling project.
+ *
+ * @param project
+ * The modeling project containing the representations file.
+ * @param monitor
+ * a {@link IProgressMonitor} to show progression of first
+ * {@link DRepresentation} opening
+ */
+ private void openFirstRepresentation(IProject project, IProgressMonitor monitor) {
+ Option<ModelingProject> opionalModelingProject = ModelingProject.asModelingProject(project);
+ if (opionalModelingProject.some()) {
+ Session session = opionalModelingProject.get().getSession();
+ if (session != null) {
+ if (!session.getSelectedViews().isEmpty()) {
+ DView view = session.getSelectedViews().iterator().next();
+ if (!view.getOwnedRepresentations().isEmpty()) {
+ DRepresentation representationToOpen = view.getOwnedRepresentations().get(0);
+ DialectUIManager.INSTANCE.openEditor(session, representationToOpen, monitor);
+ }
+ }
+ }
+ }
+ }
+
+ public void setInitialProjectName(String value) {
+ initialProjectName = value;
+ }
+
+ private String getPackageName(String projectName) {
+ String packageName = projectName.substring(0, 1).toLowerCase() + projectName.substring(1);
+ int index = packageName.lastIndexOf('.');
+ if (index != -1) {
+ packageName = packageName.substring(index + 1);
+ }
+ return packageName;
+ }
+
+ private class EcoreModelSpecPage extends WizardPage {
+
+ private static final String NAMESPACE_GROUP_LABEL = "Namespace properties";//$NON-NLS-1$
+
+ private static final String NS_PREFIX_FIELD_LABEL = "Ns Prefix"; //$NON-NLS-1$
+
+ private static final String NS_URI_FIELD_LABEL = "Ns Uri"; //$NON-NLS-1$
+
+ private static final String USE_DEFAULT_LABEL = "Use default namespace parameters"; //$NON-NLS-1$
+
+ private static final String PACKAGE_FIELD_LABEL = "Main package name"; //$NON-NLS-1$
+
+ private static final String DEFAULT_URI_BASE = "http://www.example.org/"; //$NON-NLS-1$
+
+ private static final String DEFAULT_COMMON_FILE_NAME = "model"; //$NON-NLS-1$
+
+ // widgets
+ private Text packageNameField;
+
+ private Text nsPrefixField;
+
+ private Text nsUriField;
+
+ private Button useDefaultsButton;
+
+ private EPackage ePackage;
+
+ private boolean silentModificationEnabled = true;
+
+ private final ModifyListener nsModifyListener = new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ if (!(useDefaultsButton != null && useDefaultsButton.getSelection())) {
+ setPageComplete(validatePage());
+ }
+ }
+ };
+
+ public EcoreModelSpecPage(String name) {
+ super(name);
+ }
+
+ /**
+ * Allow an other page to set the package name until the user manualy
+ * modify it.
+ *
+ * @param packageName
+ * the package name to set.
+ */
+ public void setPackageNameSilently(String packageName) {
+ if (packageNameField != null && silentModificationEnabled) {
+ packageNameField.setText(packageName);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createModelGroup(composite);
+ createNamespaceGroup(composite, false);
+
+ setPageComplete(validatePage());
+
+ setControl(composite);
+ Dialog.applyDialogFont(composite);
+ }
+
+ private void createModelGroup(Composite parent) {
+ packageNameField = createLabelAndText(parent, PACKAGE_FIELD_LABEL, getPackageName());
+ packageNameField.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ if (packageNameField.isVisible()) {
+ silentModificationEnabled = false;
+ }
+ updateNamespaceValues();
+ setPageComplete(validatePage());
+ }
+ });
+
+ }
+
+ private void createNamespaceGroup(Composite composite, boolean custom) {
+ Group nsGroup = new Group(composite, SWT.NONE);
+ nsGroup.setFont(composite.getFont());
+ nsGroup.setText(NAMESPACE_GROUP_LABEL);
+ nsGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ nsGroup.setLayout(new GridLayout(1, false));
+
+ useDefaultsButton = new Button(nsGroup, SWT.CHECK | SWT.RIGHT);
+ useDefaultsButton.setText(USE_DEFAULT_LABEL);
+
+ GridData buttonData = new GridData();
+ buttonData.horizontalSpan = 4;
+ useDefaultsButton.setLayoutData(buttonData);
+ useDefaultsButton.setSelection(!custom);
+
+ nsUriField = createLabelAndText(nsGroup, NS_URI_FIELD_LABEL, getNsUri());
+ nsPrefixField = createLabelAndText(nsGroup, NS_PREFIX_FIELD_LABEL, getNsPRefix());
+
+ nsUriField.addModifyListener(nsModifyListener);
+ nsPrefixField.addModifyListener(nsModifyListener);
+ setNameSpaceGroupActivation(custom);
+
+ useDefaultsButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ boolean useDefault = useDefaultsButton.getSelection();
+ if (useDefault) {
+ updateNamespaceValues();
+ }
+ setNameSpaceGroupActivation(!useDefault);
+ setPageComplete(validatePage());
+ }
+ });
+ }
+
+ private void setNameSpaceGroupActivation(boolean enabled) {
+ if (nsUriField != null) {
+ nsUriField.setEnabled(enabled);
+ }
+
+ if (nsPrefixField != null) {
+ nsPrefixField.setEnabled(enabled);
+ }
+ }
+
+ private void updateNamespaceValues() {
+ if (useDefaultsButton != null && useDefaultsButton.getSelection()) {
+ String packageName = getPackageName();
+ if (nsPrefixField != null) {
+ nsPrefixField.setText(packageName);
+ }
+
+ if (nsUriField != null) {
+ nsUriField.setText(getDefaultNsUri(packageName));
+ }
+ }
+ }
+
+ private Text createLabelAndText(Composite parent, String label, String initialValue) {
+ Composite group = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // label
+ Label labelField = new Label(group, SWT.NONE);
+ labelField.setText(label);
+ labelField.setFont(parent.getFont());
+
+ // text
+ Text textField = new Text(group, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 250;
+ textField.setLayoutData(data);
+ textField.setFont(parent.getFont());
+ if (initialValue != null) {
+ textField.setText(initialValue);
+ }
+ return textField;
+ }
+
+ public EPackage getEPackage() {
+ if (ePackage == null) {
+ initEPackage();
+ }
+ return ePackage;
+ }
+
+ private void initEPackage() {
+ EClass eClass = (EClass) EcorePackage.eINSTANCE.getEClassifier("EPackage");
+ EObject rootObject = EcoreFactory.eINSTANCE.create(eClass);
+
+ if (rootObject instanceof EPackage) {
+ ePackage = (EPackage) rootObject;
+ updateEPackage(ePackage);
+ }
+ }
+
+ private void updateEPackage(EPackage p) {
+ p.setName(getPackageName());
+ p.setNsPrefix(getNsPRefix());
+ p.setNsURI(getNsUri());
+ }
+
+ /**
+ * Returns whether this page's controls currently all contain valid
+ * values.
+ *
+ * @return <code>true</code> if all controls are valid, and
+ * <code>false</code> if at least one is invalid
+ */
+ protected boolean validatePage() {
+ if (ePackage == null) {
+ initEPackage();
+ } else {
+ updateEPackage(ePackage);
+ }
+
+ EcoreValidator validator = new EcoreValidator();
+ BasicDiagnostic diagnostic = new BasicDiagnostic();
+ boolean validName = validator.validateENamedElement_WellFormedName(ePackage, diagnostic, null);
+ boolean validNsUri = validator.validateEPackage_WellFormedNsURI(ePackage, diagnostic, null);
+ boolean validNsPrefix = validator.validateEPackage_WellFormedNsPrefix(ePackage, diagnostic, null);
+
+ boolean validEPackage = validName && validNsUri && validNsPrefix;
+ if (validEPackage) {
+ setErrorMessage(null);
+ } else {
+ StringBuilder sb = new StringBuilder();
+ buildCompoundMessage(sb, diagnostic);
+ setErrorMessage(sb.toString());
+ }
+ return validEPackage;
+ }
+
+ private void buildCompoundMessage(StringBuilder sb, Diagnostic diagnostic) {
+ if (!StringUtil.isEmpty(diagnostic.getMessage()) && diagnostic.getSeverity() != Diagnostic.OK) {
+ sb.append(diagnostic.getMessage());
+ sb.append("\n");
+ }
+
+ for (Diagnostic child : diagnostic.getChildren()) {
+ buildCompoundMessage(sb, child);
+ }
+ }
+
+ private String getPackageName() {
+ if (packageNameField == null) {
+ return DEFAULT_COMMON_FILE_NAME;
+ }
+
+ return packageNameField.getText().trim();
+ }
+
+ private String getNsUri() {
+ if (nsUriField == null) {
+ return getDefaultNsUri(getPackageName());
+ }
+
+ return nsUriField.getText().trim();
+ }
+
+ private String getDefaultNsUri(String packageName) {
+ return DEFAULT_URI_BASE + packageName;
+ }
+
+ private String getNsPRefix() {
+ if (nsPrefixField == null) {
+ return getPackageName();
+ }
+
+ return nsPrefixField.getText().trim();
+ }
+
+ public String getRepresentationFileName() {
+ return getPackageName() + "." + SiriusUtil.SESSION_RESOURCE_EXTENSION; //$NON-NLS-1$
+ }
+
+ public String getEcoreFileName() {
+ return getPackageName() + ".ecore"; //$NON-NLS-1$
+ }
+
+ public String getGenModelFileName() {
+ return getPackageName() + ".genmodel"; //$NON-NLS-1$
+ }
+ }
}
diff --git a/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelingProjectCreationOperation.java b/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelingProjectCreationOperation.java
index 4a4e49b..5cbaa28 100644
--- a/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelingProjectCreationOperation.java
+++ b/org.eclipse.emf.ecoretools.design.ui/src/org/eclipse/emf/ecoretools/design/ui/wizard/EcoreModelingProjectCreationOperation.java
@@ -149,7 +149,7 @@ public class EcoreModelingProjectCreationOperation extends
final IStatus status = new Status(IStatus.ERROR,
EcoreToolsDesignPlugin.PLUGIN_ID, IStatus.ERROR,
e.getMessage(), e);
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
}
public void modifyWorkspace(IProgressMonitor progressMonitor)
@@ -323,7 +323,7 @@ public class EcoreModelingProjectCreationOperation extends
EcoreToolsDesignPlugin.PLUGIN_ID,
IStatus.ERROR,
"Error occurs during generating the genmodel file.", exception);//$NON-NLS-1$
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
} finally {
monitor.done();
}
diff --git a/org.eclipse.emf.ecoretools.design/META-INF/MANIFEST.MF b/org.eclipse.emf.ecoretools.design/META-INF/MANIFEST.MF
index cd2d4d1..0933996 100644
--- a/org.eclipse.emf.ecoretools.design/META-INF/MANIFEST.MF
+++ b/org.eclipse.emf.ecoretools.design/META-INF/MANIFEST.MF
@@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.sirius.common,
org.eclipse.sirius.diagram,
org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.emf.ecore.editor,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.importer,
org.eclipse.emf.importer.ecore,
@@ -23,7 +22,7 @@ Require-Bundle: org.eclipse.sirius.common,
Bundle-ManifestVersion: 2
Bundle-Vendor: %providerName
Eclipse-LazyStart: true
-Bundle-Activator: org.eclipse.emf.ecoretools.design.service.EcoreToolsDesignPlugin
+Bundle-Activator: org.eclipse.emf.ecoretools.design.service.EcoreToolsDesignPlugin$Implementation
Export-Package: org.eclipse.emf.ecoretools.design,
org.eclipse.emf.ecoretools.design.service
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java
index 9faec6e..1ae2c49 100644
--- a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java
+++ b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java
@@ -60,7 +60,7 @@ public class EcoreToolsSessionListener extends SessionManagerListener.Stub {
set.getURIConverter().getURIMap().putAll(result);
} else {
IStatus status = new Status(IStatus.WARNING, EcoreToolsDesignPlugin.PLUGIN_ID, "The EMF API EcorePlugin.computePlatformURIMap has probably changed and is not supported yet by EcoreTools.");
- EcoreToolsDesignPlugin.getDefault().getLog().log(status);
+ EcoreToolsDesignPlugin.INSTANCE.log(status);
}
diff --git a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/DesignServices.java b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/DesignServices.java
index 5bfe67e..500ab14 100644
--- a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/DesignServices.java
+++ b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/DesignServices.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.ecoretools.design.service;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -38,7 +37,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.ETypeParameter;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
-import org.eclipse.emf.ecore.presentation.EcoreEditorPlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -68,9 +66,6 @@ import org.eclipse.sirius.tools.api.command.CommandContext;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import com.google.common.base.Ascii;
import com.google.common.base.CharMatcher;
@@ -579,20 +574,6 @@ public class DesignServices extends EReferenceServices {
return true;
}
- /**
- * Shows the Properties View. (See Double Click Action in Design ViewPoint)
- *
- * @param object
- * Any EObject
- */
- public void showPropertiesViewAction(EObject object) {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.views.PropertySheet");
- } catch (PartInitException exception) {
- EcoreEditorPlugin.INSTANCE.log(exception);
- }
- }
-
public EEnumLiteral arrowsFillDiamond(EObject any) {
return DiagramPackage.eINSTANCE.getEdgeArrows().getEEnumLiteral("FillDiamond");
}
@@ -601,30 +582,6 @@ public class DesignServices extends EReferenceServices {
return ViewpointPackage.eINSTANCE.getFontFormat().getEEnumLiteral("bold");
}
- public void openClassDiagramContextHelp(EObject any) {
- // try {
- // openContextHelp(any,
- // "org.eclipse.emf.ecoretools.design.ClassDiagram");
- // } catch (IOException e) {
- // EcoreEditorPlugin.INSTANCE.log(e);
- // }
- }
-
- public void openContextHelp(EObject any, final String contextID) throws IOException {
- if (Display.getDefault() != null)
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() != null) {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), contextID);
- PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
-
- }
- }
- });
- }
-
public void reconnectEReference(EObject element, DEdge edgeAfterReconnect) {
if (edgeAfterReconnect.getSourceNode() instanceof DSemanticDecorator && edgeAfterReconnect.getTargetNode() instanceof DSemanticDecorator) {
@@ -700,9 +657,9 @@ public class DesignServices extends EReferenceServices {
// Execute the create view task
new CreateViewTask(context, session.getModelAccessor(), createViewOp, session.getInterpreter()).execute();
} catch (MetaClassNotFoundException e) {
- EcoreEditorPlugin.INSTANCE.log(e);
+ EcoreToolsDesignPlugin.INSTANCE.log(e);
} catch (FeatureNotFoundException e) {
- EcoreEditorPlugin.INSTANCE.log(e);
+ EcoreToolsDesignPlugin.INSTANCE.log(e);
}
}
});
diff --git a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/EcoreToolsDesignPlugin.java b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/EcoreToolsDesignPlugin.java
index b5671fe..d494239 100644
--- a/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/EcoreToolsDesignPlugin.java
+++ b/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/EcoreToolsDesignPlugin.java
@@ -13,11 +13,13 @@ package org.eclipse.emf.ecoretools.design.service;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.emf.common.EMFPlugin;
+import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.sirius.business.api.componentization.ViewpointRegistry;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.business.api.session.SessionManagerListener;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
@@ -26,64 +28,122 @@ import org.osgi.framework.BundleContext;
* @author Laurent Goubet <a
* href="mailto:laurent.goubet@obeo.fr">laurent.goubet@obeo.fr</a>
*/
-public class EcoreToolsDesignPlugin extends Plugin {
+public class EcoreToolsDesignPlugin extends EMFPlugin {
+
+ public static final EcoreToolsDesignPlugin INSTANCE = new EcoreToolsDesignPlugin();
+
+ /**
+ * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ private static Implementation plugin;
+
/** The plug-in ID. */
public static final String PLUGIN_ID = "org.eclipse.emf.ecoretools.design"; //$NON-NLS-1$
- /** This plug-in's shared instance. */
- private static EcoreToolsDesignPlugin plugin;
-
private static Set<Viewpoint> viewpoints;
- private SessionManagerListener notifWhenSessionAreCreated;
-
/**
* Default constructor for the plugin.
*/
public EcoreToolsDesignPlugin() {
- plugin = this;
+ super(new ResourceLocator[] {});
}
/**
- * Returns the shared instance.
+ * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
*
- * @return the shared instance
+ * @return the singleton instance.
+ * @generated
*/
- public static EcoreToolsDesignPlugin getDefault() {
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
return plugin;
}
/**
- * {@inheritDoc}
+ * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ * @return the singleton instance.
+ * @generated
*/
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- viewpoints = new HashSet<Viewpoint>();
- viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(PLUGIN_ID + "/description/ecore.odesign"));
+ public static Implementation getPlugin() {
+ return plugin;
}
/**
- * {@inheritDoc}
+ * The actual implementation of the Eclipse <b>Plugin</b>. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ * @generated
*/
- @Override
- public void stop(final BundleContext context) throws Exception {
- plugin = null;
- if (viewpoints != null) {
- for (final Viewpoint viewpoint : viewpoints) {
- ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
+ public static class Implementation extends EclipsePlugin {
+
+ private SessionManagerListener notifWhenSessionAreCreated;
+
+ /**
+ * Creates an instance. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+
+ /**
+ * The actual implementation of the purely OSGi-compatible <b>Bundle
+ * Activator</b>. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static final class Activator extends EMFPlugin.OSGiDelegatingBundleActivator {
+ @Override
+ protected BundleActivator createBundle() {
+ return new Implementation();
}
- viewpoints.clear();
- viewpoints = null;
}
- if (notifWhenSessionAreCreated != null) {
- SessionManager.INSTANCE.removeSessionsListener(notifWhenSessionAreCreated);
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ viewpoints = new HashSet<Viewpoint>();
+ viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(PLUGIN_ID + "/description/ecore.odesign"));
}
- super.stop(context);
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ if (viewpoints != null) {
+ for (final Viewpoint viewpoint : viewpoints) {
+ ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
+ }
+ viewpoints.clear();
+ viewpoints = null;
+ }
+ if (notifWhenSessionAreCreated != null) {
+ SessionManager.INSTANCE.removeSessionsListener(notifWhenSessionAreCreated);
+ }
+
+ super.stop(context);
+ }
}
+
}

Back to the top