Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java97
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java9
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java99
3 files changed, 107 insertions, 98 deletions
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java
index 0f3ed9f5..19edbf1f 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java
@@ -8,6 +8,7 @@
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
* Dmitry Spiridenok <d.spiridenok@gmail.com> - Bug 408712
+ * Marco Descher <marco@descher.at> - Bug 434371
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
@@ -46,8 +47,17 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.plugin.IMatchRules;
+import org.eclipse.pde.core.plugin.IPluginElement;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginImport;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.IPluginObject;
+import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
+import org.eclipse.pde.internal.core.bundle.WorkspaceBundlePluginModel;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
@@ -302,4 +312,91 @@ public abstract class BaseApplicationModelWizard extends Wizard implements INewW
*/
protected void adjustDependencies(IFile file) {
}
+
+ /**
+ * Add the required dependencies (org.eclipse.e4.ui.model.workbench) and
+ * register fragment.e4xmi at the required extension point
+ * (org.eclipse.e4.workbench.model)
+ */
+ protected void adjustFragmentDependencies(IFile file) {
+ IProject project = file.getProject();
+ IFile pluginXml = PDEProject.getPluginXml(project);
+ IFile manifest = PDEProject.getManifest(project);
+
+ WorkspaceBundlePluginModel fModel = new WorkspaceBundlePluginModel(
+ manifest, pluginXml);
+ try {
+ addWorkbenchDependencyIfRequired(fModel);
+ registerWithExtensionPointIfRequired(project, fModel, file);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ MessageDialog.openError(getShell(), "Error", e.getMessage());
+ }
+ }
+
+ private void addWorkbenchDependencyIfRequired(
+ WorkspaceBundlePluginModel fModel) throws CoreException {
+ IPluginImport[] imports = fModel.getPluginBase().getImports();
+
+ final String WORKBENCH_IMPORT_ID = "org.eclipse.e4.ui.model.workbench"; //$NON-NLS-1$
+
+ for (IPluginImport iPluginImport : imports) {
+ if (WORKBENCH_IMPORT_ID.equalsIgnoreCase(iPluginImport.getId()))
+ return;
+ }
+
+ String version = "";
+ IPluginModelBase findModel = PluginRegistry
+ .findModel(WORKBENCH_IMPORT_ID);
+ if (findModel != null) {
+ BundleDescription bundleDescription = findModel
+ .getBundleDescription();
+ if (bundleDescription != null)
+ version = bundleDescription.getVersion().toString()
+ .replaceFirst("\\.qualifier$", "");
+ }
+
+ IPluginImport workbenchImport = fModel.getPluginFactory()
+ .createImport();
+ workbenchImport.setId(WORKBENCH_IMPORT_ID);
+ workbenchImport.setVersion(version);
+ workbenchImport.setMatch(IMatchRules.GREATER_OR_EQUAL);
+ fModel.getPluginBase().add(workbenchImport);
+ fModel.save();
+ }
+
+ /**
+ * Register the fragment.e4xmi with the org.eclipse.e4.workbench.model
+ * extension point, if there is not already a fragment registered.
+ */
+ private void registerWithExtensionPointIfRequired(IProject project,
+ WorkspaceBundlePluginModel fModel, IFile file) throws CoreException {
+ IPluginExtension[] extensions = fModel.getPluginBase().getExtensions();
+
+ final String WORKBENCH_MODEL_EP_ID = "org.eclipse.e4.workbench.model"; //$NON-NLS-1$
+ final String FRAGMENT = "fragment";
+
+ for (IPluginExtension iPluginExtension : extensions) {
+ if (WORKBENCH_MODEL_EP_ID
+ .equalsIgnoreCase(iPluginExtension.getId())) {
+ IPluginObject[] children = iPluginExtension.getChildren();
+ for (IPluginObject child : children) {
+ if (FRAGMENT.equalsIgnoreCase(child.getName())) //$NON-NLS-1$
+ return;
+ }
+ }
+ }
+
+ IPluginExtension extPointFragmentRegister = fModel.getPluginFactory()
+ .createExtension();
+ IPluginElement element = extPointFragmentRegister.getModel()
+ .getFactory().createElement(extPointFragmentRegister);
+ element.setName(FRAGMENT);
+ element.setAttribute("uri", file.getName()); //$NON-NLS-1$
+ extPointFragmentRegister.setId(project.getName() + "." + FRAGMENT); //$NON-NLS-1$
+ extPointFragmentRegister.setPoint(WORKBENCH_MODEL_EP_ID);
+ extPointFragmentRegister.add(element);
+ fModel.getPluginBase().add(extPointFragmentRegister);
+ fModel.save();
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
index 2f9a89d6..98cef782 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/ExtractContributionModelWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 BestSolution.at and others.
+ * Copyright (c) 2010-2014 BestSolution.at and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Sopot Cela <sopotcela@gmail.com> - initial API and implementation
+ * Marco Descher <marco@descher.at> - Bug 434371
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
@@ -15,6 +16,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.commands.MCommand;
@@ -116,5 +118,10 @@ public class ExtractContributionModelWizard extends BaseApplicationModelWizard {
protected NewModelFilePage createWizardPage(ISelection selection) {
return new NewModelFilePage(selection,getDefaultFileName());
}
+
+ @Override
+ protected void adjustDependencies(IFile file) {
+ super.adjustFragmentDependencies(file);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
index 6c3a10ad..50d18728 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
@@ -7,27 +7,14 @@
*
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- * Marco Descher <marco@descher.at> - Bug 392907
+ * Marco Descher <marco@descher.at> - Bug 392907, Bug 434371
******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.model;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.e4.ui.model.fragment.MFragmentFactory;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.pde.core.plugin.IMatchRules;
-import org.eclipse.pde.core.plugin.IPluginElement;
-import org.eclipse.pde.core.plugin.IPluginExtension;
-import org.eclipse.pde.core.plugin.IPluginImport;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.core.plugin.IPluginObject;
-import org.eclipse.pde.core.plugin.PluginRegistry;
-import org.eclipse.pde.internal.core.bundle.WorkspaceBundlePluginModel;
-import org.eclipse.pde.internal.core.project.PDEProject;
public class NewContributionModelWizard extends BaseApplicationModelWizard {
@@ -46,90 +33,8 @@ public class NewContributionModelWizard extends BaseApplicationModelWizard {
return new NewModelFilePage(selection, getDefaultFileName());
}
- /**
- * Add the required dependencies (org.eclipse.e4.ui.model.workbench) and
- * register fragment.e4xmi at the required extension point
- * (org.eclipse.e4.workbench.model)
- */
@Override
protected void adjustDependencies(IFile file) {
- IProject project = file.getProject();
- IFile pluginXml = PDEProject.getPluginXml(project);
- IFile manifest = PDEProject.getManifest(project);
-
- WorkspaceBundlePluginModel fModel = new WorkspaceBundlePluginModel(
- manifest, pluginXml);
- try {
- addWorkbenchDependencyIfRequired(fModel);
- registerWithExtensionPointIfRequired(project, fModel, file);
- } catch (CoreException e) {
- e.printStackTrace();
- MessageDialog.openError(getShell(), "Error", e.getMessage());
- }
- }
-
- private void addWorkbenchDependencyIfRequired(
- WorkspaceBundlePluginModel fModel) throws CoreException {
- IPluginImport[] imports = fModel.getPluginBase().getImports();
-
- final String WORKBENCH_IMPORT_ID = "org.eclipse.e4.ui.model.workbench"; //$NON-NLS-1$
-
- for (IPluginImport iPluginImport : imports) {
- if (WORKBENCH_IMPORT_ID.equalsIgnoreCase(iPluginImport.getId()))
- return;
- }
-
- String version = "";
- IPluginModelBase findModel = PluginRegistry
- .findModel(WORKBENCH_IMPORT_ID);
- if (findModel != null) {
- BundleDescription bundleDescription = findModel
- .getBundleDescription();
- if (bundleDescription != null)
- version = bundleDescription.getVersion().toString();
- }
-
- IPluginImport workbenchImport = fModel.getPluginFactory()
- .createImport();
- workbenchImport.setId(WORKBENCH_IMPORT_ID);
- workbenchImport.setVersion(version);
- workbenchImport.setMatch(IMatchRules.GREATER_OR_EQUAL);
- fModel.getPluginBase().add(workbenchImport);
- fModel.save();
- }
-
- /**
- * Register the fragment.e4xmi with the org.eclipse.e4.workbench.model
- * extension point, if there is not already a fragment registered.
- */
- private void registerWithExtensionPointIfRequired(IProject project,
- WorkspaceBundlePluginModel fModel, IFile file) throws CoreException {
- IPluginExtension[] extensions = fModel.getPluginBase().getExtensions();
-
- final String WORKBENCH_MODEL_EP_ID = "org.eclipse.e4.workbench.model"; //$NON-NLS-1$
- final String FRAGMENT = "fragment";
-
- for (IPluginExtension iPluginExtension : extensions) {
- if (WORKBENCH_MODEL_EP_ID
- .equalsIgnoreCase(iPluginExtension.getId())) {
- IPluginObject[] children = iPluginExtension.getChildren();
- for (IPluginObject child : children) {
- if (FRAGMENT.equalsIgnoreCase(child.getName())) //$NON-NLS-1$
- return;
- }
- }
- }
-
- IPluginExtension extPointFragmentRegister = fModel.getPluginFactory()
- .createExtension();
- IPluginElement element = extPointFragmentRegister.getModel()
- .getFactory().createElement(extPointFragmentRegister);
- element.setName(FRAGMENT);
- element.setAttribute("uri", file.getName()); //$NON-NLS-1$
- extPointFragmentRegister.setId(project.getName() + "." + FRAGMENT); //$NON-NLS-1$
- extPointFragmentRegister.setPoint(WORKBENCH_MODEL_EP_ID);
- extPointFragmentRegister.add(element);
- fModel.getPluginBase().add(extPointFragmentRegister);
- fModel.save();
+ super.adjustFragmentDependencies(file);
}
} \ No newline at end of file

Back to the top