initial commit in accordance with CQ 3784
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/.classpath b/plugins/org.eclipse.objectteams.otdt.pde.ui/.classpath
new file mode 100644
index 0000000..987380a
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="OTRE"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/.project b/plugins/org.eclipse.objectteams.otdt.pde.ui/.project
new file mode 100644
index 0000000..e948e68
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.objectteams.otdt.pde.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.objectteams.otdt.builder.OTJBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.objectteams.otdt.OTJavaNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.objectteams.otdt.pde.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..14f0b6f
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,21 @@
+#Tue Sep 18 18:30:43 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.objectteams.otdt.compiler.option.joinpoint_queries=disabled
+org.objectteams.otdt.compiler.option.scoped_keywords=enabled
+org.objectteams.otdt.compiler.problem.abstract_potential_relevant_role=warning
+org.objectteams.otdt.compiler.problem.basecall=warning
+org.objectteams.otdt.compiler.problem.binding_conventions=error
+org.objectteams.otdt.compiler.problem.decapsulation=warning
+org.objectteams.otdt.compiler.problem.deprecated_path_syntax=warning
+org.objectteams.otdt.compiler.problem.effectless_fieldaccess=warning
+org.objectteams.otdt.compiler.problem.fragile_callin=warning
+org.objectteams.otdt.compiler.problem.incomplete_build=error
+org.objectteams.otdt.compiler.problem.inferred_callout=error
+org.objectteams.otdt.compiler.problem.potential_ambiguous_playedby=warning
+org.objectteams.otdt.compiler.problem.unsafe_liftctor=warning
+org.objectteams.otdt.compiler.problem.unused_parammap=warning
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otdt.pde.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..51c2222
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OTPDEUI Plug-in
+Bundle-SymbolicName: org.eclipse.objectteams.otdt.pde.ui;singleton:=true
+Bundle-Version: 1.4.0.qualifier
+Bundle-Activator: org.eclipse.objectteams.otdt.internal.pde.ui.OTPDEUIPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.pde.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.objectteams.otdt,
+ org.eclipse.objectteams.otdt.debug,
+ org.eclipse.objectteams.otequinox,
+ org.eclipse.objectteams.otdt.ui,
+ org.eclipse.ui.forms,
+ org.eclipse.jdt.ui,
+ org.eclipse.search,
+ org.eclipse.pde.api.tools.ui;bundle-version="1.0.200"
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Bundle-Vendor: The TOPPrax consortium
+Export-Package: org.eclipse.objectteams.otdt.internal.pde.ui
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/build.properties b/plugins/org.eclipse.objectteams.otdt.pde.ui/build.properties
new file mode 100644
index 0000000..cff4459
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ plugin.xml,\
+ icons/,\
+ .,\
+ plugin.properties
+src.includes = .classpath,\
+ .project,\
+ build.properties,\
+ plugin.properties
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/newotpprj_obj.gif b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/newotpprj_obj.gif
new file mode 100644
index 0000000..98fb8a0
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/newotpprj_obj.gif
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/plugin_forcedExports.png b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/plugin_forcedExports.png
new file mode 100644
index 0000000..677e9b4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/plugin_forcedExports.png
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/wizard/newotpprj_wiz.png b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/wizard/newotpprj_wiz.png
new file mode 100644
index 0000000..a4cdb81
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/icons/ot/wizard/newotpprj_wiz.png
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.properties b/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.properties
new file mode 100644
index 0000000..b3162b8
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.properties
@@ -0,0 +1,5 @@
+# wizard:
+new.OTPluginProject.description=Create an Object Teams Plug-in Project
+
+# context menu:
+menu.addOTSupport.label=Add Object Teams support
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.xml b/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.xml
new file mode 100644
index 0000000..cc0b0d5
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/plugin.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <!-- === Wizard: === -->
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.eclipse.objectteams.otdt.ui.wizards"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.OTNewPluginProjectWizard"
+ finalPerspective="org.eclipse.objectteams.otdt.ui.OTJavaPerspective"
+ icon="icons/ot/newotpprj_obj.gif"
+ id="org.eclipse.objectteams.otdt.pde.ui.wizards.OTNewPluginProjectWizard"
+ name="Object Teams Plug-in Project "
+ preferredPerspectives="org.eclipse.objectteams.otdt.ui.OTJavaPerspective"
+ project="true">
+ <description>
+ %new.OTPluginProject.description
+ </description>
+ </wizard>
+ </extension>
+
+ <!-- === Aspects: === -->
+ <extension
+ point="org.eclipse.objectteams.otequinox.aspectBindings">
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin id="org.eclipse.pde.ui"
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"/>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.OTPluginDependenciesAdapter"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif"/>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.ExtensionEditorAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.validation.BundleValidation"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.pde.core">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.ClasspathComputerAdapter"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.validation.BundleValidation"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.PackageExplorerAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.ui">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.PackageExplorerAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.pde.api.tools.ui">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.ApiToolsAdapter"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.eclipse.objectteams.otdt.pde.ui.objectContribution1"
+ nameFilter="*"
+ objectClass="org.eclipse.core.resources.IProject">
+ <action
+ class="org.eclipse.objectteams.otdt.internal.pde.ui.ToggleOTSupportAction"
+ enablesFor="+"
+ id="org.eclipse.objectteams.otdt.pde.ui.toggleOTSupportAction"
+ label="%menu.addOTSupport.label"
+ menubarPath="org.eclipse.ui.projectConfigure/additions">
+ </action>
+ <visibility>
+ <and>
+ <objectState
+ name="projectNature"
+ value="org.eclipse.jdt.core.javanature">
+ </objectState>
+ <not>
+ <objectState
+ name="projectNature"
+ value="org.eclipse.objectteams.otdt.OTJavaNature">
+ </objectState>
+ </not>
+ </and>
+ </visibility>
+ </objectContribution>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ApiToolsAdapter.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ApiToolsAdapter.java
new file mode 100644
index 0000000..a24b78c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ApiToolsAdapter.java
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 Stephan Herrmann.
+ *
+ * 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
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.objectteams.otdt.core.IOTJavaElement;
+
+import base org.eclipse.pde.api.tools.ui.internal.JavaElementActionFilter;
+
+@SuppressWarnings("restriction")
+public team class ApiToolsAdapter {
+
+ /** Protect one more hard coded switch-case against unexpected OT elements. */
+ protected class FilterAdaptor playedBy JavaElementActionFilter {
+
+ testAttribute <- replace testAttribute;
+
+ callin boolean testAttribute(Object target) {
+ if (target instanceof IOTJavaElement)
+ // treat OT elements via their java correspondence:
+ target = ((IOTJavaElement)target).getCorrespondingJavaElement();
+ return base.testAttribute(target);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/AspectBindingsTreeNode.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/AspectBindingsTreeNode.java
new file mode 100644
index 0000000..a4fdb54
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/AspectBindingsTreeNode.java
@@ -0,0 +1,128 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 Stephan Herrmann.
+ *
+ * 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
+ * $Id: AspectBindingsTreeNode.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otequinox.Constants;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.IPluginObject;
+import org.eclipse.pde.internal.core.plugin.PluginElement;
+
+/**
+ * Nodes for representing aspect bindings in the package explorer.
+ * @author stephan
+ * @since 1.3.2
+ */
+@SuppressWarnings("restriction")
+public abstract class AspectBindingsTreeNode {
+ IJavaProject javaProject;
+}
+
+// ========== follows: concrete subclasses ==========
+
+ class AspectBindingsRootNode extends AspectBindingsTreeNode
+ {
+ static final String ASPECT_BINDINGS_NAME = "OT/Equinox Aspect Bindings";
+ protected IPluginModelBase pluginModel;
+ public AspectBindingsRootNode(IJavaProject javaProject, IPluginModelBase pluginModel) {
+ this.javaProject = javaProject;
+ this.pluginModel = pluginModel;
+ }
+ @Override
+ public String toString() {
+ return "~"+ASPECT_BINDINGS_NAME; // prepend "~" to make sorting a bit more deterministic, should we encounter CUDs at toplevel
+ }
+ }
+
+ /** Represents the aspect bindings for one base plugin. */
+ @SuppressWarnings("restriction")
+ class BasePluginNode extends AspectBindingsTreeNode
+ {
+ protected String basePlugin;
+ boolean hasForcedExports = false;
+ PluginElement element;
+ Object[] teams = null;
+
+ public BasePluginNode(IJavaProject javaProject, PluginElement element) {
+ this.javaProject = javaProject;
+ this.element = element;
+ for (IPluginObject child : element.getChildren()) {
+ if (child instanceof PluginElement) {
+ if (Constants.BASE_PLUGIN.equals(child.getName())) {
+ this.basePlugin = ((PluginElement)child).getAttribute("id").getValue();
+ for (IPluginObject subChild : ((PluginElement)child).getChildren())
+ if (Constants.FORCED_EXPORTS_ELEMENT.equals(((PluginElement)subChild).getName()))
+ this.hasForcedExports = true;
+ break;
+ }
+ }
+ }
+ }
+ /** Add the teams of other to this node. */
+ protected void merge(BasePluginNode other) {
+ Object[] myTeams = getTeams();
+ Object[] otherTeams = other.getTeams();
+ int l1=myTeams.length, l2=otherTeams.length;
+ teams = new Object[l1+l2];
+ System.arraycopy(myTeams, 0, this.teams, 0, l1);
+ System.arraycopy(otherTeams, 0, this.teams, l1, l2);
+ }
+ /** Get all teams adapting the base plugin represented by this node. */
+ protected Object[] getTeams() {
+ if (this.teams != null)
+ return this.teams;
+ List<Object> teams = new ArrayList<Object>();
+ for (IPluginObject child : element.getChildren())
+ if (child instanceof PluginElement)
+ if (Constants.TEAM.equals(child.getName()))
+ teams.add(new TeamNode(this.javaProject,
+ ((PluginElement)child).getAttribute("class").getValue()));
+ return this.teams = teams.toArray();
+ }
+ protected Object getPluginXml() {
+ return this.javaProject.getProject().findMember("plugin.xml");
+ }
+ }
+ /**
+ * Handle to a team referenced in an aspect binding,
+ * supports on demand resolving to an IType.
+ */
+ class TeamNode extends AspectBindingsTreeNode
+ {
+ protected String teamName;
+
+ protected TeamNode(IJavaProject javaProject, String teamName) {
+ this.javaProject = javaProject;
+ this.teamName = teamName;
+ }
+
+ protected IType getTeamType() {
+ try {
+ return this.javaProject.findType(this.teamName);
+ } catch (JavaModelException e) {
+ OTPDEUIPlugin.getDefault().getLog().log(
+ OTPDEUIPlugin.createErrorStatus("OpenAction: Cannot resolve team type '"+this.teamName+"'", e));
+ return null;
+ }
+ }
+ }
+
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ClasspathComputerAdapter.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ClasspathComputerAdapter.java
new file mode 100644
index 0000000..ca63f70
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ClasspathComputerAdapter.java
@@ -0,0 +1,89 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 Technical University Berlin, Germany.
+ *
+ * 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
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.core.ext.OTJavaNature;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.internal.core.PDECore;
+
+import base org.eclipse.pde.internal.core.ClasspathComputer;
+
+/**
+ * This team handles classpath updating issues
+ * @author mosconi
+ * @since 1.2.4
+ */
+@SuppressWarnings("restriction")
+public team class ClasspathComputerAdapter {
+ protected class ClasspathComputer playedBy ClasspathComputer {
+
+ // re-add OTRE container for OT plug-in projects:
+ static void updateOTClasspath(IProject project) throws CoreException {
+ OTREContainer.initializeOTJProject(project);
+ sortClasspathEntries(project);
+ }
+ void updateOTClasspath(IProject project) <- after void setClasspath(IProject project, IPluginModelBase model)
+ when (OTJavaNature.hasOTJavaNature(project));
+ }
+
+ /**
+ * Make sure OTRE comes before requiredPlugins on the project's classpath.
+ * This is needed to ensure that org.objectteams.Team is accessible.
+ * When a project finds a dependent plugin which depends on otequinox,
+ * Team will be found via that project leading to an error because Team is
+ * not re-exported from an OT plugin project.
+ * @throws CoreException
+ */
+ public static void sortClasspathEntries(IProject project) throws CoreException {
+ IJavaProject javaProject= (IJavaProject) project.getNature(JavaCore.NATURE_ID);
+ IClasspathEntry[] entries= javaProject.getRawClasspath();
+ IClasspathEntry[] newEntries= new IClasspathEntry[entries.length];
+ IClasspathEntry requiredPlugins= null;
+ int newOTREPos= -1;
+ int j=0; // index into newEntries
+ for (int i = 0; i < entries.length; i++) {
+ if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+ IPath containerPath= entries[i].getPath();
+ if (containerPath.equals(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH)) {
+ requiredPlugins= entries[i];// store intermediate
+ newOTREPos= j++; // leave empty slot in newEntries
+ continue;
+ } else if (containerPath.segment(0).equals(OTREContainer.OTRE_CONTAINER_NAME)) {
+ if (newOTREPos>-1)
+ newEntries[newOTREPos]= entries[i];
+ else
+ return; // requiredPlugins was not found before OTRE
+ continue;
+ }
+ }
+ newEntries[j++]= entries[i];
+ }
+ if (newOTREPos > -1 && requiredPlugins != null && j<newEntries.length) {
+ newEntries[j]= requiredPlugins;
+ javaProject.setRawClasspath(newEntries, new NullProgressMonitor());
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ExtensionEditorAdaptor.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ExtensionEditorAdaptor.java
new file mode 100644
index 0000000..dd9896e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ExtensionEditorAdaptor.java
@@ -0,0 +1,354 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007, 2009 Technical University Berlin, Germany.
+ *
+ * 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
+ * $Id: ExtensionEditorAdaptor.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
+import org.eclipse.jdt.internal.core.search.HierarchyScope;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.pde.core.plugin.IPluginAttribute;
+import org.eclipse.pde.core.plugin.IPluginBase;
+import org.eclipse.pde.core.plugin.IPluginElement;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.internal.core.ischema.IMetaAttribute;
+import org.eclipse.pde.internal.core.ischema.ISchema;
+import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
+import org.eclipse.pde.internal.core.ischema.ISchemaElement;
+import org.eclipse.pde.internal.core.plugin.PluginAttribute;
+import org.eclipse.pde.internal.core.schema.SchemaRegistry;
+import org.eclipse.pde.internal.core.util.IdUtil;
+import org.eclipse.pde.internal.core.util.PDEJavaHelper;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+import org.eclipse.objectteams.otdt.internal.ui.wizards.NewTeamWizardPage;
+import org.eclipse.objectteams.otdt.internal.ui.wizards.OTNewWizardMessages;
+import org.eclipse.objectteams.otdt.ui.ImageManager;
+import org.eclipse.objectteams.otdt.ui.OTDTUIPlugin;
+import org.eclipse.objectteams.otequinox.Constants;
+
+import base org.eclipse.pde.internal.ui.editor.plugin.ExtensionsSection;
+import base org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeWizard;
+import base org.eclipse.pde.internal.ui.editor.plugin.rows.ClassAttributeRow;
+import base org.eclipse.pde.internal.ui.editor.text.XMLUtil;
+
+/**
+ * This team anticipates some fixes regarding the extension editor.
+ *
+ * @author stephan
+ */
+@SuppressWarnings({"restriction","decapsulation"})
+public team class ExtensionEditorAdaptor
+{
+ // role for XMLInsertionComputer obsoleted by patch in https://bugs.eclipse.org/bugs/show_bug.cgi?id=195763
+
+ /* avoid to use the icon attribute for the label, too. */
+ protected class ExtensionsSection playedBy ExtensionsSection
+ {
+ String resolveObjectName(SchemaRegistry schemaRegistry, Object obj) <- replace String resolveObjectName(SchemaRegistry schemaRegistry, Object obj);
+ @SuppressWarnings("basecall")
+ callin static String resolveObjectName(SchemaRegistry schemaRegistry, Object obj) {
+ boolean fullNames = PDEPlugin.isFullNameModeEnabled();
+ if (obj instanceof IPluginExtension) {
+ IPluginExtension extension = (IPluginExtension) obj;
+ if (!fullNames) {
+ return extension.getPoint();
+ }
+ if (extension.getName() != null)
+ return extension.getTranslatedName();
+ ISchema schema = schemaRegistry.getSchema(extension.getPoint());
+ // try extension point schema definition
+ if (schema != null) {
+ // exists
+ return schema.getName();
+ }
+ return extension.getPoint();
+ } else if (obj instanceof IPluginElement) {
+ IPluginElement element = (IPluginElement) obj;
+ String baseName = element.getName();
+ String fullName = null;
+ ISchemaElement elementInfo = getSchemaElement(element);
+ IPluginAttribute labelAtt = null;
+ if (elementInfo != null && elementInfo.getLabelProperty() != null) {
+ labelAtt = element.getAttribute(elementInfo.getLabelProperty());
+ }
+ if (labelAtt == null) {
+ // try some hard-coded attributes that
+ // are used frequently
+ for (int i = 0; i < getCOMMON_LABEL_PROPERTIES().length; i++) {
+ labelAtt = element.getAttribute(getCOMMON_LABEL_PROPERTIES()[i]);
+ if (labelAtt != null)
+ break;
+ }
+ if (labelAtt == null) {
+ // Last try - if there is only one attribute,
+ // use that
+ if (element.getAttributeCount() == 1)
+ labelAtt = element.getAttributes()[0];
+//{ObjectTeams: not if it the icon property:
+ if (isIconAttribute(labelAtt))
+ labelAtt = null;
+// SH}
+ }
+ }
+ if (labelAtt != null && labelAtt.getValue() != null)
+ fullName = stripShortcuts(labelAtt.getValue());
+ fullName = element.getResourceString(fullName);
+ if (fullNames)
+ return fullName != null ? fullName : baseName;
+ return fullName != null
+ ? (fullName + " (" + baseName + ")") //$NON-NLS-1$ //$NON-NLS-2$
+ : baseName;
+ }
+ return obj.toString();
+ }
+ private static boolean isIconAttribute(IPluginAttribute labelAtt) {
+ if (labelAtt == null || labelAtt.getName() == null)
+ return false;
+ if (!labelAtt.getName().equals("icon")) //$NON-NLS-1$
+ return false;
+ if (labelAtt instanceof PluginAttribute) {
+ PluginAttribute attribute = (PluginAttribute) labelAtt;
+ ISchemaAttribute info = attribute.getAttributeInfo();
+ if (info != null)
+ return info.getKind() == IMetaAttribute.RESOURCE;
+ }
+ return true;
+ }
+ String[] getCOMMON_LABEL_PROPERTIES() -> get String[] COMMON_LABEL_PROPERTIES;
+ ISchemaElement getSchemaElement(IPluginElement element) -> ISchemaElement getSchemaElement(IPluginElement element);
+ String stripShortcuts(String input) -> String stripShortcuts(String input);
+ }
+ /**
+ * This role anticipates a fix to https://bugs.eclipse.org/bugs/show_bug.cgi?id=61185
+ * Restricting type selection dialogs for extension details to the 'basedOn' type, if given.
+ * Although bug 61185 is partly fixed, this role also covers bug 215139.
+ */
+ protected class ClassAttributeRow playedBy ClassAttributeRow
+ {
+ IPluginBase getPluginBase() -> IPluginBase getPluginBase();
+ Text getText() -> get Text text;
+
+ doOpenSelectionDialog <- replace doOpenSelectionDialog;
+ @SuppressWarnings("basecall")
+ callin void doOpenSelectionDialog() {
+ String superType= null;
+ try {
+ ISchemaAttribute att= getAttribute();
+ superType= att.getBasedOn();
+ } catch (Throwable t) {
+ // e.g., a CCE in getAttribute()?
+ }
+ if (superType != null && superType.startsWith(":")) //$NON-NLS-1$
+ superType= superType.substring(1);
+ if (superType == null || "java.lang.Object".equals(superType)) { //$NON-NLS-1$
+ // if no useful super type was found do the normal thing:
+ base.doOpenSelectionDialog();
+ return;
+ }
+ IResource resource = getPluginBase().getModel().getUnderlyingResource();
+ String type = selectType(
+ resource,
+ IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES,
+ getText().getText(),
+ superType);
+ if (type != null)
+ getText().setText(type);
+ }
+ ISchemaAttribute getAttribute() -> get Object att
+ with { result <- (ISchemaAttribute)att }
+
+ // from PDEJavaHelperUI, added param supertype
+ static String selectType(IResource resource, int scope, String filter, String superTypeName)
+ {
+ if (resource == null) return null;
+ IProject project = resource.getProject();
+ try {
+ // create new scope (hierarchy):
+ IJavaSearchScope searchScope = null;
+ if (superTypeName != null && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$
+ IJavaProject javaProject = JavaCore.create(project);
+ IType superType = javaProject.findType(superTypeName);
+ if (superType != null)
+ searchScope= SearchEngine.createHierarchyScope(javaProject, superType, true, true, DefaultWorkingCopyOwner.PRIMARY);
+ /* Eclipse version:
+ searchScope = SearchEngine.createHierarchyScope(superType);
+ */
+ }
+ if (searchScope == null)
+ searchScope = PDEJavaHelper.getSearchScope(project);
+
+ SelectionDialog dialog = JavaUI.createTypeDialog(
+ PDEPlugin.getActiveWorkbenchShell(),
+ PlatformUI.getWorkbench().getProgressService(),
+ searchScope,
+ //orig: PDEJavaHelper.getSearchScope(project),
+ scope,
+ false, "**"/*filter*/); //$NON-NLS-1$
+ dialog.setTitle(PDEUIMessages.ClassAttributeRow_dialogTitle);
+ if (dialog.open() == Window.OK) {
+ IType type = (IType) dialog.getResult()[0];
+ return type.getFullyQualifiedName('$');
+ }
+ } catch (JavaModelException e) {
+ }
+ return null;
+ }
+ }
+
+ /**
+ * This role adapts the PDE/UI's version of a NewTypeWizard as to use our
+ * NewTeamWizardPage when appropriate.
+ *
+ * @since 1.2.4
+ */
+ protected class JavaAttributeWizard playedBy JavaAttributeWizard
+ base when (base.fAttInfo != null && isBasedOnOOTeam(base.fAttInfo))
+ {
+ static boolean isBasedOnOOTeam(ISchemaAttribute attInfo) {
+ String basedOn = attInfo.getBasedOn();
+ if (basedOn == null)
+ return false;
+ return basedOn.equals(String.valueOf(IOTConstants.STR_ORG_OBJECTTEAMS_TEAM));
+ }
+
+ String getFClassName() -> get String fClassName;
+ IProject getFProject() -> get IProject fProject;
+ void setFMainPage(NewTypeWizardPage fMainPage) -> set NewTypeWizardPage fMainPage;
+ void addPage(IWizardPage arg0) -> void addPage(IWizardPage arg0);
+
+ void addNewTeamWizardPage() <- replace void addPages();
+
+ @SuppressWarnings("basecall")
+ callin void addNewTeamWizardPage() {
+ // use a new team wizard:
+ NewTeamWizardPage mainPage = new NewTeamWizardPage();
+
+ // init similar to base method:
+ setFMainPage(mainPage);
+ addPage(mainPage);
+ mainPage.init(null);
+
+ // since our wizard doesn't handle attribute info these inits are different:
+ initFields(mainPage, getFClassName(), getFProject());
+ }
+
+ void initFields(NewTeamWizardPage mainPage, String className, IProject project)
+ {
+ // set package and class names:
+ int loc = className.lastIndexOf('.');
+ if (loc != -1) {
+ mainPage.setPackageFragmentName(className.substring(0, loc));
+ mainPage.setTypeName(className.substring(loc+1));
+ } else {
+ mainPage.setTypeName(className);
+ }
+
+ // set source folder (in the vein of org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeWizardPage):
+ IPackageFragmentRoot srcEntryDft = null;
+ IJavaProject javaProject = JavaCore.create(project);
+ IPackageFragmentRoot[] roots;
+ try {
+ roots = javaProject.getPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+ srcEntryDft = roots[i];
+ break;
+ }
+ }
+ } catch (JavaModelException e) {
+ // can't find source folder
+ }
+ if (srcEntryDft != null)
+ mainPage.setPackageFragmentRoot(srcEntryDft, true);
+ else
+ mainPage.setPackageFragmentRoot(javaProject.getPackageFragmentRoot(javaProject.getResource()), true);
+ }
+
+ // window title
+ void setWindowTitle(String newTitle) <- replace void setWindowTitle(String newTitle);
+
+ callin void setWindowTitle(String newTitle) {
+ base.setWindowTitle(OTNewWizardMessages.NewTeamCreationWizard_title);
+ }
+
+ // header image
+ void setDefaultPageImageDescriptor(ImageDescriptor imageDescriptor)
+ <- replace void setDefaultPageImageDescriptor(ImageDescriptor imageDescriptor);
+ callin void setDefaultPageImageDescriptor(ImageDescriptor imageDescriptor)
+ {
+ base.setDefaultPageImageDescriptor(OTDTUIPlugin.getDefault().getImageRegistry().getDescriptor(ImageManager.NEW_TEAM));
+ }
+ }
+
+ /** This role makes sure that the PDE UI does not invent names that are illegal in their respective context. */
+ protected class XMLUtil playedBy XMLUtil {
+
+ /**
+ * If the project name makes an illegal package name,
+ * and if the lower-cased class name is not legal either,
+ * try appending 's' until it is legal.
+ * (this occurred when the project name contained '-' and
+ * the class name was "Team" -> "team" is an illegal package name.
+ */
+ String createDefaultPackageName(IProject project) <- replace String createDefaultPackageName(IProject project, String className);
+
+ static callin String createDefaultPackageName(IProject project) {
+ String result = base.createDefaultPackageName(project);
+ IJavaProject javaProject = JavaCore.create(project);
+ String optionSrc = javaProject.getOption(JavaCore.COMPILER_SOURCE,true);
+ String optionCompliance = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ IStatus valid;
+ while (true) {
+ valid = JavaConventions.validatePackageName(result, optionSrc, optionCompliance);
+ if (valid.isOK())
+ return result;
+ result += 's';
+ }
+ }
+
+ /**
+ * When generating a value for "basePlugin":
+ * if the project name contains illegal characters like '-' convert it to a valid bundle ID.
+ */
+ String createDefaultName() <- replace String createDefaultName(IProject project, ISchemaAttribute attInfo, int counter)
+ base when (Constants.BASE_PLUGIN.equals(attInfo.getParent().getName()));
+
+ static callin String createDefaultName() {
+ return IdUtil.getValidId(base.createDefaultName());
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ImageManager.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ImageManager.java
new file mode 100644
index 0000000..333c74b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ImageManager.java
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007 Technical University Berlin, Germany.
+ *
+ * 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
+ * $Id: DebugUIDialogAdaptor2.java 18886 2008-08-17 14:37:14Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * Provide cached access to images of this plugin.
+ *
+ * @author stephan
+ * @since 1.0.0
+ */
+public class ImageManager extends org.eclipse.objectteams.otdt.ui.ImageManager {
+
+ private static ImageManager _singleton;
+
+ /**
+ * Avoid multiple instances
+ */
+ protected ImageManager() {}
+
+ /**
+ * The only way to access plugin images
+ * @return PluginImages instance
+ */
+ public static ImageManager getSharedInstance() {
+ if (_singleton == null)
+ _singleton = new ImageManager();
+
+ return _singleton;
+ }
+
+ // overriding causes paths to be resolved relative to this plug-in.
+ @Override
+ protected AbstractUIPlugin getPlugin() {
+ return OTPDEUIPlugin.getDefault();
+ }
+
+ // specify which icons to register:
+ @Override
+ protected String[] pluginIcons() {
+ return new String[]{ OTNewPluginProjectWizard.NEW_OTPDE_PROJECT, PackageExplorerAdaptor.PLUGIN_FORCED_EXPORTS };
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTEquinoxCommonLaunching.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTEquinoxCommonLaunching.java
new file mode 100644
index 0000000..742981b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTEquinoxCommonLaunching.java
@@ -0,0 +1,83 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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
+ * $Id: OTEquinoxCommonLaunching.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.TeamBreakpointInstaller;
+
+/**
+ * Shared implementation of OTEclipseApplicationLaunchConfiguration and OTEquinoxLaunchConfiguration
+ *
+ * @author stephan
+ * @since OTDT 1.1.3
+ */
+public class OTEquinoxCommonLaunching
+{
+ static final String HOOK_CONFIGURATOR = "-Dosgi.hook.configurators.include=org.eclipse.objectteams.otequinox.hook.HookConfigurator";//$NON-NLS-1$
+ static final String CLASSLOADER_LOCKING = "-Dosgi.classloader.lock=classname"; //$NON-NLS-1$
+ static final String REPOSITORY_WORKAROUND = "-Dot.equinox"; //$NON-NLS-1$ // this causes the WORKAROUND_REPOSITORY flag being set to true in OTRE.
+ static final String OT_DEBUG_VMARG = "-Dot.debug"; //$NON-NLS-1$
+ static final String[] OT_VM_ARGS = { HOOK_CONFIGURATOR, CLASSLOADER_LOCKING, REPOSITORY_WORKAROUND };
+ static final String[] OT_VM_DEBUG_ARGS = { HOOK_CONFIGURATOR, CLASSLOADER_LOCKING, REPOSITORY_WORKAROUND, OT_DEBUG_VMARG };
+
+ static String[] extendVMArguments(String[] args, String mode) {
+ String[] otArgs = OT_VM_ARGS;
+ if (mode != null && mode.equals(ILaunchManager.DEBUG_MODE))
+ otArgs = OT_VM_DEBUG_ARGS;
+
+ if (args == null || args.length == 0)
+ return otArgs;
+
+ String[] combinedArgs = new String[args.length + otArgs.length];
+ System.arraycopy(args, 0, combinedArgs, 0, args.length);
+ System.arraycopy(otArgs, 0, combinedArgs, args.length, otArgs.length);
+ return combinedArgs;
+ }
+
+ static void installOOTBreakpoints(IProject[] projects)
+ throws CoreException
+ {
+ IJavaProject jp = null;
+ if (projects != null) {
+ for (IProject project : projects) {
+ // find org.objectteams.Team in any OT/J Project:
+ if (project.getNature(JavaCore.OTJ_NATURE_ID) != null) {
+ jp = JavaCore.create(project);
+ TeamBreakpointInstaller.installTeamBreakpoints(jp);
+ break;
+ }
+ }
+ }
+ if (jp == null)
+ OTDebugPlugin.getDefault().getLog().log(
+ new Status(Status.WARNING,
+ OTPDEUIPlugin.PLUGIN_ID,
+ 0,
+ OTPDEUIMessages.NoOTJPluginProject,
+ null));
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTNewPluginProjectWizard.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTNewPluginProjectWizard.java
new file mode 100644
index 0000000..b4470b8
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTNewPluginProjectWizard.java
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2009 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage;
+
+/**
+ * Wizard to create a plug-in project with OT/Equinox enabled (classpath, plugin dependency).
+ * @author resix
+ */
+@SuppressWarnings("restriction")
+public class OTNewPluginProjectWizard extends NewPluginProjectWizard {
+
+ static final String NEW_OTPDE_PROJECT = "wizard/newotpprj_wiz.png"; //$NON-NLS-1$
+
+ public OTNewPluginProjectWizard() {
+ super();
+ setDefaultPageImageDescriptor(OTPDEUIPlugin.getDefault().getImageRegistry().getDescriptor(NEW_OTPDE_PROJECT));
+ setWindowTitle(OTPDEUIMessages.NewOTPProjectWizard_title);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ IWizardPage mainPage= getPage("main"); //$NON-NLS-1$
+ if (mainPage != null)
+ mainPage.setTitle(OTPDEUIMessages.NewOTPProjectWizard_MainPage_title);
+ }
+
+ public boolean performFinish()
+ {
+ within (new OTPluginDependenciesAdapter()) {
+ if (!super.performFinish()) {
+ return false;
+ }
+ }
+
+ IWizardPage fMainPage = getPage("main"); //$NON-NLS-1$
+ if (fMainPage instanceof NewProjectCreationPage)
+ {
+ IProject project = ((NewProjectCreationPage)fMainPage).getProjectHandle();
+
+ try
+ {
+ OTPluginProject.makeOTPlugin(project);
+ ClasspathComputerAdapter.sortClasspathEntries(project);
+ return true;
+ }
+ catch (CoreException ex)
+ {
+ ErrorDialog.openError(getShell(),
+ OTPDEUIMessages.OTNewPluginProjectWizard_ProjectCreationError,
+ OTPDEUIMessages.OTNewPluginProjectWizard_CantAddOTSpecifics,
+ ex.getStatus());
+ OTPDEUIPlugin.getDefault().getLog().log(OTPDEUIPlugin.createErrorStatus("Project creation error", ex));
+ }
+ }
+ else
+ assert(false); // something changed in superclass, we must adapt to
+
+
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.java
new file mode 100644
index 0000000..ae451e1
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.java
@@ -0,0 +1,40 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007, 2009 Technical University Berlin, Germany.
+ *
+ * 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
+ * $Id: OTPDEUIMessages.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class OTPDEUIMessages extends NLS
+{
+ private static final String BUNDLE_NAME = OTPDEUIMessages.class.getName();
+
+
+ public static String NewOTPProjectWizard_title;
+ public static String NewOTPProjectWizard_MainPage_title;
+
+ public static String NoOTJPluginProject;
+
+ public static String OTNewPluginProjectWizard_CantAddOTSpecifics;
+ public static String OTNewPluginProjectWizard_ProjectCreationError;
+
+ public static String Validation_MissingActivationPolicy_error;
+ public static String Resolution_AddBundleActivationPolicy_label;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, OTPDEUIMessages.class);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.properties b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.properties
new file mode 100644
index 0000000..a6d72dc
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIMessages.properties
@@ -0,0 +1,10 @@
+NewOTPProjectWizard_title= New OT-Plugin Project Wizard
+NewOTPProjectWizard_MainPage_title= New Object Teams Plug-in Project
+
+NoOTJPluginProject=No OT/J plug-in project found, debug functionality not fully available.
+
+OTNewPluginProjectWizard_ProjectCreationError=Project creation errror
+OTNewPluginProjectWizard_CantAddOTSpecifics=Error adding Object Teams specifics to new project
+
+Validation_MissingActivationPolicy_error=Aspect bindings may only be effective if Bundle-ActivationPolicy is set
+Resolution_AddBundleActivationPolicy_label=Set header "Bundle-ActivationPolicy" to "lazy".
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIPlugin.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIPlugin.java
new file mode 100644
index 0000000..7b67b6c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPDEUIPlugin.java
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class OTPDEUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.objectteams.otdt.internal.pde.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static OTPDEUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public OTPDEUIPlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static OTPDEUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static IStatus createErrorStatus(String message, Throwable ex)
+ {
+ return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, ex);
+ }
+
+
+ /**
+ * Add Object Teams flavoured images to the image registry.
+ */
+ protected void initializeImageRegistry(ImageRegistry reg)
+ {
+ ImageManager.getSharedInstance().registerPluginImages(reg);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginDependenciesAdapter.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginDependenciesAdapter.java
new file mode 100644
index 0000000..e1f87db
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginDependenciesAdapter.java
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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
+ * $Id: OTPluginDependenciesAdapter.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.objectteams.otequinox.Constants;
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.ui.templates.PluginReference;
+
+import base org.eclipse.pde.internal.ui.wizards.plugin.PluginClassCodeGenerator;
+
+/**
+ * Note that this team must be mentioned in plugin.xml (aspectBinding),
+ * although it is not instantiated/activated globally, but only
+ * temporarily during OTNewPluginProjectWizard.performFinish().
+ *
+ * @author gis
+ */
+@SuppressWarnings("restriction")
+public team class OTPluginDependenciesAdapter
+{
+ public class PluginClassCodeGeneratorAdapter playedBy PluginClassCodeGenerator
+ {
+ private final IPluginReference TRANSFORMER = new PluginReference(Constants.TRANSFORMER_PLUGIN_ID, null, 0);
+
+ /**
+ * Returns Object Teams specific plugin dependencies additionally to the default
+ * plugin dependencies.
+ */
+ callin IPluginReference[] getDependencies()
+ {
+ IPluginReference[] deps = base.getDependencies();
+ for (IPluginReference dependency : deps) {
+ if (dependency.equals(TRANSFORMER))
+ return deps; // already included
+ }
+ IPluginReference[] extraDeps = new IPluginReference[] { TRANSFORMER };
+ return mergeArrays(deps, extraDeps);
+ }
+
+ IPluginReference[] mergeArrays(IPluginReference[] deps, IPluginReference[] extraDeps)
+ {
+ IPluginReference[] newDeps = new IPluginReference[deps.length + extraDeps.length];
+ System.arraycopy(deps, 0, newDeps, 0, deps.length);
+ System.arraycopy(extraDeps, 0, newDeps, deps.length, extraDeps.length);
+
+ return newDeps;
+ }
+
+ IPluginReference[] getDependencies() <- replace IPluginReference[] getDependencies();
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginProject.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginProject.java
new file mode 100644
index 0000000..0e53a16
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/OTPluginProject.java
@@ -0,0 +1,70 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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
+ * $Id: OTPluginProject.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+
+public class OTPluginProject
+{
+ public static void makeOTPlugin(IProject project) throws CoreException
+ {
+ addOTNatureAndBuilder(project);
+ OTREContainer.initializeOTJProject(project);
+ // require base-imports for base classes per default:
+ IJavaProject javaProject = JavaCore.create(project);
+ String value = javaProject.getOption(OTDTPlugin.OT_COMPILER_BINDING_CONVENTIONS, true);
+ if (!value.equals(JavaCore.ERROR))
+ javaProject.setOption(OTDTPlugin.OT_COMPILER_BINDING_CONVENTIONS, JavaCore.ERROR);
+ }
+
+ public static void addOTNatureAndBuilder(IProject project) throws CoreException
+ {
+ IProjectDescription prjDesc = project.getDescription();
+ prjDesc.setNatureIds(OTDTPlugin.createProjectNatures(prjDesc));
+ ICommand[] buildSpecs = prjDesc.getBuildSpec();
+ prjDesc.setBuildSpec(replaceOrAddOTBuilder(prjDesc, buildSpecs));
+ project.setDescription(prjDesc, null);
+ }
+
+ private static ICommand[] replaceOrAddOTBuilder(IProjectDescription prjDesc, ICommand[] buildSpecs)
+ {
+ ICommand otBuildCmd = OTDTPlugin.createProjectBuildCommand(prjDesc);
+ // replace existing Java builder?
+ for(int i=0; i<buildSpecs.length; i++) {
+ if (buildSpecs[i].getBuilderName().equals(JavaCore.BUILDER_ID)) {
+ buildSpecs[i] = otBuildCmd;
+ return buildSpecs;
+ }
+ }
+ // not found, add to front:
+ int len = buildSpecs.length;
+ System.arraycopy(buildSpecs, 0, buildSpecs = new ICommand[len+1], 1, len);
+ buildSpecs[0] = otBuildCmd;
+ return buildSpecs;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/PackageExplorerAdaptor.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/PackageExplorerAdaptor.java
new file mode 100644
index 0000000..6d4faaf
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/PackageExplorerAdaptor.java
@@ -0,0 +1,399 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 Stephan Herrmann.
+ *
+ * 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
+ * $Id: PackageExplorerAdaptor.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.objectteams.otequinox.Constants;
+import org.eclipse.pde.core.plugin.IExtensions;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.IPluginObject;
+import org.eclipse.pde.core.plugin.ISharedExtensionsModel;
+import org.eclipse.pde.core.plugin.ISharedPluginModel;
+import org.eclipse.pde.internal.core.PDECore;
+import org.eclipse.pde.internal.core.PluginModelManager;
+import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
+import org.eclipse.pde.internal.core.plugin.PluginElement;
+import org.eclipse.pde.internal.core.text.IDocumentAttributeNode;
+import org.eclipse.pde.internal.ui.PDELabelProvider;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.PDEPluginImages;
+import org.eclipse.pde.internal.ui.editor.plugin.ExtensionsPage;
+import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import base org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider;
+import base org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider;
+import base org.eclipse.jdt.ui.JavaElementComparator;
+import base org.eclipse.jdt.ui.actions.OpenAction;
+import base org.eclipse.pde.internal.core.text.plugin.PluginElementNode;
+
+/**
+ * This team adds rendering for an "Aspect Bindings" subtree for each OT/Equinox project.
+ * @author stephan
+ * @since 1.3.2
+ */
+@SuppressWarnings("restriction")
+public team class PackageExplorerAdaptor
+{
+
+ /** Icon for base plugin with forced exports. */
+ static final String PLUGIN_FORCED_EXPORTS = "plugin_forcedExports.png"; //$NON-NLS-1$
+
+ protected class ContentProvider playedBy PackageExplorerContentProvider {
+
+ @SuppressWarnings("decapsulation")
+ TreeViewer getViewer() -> get TreeViewer fViewer;
+
+ Object[] getChildren(Object parentElement) <- replace Object[] getChildren(Object parentElement);
+
+ callin Object[] getChildren(Object parentElement) {
+ Object[] result = base.getChildren(parentElement);
+ if (parentElement instanceof IJavaProject) {
+ // may want to add an "OT/Equinox Aspect Bindings" node to the project:
+ PluginModelManager modelManager = PDECore.getDefault().getModelManager();
+ IJavaProject javaProject = (IJavaProject)parentElement;
+ IPluginModelBase pluginModel = modelManager.findModel(javaProject.getProject());
+ if (pluginModel != null) {
+ if (hasAspectBindings(pluginModel)) {
+ List<Object> combined = new ArrayList<Object>(Arrays.asList(result));
+ combined.add(createAspectBindingsNode(javaProject, pluginModel));
+ return combined.toArray();
+ }
+ }
+ // no plugin.xml or no aspect bindings, wait for changes re plugin.xml
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new AspectBindingsRefresher(javaProject, null, getViewer()));
+ }
+ if (parentElement instanceof AspectBindingsRootNode) {
+ // this is the "OT/Equinox Aspect Bindings" node, fill it with BasePluginNodes
+ AspectBindingsRootNode aspectBindingsNode = (AspectBindingsRootNode)parentElement;
+ IExtensions extensions = aspectBindingsNode.pluginModel.getExtensions();
+ if (extensions != null) {
+ List<Object> bases = new ArrayList<Object>();
+ Map<String, BasePluginNode> perBaseBindings = new HashMap<String, BasePluginNode>();
+ for (IPluginExtension extension : extensions.getExtensions())
+ if(extension.getPoint().equals(Constants.ASPECT_BINDING_FQEXTPOINT_ID))
+ for (IPluginObject element : extension.getChildren())
+ if (element instanceof PluginElement) {
+ PluginElement pluginElement = (PluginElement) element;
+ BasePluginNode node = new BasePluginNode(aspectBindingsNode.javaProject, pluginElement);
+ // collate multiple bindings for the same base plugin:
+ if (perBaseBindings.containsKey(node.basePlugin)) {
+ perBaseBindings.get(node.basePlugin).merge(node);
+ } else {
+ bases.add(node);
+ perBaseBindings.put(node.basePlugin, node);
+ }
+ }
+
+ return bases.toArray();
+ }
+ }
+ if (parentElement instanceof BasePluginNode) {
+ // fill the BasePluginNode with its adapting teams
+ return ((BasePluginNode)parentElement).getTeams();
+ }
+ return result;
+ }
+
+ AspectBindingsRootNode createAspectBindingsNode (final IJavaProject javaProject, IPluginModelBase pluginModel) {
+ final AspectBindingsRootNode aspectBindings = new AspectBindingsRootNode(javaProject, pluginModel);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new AspectBindingsRefresher(javaProject, aspectBindings, getViewer()));
+ return aspectBindings;
+ }
+ }
+
+ /** Does the given plugin have an aspectBindings extension? */
+ boolean hasAspectBindings (IPluginModelBase pluginModel) {
+ IExtensions extensions = pluginModel.getExtensions();
+ for (IPluginExtension extension : extensions.getExtensions())
+ if(extension.getPoint().equals(Constants.ASPECT_BINDING_FQEXTPOINT_ID))
+ return true;
+ return false;
+ }
+
+ /** This class is responsible for any updates on aspectBindings in a project's plugin.xml. */
+ protected class AspectBindingsRefresher implements IResourceChangeListener {
+ IJavaProject javaProject;
+ AspectBindingsRootNode aspectBindings;
+ TreeViewer viewer;
+
+ protected AspectBindingsRefresher(IJavaProject javaProject, AspectBindingsRootNode aspectBindings, TreeViewer viewer) {
+ this.javaProject = javaProject;
+ this.aspectBindings = aspectBindings;
+ this.viewer = viewer;
+ }
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (aspectBindings != null)
+ refreshAspectBindings(event);
+ else
+ detectPluginXmlChanges(event.getDelta());
+ }
+ /* Aspect bindings are present, may need to be refreshed or removed. */
+ void refreshAspectBindings(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ if (delta != null)
+ delta = delta.findMember(this.javaProject.getPath().append("plugin.xml"));
+ if (delta != null) {
+ if (this.viewer == null || this.viewer.getControl().isDisposed() || !this.javaProject.isOpen()) {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ return;
+ }
+ final Object elementToRefresh;
+ if ((delta.getKind() & IResourceDelta.REMOVED) != 0) {
+ elementToRefresh = this.javaProject;
+ } else {
+ PluginModelManager modelManager = PDECore.getDefault().getModelManager();
+ if (hasAspectBindings(modelManager.findModel(javaProject.getProject())))
+ elementToRefresh = this.aspectBindings;
+ else
+ elementToRefresh = this.javaProject;
+ }
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ AspectBindingsRefresher.this.viewer.refresh(elementToRefresh);
+ }});
+ // during project refresh, getChildren will create a new listener
+ if (elementToRefresh == this.javaProject)
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ } else if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+ if (event.getResource().equals(javaProject.getProject()))
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
+ }
+ /* Aspect bindings are not yet present, wait for an event that could signal addition of aspect bindings. */
+ void detectPluginXmlChanges(IResourceDelta delta) {
+ if (delta != null)
+ delta = delta.findMember(this.javaProject.getPath().append("plugin.xml"));
+ if (delta != null) {
+ // this listener is done:
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+
+ if (this.viewer == null || this.viewer.getControl().isDisposed() || !javaProject.isOpen())
+ return;
+
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ AspectBindingsRefresher.this.viewer.refresh(AspectBindingsRefresher.this.javaProject);
+ }});
+ }
+ }
+ }
+
+ /**
+ * This role renders the elements of an "Aspect Bindings" subtree.
+ */
+ protected class LabelProvider playedBy PackageExplorerLabelProvider {
+
+ PDELabelProvider pdeLabelProvider;
+
+ // ---------- Lifecycle: ----------
+
+ // constructor:
+ @SuppressWarnings("ambiguouslowering")
+ LabelProvider(PackageExplorerLabelProvider baseLabelProvider) {
+ this.pdeLabelProvider = PDEPlugin.getDefault().getLabelProvider();
+ pdeLabelProvider.connect(this);
+ }
+
+ // finalizer:
+ @Override
+ @SuppressWarnings("ambiguouslowering")
+ protected void finalize() {
+ if (this.pdeLabelProvider != null) {
+ this.pdeLabelProvider.disconnect(this);
+ this.pdeLabelProvider = null;
+ }
+ }
+ // second trigger for finalizer:
+ finalize <- after dispose;
+
+ // ---------- Domain behavior: ----------
+
+ StyledString getStyledText(Object element)
+ <- replace StyledString getStyledText(Object element);
+
+ @SuppressWarnings("basecall")
+ callin StyledString getStyledText(Object element)
+ {
+ if (element instanceof AspectBindingsRootNode)
+ return new StyledString(AspectBindingsRootNode.ASPECT_BINDINGS_NAME);
+
+ if (element instanceof BasePluginNode)
+ return new StyledString("Base Plugin "+((BasePluginNode)element).basePlugin);
+
+ if (element instanceof TeamNode)
+ return new StyledString(((TeamNode)element).teamName);
+
+ return base.getStyledText(element);
+ }
+
+ Image getImage(Object element) <- replace Image getImage(Object element);
+
+
+ @SuppressWarnings("basecall")
+ callin Image getImage(Object element)
+ {
+ if (element instanceof AspectBindingsRootNode)
+ return org.eclipse.objectteams.otdt.ui.ImageManager.getSharedInstance().get(ImageManager.CALLOUTBINDING_IMG);
+
+ if (element instanceof BasePluginNode) {
+ if (((BasePluginNode)element).hasForcedExports)
+ return ImageManager.getSharedInstance().get(PLUGIN_FORCED_EXPORTS);
+ return pdeLabelProvider.get(PDEPluginImages.DESC_PLUGIN_OBJ);
+ }
+
+ if (element instanceof TeamNode)
+ return org.eclipse.objectteams.otdt.ui.ImageManager.getSharedInstance().get(ImageManager.TEAM_IMG);
+
+ return base.getImage(element);
+ }
+ }
+
+ /**
+ * sort the "Aspect Bindings" node below the list of package fragment roots,
+ * by pretending it were a compilation unit
+ */
+ protected class Comparator playedBy JavaElementComparator {
+
+ @SuppressWarnings("decapsulation")
+ int getCOMPILATIONUNITS() -> get int COMPILATIONUNITS;
+
+ final int COMPILATIONUNITS;
+ Comparator(JavaElementComparator b) {
+ COMPILATIONUNITS = getCOMPILATIONUNITS();
+ }
+
+ int category(Object element) <- replace int category(Object element)
+ base when (element instanceof AspectBindingsRootNode);
+
+ @SuppressWarnings("basecall")
+ callin int category(Object element) {
+ return COMPILATIONUNITS;
+ }
+
+ }
+
+ protected class Open playedBy OpenAction {
+
+ @SuppressWarnings("decapsulation")
+ boolean checkEnabled(IStructuredSelection selection) <- replace boolean checkEnabled(IStructuredSelection selection);
+
+ @SuppressWarnings("unchecked") // selection.iterator() is raw type
+ callin boolean checkEnabled(IStructuredSelection selection) {
+ if (base.checkEnabled(selection))
+ return true;
+ // similar to base method:
+ if (selection.isEmpty())
+ return false;
+ for (Iterator iter= selection.iterator(); iter.hasNext();) {
+ Object element= iter.next();
+ if (element instanceof BasePluginNode)
+ continue;
+ if (element instanceof TeamNode)
+ continue;
+ return false;
+ }
+ return true;
+ }
+
+ Object getNodeToOpen(Object object) <- replace Object getElementToOpen(Object object)
+ base when (object instanceof AspectBindingsTreeNode);
+
+ @SuppressWarnings("basecall")
+ callin Object getNodeToOpen(Object object) {
+ if (object instanceof BasePluginNode) {
+ registerListener(((BasePluginNode)object));
+ return ((BasePluginNode)object).getPluginXml();
+ }
+ if (object instanceof TeamNode)
+ return ((TeamNode)object).getTeamType();
+ return object;
+ }
+ /** register a listener for deferred selection of the current base plugin element within the extension editor. */
+ void registerListener (final BasePluginNode node) {
+ IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i= 0, length= windows.length; i < length; i++) {
+ final IPartService partService = windows[i].getPartService();
+ partService.addPartListener(new IPartListener() {
+ public void partOpened(IWorkbenchPart part) { /* nop */ }
+ public void partDeactivated(IWorkbenchPart part) { /* nop */ }
+ public void partClosed(IWorkbenchPart part) { /* nop */ }
+ public void partBroughtToTop(IWorkbenchPart part) { /* nop */ }
+
+ public void partActivated(IWorkbenchPart part) {
+ selectBaseNode(node, part);
+ partService.removePartListener(this); // immediately remove: this is a one-shot listener
+ }
+ });
+ }
+ }
+ void selectBaseNode(BasePluginNode node, IWorkbenchPart part) {
+ if (part instanceof ManifestEditor) {
+ ManifestEditor editor = (ManifestEditor) part;
+ ExtensionsPage page = (ExtensionsPage) editor.setActivePage(ExtensionsPage.PAGE_ID);
+ ISharedExtensionsModel extensions = ((IBundlePluginModelBase)page.getModel()).getExtensionsModel();
+ for (BasePluginNodeInterceptor viewNode : getAllRoles(BasePluginNodeInterceptor.class))
+ if ( extensions == viewNode.getModel() // only nodes of this editor's model
+ && node.basePlugin.equals(viewNode.basePluginName))
+ page.selectReveal(viewNode.lower());
+ }
+ }
+ }
+ /** This role intercepts reading of PluginElementNodes that represent a basePlugin element of an aspect binding. */
+ protected class BasePluginNodeInterceptor implements ILowerable playedBy PluginElementNode
+ {
+ ISharedPluginModel getModel() -> ISharedPluginModel getModel();
+
+ protected String basePluginName;
+
+ // this callin filters applicable base objects
+ void register(String tag) <- after void setXMLTagName(String tag)
+ base when ("basePlugin".equals(tag));
+
+ private void register(String tag) {
+ // nop, just registered this role
+ }
+
+ // this callin collects further information from registered base objects:
+ void setXMLAttribute(IDocumentAttributeNode attribute) <- after void setXMLAttribute(IDocumentAttributeNode attribute)
+ base when (hasRole(base, BasePluginNodeInterceptor.class));
+
+ void setXMLAttribute(IDocumentAttributeNode attribute) {
+ if ("id".equals(attribute.getAttributeName()))
+ this.basePluginName = attribute.getAttributeValue();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ToggleOTSupportAction.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ToggleOTSupportAction.java
new file mode 100644
index 0000000..ac5191b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/ui/ToggleOTSupportAction.java
@@ -0,0 +1,136 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 Technical University Berlin.
+ *
+ * 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
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Marco Mosconi - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.pde.core.plugin.IPluginBase;
+import org.eclipse.pde.core.plugin.IPluginImport;
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.internal.core.ICoreConstants;
+import org.eclipse.pde.internal.core.bundle.WorkspaceBundlePluginModel;
+import org.eclipse.pde.internal.core.natures.PDE;
+import org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase;
+import org.eclipse.pde.ui.templates.PluginReference;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Action to add (TBD: or remove) OT support on projects.
+ * To be invoked via the "Configure" context-menu in Package Explorer.
+ * @author mosconi
+ * @since 1.3.2
+ */
+@SuppressWarnings("restriction")
+public class ToggleOTSupportAction implements IObjectActionDelegate {
+
+ private Shell shell;
+ private ISelection selection;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ shell = targetPart.getSite().getShell();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ if (!(selection instanceof IStructuredSelection))
+ return;
+ for (Object element : ((IStructuredSelection) selection).toArray()) {
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ }
+ else if (element instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
+ }
+ if (project != null) {
+ toggleOTSupport(project);
+ }
+ }
+ }
+
+ private void toggleOTSupport(IProject project) {
+ try {
+ IProjectDescription description = project.getDescription();
+ if (description.hasNature(JavaCore.OTJ_NATURE_ID)) {
+ removeOTSupport(project);
+ }
+ else {
+ addOTSupport(project);
+ }
+ }
+ catch (CoreException e) {
+ ErrorDialog.openError(shell, "Project Configuration Error", "Error Configuring Project " + project.getName() + ".", e.getStatus());
+ OTPDEUIPlugin.getDefault().getLog().log(OTPDEUIPlugin.createErrorStatus("Project configuration error", e));
+ }
+ }
+
+ /**
+ * Adds OT/J nature, builder, and dependencies to the given project
+ */
+ private void addOTSupport(IProject project) throws CoreException {
+ OTPluginProject.addOTNatureAndBuilder(project);
+ if (PDE.hasPluginNature(project)) {
+ // add plug-in dependency to org.eclipse.objectteams.otequinox:
+ WorkspacePluginModelBase fModel = new WorkspaceBundlePluginModel(
+ project.getFile(ICoreConstants.BUNDLE_FILENAME_DESCRIPTOR),
+ project.getFile(ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR));
+ IPluginBase pluginBase = fModel.getPluginBase();
+ IPluginReference ref = new PluginReference(
+ "org.eclipse.objectteams.otequinox", null, 0);
+ IPluginImport iimport = fModel.getPluginFactory().createImport();
+ iimport.setId(ref.getId());
+ iimport.setVersion(ref.getVersion());
+ iimport.setMatch(ref.getMatch());
+ pluginBase.add(iimport);
+ fModel.save();
+ }
+ OTREContainer.initializeOTJProject(project);
+ if (PDE.hasPluginNature(project)) {
+ ClasspathComputerAdapter.sortClasspathEntries(project);
+ }
+ }
+
+ /**
+ * Removes OT/J nature, builder, and dependencies from the given project
+ */
+ private void removeOTSupport(IProject project) throws CoreException {
+ //TODO: yet to be implemented (also needs additional hooking in plugin.xml)
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/validation/BundleValidation.java b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/validation/BundleValidation.java
new file mode 100644
index 0000000..9eea644
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.pde.ui/src/org/eclipse/objectteams/otdt/internal/pde/validation/BundleValidation.java
@@ -0,0 +1,202 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 Technical University Berlin, Germany.
+ *
+ * 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
+ * $Id: BundleValidation.java 23470 2010-02-05 19:13:24Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.pde.validation;
+
+import static org.eclipse.objectteams.otequinox.Constants.*;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.objectteams.otdt.internal.pde.ui.OTPDEUIMessages;
+import org.eclipse.objectteams.otequinox.ActivationKind;
+import org.eclipse.pde.internal.core.builders.CompilerFlags;
+import org.eclipse.pde.internal.core.builders.IHeader;
+import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
+import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
+import org.eclipse.pde.internal.core.text.bundle.BundleActivationPolicyHeader;
+import org.eclipse.pde.internal.core.text.bundle.BundleModel;
+import org.eclipse.pde.internal.ui.correction.AbstractManifestMarkerResolution;
+import org.eclipse.pde.internal.ui.correction.AbstractPDEMarkerResolution;
+import org.eclipse.ui.IMarkerResolution;
+import org.osgi.framework.Constants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import base org.eclipse.pde.internal.core.builders.BundleErrorReporter;
+import base org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter;
+import base org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker;
+import base org.eclipse.pde.internal.ui.correction.ResolutionGenerator;
+
+/**
+ * Enhanced validation of bundle manifests.
+ * <ul>
+ * <li>Check whether all bundles with aspectBindings have a proper activation policy set,<br>
+ * Provide suitable quick assist if activation policy is wrong/missing.</li>
+ * </ul>
+ *
+ * @author stephan
+ * @since 1.2.7
+ */
+@SuppressWarnings("restriction")
+public team class BundleValidation
+{
+ /** Constant for a problem that can be resolved by adding an activation policy to the manifest. */
+ static final int ADD_ACTIVATION_POLICY = 0x1801; // must not overlap with any constant in org.eclipse.pde.internal.core.builders.PDEMarkerFactory.
+
+ ThreadLocal<BundleCheckingContext> bundleContext = new ThreadLocal<BundleCheckingContext>();
+
+ /**
+ * Defines the context of validating one bundle.
+ * One instance of this role exists per control flow (= per thread)
+ * for retrieval in downstream callin bindings.
+ */
+ protected class BundleCheckingContext playedBy ManifestConsistencyChecker
+ {
+ // flags set during validation of one bundle:
+ protected boolean isAspectBundle = false;
+ protected boolean hasTeamActivation = false;
+
+ @SuppressWarnings("decapsulation")
+ spanContext <- replace validateFiles;
+
+ callin void spanContext() {
+ BundleValidation.this.bundleContext.set(this);
+ try {
+ base.spanContext();
+ } finally {
+ // withdraw role, is for one-time use only:
+ BundleValidation.this.bundleContext.set(null);
+ BundleValidation.this.unregisterRole(this, BundleCheckingContext.class);
+ }
+ }
+ }
+
+ /**
+ * Detects aspectBindings declared in plugin.xml and records information in the current {@link BundleCheckingContext}.
+ */
+ protected class ExtensionAnalyzer playedBy ExtensionsErrorReporter
+ base when (BundleValidation.this.bundleContext.get() != null)
+ {
+ void checkAspectBinding(Element element) <- after void validateExtension(Element element);
+
+ protected void checkAspectBinding(Element element)
+ {
+ Object pointID = element.getAttribute("point"); //$NON-NLS-1$
+ if (ASPECT_BINDING_FQEXTPOINT_ID.equals(pointID))
+ {
+ BundleCheckingContext context = BundleValidation.this.bundleContext.get();
+ // it's an aspect bundle
+ context.isAspectBundle = true;
+
+ // does it have elements with relevant activation?
+ NodeList baseNodes = element.getElementsByTagName(BASE_PLUGIN);
+ if (baseNodes.getLength() > 0) {
+ String baseId = ((Element)baseNodes.item(0)).getAttribute(ID);
+ if (baseId != null && baseId.toUpperCase().equals(SELF))
+ return; // missing bundle activation is not fatal in this case
+ }
+
+ // check the teams for activation ALL_THREADS or THREAD:
+ NodeList teamNodes = element.getElementsByTagName(TEAM);
+ for (int t=0; t<teamNodes.getLength(); t++) {
+ Object activation = ((Element)teamNodes.item(t)).getAttribute(ACTIVATION);
+ if (ActivationKind.ALL_THREADS.toString().equals(activation)) {
+ context.hasTeamActivation = true;
+ break;
+ } else if (ActivationKind.THREAD.toString().equals(activation)) {
+ context.hasTeamActivation = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Validates whether activation policy is set if needed.
+ * This role is only active for bundles with one or more aspect bindings.
+ */
+ protected class BundleErrorReporter playedBy BundleErrorReporter
+ base when (BundleValidation.this.bundleContext.get().isAspectBundle)
+ {
+ @SuppressWarnings("decapsulation")
+ IHeader getHeader(String key) -> IHeader getHeader(String key);
+ void report(String message, int line, int severity, int resolution, String category)
+ -> IMarker report(String message, int line, int severity, int resolution, String category);
+
+ void validateBundleActivatorPolicy() <- after void validateBundleActivatorPolicy();
+
+ void validateBundleActivatorPolicy()
+ {
+ IHeader header = getHeader(Constants.BUNDLE_ACTIVATIONPOLICY);
+ int lineNo = 1;
+ if (header != null) {
+ if (Constants.ACTIVATION_LAZY.equals(header.getValue()))
+ return; // OK!
+ lineNo = header.getLineNumber()+1;
+ }
+ boolean hasTeamActivation = BundleValidation.this.bundleContext.get().hasTeamActivation;
+ report(OTPDEUIMessages.Validation_MissingActivationPolicy_error,
+ lineNo,
+ hasTeamActivation ? CompilerFlags.ERROR : CompilerFlags.WARNING, // only severe if relevant team activation is requested.
+ ADD_ACTIVATION_POLICY,
+ PDEMarkerFactory.CAT_FATAL);
+ }
+ }
+
+ /** Unbound role: simple rewriting of the manifest to add or correct an activation policy header. */
+ protected class SetActivationPolicyResolution extends AbstractManifestMarkerResolution
+ {
+ public SetActivationPolicyResolution(int type) {
+ super(type);
+ }
+
+ protected void createChange(BundleModel model) {
+
+ IManifestHeader header = model.getBundle().getManifestHeader(Constants.BUNDLE_ACTIVATIONPOLICY);
+
+ if (header != null && header instanceof BundleActivationPolicyHeader)
+ ((BundleActivationPolicyHeader) header).setLazyStart(true);
+ else
+ model.getBundle().setHeader(Constants.BUNDLE_ACTIVATIONPOLICY, Constants.ACTIVATION_LAZY);
+ }
+
+ public String getLabel() {
+ return OTPDEUIMessages.Resolution_AddBundleActivationPolicy_label;
+ }
+ }
+
+ /**
+ * Advise the base class for handling missing/incorrect activation policy
+ * (code {@link BundleValidation#ADD_ACTIVATION_POLICY}).
+ */
+ protected class ResolutionGenerator playedBy ResolutionGenerator {
+
+ IMarkerResolution[] getResolutions(IMarker marker) <- replace IMarkerResolution[] getResolutions(IMarker marker);
+
+ callin IMarkerResolution[] getResolutions(IMarker marker) {
+ IMarkerResolution[] result = base.getResolutions(marker);
+ if (result.length == 0) {
+ int problemID = marker.getAttribute("id", PDEMarkerFactory.NO_RESOLUTION); //$NON-NLS-1$
+ switch (problemID) {
+ case BundleValidation.ADD_ACTIVATION_POLICY :
+ return new IMarkerResolution[] {new SetActivationPolicyResolution(AbstractPDEMarkerResolution.CREATE_TYPE)};
+ }
+ }
+ return result;
+ }
+ }
+}