Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2010-09-24 21:04:44 +0000
committerRyan D. Brooks2010-09-24 21:04:44 +0000
commite899d798bb8099aa0c9911a03db5a58e235496f0 (patch)
treee249b0bc8ef0c07cdd6c6eaf16f73b8c5e2b0fae /plugins/org.eclipse.osee.framework.ui.plugin
parentf7668b3e4e34dfe032ee7b68b77d08061f6e155b (diff)
downloadorg.eclipse.osee-e899d798bb8099aa0c9911a03db5a58e235496f0.tar.gz
org.eclipse.osee-e899d798bb8099aa0c9911a03db5a58e235496f0.tar.xz
org.eclipse.osee-e899d798bb8099aa0c9911a03db5a58e235496f0.zip
refactor: Cleanup activators and unnecessary usage of OseeUiActivator
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.plugin')
-rw-r--r--plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeFormActivator.java5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActions.java89
-rw-r--r--plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActivator.java39
-rw-r--r--plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/internal/OseePluginUiActivator.java1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/HelpUtil.java40
5 files changed, 93 insertions, 81 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeFormActivator.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeFormActivator.java
index 845befe4a4c..7455f7ad3da 100644
--- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeFormActivator.java
+++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeFormActivator.java
@@ -18,8 +18,13 @@ import org.osgi.framework.BundleContext;
* @author Ryan D. Brooks
*/
public abstract class OseeFormActivator extends OseeUiActivator {
+
private FormColors formColors;
+ protected OseeFormActivator(String pluginId) {
+ super(pluginId);
+ }
+
/**
* This method is called when the plug-in is stopped
*/
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActions.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActions.java
index 7d5f04f14be..cae6c975f75 100644
--- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActions.java
+++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActions.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.ui.plugin;
import java.util.logging.Level;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
@@ -31,7 +32,7 @@ import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Version;
+import org.osgi.framework.Bundle;
public final class OseeUiActions {
private static final String BUG_TITLE = "Generate Action Against This Tool";
@@ -62,21 +63,14 @@ public final class OseeUiActions {
}
}
- public static void addButtonToEditorToolBar(final MultiPageEditorPart editorPart, IActionable actionableObject, final OseeUiActivator oseePlugin, IToolBarManager toolBar, final String editorId, final String actionableItem) {
+ public static void addButtonToEditorToolBar(final MultiPageEditorPart editorPart, final IActionable actionableObject, final String pluginId, IToolBarManager toolBar, final String editorId, final String actionableItem) {
if (!isActionReportingServiceAvailable()) {
return;
}
Action bugAction = new Action(BUG_TITLE, IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
- String version = (String) oseePlugin.getBundle().getHeaders().get("Bundle-Version");
- String desc = String.format("Found in \"%s\" version %s.", editorId, version);
- if (editorPart instanceof IActionable) {
- String moreDesc = ((IActionable) editorPart).getActionDescription();
- if (Strings.isValid(moreDesc)) {
- desc += "\n" + moreDesc;
- }
- }
+ String desc = getActionDescription(editorId, pluginId, actionableObject);
reportLogException(actionableItem, desc);
}
};
@@ -85,15 +79,15 @@ public final class OseeUiActions {
toolBar.add(bugAction);
}
- public static void addButtonToEditorToolBar(IActionable actionableObject, final OseeUiActivator oseePlugin, ToolBar toolBar, final String editorId, String actionableItem) {
- addButtonToEditorToolBar(actionableObject, oseePlugin, toolBar, null, editorId, actionableItem);
+ public static void addButtonToEditorToolBar(IActionable actionableObject, final String pluginId, ToolBar toolBar, final String editorId, String actionableItem) {
+ addButtonToEditorToolBar(actionableObject, pluginId, toolBar, null, editorId, actionableItem);
}
- public static void addButtonToEditorToolBar(IActionable actionableObject, final OseeUiActivator oseePlugin, Composite comp, final String editorId, String actionableItem) {
- addButtonToEditorToolBar(actionableObject, oseePlugin, null, comp, editorId, actionableItem);
+ public static void addButtonToEditorToolBar(IActionable actionableObject, final String pluginId, Composite comp, final String editorId, String actionableItem) {
+ addButtonToEditorToolBar(actionableObject, pluginId, null, comp, editorId, actionableItem);
}
- private static void addButtonToEditorToolBar(final IActionable actionableObject, final OseeUiActivator oseePlugin, ToolBar toolBar, Composite comp, final String editorId, final String actionableItem) {
+ private static void addButtonToEditorToolBar(final IActionable actionableObject, final String pluginId, ToolBar toolBar, Composite comp, final String editorId, final String actionableItem) {
if (!isActionReportingServiceAvailable()) {
return;
}
@@ -115,12 +109,7 @@ public final class OseeUiActions {
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- String version = (String) oseePlugin.getBundle().getHeaders().get("Bundle-Version");
- String desc = String.format("\n\nItem: %s\nVersion: %s", editorId, version);
- String moreDesc = actionableObject.getActionDescription();
- if (Strings.isValid(moreDesc)) {
- desc += "\n" + moreDesc;
- }
+ String desc = getActionDescription(editorId, pluginId, actionableObject);
reportLogException(actionableItem, desc);
}
});
@@ -132,12 +121,7 @@ public final class OseeUiActions {
@Override
public void widgetSelected(SelectionEvent e) {
- String version = (String) oseePlugin.getBundle().getHeaders().get("Bundle-Version");
- String desc = String.format("\n\nItem: %s\nVersion: %s", editorId, version);
- String moreDesc = actionableObject.getActionDescription();
- if (Strings.isValid(moreDesc)) {
- desc += "\n" + moreDesc;
- }
+ String desc = getActionDescription(editorId, pluginId, actionableObject);
reportLogException(actionableItem, desc);
}
@@ -147,7 +131,29 @@ public final class OseeUiActions {
}
}
- public static void addBugToViewToolbar(final ViewPart viewPart, final IActionable actionableObject, final OseeUiActivator oseePlugin, final String viewId, final String actionableItem) {
+ public static String getActionDescription(String itemId, String pluginId, IActionable actionable) {
+ String desc = "";
+ try {
+ Bundle bundle = Platform.getBundle(pluginId);
+ if (bundle != null) {
+ String version = (String) bundle.getHeaders().get("Bundle-Version");
+ desc = String.format("\n\nItem: %s\nVersion: %s", itemId, version);
+ }
+ String moreDesc = actionable.getActionDescription();
+ if (Strings.isValid(moreDesc)) {
+ if (Strings.isValid(desc)) {
+ desc += "\n" + moreDesc;
+ } else {
+ desc = moreDesc;
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(OseeUiActivator.class, Level.SEVERE, ex);
+ }
+ return desc;
+ }
+
+ public static void addBugToViewToolbar(final ViewPart viewPart, final IActionable actionableObject, final String pluginId, final String viewId, final String actionableItem) {
if (!isActionReportingServiceAvailable()) {
return;
}
@@ -160,12 +166,7 @@ public final class OseeUiActions {
Action bugAction = new Action("Generate Action Against This View") {
@Override
public void run() {
- String version = (String) oseePlugin.getBundle().getHeaders().get("Bundle-Version");
- String desc = String.format("\n\nItem: %s\nVersion: %s", viewId, version);
- String moreDesc = actionableObject.getActionDescription();
- if (!moreDesc.equals("")) {
- desc += "\n" + moreDesc;
- }
+ String desc = getActionDescription(viewId, pluginId, actionableObject);
reportLogException(actionableItem, desc);
}
};
@@ -176,20 +177,20 @@ public final class OseeUiActions {
toolbarManager.add(bugAction);
}
- public static Action createBugAction(OseeUiActivator oseePlugin, IAdaptable target, String itemId, String actionableItem) {
- return new BugAction(oseePlugin, target, itemId, actionableItem);
+ public static Action createBugAction(String pluginId, IAdaptable target, String itemId, String actionableItem) {
+ return new BugAction(pluginId, target, itemId, actionableItem);
}
private static final class BugAction extends Action {
private static String BUG_TITLE = "Generate Action Against This Tool";
- private final OseeUiActivator oseePlugin;
+ private final String pluginId;
private final String itemId;
private final IAdaptable target;
private final String actionableItem;
- public BugAction(OseeUiActivator oseePlugin, IAdaptable target, String itemId, String actionableItem) {
+ public BugAction(String pluginId, IAdaptable target, String itemId, String actionableItem) {
super(BUG_TITLE, IAction.AS_PUSH_BUTTON);
- this.oseePlugin = oseePlugin;
+ this.pluginId = pluginId;
this.itemId = itemId;
this.target = target;
this.actionableItem = actionableItem;
@@ -199,16 +200,8 @@ public final class OseeUiActions {
@Override
public void run() {
- Version version =
- new Version((String) oseePlugin.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION));
- String desc = String.format("Found in \"%s\" version %s.", itemId, version);
IActionable actionable = (IActionable) target.getAdapter(IActionable.class);
- if (actionable != null) {
- String moreDesc = actionable.getActionDescription();
- if (Strings.isValid(moreDesc)) {
- desc += "\n" + moreDesc;
- }
- }
+ String desc = getActionDescription(itemId, pluginId, actionable);
reportLogException(actionableItem, desc);
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActivator.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActivator.java
index c55216b4492..35a82ba4d71 100644
--- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActivator.java
+++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/OseeUiActivator.java
@@ -22,18 +22,13 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.plugin.core.ActivatorHelper;
+import org.eclipse.osee.framework.plugin.core.PluginUtil;
import org.eclipse.osee.framework.ui.plugin.internal.OseePluginUiActivator;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -42,13 +37,12 @@ import org.osgi.framework.BundleContext;
*/
public abstract class OseeUiActivator extends AbstractUIPlugin {
private OseeUiActivator parentPlugin;
- private ActivatorHelper helper;
+ private PluginUtil helper;
+ private final String pluginId;
- /**
- * The constructor.
- */
- protected OseeUiActivator() {
+ protected OseeUiActivator(String pluginId) {
super();
+ this.pluginId = pluginId;
}
/**
@@ -91,8 +85,7 @@ public abstract class OseeUiActivator extends AbstractUIPlugin {
parentPlugin = null;
}
- helper = new ActivatorHelper(context, this);
-
+ helper = new PluginUtil(pluginId);
}
/**
@@ -124,26 +117,6 @@ public abstract class OseeUiActivator extends AbstractUIPlugin {
return null;
}
- public void setHelp(Control control, String name, String library) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(control, library + "." + name);
- }
-
- public void setHelp(IAction action, String name, String library) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(action, library + "." + name);
- }
-
- public void setHelp(Menu menu, String name, String library) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(menu, library + "." + name);
- }
-
- public void setHelp(MenuItem menuItem, String name, String library) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(menuItem, library + "." + name);
- }
-
- public void displayHelp(String name, String library) {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(library + "." + name);
- }
-
protected String getPluginName() {
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/internal/OseePluginUiActivator.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/internal/OseePluginUiActivator.java
index b8626adfb93..d17d4f93a1c 100644
--- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/internal/OseePluginUiActivator.java
+++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/internal/OseePluginUiActivator.java
@@ -28,6 +28,7 @@ public class OseePluginUiActivator extends OseeUiActivator {
private ServiceTracker tracker;
public OseePluginUiActivator() {
+ super(PLUGIN_ID);
plugin = this;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/HelpUtil.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/HelpUtil.java
new file mode 100644
index 00000000000..450ccffc6ff
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/HelpUtil.java
@@ -0,0 +1,40 @@
+/*
+ * Created on Sep 24, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.plugin.util;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.PlatformUI;
+
+public class HelpUtil {
+
+ public static void setHelp(Control control, String name, String library) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(control, library + "." + name);
+ }
+
+ public static void setHelp(IAction action, String name, String library) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(action, library + "." + name);
+ }
+
+ public static void setHelp(Menu menu, String name, String library) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(menu, library + "." + name);
+ }
+
+ public static void setHelp(MenuItem menuItem, String name, String library) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(menuItem, library + "." + name);
+ }
+
+ public static void displayHelp(String name, String library) {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(library + "." + name);
+ }
+
+ public static void displayHelp(String contextId) {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp();
+ }
+
+}

Back to the top