summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-07-31 15:45:04 (EDT)
committer Curtis Windatt2013-07-31 15:45:04 (EDT)
commitbabf8d486119cf88563851ee8a2a216caa679023 (patch)
tree920e5cedbe228afee01bec2eba7b15c72eb7a559
parent4bca27b30584b7401960ee3ece26714efe4bd796 (diff)
downloadeclipse.pde.ui-babf8d486119cf88563851ee8a2a216caa679023.zip
eclipse.pde.ui-babf8d486119cf88563851ee8a2a216caa679023.tar.gz
eclipse.pde.ui-babf8d486119cf88563851ee8a2a216caa679023.tar.bz2
Bug 414164 - Remove macro tool from PDE UI Tests
-rw-r--r--ui/org.eclipse.pde.ui.tests/.classpath2
-rw-r--r--ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF2
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/AbstractStructuredCommand.java225
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/BooleanSelectionCommand.java159
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CheckCommand.java64
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ChoiceSelectionCommand.java162
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CommandTarget.java46
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/EditorCommandTarget.java38
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ExpansionCommand.java74
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/FocusCommand.java73
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IIndexHandler.java40
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IPlayable.java20
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IRecorderListener.java29
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWidgetResolver.java32
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWritable.java18
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/KeyCommand.java89
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/Macro.java241
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommand.java72
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommandShell.java548
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroIndex.java31
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroInstruction.java63
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroManager.java339
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroPlugin.java112
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroUtil.java913
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ModifyCommand.java120
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/StructuredSelectionCommand.java80
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ToggleStructuredCommand.java48
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ViewCommandTarget.java34
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WaitCommand.java133
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WidgetIdentifier.java51
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WindowCommandTarget.java36
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WizardCommandTarget.java29
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/XMLDefaultHandler.java135
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultIndexHandler.java36
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultWidgetResolver.java58
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexAction.java87
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexPage.java117
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexWizard.java36
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/NewMacroWizard.java69
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/PlaybackAction.java97
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordAction.java93
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordBlock.java105
-rw-r--r--ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/StopAction.java87
-rw-r--r--ui/org.eclipse.pde.ui.tests/build.properties5
-rw-r--r--ui/org.eclipse.pde.ui.tests/plugin.xml84
-rw-r--r--ui/org.eclipse.pde.ui.tests/schema/macroSupport.exsd115
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestsPlugin.java40
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java11
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathcontributor/ClasspathContributorTest.java5
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java5
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExportBundleTests.java5
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java6
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/OpenManifestEditorPerfTest.java5
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java7
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/ProjectCreationTests.java5
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/AbstractRegistryModelTest.java138
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/TestUtils.java24
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java20
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java4
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java13
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java8
-rw-r--r--ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java4
62 files changed, 178 insertions, 5169 deletions
diff --git a/ui/org.eclipse.pde.ui.tests/.classpath b/ui/org.eclipse.pde.ui.tests/.classpath
index 6acd325..b7464f3 100644
--- a/ui/org.eclipse.pde.ui.tests/.classpath
+++ b/ui/org.eclipse.pde.ui.tests/.classpath
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="Macro Manager"/>
- <classpathentry kind="src" path="Macro UI"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="output" path="bin"/>
diff --git a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF
index 240d830..9225d7d 100644
--- a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: PDE JUnit Tests
Bundle-SymbolicName: org.eclipse.pde.ui.tests; singleton:=true
Bundle-Version: 3.1.500.qualifier
Bundle-ClassPath: tests.jar
-Bundle-Activator: org.eclipse.pde.internal.ui.tests.macro.MacroPlugin
+Bundle-Activator: org.eclipse.pde.ui.tests.PDETestsPlugin
Bundle-Vendor: Eclipse.org
Require-Bundle: org.junit,
org.eclipse.pde.ui,
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/AbstractStructuredCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/AbstractStructuredCommand.java
deleted file mode 100644
index 7091323..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/AbstractStructuredCommand.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.*;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public abstract class AbstractStructuredCommand extends MacroCommand {
- protected ArrayList items;
-
- public AbstractStructuredCommand(WidgetIdentifier wid) {
- super(wid);
- items = new ArrayList();
- }
-
- public boolean mergeEvent(Event e) {
- items.clear();
- processEvent(e);
- return true;
- }
-
- protected Widget[] getItemsForEvent(Event e) {
- Widget item = null;
- if (e.item != null)
- item = e.item;
- else if (e.widget instanceof Item)
- item = e.widget;
- if (item != null)
- return new Widget[] {item};
- return null;
- }
-
- public void processEvent(Event event) {
- Widget[] eventItems = getItemsForEvent(event);
-
- if (eventItems != null) {
- for (int i = 0; i < eventItems.length; i++) {
- String id = getItemId(eventItems[i]);
- if (id != null)
- items.add(id);
- }
- }
- }
-
- protected String getItemId(Widget item) {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- String id = recorder.resolveWidget(item);
- if (id != null)
- return id;
- Object data = item.getData();
- if (data != null)
- return data.getClass().getName();
- return null;
- }
-
- protected void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("item")) {
- String path = MacroUtil.getAttribute(child, "path");
- if (path != null)
- items.add(path);
- }
- }
- }
-
- protected void writeAdditionalAttributes(PrintWriter writer) {
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.print("\"");
- writeAdditionalAttributes(writer);
- writer.println(">");
- String cindent = indent + " ";
- for (int i = 0; i < items.size(); i++) {
- writer.print(cindent);
- writer.print("<item path=\"");
- writer.print((String) items.get(i));
- writer.println("\"/>");
- }
- writer.println(indent + "</command>");
- }
-
- protected abstract void playTreeCommand(Tree tree, TreeItem[] matches);
-
- protected abstract void playTableCommand(Table table, TableItem[] matches);
-
- protected abstract void playTableTreeCommand(TableTree tableTree, TableTreeItem[] matches);
-
- public final boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), getStartLine());
-
- if (target == null)
- return false;
- target.setFocus();
- MacroUtil.processDisplayEvents(display);
-
- Widget widget = target.getWidget();
-
- if (widget == null || widget.isDisposed())
- return false;
-
- if (widget instanceof Tree) {
- TreeItem[] matches = findMatches((Tree) widget);
- playTreeCommand((Tree) widget, matches);
- } else if (widget instanceof Table) {
- TableItem[] matches = findMatches((Table) widget);
- playTableCommand((Table) widget, matches);
- } else if (widget instanceof TableTree) {
- TableTreeItem[] matches = findMatches((TableTree) widget);
- playTableTreeCommand((TableTree) widget, matches);
- }
- return true;
- }
-
- private TreeItem[] findMatches(Tree tree) {
- TreeItem[] children = tree.getItems();
- ArrayList matches = new ArrayList();
- for (int i = 0; i < items.size(); i++) {
- String itemId = (String) items.get(i);
- TreeItem item = findTreeItem(children, itemId);
- if (item != null)
- matches.add(item);
- }
- return (TreeItem[]) matches.toArray(new TreeItem[matches.size()]);
- }
-
- private TableItem[] findMatches(Table table) {
- TableItem[] elements = table.getItems();
- ArrayList matches = new ArrayList();
-
- for (int i = 0; i < items.size(); i++) {
- String itemId = (String) items.get(i);
- TableItem item = findTableItem(elements, itemId);
- if (item != null)
- matches.add(item);
- }
- return (TableItem[]) matches.toArray(new TableItem[matches.size()]);
- }
-
- private TableTreeItem[] findMatches(TableTree tableTree) {
- TableTreeItem[] children = tableTree.getItems();
- ArrayList matches = new ArrayList();
-
- for (int i = 0; i < items.size(); i++) {
- String itemId = (String) items.get(i);
- TableTreeItem item = findTableTreeItem(children, itemId);
- if (item != null)
- matches.add(item);
- }
- return (TableTreeItem[]) matches.toArray(new TableTreeItem[matches.size()]);
- }
-
- private TreeItem findTreeItem(TreeItem[] children, String itemId) {
- for (int i = 0; i < children.length; i++) {
- TreeItem item = children[i];
- String id = getItemId(item);
- //Test the item itself
- if (id != null && id.equals(itemId))
- return item;
- int ccount = item.getItemCount();
- if (ccount > 0) {
- //Test the item's children
- TreeItem citem = findTreeItem(item.getItems(), itemId);
- if (citem != null)
- return citem;
- }
- }
- return null;
- }
-
- private TableItem findTableItem(TableItem[] children, String itemId) {
- for (int i = 0; i < children.length; i++) {
- TableItem item = children[i];
- String id = getItemId(item);
-
- if (id != null && id.equals(itemId))
- return item;
- }
- return null;
- }
-
- private TableTreeItem findTableTreeItem(TableTreeItem[] children, String itemId) {
- for (int i = 0; i < children.length; i++) {
- TableTreeItem item = children[i];
- String id = getItemId(item);
- //Test the item itself
- if (id != null && id.equals(itemId))
- return item;
- int ccount = item.getItemCount();
- if (ccount > 0) {
- //Test the item's children
- TableTreeItem citem = findTableTreeItem(item.getItems(), itemId);
- if (citem != null)
- return citem;
- }
- }
- return null;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/BooleanSelectionCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/BooleanSelectionCommand.java
deleted file mode 100644
index ee8a20c..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/BooleanSelectionCommand.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class BooleanSelectionCommand extends MacroCommand {
- public static final String TYPE = "select";
- private Boolean selection;
- private ArrayList path;
-
- public BooleanSelectionCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public String getType() {
- return TYPE;
- }
-
- public void processEvent(Event e) {
- selection = getSelection(e.widget);
- if (e.widget instanceof MenuItem) {
- //System.out.println("Item="+e.widget+" data = "+e.widget.getData());
- path = getPath((MenuItem) e.widget);
- }
- }
-
- private Boolean getSelection(Widget widget) {
- if ((widget.getStyle() & (SWT.CHECK | SWT.RADIO)) == 0)
- return null;
- if (widget instanceof Button)
- return new Boolean(((Button) widget).getSelection());
- if (widget instanceof ToolItem)
- return new Boolean(((ToolItem) widget).getSelection());
- if (widget instanceof MenuItem)
- return new Boolean(((MenuItem) widget).getSelection());
- return null;
- }
-
- private ArrayList getPath(MenuItem item) {
- ArrayList segments = new ArrayList();
- Object data = item.getData();
-
- if (data instanceof ContributionItem) {
- ContributionItem aitem = (ContributionItem) data;
- MenuManager manager = (MenuManager) aitem.getParent();
- while (manager != null) {
- String id = manager.getId();
- if (id == null)
- break;
- segments.add(0, id);
- manager = (MenuManager) manager.getParent();
- }
- }
- return segments.size() > 0 ? segments : null;
- }
-
- protected void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
- String sel = MacroUtil.getAttribute(node, "selection");
- if (sel != null) {
- selection = sel.equals("true") ? Boolean.TRUE : Boolean.FALSE;
- }
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("parent")) {
- if (path == null)
- path = new ArrayList();
- path.add(MacroUtil.getAttribute(child, "widgetId"));
- }
- }
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.print("\"");
- if (selection != null) {
- writer.print(" selection=\"");
- writer.print(selection.equals(Boolean.TRUE) ? "true" : "false");
- writer.print("\"");
- }
- if (path != null) {
- writer.println(">");
- String pindent = indent + " ";
- for (int i = 0; i < path.size(); i++) {
- writer.print(pindent);
- writer.print("<parent widgetId=\"");
- writer.print((String) path.get(i));
- writer.println("\"/>");
- }
- writer.print(indent);
- writer.println("</command>");
- } else
- writer.println("/>");
- }
-
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), path, getStartLine());
- if (target == null)
- return false;
- target.setFocus();
- Widget widget = target.getWidget();
-
- if ((widget.getStyle() & (SWT.CHECK | SWT.RADIO)) == 0) {
- doClick(widget);
- } else if (selection != null)
- doSelect(widget);
- return true;
- }
-
- private void doClick(Widget widget) {
- Event e = new Event();
- e.type = SWT.Selection;
- e.widget = widget;
- widget.notifyListeners(e.type, e);
- }
-
- protected Event createMouseEvent(Widget widget, int type) {
- Event e = new Event();
- e.type = type;
- e.button = 1;
- e.widget = widget;
- return e;
- }
-
- private void doSelect(Widget widget) {
- if (widget instanceof Button)
- ((Button) widget).setSelection(selection.booleanValue());
- else if (widget instanceof ToolItem)
- ((ToolItem) widget).setSelection(selection.booleanValue());
- else if (widget instanceof MenuItem)
- ((MenuItem) widget).setSelection(selection.booleanValue());
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CheckCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CheckCommand.java
deleted file mode 100644
index d3f66b7..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CheckCommand.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-public class CheckCommand extends ToggleStructuredCommand {
- public static final String TYPE = "item-check";
-
- /**
- * @param wid
- */
- public CheckCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public String getType() {
- return TYPE;
- }
-
- public void processEvent(Event event) {
- super.processEvent(event);
- Widget item = event.item;
- if (item instanceof TreeItem)
- value = ((TreeItem) item).getChecked();
- else if (item instanceof TableItem)
- value = ((TableItem) item).getChecked();
- else if (item instanceof TableTreeItem)
- value = ((TableTreeItem) item).getChecked();
- }
-
- protected void playTreeCommand(Tree tree, TreeItem[] matches) {
- for (int i = 0; i < matches.length; i++) {
- matches[i].setChecked(getValue());
- }
- }
-
- protected void playTableCommand(Table table, TableItem[] matches) {
- for (int i = 0; i < matches.length; i++) {
- matches[i].setChecked(getValue());
- }
- }
-
- protected void playTableTreeCommand(TableTree tableTree, TableTreeItem[] matches) {
- for (int i = 0; i < matches.length; i++) {
- matches[i].setChecked(getValue());
- }
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ChoiceSelectionCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ChoiceSelectionCommand.java
deleted file mode 100644
index 958fc45..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ChoiceSelectionCommand.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Widget;
-import org.w3c.dom.Node;
-
-public class ChoiceSelectionCommand extends MacroCommand {
- public static final String TYPE = "choice-select";
-
- private String choiceId;
-
- public ChoiceSelectionCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public String getType() {
- return TYPE;
- }
-
- public void processEvent(Event e) {
- choiceId = computeChoiceId(e.widget, e.item);
- }
-
- private String computeChoiceId(Widget widget, Widget item) {
- int index = -1;
-
- if (widget instanceof Combo) {
- Combo combo = (Combo) widget;
- index = combo.getSelectionIndex();
- } else if (widget instanceof CCombo) {
- CCombo combo = (CCombo) widget;
- index = combo.getSelectionIndex();
- } else {
- String id = MacroPlugin.getDefault().getMacroManager().resolveWidget(item);
- if (id != null)
- return id;
- if (widget instanceof TabFolder) {
- TabFolder tabFolder = (TabFolder) widget;
- TabItem tabItem = (TabItem) item;
- index = tabFolder.indexOf(tabItem);
- } else if (widget instanceof CTabFolder) {
- CTabFolder tabFolder = (CTabFolder) widget;
- CTabItem tabItem = (CTabItem) item;
- index = tabFolder.indexOf(tabItem);
- }
- }
- return (index != -1) ? getPositionId(index) : null;
- }
-
- private String getPositionId(int index) {
- return "item#" + index;
- }
-
- protected void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
- choiceId = MacroUtil.getAttribute(node, "choiceId");
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.print("\"");
- if (choiceId != null) {
- writer.print(" choiceId=\"");
- writer.print(choiceId);
- writer.print("\"");
- }
- writer.println("/>");
- }
-
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), getStartLine());
- if (target == null)
- return false;
- target.setFocus();
- Widget widget = target.getWidget();
- if (widget instanceof TabFolder)
- doSelect((TabFolder) widget);
- else if (widget instanceof CTabFolder)
- doSelect((CTabFolder) widget);
- else if (widget instanceof Combo)
- doSelect((Combo) widget);
- else if (widget instanceof CCombo)
- doSelect((CCombo) widget);
- return true;
- }
-
- private void doSelect(TabFolder tabFolder) {
- TabItem[] items = tabFolder.getItems();
- for (int i = 0; i < items.length; i++) {
- TabItem item = items[i];
- String id = computeChoiceId(tabFolder, item);
- if (id != null && id.equals(choiceId)) {
- tabFolder.setSelection(i);
- break;
- }
- }
- }
-
- private void doSelect(CTabFolder tabFolder) {
- CTabItem[] items = tabFolder.getItems();
- for (int i = 0; i < items.length; i++) {
- CTabItem item = items[i];
- String id = computeChoiceId(tabFolder, item);
- if (id != null && id.equals(choiceId)) {
- tabFolder.setSelection(i);
- break;
- }
- }
- }
-
- private void doSelect(Combo combo) {
- int index = getIndexFromChoice();
- if (index != -1)
- combo.select(index);
- }
-
- private void doSelect(CCombo combo) {
- int index = getIndexFromChoice();
- if (index != -1)
- combo.select(index);
- }
-
- private int getIndexFromChoice() {
- int loc = choiceId.indexOf('#');
- if (loc == -1)
- return -1;
- try {
- return new Integer(choiceId.substring(loc + 1)).intValue();
- } catch (NumberFormatException e) {
- return -1;
- }
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CommandTarget.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CommandTarget.java
deleted file mode 100644
index 43efc8f..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/CommandTarget.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Widget;
-
-public class CommandTarget {
- private Widget widget;
- private Object context;
-
- public CommandTarget(Widget widget, Object context) {
- this.widget = widget;
- this.context = context;
- }
-
- public void ensureVisible() {
- }
-
- public Widget getWidget() {
- return widget;
- }
-
- public Object getContext() {
- return context;
- }
-
- public void setFocus() {
- ensureVisible();
- Display display = widget.getDisplay();
- if (widget instanceof Control) {
- Control c = (Control) widget;
- if (!c.equals(display.getFocusControl()))
- c.setFocus();
- }
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/EditorCommandTarget.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/EditorCommandTarget.java
deleted file mode 100644
index b31fb49..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/EditorCommandTarget.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-
-public class EditorCommandTarget extends CommandTarget {
- /**
- * @param widget
- * @param context
- */
- public EditorCommandTarget(Widget widget, IEditorPart editor) {
- super(widget, editor);
- }
-
- public IEditorPart getEditor() {
- return (IEditorPart) getContext();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.CommandTarget#ensureVisible()
- */
- public void ensureVisible() {
- IEditorPart editor = getEditor();
- IWorkbenchPage page = editor.getEditorSite().getPage();
- page.activate(editor);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ExpansionCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ExpansionCommand.java
deleted file mode 100644
index 57072fc..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ExpansionCommand.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-public class ExpansionCommand extends ToggleStructuredCommand {
- public static final String TYPE = "item-expand";
-
- /**
- * @param wid
- */
- public ExpansionCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public void processEvent(Event event) {
- super.processEvent(event);
- Widget item = event.item;
-
- if (item instanceof TreeItem)
- value = !((TreeItem) item).getExpanded();
- else if (item instanceof TableTreeItem)
- value = !((TableTreeItem) item).getExpanded();
- }
-
- protected void playTreeCommand(Tree tree, TreeItem[] matches) {
- for (int i = 0; i < matches.length; i++) {
- matches[i].setExpanded(getValue());
- fireEvent(tree, matches[i]);
- }
- }
-
- private void fireEvent(Widget widget, Widget item) {
- Event event = new Event();
- event.type = getValue() ? SWT.Expand : SWT.Collapse;
- event.widget = widget;
- event.item = item;
- widget.notifyListeners(event.type, event);
- }
-
- protected void playTableCommand(Table table, TableItem[] matches) {
- }
-
- protected void playTableTreeCommand(TableTree tableTree, TableTreeItem[] matches) {
- for (int i = 0; i < matches.length; i++) {
- matches[i].setExpanded(getValue());
- fireEvent(tableTree, matches[i]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.SelectionCommand#getKind()
- */
- public String getType() {
- return TYPE;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/FocusCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/FocusCommand.java
deleted file mode 100644
index 5ca5565..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/FocusCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-
-public class FocusCommand extends MacroCommand {
- public static final String TYPE = "focus";
-
- public FocusCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public boolean mergeEvent(Event e) {
- // we can directly merge repeated focus requests
- // on the same widget
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.MacroCommand#getType()
- */
- public String getType() {
- return TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.MacroCommand#processEvent(org.eclipse.swt.widgets.Event)
- */
- public void processEvent(Event e) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.IWritable#write(java.lang.String, java.io.PrintWriter)
- */
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.print("\"");
- writer.println("/>");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.IPlayable#playback(org.eclipse.swt.widgets.Composite)
- */
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- if (parent.isDisposed())
- return false;
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), getStartLine());
- if (target != null)
- target.setFocus();
- return true;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IIndexHandler.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IIndexHandler.java
deleted file mode 100644
index 96e0163..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IIndexHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Classes that implement this interface are registered with
- * the macro manager to handle cases where the user interrupted
- * the recording process to insert a named index. Upon playback,
- * index handler will be called to handle the named index
- * when reached in the script.
- *
- * @since 3.1
- */
-
-public interface IIndexHandler {
- /**
- * Evaluates the state of the platform at the provided script
- * index. Error status returned from the method will cause
- * the script manager to stop the script execution and
- * throw a <code>CoreException</code>.
- *
- * @param shell the active shell when the index was reached
- * @param indexId the unique identifier of the index
- * inserted in the script
- * @return <code>Status.OK_STATUS</code> if the script can proceed, or
- * an error status otherwise.
- */
- IStatus processIndex(Shell shell, String indexId);
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IPlayable.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IPlayable.java
deleted file mode 100644
index 835306a..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IPlayable.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public interface IPlayable {
- boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException;
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IRecorderListener.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IRecorderListener.java
deleted file mode 100644
index d018edf..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IRecorderListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-public interface IRecorderListener {
- int STOP = 1;
- int INDEX = 2;
-
- void recordingStarted();
-
- void recordingStopped();
-
- /**
- * Called when the user pressed Ctrl+Shift+F10 (index)
- * or Ctrl+Shift+F11 (stop) to interrupt
- * the recording process. Clients may use this event
- * to insert named indexes, stop the recording etc.
- * @param type <code>STOP</code> or <code>INDEX</code>
- */
- void recordingInterrupted(int type);
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWidgetResolver.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWidgetResolver.java
deleted file mode 100644
index 7d908dc..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWidgetResolver.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * This interface is registered using extension point
- * <code>org.eclipse.ui.macro</code> return unique identifier
- * from a provided widget. The identifier must be reproducable
- * between sessions so that it can be used to locate the
- * widget on playback.
- *
- * @since 3.1
- */
-public interface IWidgetResolver {
- /**
- * Returns a unique identifier for the provided widget.
- * @param widget the widget to identify
- * @return unique identifier that can be used to locate the
- * widget or <code>null</code> if none can be found.
- */
- String getUniqueId(Widget widget);
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWritable.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWritable.java
deleted file mode 100644
index 6615269..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/IWritable.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-
-public interface IWritable {
- void write(String indent, PrintWriter writer);
-
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/KeyCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/KeyCommand.java
deleted file mode 100644
index 207b4ce..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/KeyCommand.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ExecutionException;
-import org.eclipse.ui.commands.ICommand;
-import org.eclipse.ui.commands.IWorkbenchCommandSupport;
-import org.eclipse.ui.commands.NotHandledException;
-
-public class KeyCommand extends MacroCommand {
- public static final String TYPE = "key-binding";
- private String commandId;
-
- /**
- * @param widgetId
- */
- public KeyCommand(WidgetIdentifier widgetId, String commandId) {
- super(widgetId);
- this.commandId = commandId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.macro.MacroCommand#getType()
- */
- public String getType() {
- return TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.macro.MacroCommand#processEvent(org.eclipse.swt.widgets.Event)
- */
- public void processEvent(Event e) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.macro.IWritable#write(java.lang.String, java.io.PrintWriter)
- */
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.print("\" commandId=\"");
- writer.print(commandId);
- writer.println("\"/>");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.macro.IPlayable#playback(org.eclipse.swt.widgets.Display, org.eclipse.swt.widgets.Composite, org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), getStartLine());
- if (target == null)
- return false;
- IWorkbenchCommandSupport csupport = PlatformUI.getWorkbench().getCommandSupport();
- ICommand command = csupport.getCommandManager().getCommand(commandId);
- if (command != null) {
- try {
- command.execute(null);
- return true;
- } catch (ExecutionException e) {
- MacroPlugin.logException(e);
- } catch (NotHandledException e) {
- MacroPlugin.logException(e);
- }
- }
- return false;
- }
-
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/Macro.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/Macro.java
deleted file mode 100644
index fd9626e..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/Macro.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Stack;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.w3c.dom.Node;
-
-public class Macro implements IWritable, IPlayable {
- private static final String SYNTAX_VERSION = "0.1";
- private transient IIndexHandler indexHandler;
- ArrayList shells;
- private String name;
- private Stack shellStack;
-
- public Macro() {
- shells = new ArrayList();
- }
-
- public Macro(String name) {
- this();
- this.name = name;
- }
-
- void addShell(Node node, Hashtable lineTable) {
- String sid = MacroUtil.getAttribute(node, "id");
- MacroCommandShell shell = new MacroCommandShell(null, sid);
- shell.load(node, lineTable);
- shells.add(shell);
- }
-
- public void initializeForRecording(Display display) {
- shellStack = new Stack();
- shells.clear();
- Shell currentShell = display.getActiveShell();
- MacroCommandShell commandShell = createCommandShell(currentShell);
- shellStack.push(commandShell);
- shells.add(commandShell);
- }
-
- private MacroCommandShell createCommandShell(Shell shell) {
- WidgetIdentifier wi = MacroUtil.getWidgetIdentifier(shell);
- if (wi == null)
- return null;
- return new MacroCommandShell(shell, wi.getWidgetId());
- }
-
- private boolean isCurrent(Shell shell) {
- if (shellStack.isEmpty())
- return false;
- MacroCommandShell cshell = (MacroCommandShell) shellStack.peek();
- return cshell.tracks(shell);
- }
-
- public void stopRecording() {
- reset();
- }
-
- public boolean addEvent(Event event) throws Exception {
- if (isIgnorableEvent(event))
- return false;
- try {
- if (event.widget instanceof Shell) {
- switch (event.type) {
- case SWT.Activate :
- activateShell((Shell) event.widget);
- break;
- case SWT.Close :
- boolean stop = closeShell((Shell) event.widget);
- if (stop)
- return true;
- break;
- }
- } else if (getTopShell() != null) {
- getTopShell().addEvent(event);
- }
- } catch (Exception e) {
- throw e;
- }
- return false;
- }
-
- private boolean isIgnorableEvent(Event e) {
- Shell shell = e.display.getActiveShell();
- if (shell != null) {
- Boolean ivalue = (Boolean) shell.getData(MacroManager.IGNORE);
- if (ivalue != null && ivalue.equals(Boolean.TRUE))
- return true;
- }
- return false;
- }
-
- public void addPause() {
- getTopShell().addPause();
- }
-
- public void addIndex(String id) {
- getTopShell().addIndex(id);
- }
-
- public MacroCommandShell getTopShell() {
- if (shellStack.isEmpty())
- return null;
- return (MacroCommandShell) shellStack.peek();
- }
-
- private void activateShell(Shell shell) {
- Object data = shell.getData();
- if (data instanceof Dialog) {
- if (!isCurrent(shell)) {
- MacroCommandShell commandShell = createCommandShell(shell);
- getTopShell().addCommandShell(commandShell);
- shellStack.push(commandShell);
- }
- } else if (data instanceof Window) {
- updateStack();
- if (!isCurrent(shell)) {
- // pop the current
- popStack();
- MacroCommandShell commandShell = createCommandShell(shell);
- shellStack.push(commandShell);
- shells.add(commandShell);
- }
- }
- }
-
- private void popStack() {
- if (shellStack.isEmpty())
- return;
- MacroCommandShell top = (MacroCommandShell) shellStack.pop();
- top.extractExpectedReturnCode();
- }
-
- private boolean closeShell(Shell shell) {
- if (shellStack.isEmpty())
- return false;
- MacroCommandShell top = (MacroCommandShell) shellStack.peek();
- if (top.tracks(shell))
- popStack();
- return shellStack.isEmpty();
- }
-
- private void updateStack() {
- while (shellStack.size() > 0) {
- MacroCommandShell top = getTopShell();
- if (top.isDisposed())
- popStack();
- else
- break;
- }
- }
-
- private void closeSecondaryShells() {
- }
-
- public String[] getExistingIndices() {
- ArrayList list = new ArrayList();
- for (int i = 0; i < shells.size(); i++) {
- MacroCommandShell shell = (MacroCommandShell) shells.get(i);
- shell.addExistingIndices(list);
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
-
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- reset();
- String mname = name != null ? name : "macro";
- monitor.beginTask("Executing " + mname + " ...", shells.size());
- for (int i = 0; i < shells.size(); i++) {
- MacroCommandShell shell = (MacroCommandShell) shells.get(i);
- shell.setIndexHandler(getIndexHandler());
- final Shell[] sh = new Shell[1];
- display.syncExec(new Runnable() {
- public void run() {
- sh[0] = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
- });
- try {
- boolean result = shell.playback(display, sh[0], new SubProgressMonitor(monitor, 1));
- if (!result)
- return false;
- } catch (CoreException e) {
- closeSecondaryShells();
- throw e;
- }
- }
- return true;
- }
-
- private void reset() {
- shellStack = null;
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- writer.print("<macro version=\"");
- writer.print(SYNTAX_VERSION);
- writer.println("\">");
- String cindent = " ";
- for (int i = 0; i < shells.size(); i++) {
- MacroCommandShell cshell = (MacroCommandShell) shells.get(i);
- cshell.write(cindent, writer);
- }
- writer.println("</macro>");
- }
-
- public IIndexHandler getIndexHandler() {
- return indexHandler;
- }
-
- public void setIndexHandler(IIndexHandler indexHandler) {
- this.indexHandler = indexHandler;
- }
-
- public String getName() {
- return name;
- }
-
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommand.java
deleted file mode 100644
index ac02f79..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.widgets.Event;
-import org.w3c.dom.Node;
-
-public abstract class MacroCommand implements IWritable, IPlayable {
- private WidgetIdentifier widgetId;
- private int[] range;
-
- public MacroCommand(WidgetIdentifier widgetId) {
- this.widgetId = widgetId;
- }
-
- public abstract String getType();
-
- public abstract void processEvent(Event e);
-
- protected void load(Node node, Hashtable lineTable) {
- String cid = MacroUtil.getAttribute(node, "contextId");
- String wid = MacroUtil.getAttribute(node, "widgetId");
- if (wid != null && cid != null)
- widgetId = new WidgetIdentifier(new Path(cid), new Path(wid));
- bindSourceLocation(node, lineTable);
- }
-
- void bindSourceLocation(Node node, Map lineTable) {
- Integer[] lines = (Integer[]) lineTable.get(node);
- if (lines != null) {
- range = new int[2];
- range[0] = lines[0].intValue();
- range[1] = lines[1].intValue();
- }
- }
-
- public int getStartLine() {
- if (range == null)
- return -1;
- return range[0];
- }
-
- public int getStopLine() {
- if (range == null)
- return -1;
- return range[1];
- }
-
- public boolean mergeEvent(Event e) {
- return false;
- }
-
- public WidgetIdentifier getWidgetId() {
- return widgetId;
- }
-
- public String toString() {
- return "MacroCommand [" + getType() + ", line " + getStartLine() + "]";
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommandShell.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommandShell.java
deleted file mode 100644
index 2a33519..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroCommandShell.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.IWorkbenchCommandSupport;
-import org.eclipse.ui.keys.KeySequence;
-import org.eclipse.ui.keys.KeyStroke;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class MacroCommandShell extends MacroInstruction {
- private ArrayList commands;
-
- private int expectedReturnCode;
-
- private transient Event lastEvent;
-
- private transient Display display;
-
- private transient Shell shell;
-
- private transient IIndexHandler indexHandler;
-
- private transient Window window;
-
- private static class NestedShell implements Listener, Runnable {
- private MacroCommandShell cshell;
-
- private Display display;
-
- private Shell nshell;
-
- private boolean released;
-
- private CoreException exception;
-
- private IProgressMonitor monitor;
-
- public NestedShell(Display display, MacroCommandShell cshell, IProgressMonitor monitor) {
- this.display = display;
- this.cshell = cshell;
- this.monitor = monitor;
- }
-
- public void handleEvent(Event e) {
- if (e.widget instanceof Shell) {
- // shell activated
- Shell shell = (Shell) e.widget;
- IPath path = MacroUtil.getShellId(shell);
- String sid = path.toString();
- if (sid.equals(cshell.getId())) {
- shell.getDisplay().removeFilter(SWT.Activate, this);
- released = true;
- this.nshell = shell;
- shell.getDisplay().asyncExec(this);
- }
- }
- }
-
- public boolean getResult() {
- return cshell.matchesReturnCode();
- }
-
- public boolean isReleased() {
- return released;
- }
-
- public void run() {
- try {
- cshell.playback(display, nshell, monitor);
- } catch (CoreException e) {
- this.exception = e;
- if (nshell != null && !nshell.isDisposed())
- nshell.close();
- }
- }
-
- public CoreException getException() {
- return exception;
- }
- }
-
- public MacroCommandShell() {
- this(null, null);
- }
-
- public MacroCommandShell(Shell shell, String path) {
- super(path);
- commands = new ArrayList();
- this.shell = shell;
- hookWindow(false);
- }
-
- private void hookWindow(boolean playback) {
- if (shell != null) {
- if (!playback)
- doHookWindow();
- else
- display.syncExec(new Runnable() {
- public void run() {
- doHookWindow();
- }
- });
- }
- }
-
- private void doHookWindow() {
- Object data = shell.getData();
- if (data != null && data instanceof Window)
- this.window = (Window) data;
- }
-
- public void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
-
- String codeId = MacroUtil.getAttribute(node, "return-code");
- if (codeId != null) {
- try {
- expectedReturnCode = new Integer(codeId).intValue();
- } catch (NumberFormatException e) {
- }
- }
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- String name = child.getNodeName();
- if (name.equals("command"))
- processCommand(child, lineTable);
- else if (name.equals("shell"))
- processShell(child, lineTable);
- else if (name.equals("index"))
- processIndex(child, lineTable);
- }
- }
- }
-
- private void processCommand(Node node, Hashtable lineTable) {
- String wid = MacroUtil.getAttribute(node, "widgetId");
- String cid = MacroUtil.getAttribute(node, "contextId");
- String type = MacroUtil.getAttribute(node, "type");
- if (type == null)
- return;
- MacroCommand command = null;
- WidgetIdentifier wi = (wid != null && cid != null) ? new WidgetIdentifier(new Path(wid), new Path(cid)) : null;
- if (type.equals(ModifyCommand.TYPE))
- command = new ModifyCommand(wi);
- else if (type.equals(BooleanSelectionCommand.TYPE))
- command = new BooleanSelectionCommand(wi);
- else if (type.equals(StructuredSelectionCommand.ITEM_SELECT) || type.equals(StructuredSelectionCommand.DEFAULT_SELECT))
- command = new StructuredSelectionCommand(wi, type);
- else if (type.equals(ExpansionCommand.TYPE))
- command = new ExpansionCommand(wi);
- else if (type.equals(CheckCommand.TYPE))
- command = new CheckCommand(wi);
- else if (type.equals(FocusCommand.TYPE))
- command = new FocusCommand(wi);
- else if (type.equals(ChoiceSelectionCommand.TYPE))
- command = new ChoiceSelectionCommand(wi);
- else if (type.equals(WaitCommand.TYPE))
- command = new WaitCommand();
- if (command != null) {
- command.load(node, lineTable);
- commands.add(command);
- }
- }
-
- private void processShell(Node node, Hashtable lineTable) {
- MacroCommandShell shell = new MacroCommandShell();
- shell.load(node, lineTable);
- commands.add(shell);
- }
-
- private void processIndex(Node node, Hashtable lineTable) {
- MacroIndex index = new MacroIndex();
- index.load(node, lineTable);
- commands.add(index);
- }
-
- public void addCommandShell(MacroCommandShell cshell) {
- commands.add(cshell);
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<shell id=\"");
- writer.print(getId());
- writer.print("\" return-code=\"");
- writer.print(expectedReturnCode + "");
- writer.println("\">");
- String cindent = indent + " ";
- for (int i = 0; i < commands.size(); i++) {
- IWritable writable = (IWritable) commands.get(i);
- if (i < commands.size() - 1 || !(writable instanceof WaitCommand))
- writable.write(cindent, writer);
- }
- writer.print(indent);
- writer.println("</shell>");
- }
-
- public void addEvent(Event event) {
- if (event.widget instanceof Control) {
- if (((Control) event.widget).isVisible() == false)
- return;
- }
- MacroCommand command = createCommand(event);
- if (command != null) {
- command.processEvent(event);
- MacroCommand lastCommand = getLastCommand();
- if (lastCommand != null && lastCommand.getWidgetId().equals(command.getWidgetId()) && lastCommand.getType().equals(FocusCommand.TYPE) && isFocusCommand(command.getType())) {
- // focus followed by select or modify - focus implied
- commands.remove(lastCommand);
- }
- commands.add(command);
- lastEvent = event;
- }
- }
-
- public void addPause() {
- WaitCommand command = new WaitCommand();
- MacroCommand lastCommand = getLastCommand();
- if (lastCommand != null && lastCommand.getType() != WaitCommand.TYPE)
- commands.add(command);
- }
-
- public void addIndex(String id) {
- commands.add(new MacroIndex(id));
- }
-
- public void extractExpectedReturnCode() {
- if (window != null)
- expectedReturnCode = window.getReturnCode();
- }
-
- public boolean matchesReturnCode() {
- if (window != null) {
- return window.getReturnCode() == expectedReturnCode;
- }
- return true;
- }
-
- private boolean isFocusCommand(String type) {
- return type.equals(BooleanSelectionCommand.TYPE) || type.equals(StructuredSelectionCommand.ITEM_SELECT) || type.equals(StructuredSelectionCommand.DEFAULT_SELECT) || type.equals(ExpansionCommand.TYPE) || type.equals(CheckCommand.TYPE) || type.equals(ModifyCommand.TYPE);
- }
-
- protected MacroCommand createCommand(Event event) {
- MacroCommand lastCommand = getLastCommand();
- if (lastEvent != null && lastEvent.widget.equals(event.widget)) {
- if (lastEvent.type == event.type || (lastEvent.type == SWT.Selection && event.type == SWT.DefaultSelection)) {
- if (lastCommand != null && lastCommand.mergeEvent(event))
- return null;
- }
- }
- MacroCommand command = null;
- WidgetIdentifier wi = MacroUtil.getWidgetIdentifier(event.widget);
- if (wi == null)
- return null;
-
- switch (event.type) {
- case SWT.Modify :
- if (!isEditable(event.widget))
- return null;
- command = new ModifyCommand(wi);
- break;
- case SWT.Selection :
- case SWT.DefaultSelection :
- command = createSelectionCommand(wi, event);
- break;
- case SWT.FocusIn :
- command = new FocusCommand(wi);
- break;
- case SWT.Expand :
- case SWT.Collapse :
- command = new ExpansionCommand(wi);
- break;
- /*
- * case SWT.KeyUp: command = findKeyBinding(wi, event); break;
- */
- }
- return command;
- }
-
- private boolean isEditable(Widget widget) {
- if (widget instanceof Control) {
- Control control = (Control) widget;
- if (!control.isEnabled())
- return false;
- if (control instanceof Text)
- return ((Text) control).getEditable();
- if (control instanceof Combo || control instanceof CCombo)
- return ((control.getStyle() & SWT.READ_ONLY) == 0);
- if (control instanceof StyledText)
- return ((StyledText) control).getEditable();
- }
- return true;
- }
-
- private MacroCommand createSelectionCommand(WidgetIdentifier wid, Event event) {
- if (event.widget instanceof MenuItem || event.widget instanceof ToolItem || event.widget instanceof Button) {
- String wId = wid.getWidgetId();
- if (wId.endsWith("org.eclipse.pde.ui.tests.StopAction"))
- return null;
- if (wId.endsWith("org.eclipse.pde.ui.tests.IndexAction"))
- return null;
- return new BooleanSelectionCommand(wid);
- }
- if (event.widget instanceof Tree || event.widget instanceof Table || event.widget instanceof TableTree) {
- if (event.detail == SWT.CHECK)
- return new CheckCommand(wid);
- String type = event.type == SWT.DefaultSelection ? StructuredSelectionCommand.DEFAULT_SELECT : StructuredSelectionCommand.ITEM_SELECT;
- return new StructuredSelectionCommand(wid, type);
- }
- if (event.widget instanceof TabFolder || event.widget instanceof CTabFolder)
- return new ChoiceSelectionCommand(wid);
- if (event.widget instanceof Combo || event.widget instanceof CCombo)
- return new ChoiceSelectionCommand(wid);
- return null;
- }
-
- protected MacroCommand findKeyBinding(WidgetIdentifier wid, Event e) {
- System.out.println("mask=" + e.stateMask + ", char=" + e.character);
- java.util.List keyStrokes = MacroUtil.generatePossibleKeyStrokes(e);
- if (keyStrokes.size() == 0)
- return null;
- for (int i = 0; i < keyStrokes.size(); i++) {
- if (!((KeyStroke) keyStrokes.get(i)).isComplete())
- return null;
- }
- System.out.println("keyStrokes=" + keyStrokes);
- IWorkbenchCommandSupport csupport = PlatformUI.getWorkbench().getCommandSupport();
- KeySequence keySequence = KeySequence.getInstance(keyStrokes);
- System.out.println("keySequence=" + keySequence);
- String commandId = csupport.getCommandManager().getPerfectMatch(keySequence);
- System.out.println("Command id=" + commandId);
- if (commandId == null)
- return null;
- return new KeyCommand(wid, commandId);
- }
-
- private MacroCommand getLastCommand() {
- if (commands.size() > 0) {
- Object item = commands.get(commands.size() - 1);
- if (item instanceof MacroCommand)
- return (MacroCommand) item;
- }
- return null;
- }
-
- public boolean isDisposed() {
- return this.shell != null && this.shell.isDisposed();
- }
-
- public void close() {
- if (this.shell != null && !this.shell.isDisposed())
- this.shell.close();
- }
-
- public boolean tracks(Shell shell) {
- if (this.shell != null && this.shell.equals(shell))
- return true;
- return false;
- }
-
- public boolean playback(final Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- if (parent instanceof Shell) {
- this.shell = (Shell) parent;
- this.display = display;
- hookWindow(true);
- }
-
- NestedShell nestedShell = null;
-
- monitor.beginTask("", commands.size());
-
- for (int i = 0; i < commands.size(); i++) {
- Object c = commands.get(i);
- if (c instanceof MacroIndex) {
- String id = ((MacroIndex) c).getId();
- if (id != null && indexHandler != null) {
- IStatus status = indexHandler.processIndex(shell, id);
- if (status.getSeverity() == IStatus.OK)
- continue;
- throw new CoreException(status);
- }
- // ignore the index
- continue;
- }
- IPlayable playable = (IPlayable) c;
- if (i < commands.size() - 1) {
- // check the next command
- IPlayable next = (IPlayable) commands.get(i + 1);
- if (next instanceof MacroCommandShell) {
- // this command will open a new shell
- // add a listener before it is too late
- MacroCommandShell nestedCommand = (MacroCommandShell) next;
- nestedShell = new NestedShell(display, nestedCommand, new SubProgressMonitor(monitor, 1));
- final NestedShell fnestedShell = nestedShell;
- display.syncExec(new Runnable() {
- public void run() {
- display.addFilter(SWT.Activate, fnestedShell);
- }
- });
- }
- }
- if (playable instanceof MacroCommand) {
- boolean last = i == commands.size() - 1;
- playInGUIThread(display, playable, last, monitor);
- monitor.worked(1);
- } else if (nestedShell != null) {
- CoreException e = null;
- if (nestedShell.isReleased() == false) {
- final NestedShell fnestedShell = nestedShell;
- display.syncExec(new Runnable() {
- public void run() {
- display.removeFilter(SWT.Activate, fnestedShell);
- }
- });
- }
- e = nestedShell.getException();
- boolean result = nestedShell.getResult();
- nestedShell = null;
- if (e != null)
- throw e;
- if (!result)
- return false;
- }
- }
- shell = null;
- return true;
- }
-
- void addExistingIndices(ArrayList list) {
- for (int i = 0; i < commands.size(); i++) {
- Object c = commands.get(i);
- if (c instanceof MacroIndex) {
- list.add(((MacroIndex) c).getId());
- } else if (c instanceof MacroCommandShell) {
- ((MacroCommandShell) c).addExistingIndices(list);
- }
- }
- }
-
- private void playInGUIThread(final Display display, final IPlayable playable, boolean last, final IProgressMonitor monitor) throws CoreException {
- final CoreException[] ex = new CoreException[1];
-
- Runnable runnable = new Runnable() {
- public void run() {
- try {
- //System.out.println("Executing: "+playable.toString());
- playable.playback(display, MacroCommandShell.this.shell, monitor);
- MacroUtil.processDisplayEvents(display);
- } catch (ClassCastException e) {
- ex[0] = createPlaybackException(playable, e);
- } catch (CoreException e) {
- ex[0] = e;
- } catch (SWTException e) {
- ex[0] = createPlaybackException(playable, e);
- } catch (SWTError error) {
- ex[0] = createPlaybackException(playable, error);
- }
- }
- };
- // if (last)
- // shell.getDisplay().asyncExec(runnable);
- // else
- // display.syncExec(runnable);
- if (playable instanceof WaitCommand) {
- playable.playback(display, this.shell, monitor);
- } else
- display.syncExec(runnable);
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
-
- // for (;;) {
- // if (display.isDisposed() || !display.readAndDispatch())
- // break;
- // }
-
- if (ex[0] != null)
- throw ex[0];
- }
-
- public IIndexHandler getIndexHandler() {
- return indexHandler;
- }
-
- public void setIndexHandler(IIndexHandler indexHandler) {
- this.indexHandler = indexHandler;
- for (int i = 0; i < commands.size(); i++) {
- Object c = commands.get(i);
- if (c instanceof MacroCommandShell) {
- MacroCommandShell child = (MacroCommandShell) c;
- child.setIndexHandler(indexHandler);
- }
- }
- }
-
- private CoreException createPlaybackException(IPlayable playable, Throwable th) {
- IStatus status = new Status(IStatus.ERROR, "org.eclipse.pde.ui.tests", IStatus.OK, "Error while executing a macro command: " + playable.toString(), th);
- return new CoreException(status);
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroIndex.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroIndex.java
deleted file mode 100644
index e27970f..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroIndex.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-
-public class MacroIndex extends MacroInstruction {
-
- public MacroIndex() {
- super(null);
- }
-
- public MacroIndex(String id) {
- super(id);
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<index id=\"");
- writer.print(getId());
- writer.println("\"/>");
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroInstruction.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroInstruction.java
deleted file mode 100644
index 5cad7fa..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroInstruction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.w3c.dom.Node;
-
-public abstract class MacroInstruction implements IWritable, IPlayable {
- private int[] range;
- private String id;
-
- public MacroInstruction(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- protected void load(Node node, Hashtable lineTable) {
- this.id = MacroUtil.getAttribute(node, "id");
- bindSourceLocation(node, lineTable);
- }
-
- void bindSourceLocation(Node node, Map lineTable) {
- Integer[] lines = (Integer[]) lineTable.get(node);
- if (lines != null) {
- range = new int[2];
- range[0] = lines[0].intValue();
- range[1] = lines[1].intValue();
- }
- }
-
- public int getStartLine() {
- if (range == null)
- return -1;
- return range[0];
- }
-
- public int getStopLine() {
- if (range == null)
- return -1;
- return range[1];
- }
-
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- return false;
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroManager.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroManager.java
deleted file mode 100644
index 7f07a4b..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroManager.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Vector;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-public class MacroManager {
- public static final String IGNORE = "__macro_ignore__";
- public static final int IDLE = 0;
-
- public static final int RUNNING = 1;
-
- public static final int DONE = 2;
-
- private Macro currentMacro;
-
- private IIndexHandler indexHandler;
-
- class DisplayListener implements Listener {
- public void handleEvent(Event event) {
- onEvent(event);
- }
- }
-
- class JobListener extends JobChangeAdapter {
- private int state = IDLE;
-
- public void running(IJobChangeEvent event) {
- if (!event.getJob().isSystem() && state == IDLE)
- state = RUNNING;
- }
-
- public void done(IJobChangeEvent event) {
- if (!event.getJob().isSystem() && state == RUNNING)
- state = DONE;
- }
-
- public void reset() {
- state = IDLE;
- }
-
- public int getState() {
- return state;
- }
- }
-
- private DisplayListener listener;
-
- private JobListener jobListener;
-
- private Vector listeners;
-
- private ArrayList widgetResolvers;
- private SAXParser parser;
-
- public MacroManager() {
- listener = new DisplayListener();
- jobListener = new JobListener();
- listeners = new Vector();
- }
-
- public void addRecorderListener(IRecorderListener listener) {
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
-
- public void addIndex(String indexId) {
- if (currentMacro != null) {
- currentMacro.addIndex(indexId);
- }
- }
-
- public void removeRecorderListener(IRecorderListener listener) {
- if (listeners.contains(listener))
- listeners.remove(listener);
- }
-
- public boolean isRecording() {
- return currentMacro != null;
- }
-
- public void startRecording() {
- Display display = PlatformUI.getWorkbench().getDisplay();
- hookListeners(display);
- currentMacro = new Macro();
- currentMacro.initializeForRecording(display);
- IRecorderListener[] array = (IRecorderListener[]) listeners.toArray(new IRecorderListener[listeners.size()]);
- for (int i = 0; i < array.length; i++) {
- array[i].recordingStarted();
- }
- }
-
- public String[] getExistingIndices() {
- if (currentMacro != null) {
- return currentMacro.getExistingIndices();
- }
- return new String[0];
- }
-
- public Macro stopRecording() {
- Display display = PlatformUI.getWorkbench().getDisplay();
- unhookListeners(display);
- currentMacro.stopRecording();
- Macro newMacro = currentMacro;
- currentMacro = null;
- IRecorderListener[] array = (IRecorderListener[]) listeners.toArray(new IRecorderListener[listeners.size()]);
- for (int i = 0; i < array.length; i++) {
- array[i].recordingStopped();
- }
- return newMacro;
- }
-
- public void hookListeners(Display display) {
- display.addFilter(SWT.KeyDown, listener);
- display.addFilter(SWT.Selection, listener);
- display.addFilter(SWT.DefaultSelection, listener);
- display.addFilter(SWT.Expand, listener);
- display.addFilter(SWT.Collapse, listener);
- display.addFilter(SWT.Modify, listener);
- display.addFilter(SWT.Activate, listener);
- display.addFilter(SWT.Close, listener);
- display.addFilter(SWT.FocusIn, listener);
- IJobManager jobManager = Platform.getJobManager();
- jobManager.addJobChangeListener(jobListener);
- }
-
- public void unhookListeners(Display display) {
- display.removeFilter(SWT.KeyDown, listener);
- display.removeFilter(SWT.Selection, listener);
- display.removeFilter(SWT.DefaultSelection, listener);
- display.removeFilter(SWT.Expand, listener);
- display.removeFilter(SWT.Collapse, listener);
- display.removeFilter(SWT.Modify, listener);
- display.removeFilter(SWT.Activate, listener);
- display.removeFilter(SWT.Close, listener);
- display.removeFilter(SWT.FocusIn, listener);
- IJobManager jobManager = Platform.getJobManager();
- jobManager.removeJobChangeListener(jobListener);
- }
-
- public void shutdown() {
- if (currentMacro != null) {
- Display display = PlatformUI.getWorkbench().getDisplay();
- unhookListeners(display);
- currentMacro.stopRecording();
- currentMacro = null;
- }
- }
-
- /**
- * Plays a provided macro stream. The method will close the input stream
- * upon parsing.
- *
- * @param is
- * @throws CoreException
- */
- public boolean play(final Display display, IRunnableContext context, String scriptName, InputStream is) throws CoreException {
- XMLDefaultHandler handler = createMacroDocument(is);
- Node root = handler.getDocumentElement();
- NodeList children = root.getChildNodes();
-
- final Macro macro = new Macro(scriptName);
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeName().equals("shell")) {
- macro.addShell(child, handler.getLineTable());
- }
- }
- // discard the DOM
- handler = null;
-
- macro.setIndexHandler(getIndexHandler());
-
- final boolean[] result = new boolean[1];
-
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- //System.out.println("Start macro: "+macro.getName());
- result[0] = macro.playback(display, null, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (ClassCastException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- //System.out.println("Stop macro: "+macro.getName());
- }
- }
- };
- try {
- context.run(true, true, op);
- } catch (InterruptedException e) {
- } catch (InvocationTargetException e) {
- MacroPlugin.logException(e);
- return false;
- }
- return result[0];
- }
-
- private XMLDefaultHandler createMacroDocument(InputStream is) throws CoreException {
- XMLDefaultHandler handler = null;
- try {
- SAXParser parser = getParser();
- handler = new XMLDefaultHandler();
- parser.parse(is, handler);
- } catch (SAXException e) {
- MacroUtil.throwCoreException("Error parsing the macro file", 0, e);
- } catch (IOException e) {
- MacroUtil.throwCoreException("Error parsing the macro file", 0, e);
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- return handler;
- }
-
- private SAXParser getParser() throws CoreException {
- if (parser == null) {
- try {
- return SAXParserFactory.newInstance().newSAXParser();
- } catch (ParserConfigurationException e) {
- MacroUtil.throwCoreException("Error parsing the macro file", 0, e);
- } catch (SAXException e) {
- MacroUtil.throwCoreException("Error parsing the macro file", 0, e);
- }
- }
- return parser;
- }
-
- private void onEvent(Event event) {
- try {
- if (event.type == SWT.KeyDown) {
- if ((event.stateMask & SWT.SHIFT) != 0 && (event.stateMask & SWT.CTRL) != 0) {
- int key = event.keyCode & SWT.KEY_MASK;
- if (key == SWT.F11)
- notifyInterrupt(IRecorderListener.STOP);
- else if (key == SWT.F10)
- notifyInterrupt(IRecorderListener.INDEX);
- }
- return;
- }
- if ((event.type == SWT.Close || event.type == SWT.Activate) && !(event.widget instanceof Shell))
- return;
- if (jobListener.getState() == RUNNING || jobListener.getState() == DONE)
- currentMacro.addPause();
- jobListener.reset();
- boolean stop = currentMacro.addEvent(event);
- if (stop) {
- notifyInterrupt(IRecorderListener.STOP);
- }
- } catch (Exception e) {
- MacroPlugin.logException(e);
- stopRecording();
- }
- }
-
- private void notifyInterrupt(int type) {
- IRecorderListener[] array = (IRecorderListener[]) listeners.toArray(new IRecorderListener[listeners.size()]);
- for (int i = 0; i < array.length; i++) {
- array[i].recordingInterrupted(type);
- }
- }
-
- public String resolveWidget(Widget widget) {
- if (widgetResolvers == null)
- loadWidgetResolvers();
- for (int i = 0; i < widgetResolvers.size(); i++) {
- IWidgetResolver resolver = (IWidgetResolver) widgetResolvers.get(i);
- String id = resolver.getUniqueId(widget);
- if (id != null)
- return id;
- }
- return null;
- }
-
- private void loadWidgetResolvers() {
- widgetResolvers = new ArrayList();
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.pde.ui.tests.macroSupport");
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals("widgetResolver")) {
- try {
- Object obj = elements[i].createExecutableExtension("class");
- if (obj instanceof IWidgetResolver)
- widgetResolvers.add(obj);
- } catch (CoreException e) {
- System.out.println(e);
- }
- }
- }
- }
-
- public IIndexHandler getIndexHandler() {
- return indexHandler;
- }
-
- public void setIndexHandler(IIndexHandler indexHandler) {
- this.indexHandler = indexHandler;
- }
-
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroPlugin.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroPlugin.java
deleted file mode 100644
index 551ece7..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroPlugin.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class MacroPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static MacroPlugin plugin;
-
- private MacroManager recorder;
-
- private PackageAdmin packageAdmin;
-
- /**
- * The constructor.
- */
- public MacroPlugin() {
- super();
- plugin = this;
- recorder = new MacroManager();
- }
-
- public MacroManager getMacroManager() {
- return recorder;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- packageAdmin = (PackageAdmin) context.getService(context.getServiceReference(PackageAdmin.class.getName()));
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- recorder.shutdown();
- packageAdmin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- */
- public static MacroPlugin getDefault() {
- return plugin;
- }
-
- public static void logException(Throwable e) {
- logException(e, null, null);
- }
-
- public static void logException(Throwable e, final String title, String message) {
- if (e instanceof InvocationTargetException) {
- e = ((InvocationTargetException) e).getTargetException();
- }
- IStatus status = null;
- if (e instanceof CoreException)
- status = ((CoreException) e).getStatus();
- else {
- if (message == null)
- message = e.getMessage();
- if (message == null)
- message = e.toString();
- status = new Status(IStatus.ERROR, "org.eclipse.pde.ui.tests", IStatus.OK, message, e);
- }
- ResourcesPlugin.getPlugin().getLog().log(status);
- Display display = Display.getCurrent();
- if (display == null)
- display = Display.getDefault();
- final IStatus fstatus = status;
- display.asyncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(null, title, null, fstatus);
- }
- });
- }
-
- public static BundleContext getBundleContext() {
- return getDefault().getBundle().getBundleContext();
- }
-
- public PackageAdmin getPackageAdmin() {
- return packageAdmin;
- }
-
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroUtil.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroUtil.java
deleted file mode 100644
index 1e6ce8e..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/MacroUtil.java
+++ /dev/null
@@ -1,913 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.internal.WorkbenchPartReference;
-import org.eclipse.ui.keys.SWTKeySupport;
-import org.w3c.dom.Node;
-
-public class MacroUtil {
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /**
- * Returns the path where counters of the given event are stored, or null if
- * we are not keeping records of the given event.
- *
- * @param event
- * @return
- */
- public static WidgetIdentifier getWidgetIdentifier(Widget widget) {
- if (widget instanceof MenuItem) {
-
- MenuItem menuItem = (MenuItem) widget;
-
- if (onMenubar(menuItem)) {
- return new WidgetIdentifier(new Path("menus"), new Path(getActionId(menuItem))); //$NON-NLS-1$
- }
- Control c = widget.getDisplay().getFocusControl();
- WidgetIdentifier ci = getControlIdentifier(c);
- if (ci == null)
- return null;
- return new WidgetIdentifier(new Path("popup").append(ci.getFullyQualifiedPath()), new Path(getActionId(menuItem))); //$NON-NLS-1$
- } else if (widget instanceof ToolItem) {
- ToolItem toolItem = (ToolItem) widget;
-
- if (onToolbar(toolItem))
- return new WidgetIdentifier(new Path("toolbar"), new Path(getActionId(toolItem))); //$NON-NLS-1$
- // local toolbar somewhere - locate the parent
- // first
- ToolBar toolBar = toolItem.getParent();
- WidgetIdentifier controlId = getControlIdentifier(toolBar);
- IPath localPath = controlId.getFullyQualifiedPath();
- return new WidgetIdentifier(new Path("local-toolbar").append(localPath), new Path(getActionId(toolItem)));
- } else if (widget instanceof Shell) {
- return new WidgetIdentifier(new Path("shell"), getShellId((Shell) widget));
- } else if (widget instanceof Control) {
- return getControlIdentifier((Control) widget);
- } else if (widget instanceof Menu) {
- return new WidgetIdentifier(new Path("menu"), new Path(getActionId((Menu) widget)));
- }
- return null;
- }
-
- public static IPath getShellId(Shell shell) {
- Object data = shell.getData();
- String id = "";
- if (data instanceof WizardDialog) {
- id = data.getClass().getName().toString();
- } else if (data instanceof Window) {
- id = data.getClass().getName().toString();
- }
- return new Path(id);
- }
-
- public static WidgetIdentifier getControlIdentifier(Control control) {
- Shell shell = control.getShell();
- Object data = shell.getData();
- if (data instanceof WizardDialog) {
- // in wizard
- WizardDialog wd = (WizardDialog) data;
- IWizardPage page = wd.getCurrentPage();
- if (page == null)
- return null;
- Control pageControl = page.getControl();
- String relativePath = computeRelativePath((Composite) pageControl, null, control);
- if (relativePath != null) {
- IPath path = new Path("wizard-page").append(page.getName());
- return new WidgetIdentifier(path, new Path(relativePath));
- }
- // check for wizard buttons
- if (control instanceof Button) {
- relativePath = computeRelativePath(shell, (Composite) pageControl, control);
- return new WidgetIdentifier(new Path("wizard"), new Path(relativePath));
- }
- return null;
- } else if (data instanceof IWorkbenchWindow) {
- IWorkbenchWindow window = (IWorkbenchWindow) data;
- IWorkbenchPage page = window.getActivePage();
- IWorkbenchPart part = page.getActivePart();
- IWorkbenchPartSite site = part.getSite();
- IPath path;
- if (part instanceof IViewPart)
- path = new Path("view").append(site.getId());
- else if (part instanceof IEditorPart) {
- String inputName = ((IEditorPart) part).getEditorInput().getName();
- path = new Path("editor").append(site.getId()).append(inputName);
- } else
- return null;
- Composite paneComposite = (Composite) getPartControl(part);
- // If the control we are looking for is a local tool bar,
- // go up one level
- if (part instanceof IViewPart && control instanceof ToolBar)
- paneComposite = paneComposite.getParent();
- String relativePath = computeRelativePath(paneComposite, null, control);
- if (relativePath != null) {
- return new WidgetIdentifier(path, new Path(relativePath));
- }
- } else {
- // unknown shell - fetch controls starting from the shell
- String relativePath = computeRelativePath(shell, null, control);
- return new WidgetIdentifier(new Path("shell"), new Path(relativePath));
- }
- return null;
- }
-
- private static String computeRelativePath(Composite parent, Composite skip, Control control) {
- int[] counter = new int[1];
- counter[0] = 0;
- boolean result = computeControlToken(parent, skip, control, counter);
- if (!result && skip == null)
- return null;
- int index = result ? counter[0] : 0;
- return getControlId(control, index);
- }
-
- private static String getControlId(Control control, int index) {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- String controlId = recorder.resolveWidget(control);
- if (controlId == null)
- controlId = index + "";
- return control.getClass().getName() + "#" + controlId;
- }
-
- private static boolean computeControlToken(Composite parent, Composite skip, Control control, int[] counter) {
- Control[] children = parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
-
- if (!child.isVisible())
- continue;
-
- if (child.getClass().equals(control.getClass())) {
- // same type - increment counter
- counter[0]++;
- if (control.equals(child)) {
- // bingo
- return true;
- }
- } else if (child instanceof Composite) {
- if (skip != null && child.equals(skip))
- continue;
- boolean status = computeControlToken((Composite) child, skip, control, counter);
- if (status)
- return true;
- }
- }
- return false;
- }
-
- public static boolean isInputControl(Control control) {
- return true;
- }
-
- /**
- * @param menuItem
- * @return
- */
- private static boolean onMenubar(MenuItem menuItem) {
- Menu parent = menuItem.getParent();
- MenuItem parentItem = parent.getParentItem();
-
- if (parentItem != null) {
- return onMenubar(parentItem);
- }
-
- Shell theShell = parent.getShell();
-
- return parent == theShell.getMenuBar();
- }
-
- private static boolean onToolbar(ToolItem toolItem) {
- ToolBar toolBar = toolItem.getParent();
- Shell shell = toolBar.getShell();
- Object data = shell.getData();
- if (data instanceof ApplicationWindow) {
- ApplicationWindow window = (ApplicationWindow) data;
- ToolBarManager mng = window.getToolBarManager();
- if (mng != null) {
- if (mng.getControl() != null && mng.getControl() == toolBar)
- return true;
- }
- CoolBarManager cmng = window.getCoolBarManager();
- if (cmng != null) {
- CoolBar cbar = cmng.getControl();
- Composite parent = toolBar.getParent();
- while (parent != null) {
- if (parent == cbar)
- return true;
- parent = parent.getParent();
- }
- }
- }
- return false;
- }
-
- /**
- * @param toolItem
- * @return
- */
- private static String getActionId(ToolItem toolItem) {
- Object data = toolItem.getData();
- if (data != null && (data instanceof IContributionItem)) {
- String result = getActionId((IContributionItem) data);
- if (!result.equals(EMPTY_STRING)) {
- return result;
- }
- }
-
- return "readablename/" + getDisplayName(toolItem); //$NON-NLS-1$
- }
-
- /**
- * @param toolItem
- * @return
- */
- private static String getDisplayName(ToolItem toolItem) {
- String name = toolItem.getText();
-
- if (name != null && !name.equals(EMPTY_STRING)) {
- return name;
- }
-
- name = toolItem.getToolTipText();
-
- if (name != null) {
- return name;
- }
-
- return "unknown"; //$NON-NLS-1$
- }
-
- /**
- * Returns an identifier for the given MenuItem, based on its user-readable
- * strings
- *
- * @param menuItem
- * @return
- */
- private static String getDisplayName(MenuItem menuItem) {
-
- if (menuItem.getParent() == null || menuItem.getParent().getParentItem() == null) {
- return removeChar(menuItem.getText(), '&');
- }
-
- return getDisplayName(menuItem.getParent()) + "/" //$NON-NLS-1$
- + removeChar(menuItem.getText(), '&');
- }
-
- /**
- * Returns an identifier for the given Menu, based on its user-readable
- * strings
- *
- * @param menu
- * @return
- */
- private static String getDisplayName(Menu menu) {
-
- MenuItem parentItem = menu.getParentItem();
-
- if (parentItem == null) {
- return EMPTY_STRING;
- }
-
- return getDisplayName(parentItem);
- }
-
- protected String getContribId(MenuItem menuItem) {
- Object data = menuItem.getData();
- if (data != null && (data instanceof IContributionItem)) {
- String result = ((IContributionItem) data).getId();
-
- if (result != null) {
- return result;
- }
- }
-
- return EMPTY_STRING;
- }
-
- /**
- * @param menuItem
- * @return
- */
- private static String getActionId(MenuItem menuItem) {
- Object data = menuItem.getData();
- if (data != null && (data instanceof IContributionItem)) {
- String result = getActionId((IContributionItem) data);
- if (!result.equals(EMPTY_STRING)) {
- return result;
- }
- }
-
- // return EMPTY_STRING;
-
- return "readablename/" + getDisplayName(menuItem); //$NON-NLS-1$
- }
-
- private static String getActionId(Menu menu) {
- Object data = menu.getData();
- if (data != null && (data instanceof IContributionItem)) {
- String result = getActionId((IContributionItem) data);
- if (!result.equals(EMPTY_STRING)) {
- return result;
- }
- }
-
- // return EMPTY_STRING;
-
- return "readablename/" + getDisplayName(menu); //$NON-NLS-1$
- }
-
- private static String getActionId(IContributionItem contrib) {
- String id = null;
-
- if (contrib instanceof IPluginContribution) {
- id = ((IPluginContribution) contrib).getLocalId();
- }
- if (id == null)
- id = contrib.getId();
-
- if (id != null) {
- return "contribid/" + id; //$NON-NLS-1$
- }
-
- if (contrib instanceof ActionContributionItem) {
- ActionContributionItem actionItem = (ActionContributionItem) contrib;
-
- id = actionItem.getId();
-
- if (id != null) {
- return "actionid/" + id; //$NON-NLS-1$
- }
-
- IAction action = actionItem.getAction();
-
- id = action.getActionDefinitionId();
-
- if (id != null) {
- return "defid/" + id; //$NON-NLS-1$
- }
-
- return "actionclass/" + action.getClass().getName(); //$NON-NLS-1$
- }
- return "contribclass/" + contrib.getClass().getName(); //$NON-NLS-1$
- }
-
- public Object getDefaultValue(IPath node) {
- return null;
- }
-
- private MenuItem getMenuItem(Menu menu, IPath menuPath) {
- if (menuPath.isEmpty()) {
- return null;
- }
-
- String toFind = menuPath.segment(0);
- MenuItem[] items = menu.getItems();
-
- for (int idx = 0; idx < items.length; idx++) {
- MenuItem item = items[idx];
-
- String itemName = removeChar(item.getText(), '&');
-
- if (itemName.equals(toFind)) {
- return getMenuItem(item, menuPath.removeFirstSegments(1));
- }
- }
-
- return null;
- }
-
- private MenuItem getMenuItem(MenuItem menu, IPath menuPath) {
- if (menuPath.isEmpty()) {
- return menu;
- }
-
- Menu subMenu = menu.getMenu();
- if (subMenu == null) {
- return null;
- }
-
- return getMenuItem(subMenu, menuPath);
-
- }
-
- public static String removeChar(String input, char toRemove) {
- StringBuffer buf = new StringBuffer(input.length());
-
- int last = 0;
- for (int pos = input.indexOf(toRemove); pos != -1; pos = input.indexOf(toRemove, last)) {
- buf.append(input.substring(last, pos));
- last = pos + 1;
- }
-
- buf.append(input.substring(last, input.length()));
-
- return buf.toString();
- }
-
- public static String getAttribute(Node node, String name) {
- Node value = node.getAttributes().getNamedItem(name);
- if (value != null)
- return value.getNodeValue();
- return null;
- }
-
- public static String getNormalizedText(String source) {
- if (source == null)
- return "";
- //String result = source.replace('\t', ' ');
- String result = source;
- result = result.trim();
- return result;
- }
-
- public static String getWritableText(String input) {
- String result = input.trim();
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < result.length(); i++) {
- char c = result.charAt(i);
- switch (c) {
- case '<' :
- buf.append("&lt;"); //$NON-NLS-1$
- break;
- case '>' :
- buf.append("&gt;"); //$NON-NLS-1$
- break;
- case '&' :
- buf.append("&amp;"); //$NON-NLS-1$
- break;
- case '\'' :
- buf.append("&apos;"); //$NON-NLS-1$
- break;
- case '\"' :
- buf.append("&quot;"); //$NON-NLS-1$
- break;
- default :
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
- public static CommandTarget locateCommandTarget(Composite parent, WidgetIdentifier wid, int line) throws CoreException {
- return locateCommandTarget(parent, wid, null, line);
- }
-
- public static CommandTarget locateCommandTarget(Composite parent, WidgetIdentifier wid, ArrayList parents, int line) throws CoreException {
- Shell shell = (Shell) parent;
-
- String firstToken = wid.contextPath.segment(0);
- IPath wpath = wid.widgetPath;
- Iterator iter = parents != null ? parents.iterator() : null;
- if (firstToken.equals("menus"))
- return locateMenuBarItem(shell, wpath, iter, line);
- if (firstToken.equals("popup"))
- return locatePopupMenuItem(shell, wid, iter, line);
- if (firstToken.equals("toolbar"))
- return locateToolItem(shell, wpath, line);
- if (firstToken.equals("local-toolbar"))
- return locateLocalToolItem(shell, wid, line);
- if (firstToken.equals("wizard"))
- return locateWizardControl(shell, wpath, line);
- if (firstToken.equals("shell"))
- return locateShellControl(shell, wpath, line);
-
- String id = wid.contextPath.segment(1);
- if (firstToken.equals("wizard-page"))
- return locateWizardPageControl(shell, id, wpath, line);
- if (firstToken.equals("view"))
- return locateViewControl(shell, id, wpath, line);
- if (firstToken.equals("editor")) {
- String inputName = wid.contextPath.segment(2);
- return locateEditorControl(shell, id, inputName, wpath, line);
- }
- return null;
- }
-
- private static CommandTarget locateMenuBarItem(Shell shell, IPath path, Iterator parents, int line) throws CoreException {
- MenuItem item = null;
- Object data = shell.getData();
- Menu menuBar = shell.getMenuBar();
-
- if (data instanceof ApplicationWindow && parents != null) {
- ApplicationWindow window = (ApplicationWindow) data;
- MenuManager manager = window.getMenuBarManager();
- item = locateMenuItem(manager, path.toString(), parents, line);
- } else {
- item = locateMenuItem(menuBar, path.toString(), line);
- }
- if (item != null)
- return new CommandTarget(item, menuBar);
- throwCoreException("Cannot locate menu item: " + path.toString(), line);
- return null;
- }
-
- private static MenuItem locateMenuItem(Menu menu, String id, int line) {
- MenuItem[] items = menu.getItems();
-
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items[i];
-
- Menu submenu = item.getMenu();
- if (submenu != null) {
- MenuItem hit = locateMenuItem(submenu, id, line);
- if (hit != null)
- return hit;
- } else {
- String itemId = getActionId(item);
- if (itemId != null && id.equals(itemId))
- return item;
- }
- }
- return null;
- }
-
- private static MenuItem locateMenuItem(MenuManager mng, String id, Iterator parents, int line) {
- IContributionItem[] items = mng.getItems();
-
- String parentId = null;
- if (parents.hasNext())
- parentId = (String) parents.next();
-
- for (int i = 0; i < items.length; i++) {
- IContributionItem citem = items[i];
-
- if (citem instanceof MenuManager) {
- MenuManager submenu = (MenuManager) citem;
- String subId = submenu.getId();
-
- if (subId.equals(parentId)) {
- // show this menu to force dynamic items
- // to show
- Menu menu = submenu.getMenu();
- forceMenuOpen(null, menu);
-
- MenuItem hit = locateMenuItem(submenu, id, parents, line);
- forceMenuClosed(menu);
- if (hit != null)
- return hit;
- }
- } else {
- String itemId = getActionId(citem);
- if (itemId != null && id.equals(itemId)) {
- MenuItem hit = locateMenuItem(mng.getMenu(), id, line);
- if (hit != null)
- return hit;
- }
- }
- }
- return null;
- }
-
- private static void forceMenuOpen(Control c, Menu menu) {
- Event e = new Event();
- e.type = SWT.Show;
- e.widget = menu;
- /*
- if (c!=null) {
- Point midpoint = c.getSize();
- midpoint.x /= 2;
- midpoint.y /= 2;
- midpoint = c.toDisplay(midpoint);
- menu.setLocation(midpoint);
- }
- */
- //menu.setVisible(true);
- menu.notifyListeners(e.type, e);
- processDisplayEvents(menu.getDisplay());
- }
-
- private static void forceMenuClosed(Menu menu) {
- Event e = new Event();
- e.type = SWT.Hide;
- //menu.setVisible(false);
- e.widget = menu;
- menu.notifyListeners(e.type, e);
- processDisplayEvents(menu.getDisplay());
- }
-
- public static void processDisplayEvents(Display display) {
- for (;;) {
- if (!display.readAndDispatch())
- break;
- }
- }
-
- private static CommandTarget locatePopupMenuItem(Shell shell, WidgetIdentifier wid, Iterator parents, int line) throws CoreException {
- IPath contextPath = wid.contextPath.removeFirstSegments(1);
- IPath wpath = new Path(contextPath.lastSegment());
- contextPath = contextPath.removeLastSegments(1);
- CommandTarget target = locateCommandTarget(shell, new WidgetIdentifier(contextPath, wpath), line);
- if (target != null) {
- Control control = (Control) target.getWidget();
- Menu popupMenu = control.getMenu();
- if (popupMenu != null) {
- forceMenuOpen(control, popupMenu);
- MenuItem menuItem = locateMenuItem(popupMenu, wid.getWidgetId(), line);
- forceMenuClosed(popupMenu);
- if (menuItem != null) {
- return new CommandTarget(menuItem, control);
- }
- }
- }
- throwCoreException("Cannot locate pop-up menu item: " + wid.getWidgetId(), line);
- return null;
- }
-
- private static CommandTarget locateToolItem(Shell shell, IPath path, int line) throws CoreException {
- Object data = shell.getData();
- CommandTarget target = null;
- if (data instanceof ApplicationWindow) {
- ApplicationWindow window = (ApplicationWindow) data;
- CoolBarManager coolMng = window.getCoolBarManager();
- if (coolMng != null) {
- target = locateToolItem(coolMng, path.toString(), line);
- }
- ToolBarManager toolMng = window.getToolBarManager();
- if (toolMng != null) {
- target = locateToolItem(toolMng, path.toString(), line);
- }
- }
- if (target == null)
- throwCoreException("Cannot locate pop-up menu item: " + path.toString(), line);
- return target;
- }
-
- private static CommandTarget locateToolItem(ICoolBarManager coolMng, String id, int line) {
- IContributionItem[] items = coolMng.getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof ToolBarContributionItem) {
- ToolBarContributionItem item = (ToolBarContributionItem) items[i];
- IToolBarManager toolMng = item.getToolBarManager();
- CommandTarget target = locateToolItem((ToolBarManager) toolMng, id, line);
- if (target != null)
- return target;
- }
- }
- return null;
- }
-
- private static CommandTarget locateToolItem(ToolBarManager toolMng, String id, int line) {
- return locateToolItem(toolMng.getControl(), id, line);
- }
-
- private static CommandTarget locateToolItem(ToolBar toolBar, String id, int line) {
- ToolItem[] items = toolBar.getItems();
- for (int i = 0; i < items.length; i++) {
- ToolItem item = items[i];
- String itemId = getActionId(item);
- if (itemId != null && itemId.equals(id))
- return new CommandTarget(item, toolBar);
- }
- return null;
- }
-
- private static CommandTarget locateLocalToolItem(Shell shell, WidgetIdentifier wid, int line) throws CoreException {
- IPath wpath = wid.contextPath.removeFirstSegments(1);
- String firstToken = wpath.segment(0);
-
- if (firstToken.equals("view")) {
- String id = wpath.segment(1);
- IViewPart view = locateView(shell, id, line);
- if (view != null) {
- Control control = getPartControl(view);
- processDisplayEvents(shell.getDisplay());
- Composite parent = control.getParent();
- Control c = locateVisibleChild(parent, null, wpath.removeFirstSegments(2));
- if (c != null) {
- //TODO bad cast
- ToolBarManager mng = (ToolBarManager) view.getViewSite().getActionBars().getToolBarManager();
- CommandTarget target = locateToolItem(mng, wid.getWidgetId(), line);
- if (target != null)
- return target;
- }
- }
- }
- throwCoreException("Cannot locate local tool bar item: " + wid.getFullyQualifiedId().toString(), line);
- return null;
- }
-
- private static WizardCommandTarget locateWizardControl(Shell shell, IPath wpath, int line) throws CoreException {
- WizardDialog wdialog = (WizardDialog) shell.getData();
- IWizardPage page = wdialog.getCurrentPage();
- Composite pparent = (Composite) page.getControl();
- Control control = locateVisibleChild(shell, pparent, wpath);
- if (control == null)
- throwCoreException("Cannot locate wizard control: " + wpath.toString(), line);
- if (control.isDisposed())
- throwCoreException("Wizard control is disposed: " + wpath.toString(), line);
- return new WizardCommandTarget(control, wdialog);
- }
-
- private static WindowCommandTarget locateShellControl(Shell shell, IPath wpath, int line) throws CoreException {
- Window window = (Window) shell.getData();
- Control control = locateVisibleChild(shell, null, wpath);
- if (control == null)
- throwCoreException("Cannot locate shell control: " + wpath.toString(), line);
- if (control.isDisposed())
- throwCoreException("Shell control is disposed: " + wpath.toString(), line);
- return new WindowCommandTarget(control, window);
- }
-
- private static WizardCommandTarget locateWizardPageControl(Shell shell, String id, IPath wpath, int line) throws CoreException {
- Control control = null;
- Object data = shell.getData();
- if (data instanceof WizardDialog) {
- WizardDialog wdialog = (WizardDialog) data;
- IWizardPage page = wdialog.getCurrentPage();
- String pname = page.getName();
- // assert page
- if (pname.equals(id) == false)
- throwCoreException("Unexpected wizard page: " + pname + ", expected " + id, line);
- Composite pparent = (Composite) page.getControl();
- control = locateVisibleChild(pparent, null, wpath);
- if (control != null)
- return new WizardCommandTarget(control, wdialog);
- }
- if (control == null)
- throwCoreException("Cannot locate wizard page control: " + wpath.toString(), line);
- return null;
- }
-
- private static IViewPart locateView(Shell shell, String id, int line) throws CoreException {
- Object data = shell.getData();
-
- if (data instanceof IWorkbenchWindow) {
- IWorkbenchWindow window = (IWorkbenchWindow) data;
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IViewPart view = page.showView(id);
- return view;
- }
- }
- throwCoreException("Cannot locate view: " + id, line);
- return null;
- }
-
- /**
- * Retrieves the primary SWT control of the given workbench part.
- * <p>
- * <b>Note:</b> This method uses workbench internals that are not part of
- * the public Eclipse API. Changing the code contained within this method
- * may cause breakage across Eclipse 3.x and Eclipse 4.x.
- * </p>
- */
- private static Control getPartControl(IWorkbenchPart part) {
- IWorkbenchPartSite site = part.getSite();
- return ((WorkbenchPartReference) site.getPage().getReference(part)).getPane().getControl();
- }
-
- private static ViewCommandTarget locateViewControl(Shell shell, String id, IPath wpath, int line) throws CoreException {
- Control control = null;
-
- IViewPart view = locateView(shell, id, line);
- if (view != null) {
- Control c = getPartControl(view);
- control = locateVisibleChild((Composite) c, null, wpath);
- if (control != null) {
- return new ViewCommandTarget(control, view);
- }
- }
- throwCoreException("Cannot locate view control: " + wpath.toString(), line);
- return null;
- }
-
- private static EditorCommandTarget locateEditorControl(Shell shell, String id, String inputName, IPath wpath, int line) throws CoreException {
- Control control = null;
-
- Object data = shell.getData();
-
- if (data instanceof IWorkbenchWindow) {
- IWorkbenchWindow window = (IWorkbenchWindow) data;
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorReference[] erefs = page.getEditorReferences();
- IEditorPart editor = null;
- for (int i = 0; i < erefs.length; i++) {
- IEditorReference eref = erefs[i];
- if (eref.getId().equals(id)) {
- // check the input
- IEditorPart part = eref.getEditor(true);
- if (part.getEditorInput().getName().equals(inputName)) {
- editor = part;
- break;
- }
- }
- }
- if (editor != null) {
- Control c = getPartControl(editor);
- control = locateVisibleChild((Composite) c, null, wpath);
- if (control != null) {
- return new EditorCommandTarget(control, editor);
- }
- }
- }
- }
- if (control == null)
- throwCoreException("Cannot locate editor control: " + wpath.toString(), line);
- return null;
- }
-
- private static Control locateVisibleChild(Composite parent, Composite skip, IPath wpath) {
- int[] counter = new int[1];
- counter[0] = 0;
- String wid = wpath.toString();
- int sloc = wid.lastIndexOf('#');
- if (sloc == -1)
- return null;
- String wclassName = wid.substring(0, sloc);
- return locateVisibleChild(parent, skip, wid, wclassName, counter);
- }
-
- private static Control locateVisibleChild(Composite parent, Composite skip, String id, String wclassName, int[] counter) {
- Control[] children = parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
-
- if (child.getClass().getName().equals(wclassName)) {
- // same type - increment counter
- if (child.isVisible() == false)
- continue;
- counter[0]++;
- String cid = getControlId(child, counter[0]);
- if (cid.equals(id)) {
- // bingo
- return child;
- }
- } else if (child instanceof Composite) {
- if (skip != null && child.equals(skip))
- continue;
- if (!child.isVisible())
- continue;
- Control c = locateVisibleChild((Composite) child, skip, id, wclassName, counter);
- if (c != null)
- return c;
- }
- }
- return null;
- }
-
- public static void throwCoreException(String message, int line) throws CoreException {
- throwCoreException(message, line, null);
- }
-
- public static void throwCoreException(String message, int line, Throwable t) throws CoreException {
- if (line > 0)
- message = "Line " + line + ": " + message;
- Status s = new Status(IStatus.ERROR, "org.eclipse.ui.macro", IStatus.OK, message, t);
- throw new CoreException(s);
- }
-
- public static java.util.List generatePossibleKeyStrokes(Event event) {
- final java.util.List keyStrokes = new ArrayList(3);
-
- /*
- * If this is not a keyboard event, then there are no key strokes. This
- * can happen if we are listening to focus traversal events.
- */
- if ((event.stateMask == 0) && (event.keyCode == 0) && (event.character == 0)) {
- return keyStrokes;
- }
-
- // Add each unique key stroke to the list for consideration.
- final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
- keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator));
-
- // We shouldn't allow delete to undergo shift resolution.
- if (event.character == SWT.DEL) {
- return keyStrokes;
- }
-
- final int secondAccelerator = SWTKeySupport.convertEventToUnshiftedModifiedAccelerator(event);
- if (secondAccelerator != firstAccelerator) {
- keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator));
- }
-
- final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event);
- if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) {
- keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator));
- }
-
- return keyStrokes;
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ModifyCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ModifyCommand.java
deleted file mode 100644
index 0be3f4d..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ModifyCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ModifyCommand extends MacroCommand {
- public static final String TYPE = "modify";
-
- private String text;
-
- public ModifyCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public String getType() {
- return TYPE;
- }
-
- public boolean mergeEvent(Event e) {
- return doProcessEvent(e);
- }
-
- public void processEvent(Event e) {
- doProcessEvent(e);
- }
-
- protected void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
-
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.TEXT_NODE) {
- text = MacroUtil.getNormalizedText(child.getNodeValue());
- break;
- }
- }
- }
-
- private boolean doProcessEvent(Event e) {
- String text = extractText(e.widget);
- if (text != null) {
- this.text = text;
- return true;
- }
- return false;
- }
-
- private String extractText(Widget widget) {
- if (widget instanceof Text)
- return ((Text) widget).getText();
- if (widget instanceof Combo)
- return ((Combo) widget).getText();
- if (widget instanceof CCombo)
- return ((CCombo) widget).getText();
- if (widget instanceof StyledText)
- return MacroUtil.getWritableText(((StyledText) widget).getText());
- return null;
- }
-
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\" contextId=\"");
- writer.print(getWidgetId().getContextId());
- writer.print("\" widgetId=\"");
- writer.print(getWidgetId().getWidgetId());
- writer.println("\">");
- if (text != null) {
- writer.print(indent);
- writer.print(text);
- writer.println();
- }
- writer.print(indent);
- writer.println("</command>");
- }
-
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- if (parent.isDisposed())
- return false;
- CommandTarget target = MacroUtil.locateCommandTarget(parent, getWidgetId(), getStartLine());
- if (target != null) {
- target.setFocus();
- Widget widget = target.getWidget();
- if (widget instanceof Text)
- ((Text) widget).setText(text);
- else if (widget instanceof Combo)
- ((Combo) widget).setText(text);
- else if (widget instanceof CCombo)
- ((CCombo) widget).setText(text);
- else if (widget instanceof StyledText)
- ((StyledText) widget).setText(text);
- }
- return true;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/StructuredSelectionCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/StructuredSelectionCommand.java
deleted file mode 100644
index 2aa967c..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/StructuredSelectionCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-public class StructuredSelectionCommand extends AbstractStructuredCommand {
- private String type;
- public static final String DEFAULT_SELECT = "default-select";
- public static final String ITEM_SELECT = "item-select";
-
- public StructuredSelectionCommand(WidgetIdentifier wid, String type) {
- super(wid);
- items = new ArrayList();
- this.type = type;
- }
-
- public boolean mergeEvent(Event e) {
- if (e.type == SWT.DefaultSelection) {
- this.type = DEFAULT_SELECT;
- }
- return super.mergeEvent(e);
- }
-
- public String getType() {
- return type;
- }
-
- protected Widget[] getItemsForEvent(Event event) {
- if (event.widget instanceof Tree) {
- return ((Tree) event.widget).getSelection();
- } else if (event.widget instanceof Table) {
- return ((Table) event.widget).getSelection();
- } else if (event.widget instanceof TableTree) {
- return ((TableTree) event.widget).getSelection();
- }
- return super.getItemsForEvent(event);
- }
-
- protected void playTreeCommand(Tree tree, TreeItem[] matches) {
- tree.setSelection(matches);
- fireEvent(tree, matches);
- }
-
- private void fireEvent(Widget widget, Widget[] items) {
- Event e = new Event();
- e.widget = widget;
- e.type = type.equals(ITEM_SELECT) ? SWT.Selection : SWT.DefaultSelection;
- e.item = items.length > 0 ? items[0] : null;
- widget.notifyListeners(e.type, e);
- }
-
- protected void playTableCommand(Table table, TableItem[] matches) {
- table.setSelection(matches);
- fireEvent(table, matches);
- }
-
- protected void playTableTreeCommand(TableTree tableTree, TableTreeItem[] matches) {
- tableTree.setSelection(matches);
- fireEvent(tableTree, matches);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ToggleStructuredCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ToggleStructuredCommand.java
deleted file mode 100644
index c0a7f50..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ToggleStructuredCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-import java.util.Hashtable;
-
-import org.eclipse.swt.widgets.Event;
-import org.w3c.dom.Node;
-
-public abstract class ToggleStructuredCommand extends AbstractStructuredCommand {
- protected boolean value;
-
- /**
- * @param wid
- */
- public ToggleStructuredCommand(WidgetIdentifier wid) {
- super(wid);
- }
-
- public boolean mergeEvent(Event e) {
- return false;
- }
-
- protected void load(Node node, Hashtable lineTable) {
- super.load(node, lineTable);
- String att = MacroUtil.getAttribute(node, "value");
- this.value = att != null && att.equals("true");
- }
-
- protected void writeAdditionalAttributes(PrintWriter writer) {
- writer.print(" value=\"");
- writer.print(value ? "true" : "false");
- writer.print("\"");
- }
-
- public boolean getValue() {
- return value;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ViewCommandTarget.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ViewCommandTarget.java
deleted file mode 100644
index c2d8290..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/ViewCommandTarget.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-
-public class ViewCommandTarget extends CommandTarget {
- public ViewCommandTarget(Widget widget, IViewPart view) {
- super(widget, view);
- }
-
- public IViewPart getView() {
- return (IViewPart) getContext();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.CommandTarget#ensureVisible()
- */
- public void ensureVisible() {
- IViewPart view = getView();
- IWorkbenchPage page = view.getViewSite().getPage();
- page.activate(view);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WaitCommand.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WaitCommand.java
deleted file mode 100644
index 5966c2f..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WaitCommand.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.PrintWriter;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-
-public class WaitCommand extends MacroCommand {
- public static final String TYPE = "wait";
- private static final WidgetIdentifier nullIdentifier = new WidgetIdentifier(new Path(""), new Path(""));
-
- private static class JobListener extends JobChangeAdapter {
- private int counter = 0;
- private IProgressMonitor monitor;
- private Thread t;
-
- public JobListener(IProgressMonitor monitor, Thread t, int number) {
- this.counter = number;
- this.monitor = monitor;
- this.t = t;
- }
-
- private synchronized void change(int increment) {
- this.counter += increment;
- if (counter == 0) {
- monitor.subTask("");
- synchronized (t) {
- t.interrupt();
- }
- }
- }
-
- public void running(IJobChangeEvent event) {
- Job job = event.getJob();
- if (!job.isSystem())
- change(1);
- }
-
- public void done(IJobChangeEvent event) {
- Job job = event.getJob();
- if (!job.isSystem())
- change(-1);
- }
- }
-
- public WaitCommand() {
- super(nullIdentifier);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.macro.MacroCommand#getType()
- */
- public String getType() {
- return TYPE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.macro.MacroCommand#processEvent(org.eclipse.swt.widgets.Event)
- */
- public void processEvent(Event e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.macro.IWritable#write(java.lang.String,
- * java.io.PrintWriter)
- */
- public void write(String indent, PrintWriter writer) {
- writer.print(indent);
- writer.print("<command type=\"");
- writer.print(getType());
- writer.print("\"");
- writer.println("/>");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.macro.IPlayable#playback(org.eclipse.swt.widgets.Composite)
- */
- public boolean playback(Display display, Composite parent, IProgressMonitor monitor) throws CoreException {
- if (parent.isDisposed())
- return false;
- IJobManager jobManager = Platform.getJobManager();
- int nrunning = getNumberOfRunningJobs(jobManager);
- if (nrunning == 0)
- return true;
- String message = "Waiting for the background jobs...";
- JobListener listener = new JobListener(monitor, Thread.currentThread(), nrunning);
- jobManager.addJobChangeListener(listener);
- monitor.subTask(message);
- try {
- Thread.sleep(30000);
- } catch (InterruptedException e) {
- }
- jobManager.removeJobChangeListener(listener);
- return true;
- }
-
- private int getNumberOfRunningJobs(IJobManager manager) {
- int count = 0;
- Job[] jobs = manager.find(null);
- for (int i = 0; i < jobs.length; i++) {
- if (!jobs[i].isSystem() && jobs[i].getState() == Job.RUNNING)
- count++;
- }
- return count;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WidgetIdentifier.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WidgetIdentifier.java
deleted file mode 100644
index 26fb0dc..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WidgetIdentifier.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.core.runtime.IPath;
-
-public class WidgetIdentifier {
- public IPath contextPath;
- public IPath widgetPath;
-
- public WidgetIdentifier(IPath contextPath, IPath widgetPath) {
- this.contextPath = contextPath;
- this.widgetPath = widgetPath;
- }
-
- public String getContextId() {
- return contextPath.toString();
- }
-
- public String getWidgetId() {
- return widgetPath.toString();
- }
-
- public IPath getFullyQualifiedPath() {
- return contextPath.append(widgetPath);
- }
-
- public String getFullyQualifiedId() {
- return getFullyQualifiedPath().toString();
- }
-
- public boolean equals(Object obj) {
- if (obj == null)
- return false;
- if (obj == this)
- return true;
- if (obj instanceof WidgetIdentifier) {
- WidgetIdentifier wid = (WidgetIdentifier) obj;
- return wid.contextPath.equals(contextPath) && wid.widgetPath.equals(widgetPath);
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WindowCommandTarget.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WindowCommandTarget.java
deleted file mode 100644
index 2e02d28..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WindowCommandTarget.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Widget;
-
-public class WindowCommandTarget extends CommandTarget {
- /**
- * @param widget
- * @param context
- */
- public WindowCommandTarget(Widget widget, Window window) {
- super(widget, window);
- }
-
- Window getWindow() {
- return (Window) getContext();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.macro.CommandTarget#ensureVisible()
- */
- public void ensureVisible() {
- Window window = getWindow();
- window.getShell().setActive();
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WizardCommandTarget.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WizardCommandTarget.java
deleted file mode 100644
index 7e64286..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/WizardCommandTarget.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Widget;
-
-public class WizardCommandTarget extends WindowCommandTarget {
- /**
- * @param widget
- * @param window
- */
- public WizardCommandTarget(Widget widget, Window window) {
- super(widget, window);
- }
-
- public WizardDialog getWizardDialog() {
- return (WizardDialog) getWindow();
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/XMLDefaultHandler.java b/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/XMLDefaultHandler.java
deleted file mode 100644
index 7203a93..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro Manager/org/eclipse/pde/internal/ui/tests/macro/XMLDefaultHandler.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.util.Hashtable;
-import java.util.Stack;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class XMLDefaultHandler extends DefaultHandler {
-
- private org.w3c.dom.Document fDocument;
-
- private Locator fLocator;
-
- private Hashtable fLineTable;
-
- private Element fRootElement;
-
- private Stack fElementStack = new Stack();
-
- public XMLDefaultHandler() {
- fLineTable = new Hashtable();
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- Element element = fDocument.createElement(qName);
- for (int i = 0; i < attributes.getLength(); i++) {
- element.setAttribute(attributes.getQName(i), attributes.getValue(i));
- }
-
- Integer lineNumber = new Integer(fLocator.getLineNumber());
- Integer[] range = new Integer[] {lineNumber, new Integer(-1)};
- fLineTable.put(element, range);
- if (fRootElement == null)
- fRootElement = element;
- else
- ((Element) fElementStack.peek()).appendChild(element);
- fElementStack.push(element);
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- Integer[] range = (Integer[]) fLineTable.get(fElementStack.pop());
- range[1] = new Integer(fLocator.getLineNumber());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator)
- */
- public void setDocumentLocator(Locator locator) {
- fLocator = locator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#startDocument()
- */
- public void startDocument() throws SAXException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- fDocument = factory.newDocumentBuilder().newDocument();
- } catch (ParserConfigurationException e) {
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#endDocument()
- */
- public void endDocument() throws SAXException {
- fDocument.appendChild(fRootElement);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String,
- * java.lang.String)
- */
- public void processingInstruction(String target, String data) throws SAXException {
- fDocument.appendChild(fDocument.createProcessingInstruction(target, data));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
- */
- public void characters(char[] characters, int start, int length) throws SAXException {
- StringBuffer buff = new StringBuffer();
- for (int i = 0; i < length; i++) {
- buff.append(characters[start + i]);
- }
- Text text = fDocument.createTextNode(buff.toString());
- if (fRootElement == null)
- fDocument.appendChild(text);
- else
- ((Element) fElementStack.peek()).appendChild(text);
- }
-
- public Node getDocumentElement() {
- fDocument.getDocumentElement().normalize();
- return fDocument.getDocumentElement();
- }
-
- public org.w3c.dom.Document getDocument() {
- fDocument.getDocumentElement().normalize();
- return fDocument;
- }
-
- public Hashtable getLineTable() {
- return fLineTable;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultIndexHandler.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultIndexHandler.java
deleted file mode 100644
index 026d876..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultIndexHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-
-public class DefaultIndexHandler implements IIndexHandler {
-
- public DefaultIndexHandler() {
- }
-
- public IStatus processIndex(final Shell shell, String indexId) {
- final String message = "Index reached: " + indexId;
-
- final IStatus[] result = new IStatus[1];
-
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(shell, "Macro Playback", message);
- result[0] = Status.OK_STATUS;
- }
- });
- return result[0];
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultWidgetResolver.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultWidgetResolver.java
deleted file mode 100644
index cdbe8ce..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/DefaultWidgetResolver.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.pde.core.IIdentifiable;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IPluginContribution;
-
-public class DefaultWidgetResolver implements IWidgetResolver {
- public String getUniqueId(Widget widget) {
- Object data = widget.getData();
-
- // direct resolution (widget-independent)
- if (data instanceof IPluginContribution)
- return ((IPluginContribution) data).getLocalId();
-
- // widget-specific resolution
- if (widget instanceof TreeItem || widget instanceof TableItem) {
- if (data instanceof IJavaElement)
- return ((IJavaElement) data).getPath().toString();
- if (data instanceof IResource)
- return ((IResource) data).getFullPath().toString();
- if (data instanceof IClasspathContainer)
- return ((IClasspathContainer) data).getPath().toString();
- if (data instanceof IPluginModelBase)
- return ((IPluginModelBase) data).getPluginBase().getId();
- if (data instanceof IFeatureModel)
- return ((IFeatureModel) data).getFeature().getId();
- if (data instanceof IIdentifiable)
- return ((IIdentifiable) data).getId();
- }
- if (widget instanceof Button) {
- if (data instanceof Integer)
- return "ButtonId=" + ((Integer) data).intValue();
- }
- if (widget instanceof TabFolder || widget instanceof CTabFolder) {
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexAction.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexAction.java
deleted file mode 100644
index 193399d..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexAction.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-public class IndexAction implements IWorkbenchWindowActionDelegate, IRecorderListener {
- private IAction action;
-
- /**
- * The constructor.
- */
- public IndexAction() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.addRecorderListener(this);
- }
-
- /**
- * The action has been activated. The argument of the
- * method represents the 'real' action sitting
- * in the workbench UI.
- * @see IWorkbenchWindowActionDelegate#run
- */
- public void run(IAction action) {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- this.action = action;
- if (!recorder.isRecording()) {
- action.setEnabled(false);
- return;
- }
- RecordBlock.getInstance().insertIndex();
- }
-
- /**
- * Selection in the workbench has been changed. We
- * can change the state of the 'real' action here
- * if we want, but this can only happen after
- * the delegate has been created.
- * @see IWorkbenchWindowActionDelegate#selectionChanged
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- public void recordingStarted() {
- if (action != null)
- action.setEnabled(true);
- }
-
- public void recordingStopped() {
- if (action != null)
- action.setEnabled(false);
- }
-
- public void recordingInterrupted(int type) {
- }
-
- /**
- * We can use this method to dispose of any system
- * resources we previously allocated.
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.removeRecorderListener(this);
- RecordBlock.dispose();
- }
-
- /**
- * We will cache window object in order to
- * be able to provide parent shell for the message dialog.
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- RecordBlock.init(window);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexPage.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexPage.java
deleted file mode 100644
index 2b0e4b8..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexPage.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class IndexPage extends WizardPage {
- private String indexId;
- private Text text;
- private TableViewer tableViewer;
- private String[] existingIndices;
-
- class ExistingProvider implements IStructuredContentProvider {
- public Object[] getElements(Object inputElement) {
- return existingIndices;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- public IndexPage(String[] existingIndices) {
- super("index");
- setTitle("Script index");
- setDescription("Enter a unique id for the script index. The index will be processed by index handled during execution of the script.");
- this.existingIndices = existingIndices;
- }
-
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- container.setLayout(layout);
- Label label = new Label(container, SWT.NULL);
- label.setText("&Index identifier:");
- text = new Text(container, SWT.SINGLE | SWT.BORDER);
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateStatus();
- }
- });
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- label = new Label(container, SWT.NULL);
- label.setText("&Existing indices:");
- tableViewer = new TableViewer(container, SWT.BORDER);
- tableViewer.setContentProvider(new ExistingProvider());
- tableViewer.setInput(this);
- tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- Object obj = sel.getFirstElement();
- if (obj != null)
- text.setText(obj.toString());
- }
- });
- setPageComplete(false);
- setControl(container);
- }
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible)
- text.setFocus();
- }
-
- private void updateStatus() {
- String id = text.getText();
- String errorMessage = null;
- if (id.length() == 0) {
- errorMessage = "Index id cannot be empty.";
- } else {
- boolean exists = false;
- for (int i = 0; i < existingIndices.length; i++) {
- if (id.equals(existingIndices[i])) {
- exists = true;
- break;
- }
- }
- if (exists)
- errorMessage = "Index id already exists.";
- }
- setErrorMessage(errorMessage);
- setPageComplete(errorMessage == null);
- if (errorMessage == null)
- this.indexId = id;
- }
-
- public String getIndexId() {
- return indexId;
- }
-} \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexWizard.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexWizard.java
deleted file mode 100644
index f99cac5..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/IndexWizard.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.wizard.Wizard;
-
-public class IndexWizard extends Wizard {
- private IndexPage page;
- private MacroManager macroManager;
-
- public IndexWizard(MacroManager manager) {
- this.macroManager = manager;
- setWindowTitle("Macro Recorder");
- }
-
- public void addPages() {
- page = new IndexPage(macroManager.getExistingIndices());
- addPage(page);
- }
-
- public boolean performFinish() {
- String indexId = page.getIndexId();
- if (indexId != null) {
- macroManager.addIndex(indexId);
- }
- return true;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/NewMacroWizard.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/NewMacroWizard.java
deleted file mode 100644
index a48f1b5..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/NewMacroWizard.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-
-public class NewMacroWizard extends Wizard {
- private String contents;
- private NewMacroPage page;
-
- class NewMacroPage extends WizardNewFileCreationPage {
- public NewMacroPage(IStructuredSelection ssel) {
- super("newFile", ssel);
- setTitle("Macro script name");
- setDescription("Select the target location and the name of the new script (extension *.emc).");
- }
-
- public InputStream getInitialContents() {
- InputStream is = null;
- try {
- is = new ByteArrayInputStream(contents.getBytes("UTF8"));
- } catch (UnsupportedEncodingException e) {
- }
- return is;
- }
- }
-
- public NewMacroWizard(String contents) {
- this.contents = contents;
- setWindowTitle("Macro Recorder");
- }
-
- public void addPages() {
- ISelectionService sservice = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
- ISelection selection = sservice.getSelection();
- IStructuredSelection ssel;
- if (!(selection instanceof IStructuredSelection))
- ssel = new StructuredSelection();
- else
- ssel = (IStructuredSelection) selection;
-
- page = new NewMacroPage(ssel);
- addPage(page);
- }
-
- public boolean performFinish() {
- IFile file = page.createNewFile();
- return file != null;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/PlaybackAction.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/PlaybackAction.java
deleted file mode 100644
index 1289140..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/PlaybackAction.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Our sample action implements workbench action delegate.
- * The action proxy will be created by the workbench and
- * shown in the UI. When the user tries to use the action,
- * this delegate will be created and execution will be
- * delegated to it.
- * @see IWorkbenchWindowActionDelegate
- */
-public class PlaybackAction implements IWorkbenchWindowActionDelegate {
- private IWorkbenchWindow window;
-
- /**
- * The constructor.
- */
- public PlaybackAction() {
- }
-
- /**
- * The action has been activated. The argument of the
- * method represents the 'real' action sitting
- * in the workbench UI.
- * @see IWorkbenchWindowActionDelegate#run
- */
- public void run(IAction action) {
- ISelection selection = window.getSelectionService().getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- Object el = ssel.getFirstElement();
- if (el instanceof IFile) {
- action.setEnabled(false);
- runFile((IFile) el);
- action.setEnabled(true);
- }
- }
- }
-
- private void runFile(IFile file) {
- try {
- InputStream is = file.getContents();
- MacroManager mng = MacroPlugin.getDefault().getMacroManager();
- mng.setIndexHandler(new DefaultIndexHandler());
- mng.play(window.getShell().getDisplay(), window, file.getName(), is);
- mng.setIndexHandler(null);
- } catch (CoreException e) {
- MacroPlugin.logException(e);
- }
- }
-
- /**
- * Selection in the workbench has been changed. We
- * can change the state of the 'real' action here
- * if we want, but this can only happen after
- * the delegate has been created.
- * @see IWorkbenchWindowActionDelegate#selectionChanged
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /**
- * We can use this method to dispose of any system
- * resources we previously allocated.
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- }
-
- /**
- * We will cache window object in order to
- * be able to provide parent shell for the message dialog.
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- this.window = window;
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordAction.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordAction.java
deleted file mode 100644
index fbaf741..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordAction.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Our sample action implements workbench action delegate.
- * The action proxy will be created by the workbench and
- * shown in the UI. When the user tries to use the action,
- * this delegate will be created and execution will be
- * delegated to it.
- * @see IWorkbenchWindowActionDelegate
- */
-public class RecordAction implements IWorkbenchWindowActionDelegate, IRecorderListener {
- private IAction action;
-
- /**
- * The constructor.
- */
- public RecordAction() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.addRecorderListener(this);
- }
-
- /**
- * The action has been activated. The argument of the
- * method represents the 'real' action sitting
- * in the workbench UI.
- * @see IWorkbenchWindowActionDelegate#run
- */
- public void run(IAction action) {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- this.action = action;
- if (recorder.isRecording()) {
- action.setEnabled(false);
- return;
- }
- RecordBlock.getInstance().startRecording();
- }
-
- /**
- * Selection in the workbench has been changed. We
- * can change the state of the 'real' action here
- * if we want, but this can only happen after
- * the delegate has been created.
- * @see IWorkbenchWindowActionDelegate#selectionChanged
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /**
- * We can use this method to dispose of any system
- * resources we previously allocated.
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.removeRecorderListener(this);
- RecordBlock.dispose();
- }
-
- public void recordingStarted() {
- this.action.setEnabled(false);
- }
-
- public void recordingStopped() {
- this.action.setEnabled(true);
- }
-
- public void recordingInterrupted(int type) {
- }
-
- /**
- * We will cache window object in order to
- * be able to provide parent shell for the message dialog.
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- RecordBlock.init(window);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordBlock.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordBlock.java
deleted file mode 100644
index b19b4cf..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/RecordBlock.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-
-public class RecordBlock implements IRecorderListener {
- private IWorkbenchWindow window;
- private static RecordBlock instance;
-
- private RecordBlock() {
- }
-
- public static RecordBlock getInstance() {
- if (instance == null) {
- instance = new RecordBlock();
- }
- return instance;
- }
-
- public static void init(IWorkbenchWindow window) {
- if (instance == null) {
- getInstance().internalInit(window);
- }
- }
-
- private void internalInit(IWorkbenchWindow window) {
- this.window = window;
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.addRecorderListener(this);
- }
-
- public static void dispose() {
- if (instance != null) {
- instance.internalDispose();
- instance = null;
- }
- }
-
- private void internalDispose() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.removeRecorderListener(this);
- }
-
- public void startRecording() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.startRecording();
- }
-
- public void stopRecording() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- Macro macro = recorder.stopRecording();
- StringWriter swriter = new StringWriter();
- PrintWriter pwriter = new PrintWriter(swriter);
- macro.write("", pwriter);
- pwriter.close();
- try {
- swriter.close();
- } catch (IOException e) {
- System.out.println(e);
- }
- String contents = swriter.toString();
- NewMacroWizard wizard = new NewMacroWizard(contents);
- WizardDialog wd = new WizardDialog(window.getShell(), wizard);
- wd.setMinimumPageSize(500, 500);
- wd.open();
- }
-
- public void recordingStarted() {
- }
-
- public void recordingStopped() {
- }
-
- public void recordingInterrupted(int interruptType) {
- if (interruptType == STOP)
- stopRecording();
- else if (interruptType == INDEX)
- insertIndex();
- }
-
- public void insertIndex() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- IndexWizard wizard = new IndexWizard(recorder);
- WizardDialog wd = new WizardDialog(window.getShell(), wizard);
- //wd.setMinimumPageSize(300, 400);
- wd.create();
- wd.getShell().setData(MacroManager.IGNORE, Boolean.TRUE);
- wd.getShell().setSize(300, 400);
- wd.open();
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/StopAction.java b/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/StopAction.java
deleted file mode 100644
index d17ea12..0000000
--- a/ui/org.eclipse.pde.ui.tests/Macro UI/org/eclipse/pde/internal/ui/tests/macro/StopAction.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.tests.macro;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-public class StopAction implements IWorkbenchWindowActionDelegate, IRecorderListener {
- private IAction action;
-
- /**
- * The constructor.
- */
- public StopAction() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.addRecorderListener(this);
- }
-
- /**
- * The action has been activated. The argument of the
- * method represents the 'real' action sitting
- * in the workbench UI.
- * @see IWorkbenchWindowActionDelegate#run
- */
- public void run(IAction action) {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- this.action = action;
- if (!recorder.isRecording()) {
- action.setEnabled(false);
- return;
- }
- RecordBlock.getInstance().stopRecording();
- }
-
- /**
- * Selection in the workbench has been changed. We
- * can change the state of the 'real' action here
- * if we want, but this can only happen after
- * the delegate has been created.
- * @see IWorkbenchWindowActionDelegate#selectionChanged
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- public void recordingStarted() {
- if (action != null)
- action.setEnabled(true);
- }
-
- public void recordingStopped() {
- if (action != null)
- action.setEnabled(false);
- }
-
- public void recordingInterrupted(int type) {
- }
-
- /**
- * We can use this method to dispose of any system
- * resources we previously allocated.
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- MacroManager recorder = MacroPlugin.getDefault().getMacroManager();
- recorder.removeRecorderListener(this);
- RecordBlock.dispose();
- }
-
- /**
- * We will cache window object in order to
- * be able to provide parent shell for the message dialog.
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- RecordBlock.init(window);
- }
-}
diff --git a/ui/org.eclipse.pde.ui.tests/build.properties b/ui/org.eclipse.pde.ui.tests/build.properties
index b117b26..300ba78 100644
--- a/ui/org.eclipse.pde.ui.tests/build.properties
+++ b/ui/org.eclipse.pde.ui.tests/build.properties
@@ -8,15 +8,12 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-source.tests.jar = src/,\
- Macro Manager/,\
- Macro UI/
+source.tests.jar = src/
output.tests.jar = bin/
bin.includes = tests.jar,\
plugin.xml,\
test.xml,\
about.html,\
- schema/,\
icons/,\
META-INF/,\
tests/,\
diff --git a/ui/org.eclipse.pde.ui.tests/plugin.xml b/ui/org.eclipse.pde.ui.tests/plugin.xml
index 75a3e45..2c1967c 100644
--- a/ui/org.eclipse.pde.ui.tests/plugin.xml
+++ b/ui/org.eclipse.pde.ui.tests/plugin.xml
@@ -13,90 +13,6 @@
<plugin>
- <extension-point id="macroSupport" name="Macro Support" schema="schema/macroSupport.exsd"/>
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- label="Sample Action Set"
- visible="true"
- id="org.eclipse.ui.macro.actionSet">
- <menu
- label="&amp;Macros..."
- path="window/additions"
- id="macro">
- <separator name="group1"/>
- </menu>
- <action
- toolbarPath="sampleGroup"
- label="&amp;Start Recording"
- class="org.eclipse.pde.internal.ui.tests.macro.RecordAction"
- tooltip="Start Recording"
- icon="icons/external_tools.gif"
- menubarPath="window/macro/group1"
- id="org.eclipse.pde.ui.tests.RecordAction"/>
- <action
- class="org.eclipse.pde.internal.ui.tests.macro.IndexAction"
- definitionId="org.eclipse.pde.ui.tests.index"
- icon="icons/suspend_co.gif"
- id="org.eclipse.pde.ui.tests.IndexAction"
- label="&amp;Pause for Indexing"
- menubarPath="window/macro/group1"
- toolbarPath="sampleGroup"
- tooltip="Pause for Indexing"/>
- <action
- class="org.eclipse.pde.internal.ui.tests.macro.StopAction"
- definitionId="org.eclipse.pde.ui.tests.stopRecording"
- icon="icons/terminate_co.gif"
- id="org.eclipse.pde.ui.tests.StopAction"
- label="S&amp;top Recording"
- menubarPath="window/macro/group1"
- toolbarPath="sampleGroup"
- tooltip="Stop Recording"/>
- <action
- enablesFor="1"
- toolbarPath="sampleGroup"
- label="&amp;Playback"
- icon="icons/run_exc.gif"
- tooltip="&amp;Run Macro"
- class="org.eclipse.pde.internal.ui.tests.macro.PlaybackAction"
- menubarPath="window/macro/group1"
- id="org.eclipse.pde.ui.tests.PlaybackAction">
- <enablement>
- <and>
- <objectClass name="org.eclipse.core.resources.IFile"/>
- <objectState name="extension" value="emc"/>
- </and>
- </enablement>
- </action>
- </actionSet>
- </extension>
- <extension
- point="org.eclipse.pde.ui.tests.macroSupport">
- <widgetResolver class="org.eclipse.pde.internal.ui.tests.macro.DefaultWidgetResolver"/>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- description="Stops the recording of the macro"
- categoryId="org.eclipse.ui.category.window"
- name="Stop Macro Recording"
- id="org.eclipse.pde.ui.tests.stopRecording"/>
- <command
- description="Places a named index in the macro"
- categoryId="org.eclipse.ui.category.window"
- name="Index Macro"
- id="org.eclipse.pde.ui.tests.index"/>
- <keyBinding
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- commandId="org.eclipse.pde.ui.tests.stopRecording"
- keySequence="Ctrl+Shift+F11"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
- <keyBinding
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- commandId="org.eclipse.pde.ui.tests.index"
- keySequence="Ctrl+Shift+F10"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
- </extension>
<extension
point="org.eclipse.jdt.launching.executionEnvironments">
<environment
diff --git a/ui/org.eclipse.pde.ui.tests/schema/macroSupport.exsd b/ui/org.eclipse.pde.ui.tests/schema/macroSupport.exsd
deleted file mode 100644
index 0547335..0000000
--- a/ui/org.eclipse.pde.ui.tests/schema/macroSupport.exsd
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.pde.ui.tests">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.pde.ui.tests" id="macroSupport" name="Macro Support"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="widgetResolver" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="widgetResolver">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.ui.macro.IWidgetResolver"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2005 IBM Corporation and others.
-
-&lt;br&gt;
-
-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
-
-&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;.
- </documentation>
- </annotation>
-
-</schema>
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestsPlugin.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestsPlugin.java
new file mode 100644
index 0000000..8d87864
--- /dev/null
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestsPlugin.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.ui.tests;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class PDETestsPlugin extends AbstractUIPlugin {
+
+ private static PDETestsPlugin fgDefault = null;
+
+ public PDETestsPlugin() {
+ fgDefault = this;
+ }
+
+ /**
+ * Returns the test plug-in.
+ *
+ * @return the test plug-in
+ */
+ public static PDETestsPlugin getDefault() {
+ return fgDefault;
+ }
+
+ public static BundleContext getBundleContext() {
+ return getDefault().getBundle().getBundleContext();
+ }
+
+}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java
index 0f13f06..0facbac 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.build.properties;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.*;
import java.net.URL;
import java.util.Enumeration;
@@ -28,7 +30,6 @@ import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.core.natures.PDE;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.correction.ResolutionGenerator;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.pde.ui.tests.target.LocalTargetDefinitionTests;
import org.eclipse.ui.IMarkerResolution;
import org.osgi.service.prefs.BackingStoreException;
@@ -50,12 +51,12 @@ public abstract class AbstractBuildValidationTest extends TestCase {
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
- URL location = MacroPlugin.getBundleContext().getBundle().getEntry("/tests/build.properties/build.properties.tests.zip");
+ URL location = PDETestsPlugin.getBundleContext().getBundle().getEntry("/tests/build.properties/build.properties.tests.zip");
File projectFile = new File(FileLocator.toFileURL(location).getFile());
assertTrue("Could not find test zip file at " + projectFile, projectFile.isFile());
- doUnZip(MacroPlugin.getDefault().getStateLocation().removeLastSegments(2), "/tests/build.properties/build.properties.tests.zip");
+ doUnZip(PDETestsPlugin.getDefault().getStateLocation().removeLastSegments(2), "/tests/build.properties/build.properties.tests.zip");
- projectFile = MacroPlugin.getDefault().getStateLocation().removeLastSegments(3).toFile();
+ projectFile = PDETestsPlugin.getDefault().getStateLocation().removeLastSegments(3).toFile();
File[] projects = projectFile.listFiles(new FileFilter() {
public boolean accept(File pathname) {
@@ -212,7 +213,7 @@ public abstract class AbstractBuildValidationTest extends TestCase {
* @throws IOException
*/
protected IPath doUnZip(IPath location, String archivePath) throws IOException {
- URL zipURL = MacroPlugin.getBundleContext().getBundle().getEntry(archivePath);
+ URL zipURL = PDETestsPlugin.getBundleContext().getBundle().getEntry(archivePath);
Path zipPath = new Path(new File(FileLocator.toFileURL(zipURL).getFile()).getAbsolutePath());
ZipFile zipFile = new ZipFile(zipPath.toFile());
Enumeration entries = zipFile.entries();
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathcontributor/ClasspathContributorTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathcontributor/ClasspathContributorTest.java
index c17929c..49279ef 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathcontributor/ClasspathContributorTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathcontributor/ClasspathContributorTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.classpathcontributor;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
@@ -20,7 +22,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
import org.eclipse.pde.core.IClasspathContributor;
import org.eclipse.pde.internal.core.PDECore;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.pde.ui.tests.classpathresolver.ClasspathResolverTest;
/**
@@ -81,7 +82,7 @@ public class ClasspathContributorTest extends TestCase {
IProject importProject(IWorkspace workspace) throws IOException, CoreException {
File rootFile = workspace.getRoot().getLocation().toFile();
- URL srcURL = MacroPlugin.getBundleContext().getBundle ().getEntry("tests/projects/" + ClasspathResolverTest.bundleName);
+ URL srcURL = PDETestsPlugin.getBundleContext().getBundle ().getEntry("tests/projects/" + ClasspathResolverTest.bundleName);
File srcBasedir = new File(FileLocator.toFileURL(srcURL).getFile());
File dstBasedir = new File(rootFile, ClasspathResolverTest.bundleName);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java
index 25a5c79..b8c063b 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.classpathresolver;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.*;
import java.net.URL;
import java.util.Properties;
@@ -25,7 +27,6 @@ import org.eclipse.pde.core.IBundleClasspathResolver;
import org.eclipse.pde.internal.core.ClasspathHelper;
import org.eclipse.pde.internal.launching.sourcelookup.PDESourceLookupDirector;
import org.eclipse.pde.internal.launching.sourcelookup.PDESourceLookupQuery;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
/**
* Tests {@link IBundleClasspathResolver} API to extend how the classpath and source lookup path
@@ -115,7 +116,7 @@ public class ClasspathResolverTest extends TestCase {
IProject importProject(IWorkspace workspace) throws IOException, CoreException {
File rootFile = workspace.getRoot().getLocation().toFile();
- URL srcURL = MacroPlugin.getBundleContext().getBundle().getEntry("tests/projects/" + bundleName);
+ URL srcURL = PDETestsPlugin.getBundleContext().getBundle().getEntry("tests/projects/" + bundleName);
File srcBasedir = new File(FileLocator.toFileURL(srcURL).getFile());
File dstBasedir = new File(rootFile, bundleName);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExportBundleTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExportBundleTests.java
index 1a67665..1cbf988 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExportBundleTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExportBundleTests.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.ee;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IProject;
@@ -23,7 +25,6 @@ import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
import org.eclipse.pde.internal.core.exports.PluginExportOperation;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.pde.ui.tests.PDETestCase;
import org.eclipse.pde.ui.tests.util.ProjectUtils;
@@ -32,7 +33,7 @@ import org.eclipse.pde.ui.tests.util.ProjectUtils;
*/
public class ExportBundleTests extends PDETestCase {
- private static final IPath EXPORT_PATH = MacroPlugin.getDefault().getStateLocation().append(".export");
+ private static final IPath EXPORT_PATH = PDETestsPlugin.getDefault().getStateLocation().append(".export");
public static Test suite() {
return new TestSuite(ExportBundleTests.class);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java
index 6945000..43ff0f0 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java
@@ -11,12 +11,12 @@
package org.eclipse.pde.ui.tests.performance.parts;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
-
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.test.performance.PerformanceTestCase;
import org.osgi.framework.Bundle;
@@ -59,7 +59,7 @@ public abstract class AbstractSchemaPerfTest extends PerformanceTestCase {
* @throws IOException
*/
private void setUpSchemaFile() throws Exception, IOException {
- MacroPlugin plugin = MacroPlugin.getDefault();
+ PDETestsPlugin plugin = PDETestsPlugin.getDefault();
if (plugin == null)
throw new Exception("ERROR: Macro plug-in uninitialized"); //$NON-NLS-1$
Bundle bundle = plugin.getBundle();
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/OpenManifestEditorPerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/OpenManifestEditorPerfTest.java
index 7675ddb..42ba057 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/OpenManifestEditorPerfTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/OpenManifestEditorPerfTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.performance.parts;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.File;
import java.net.URL;
import junit.framework.Test;
@@ -19,7 +21,6 @@ import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.pde.internal.ui.*;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.test.performance.*;
import org.eclipse.ui.*;
import org.eclipse.ui.ide.FileStoreEditorInput;
@@ -81,7 +82,7 @@ public class OpenManifestEditorPerfTest extends PerformanceTestCase {
* @throws Exception
*/
private Bundle getBundle() throws Exception {
- MacroPlugin plugin = MacroPlugin.getDefault();
+ PDETestsPlugin plugin = PDETestsPlugin.getDefault();
if (plugin == null) {
throw new Exception("ERROR: Macro plug-in uninitialized"); //$NON-NLS-1$
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
index adf3bc3..1c99d0f 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.performance.parts;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.*;
import java.net.URL;
import java.util.*;
@@ -26,7 +28,6 @@ import org.eclipse.pde.core.project.IBundleProjectDescription;
import org.eclipse.pde.core.project.IBundleProjectService;
import org.eclipse.pde.core.target.*;
import org.eclipse.pde.internal.core.PDECore;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.eclipse.pde.ui.tests.target.LocalTargetDefinitionTests;
import org.eclipse.pde.ui.tests.util.TestBundleCreator;
import org.eclipse.test.performance.Dimension;
@@ -229,7 +230,7 @@ public class TargetPlatformPerfTest extends PerformanceTestCase {
}
private IPath extractTargetPerfTestPlugins() throws Exception {
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("targetPerfTestPlugins");
if (!location.toFile().exists()) {
return doUnZip(location, TEST_PLUGIN_LOCATION);
@@ -245,7 +246,7 @@ public class TargetPlatformPerfTest extends PerformanceTestCase {
* @throws IOException
*/
private IPath doUnZip(IPath location, String archivePath) throws IOException {
- URL zipURL = MacroPlugin.getBundleContext().getBundle().getEntry(archivePath);
+ URL zipURL = PDETestsPlugin.getBundleContext().getBundle().getEntry(archivePath);
Path zipPath = new Path(new File(FileLocator.toFileURL(zipURL).getFile()).getAbsolutePath());
ZipFile zipFile = new ZipFile(zipPath.toFile());
Enumeration entries = zipFile.entries();
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/ProjectCreationTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/ProjectCreationTests.java
index da5433f..6b69bcf 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/ProjectCreationTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/ProjectCreationTests.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.project;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
+
import java.io.*;
import java.net.URL;
import java.nio.ByteBuffer;
@@ -33,7 +35,6 @@ import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.core.text.bundle.BundleModelFactory;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -969,7 +970,7 @@ public class ProjectCreationTests extends TestCase {
}
parent = parent.getParent();
}
- URL zipURL = MacroPlugin.getBundleContext().getBundle().getEntry("tests/A.jar");
+ URL zipURL = PDETestsPlugin.getBundleContext().getBundle().getEntry("tests/A.jar");
File ioFile = new File(FileLocator.toFileURL(zipURL).getFile());
FileInputStream stream = new FileInputStream(ioFile);
file.create(stream, false, null);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/AbstractRegistryModelTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/AbstractRegistryModelTest.java
index 753503e..6ee8161 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/AbstractRegistryModelTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/AbstractRegistryModelTest.java
@@ -17,230 +17,230 @@ import org.eclipse.core.runtime.*;
import org.eclipse.pde.internal.runtime.registry.model.*;
import org.eclipse.pde.internal.runtime.registry.model.Bundle;
import org.eclipse.pde.internal.runtime.registry.model.ServiceRegistration;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.osgi.framework.*;
public abstract class AbstractRegistryModelTest extends TestCase implements ModelChangeListener {
public static class MockFramework {
private EventListener listener;
-
+
public void createBundleEvent(int type, org.osgi.framework.Bundle bundle) {
assertTrue(listener instanceof BundleListener);
((BundleListener)listener).bundleChanged(new BundleEvent(type, bundle));
}
-
+
public void createRegistryAddedEvent(IExtension[] ext) {
assertTrue(listener instanceof IRegistryEventListener);
((IRegistryEventListener)listener).added(ext);
}
-
+
public void createRegistryRemovedEvent(IExtension[] ext) {
assertTrue(listener instanceof IRegistryEventListener);
((IRegistryEventListener)listener).removed(ext);
}
-
+
public void createRegistryAddedEvent(IExtensionPoint[] ext) {
assertTrue(listener instanceof IRegistryEventListener);
((IRegistryEventListener)listener).added(ext);
}
-
+
public void createRegistryRemovedEvent(IExtensionPoint[] ext) {
assertTrue(listener instanceof IRegistryEventListener);
((IRegistryEventListener)listener).removed(ext);
}
-
+
public void createServiceEvent(int type, ServiceReference ref) {
assertTrue(listener instanceof ServiceListener);
((ServiceListener)listener).serviceChanged(new ServiceEvent(type, ref));
}
-
+
public void setListener(EventListener listener) {
this.listener = listener;
- }
+ }
}
-
+
public static final String TEST_EXT_POINT = "org.eclipse.ui.views";
public static final String TEST_EXT_POINT_BUNDLE = "org.eclipse.ui";
-
+
protected MockFramework mockFramework = new MockFramework();
-
+
protected org.osgi.framework.Bundle testBundle;
protected ServiceReference testServiceReference;
-
+
protected IExtensionPoint testExtPoint;
protected org.osgi.framework.Bundle testExtPointBundle;
-
+
protected RegistryModel model;
-
+
protected ModelChangeDelta[] deltas;
-
+
public void modelChanged(ModelChangeDelta[] deltas) {
this.deltas = deltas;
}
-
+
abstract protected RegistryModel createModel() throws URISyntaxException;
-
+
public AbstractRegistryModelTest() {
- testBundle = MacroPlugin.getBundleContext().getBundle();
- org.osgi.framework.ServiceRegistration registration = MacroPlugin.getBundleContext().registerService(getClass().getName(), this, null);
+ testBundle = PDETestsPlugin.getBundleContext().getBundle();
+ org.osgi.framework.ServiceRegistration registration = PDETestsPlugin.getBundleContext().registerService(getClass().getName(), this, null);
testServiceReference = registration.getReference();
-
+
testExtPoint = Platform.getExtensionRegistry().getExtensionPoint(TEST_EXT_POINT);
- testExtPointBundle = MacroPlugin.getDefault().getPackageAdmin().getBundles(TEST_EXT_POINT_BUNDLE, null)[0];
+ testExtPointBundle = TestUtils.getBundle(TEST_EXT_POINT_BUNDLE);
}
-
+
protected void setUp() throws Exception {
model = createModel();
model.connect(new NullProgressMonitor(), false);
-
+
deltas = new ModelChangeDelta[0];
model.addModelChangeListener(this);
}
-
+
protected void tearDown() {
model.removeModelChangeListener(this);
model.disconnect();
}
-
+
/**
- * Verifies that model provides correct list of installed bundles
+ * Verifies that model provides correct list of installed bundles
*/
public void testInstalledBundles() {
- org.osgi.framework.Bundle[] origBundles = MacroPlugin.getBundleContext().getBundles();
+ org.osgi.framework.Bundle[] origBundles = PDETestsPlugin.getBundleContext().getBundles();
model.initialize(new NullProgressMonitor());
Bundle[] bundles = model.getBundles();
-
+
assertEquals(origBundles.length, bundles.length);
}
-
+
public void testBundleInstalled() {
mockFramework.createBundleEvent(BundleEvent.INSTALLED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.ADDED, deltas[0].getFlag());
}
-
+
public void testBundleStartedEvent() {
mockFramework.createBundleEvent(BundleEvent.STARTED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.STARTED, deltas[0].getFlag());
}
-
+
public void testBundleStoppedEvent() {
mockFramework.createBundleEvent(BundleEvent.STOPPED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.STOPPED, deltas[0].getFlag());
}
-
+
public void testBundleUpdatedEvent() {
mockFramework.createBundleEvent(BundleEvent.UPDATED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.UPDATED, deltas[0].getFlag());
}
-
+
public void testBundleUninstalledEvent() {
mockFramework.createBundleEvent(BundleEvent.UNINSTALLED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.REMOVED, deltas[0].getFlag());
}
-
+
public void testBundleResolvedEvent() {
mockFramework.createBundleEvent(BundleEvent.RESOLVED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.RESOLVED, deltas[0].getFlag());
}
-
+
public void testBundleUnresolvedEvent() {
mockFramework.createBundleEvent(BundleEvent.UNRESOLVED, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.UNRESOLVED, deltas[0].getFlag());
}
-
+
public void testBundleStartingEvent() {
mockFramework.createBundleEvent(BundleEvent.STARTING, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.STARTING, deltas[0].getFlag());
}
-
+
public void testBundleStoppingEvent() {
mockFramework.createBundleEvent(BundleEvent.STOPPING, testBundle);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Bundle);
assertEquals(testBundle.getSymbolicName(), ((Bundle)deltas[0].getModelObject()).getSymbolicName());
assertEquals(ModelChangeDelta.STOPPING, deltas[0].getFlag());
}
-
+
public void testServiceRegisteredEvent() {
mockFramework.createServiceEvent(ServiceEvent.REGISTERED, testServiceReference);
-
+
assertEquals(2, deltas.length);
ModelChangeDelta delta = deltas[0];
assertTrue(delta.getModelObject() instanceof ServiceName);
assertEquals(getClass().getName(), ((ServiceName)delta.getModelObject()).getClasses()[0]);
assertEquals(ModelChangeDelta.ADDED, delta.getFlag());
-
+
delta = deltas[1];
assertTrue(delta.getModelObject() instanceof ServiceRegistration);
assertEquals(getClass().getName(), ((ServiceRegistration)delta.getModelObject()).getName().getClasses()[0]);
assertEquals(ModelChangeDelta.ADDED, delta.getFlag());
}
-
+
public void testServiceUnregisteringEvent() {
mockFramework.createServiceEvent(ServiceEvent.UNREGISTERING, testServiceReference);
-
+
assertEquals(2, deltas.length);
ModelChangeDelta delta = deltas[0];
assertTrue(delta.getModelObject() instanceof ServiceName);
assertEquals(getClass().getName(), ((ServiceName)delta.getModelObject()).getClasses()[0]);
assertEquals(ModelChangeDelta.REMOVED, delta.getFlag());
-
+
delta = deltas[1];
assertTrue(delta.getModelObject() instanceof ServiceRegistration);
assertEquals(getClass().getName(), ((ServiceRegistration)delta.getModelObject()).getName().getClasses()[0]);
assertEquals(ModelChangeDelta.REMOVED, delta.getFlag());
}
-
+
public void testServiceModifiedEvent() {
mockFramework.createServiceEvent(ServiceEvent.MODIFIED, testServiceReference);
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof ServiceRegistration);
assertEquals(getClass().getName(), ((ServiceRegistration)deltas[0].getModelObject()).getName().getClasses()[0]);
assertEquals(ModelChangeDelta.UPDATED, deltas[0].getFlag());
}
-
+
public void testExtensionAddedEvent() {
mockFramework.createRegistryAddedEvent(new IExtensionPoint[] {testExtPoint});
-
+
IExtension ext = testExtPoint.getExtensions()[0];
-
+
mockFramework.createRegistryAddedEvent(new IExtension[] {ext});
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Extension);
assertEquals(ext.getLabel(), ((Extension)deltas[0].getModelObject()).getLabel());
@@ -248,39 +248,39 @@ public abstract class AbstractRegistryModelTest extends TestCase implements Mode
assertEquals(ext.getNamespaceIdentifier(), ((Extension)deltas[0].getModelObject()).getNamespaceIdentifier());
assertEquals(ModelChangeDelta.ADDED, deltas[0].getFlag());
}
-
+
public void testExtensionRemovedEvent() {
mockFramework.createRegistryAddedEvent(new IExtensionPoint[] {testExtPoint});
-
+
IExtension ext = testExtPoint.getExtensions()[0];
-
+
mockFramework.createRegistryRemovedEvent(new IExtension[] {ext});
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof Extension);
Extension modelObject = ((Extension)deltas[0].getModelObject());
assertEquals(ext.getLabel(), modelObject.getLabel());
assertEquals(ext.getExtensionPointUniqueIdentifier(), modelObject.getExtensionPointUniqueIdentifier());
assertEquals(ext.getNamespaceIdentifier(), modelObject.getNamespaceIdentifier());
- assertEquals(ModelChangeDelta.REMOVED, deltas[0].getFlag());
+ assertEquals(ModelChangeDelta.REMOVED, deltas[0].getFlag());
}
-
+
public void testExtensionPointAddedEvent() {
mockFramework.createRegistryAddedEvent(new IExtensionPoint[] {testExtPoint});
-
+
assertEquals(1, deltas.length);
assertTrue(deltas[0].getModelObject() instanceof ExtensionPoint);
-
+
ExtensionPoint modelObject = ((ExtensionPoint)deltas[0].getModelObject());
assertEquals(testExtPoint.getLabel(), modelObject.getLabel());
assertEquals(testExtPoint.getNamespaceIdentifier(), modelObject.getNamespaceIdentifier());
assertEquals(testExtPoint.getUniqueIdentifier(), modelObject.getUniqueIdentifier());
assertEquals(ModelChangeDelta.ADDED, deltas[0].getFlag());
}
-
+
public void testExtensionPointRemovedEvent() {
mockFramework.createRegistryRemovedEvent(new IExtensionPoint[] {testExtPoint});
-
+
ExtensionPoint modelObject = ((ExtensionPoint)deltas[0].getModelObject());
assertEquals(testExtPoint.getLabel(), modelObject.getLabel());
assertEquals(testExtPoint.getNamespaceIdentifier(), modelObject.getNamespaceIdentifier());
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/TestUtils.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/TestUtils.java
index b08a295..4ff7854 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/TestUtils.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/runtime/TestUtils.java
@@ -12,38 +12,44 @@ package org.eclipse.pde.ui.tests.runtime;
import java.util.Collections;
import org.eclipse.core.runtime.*;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
/**
* Utility methods for JUnit tests.
*/
public class TestUtils {
+ private static PackageAdmin packageAdmin;
+
public static Bundle getBundle(String symbolicName) {
- Bundle[] bundles = MacroPlugin.getDefault().getPackageAdmin().getBundles(symbolicName, null);
-
+ if (packageAdmin == null) {
+ packageAdmin = (PackageAdmin) PDETestsPlugin.getBundleContext().getService(PDETestsPlugin.getBundleContext().getServiceReference(PackageAdmin.class.getName()));
+ }
+ Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
+
if (bundles != null) {
return bundles[0];
}
-
+
return null;
}
-
+
public static IExtensionPoint getExtensionPoint(String extensionPointId) {
return Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);
}
-
+
public static IExtension getExtension(String extensionId) {
return Platform.getExtensionRegistry().getExtension(extensionId);
}
-
+
public static ServiceReference getServiceReference(String clazzName) {
- return MacroPlugin.getBundleContext().getServiceReference(clazzName);
+ return PDETestsPlugin.getBundleContext().getServiceReference(clazzName);
}
public static String findPath(String path) {
- return FileLocator.find(MacroPlugin.getBundleContext().getBundle(), new Path(path), Collections.EMPTY_MAP).toString();
+ return FileLocator.find(PDETestsPlugin.getBundleContext().getBundle(), new Path(path), Collections.EMPTY_MAP).toString();
}
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java
index dda19f5..ce81048 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java
@@ -20,7 +20,7 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.pde.core.plugin.TargetPlatform;
import org.eclipse.pde.core.target.*;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.osgi.framework.ServiceReference;
/**
@@ -35,11 +35,11 @@ public abstract class AbstractTargetTest extends TestCase {
* @return target platform service
*/
protected ITargetPlatformService getTargetService() {
- ServiceReference reference = MacroPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
+ ServiceReference reference = PDETestsPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
assertNotNull("Missing target platform service", reference);
if (reference == null)
return null;
- return (ITargetPlatformService) MacroPlugin.getBundleContext().getService(reference);
+ return (ITargetPlatformService) PDETestsPlugin.getBundleContext().getService(reference);
}
/**
@@ -50,7 +50,7 @@ public abstract class AbstractTargetTest extends TestCase {
* @throws Exception
*/
protected IPath extractAbcdePlugins() throws Exception {
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("abcde-plugins");
if (location.toFile().exists()) {
// recursively delete
@@ -69,7 +69,7 @@ public abstract class AbstractTargetTest extends TestCase {
* @throws Exception
*/
protected IPath extractLinkedPlugins() throws Exception {
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("abcde/linked/eclipse/plugins");
if (location.toFile().exists()) {
// recursively delete
@@ -88,7 +88,7 @@ public abstract class AbstractTargetTest extends TestCase {
*/
protected IPath extractClassicPlugins() throws Exception {
// extract the 3.0.2 skeleton
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("classic/eclipse");
if (location.toFile().exists()) {
return location.append("plugins");
@@ -105,7 +105,7 @@ public abstract class AbstractTargetTest extends TestCase {
* @throws Exception
*/
protected IPath extractModifiedFeatures() throws Exception {
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("modified-jdt-features");
if (location.toFile().exists()) {
return location;
@@ -130,7 +130,7 @@ public abstract class AbstractTargetTest extends TestCase {
* @throws Exception
*/
protected IPath extractMultiVersionPlugins() throws Exception {
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("multi-versions");
if (location.toFile().exists()) {
return location;
@@ -148,7 +148,7 @@ public abstract class AbstractTargetTest extends TestCase {
*/
protected IPath extractClassicNonBundleManifestPlugins() throws Exception {
// extract the 3.0.2 skeleton
- IPath stateLocation = MacroPlugin.getDefault().getStateLocation();
+ IPath stateLocation = PDETestsPlugin.getDefault().getStateLocation();
IPath location = stateLocation.append("eclipse-nbm");
if (location.toFile().exists()) {
return location.append("plugins");
@@ -165,7 +165,7 @@ public abstract class AbstractTargetTest extends TestCase {
* @throws IOException
*/
private IPath doUnZip(IPath location, String archivePath) throws IOException {
- URL zipURL = MacroPlugin.getBundleContext().getBundle().getEntry(archivePath);
+ URL zipURL = PDETestsPlugin.getBundleContext().getBundle().getEntry(archivePath);
Path zipPath = new Path(new File(FileLocator.toFileURL(zipURL).getFile()).getAbsolutePath());
ZipFile zipFile = new ZipFile(zipPath.toFile());
Enumeration entries = zipFile.entries();
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
index 375ff22..6fce79a 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
@@ -29,7 +29,7 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.pde.core.target.*;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.target.*;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
@@ -66,7 +66,7 @@ public class IUBundleContainerTests extends AbstractTargetTest {
* @throws Exception
*/
protected URI getURI(String relativePath) throws Exception {
- URL url = MacroPlugin.getBundleContext().getBundle().getEntry(relativePath);
+ URL url = PDETestsPlugin.getBundleContext().getBundle().getEntry(relativePath);
Path path = new Path(new File(FileLocator.toFileURL(url).getFile()).getAbsolutePath());
return URIUtil.toURI(path);
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java
index daf04cc..8acba72 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.pde.ui.tests.target;
-import org.eclipse.pde.core.target.*;
-
import java.io.*;
import java.net.URL;
import java.util.*;
@@ -20,11 +18,12 @@ import junit.framework.TestSuite;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.pde.core.plugin.*;
+import org.eclipse.pde.core.target.*;
import org.eclipse.pde.internal.core.*;
import org.eclipse.pde.internal.core.target.TargetDefinition;
import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper;
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.osgi.framework.ServiceReference;
/**
@@ -48,11 +47,11 @@ public class LocalTargetDefinitionTests extends AbstractTargetTest {
* @return target platform service
*/
protected ITargetPlatformService getTargetService() {
- ServiceReference reference = MacroPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
+ ServiceReference reference = PDETestsPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
assertNotNull("Missing target platform service", reference);
if (reference == null)
return null;
- return (ITargetPlatformService) MacroPlugin.getBundleContext().getService(reference);
+ return (ITargetPlatformService) PDETestsPlugin.getBundleContext().getService(reference);
}
/**
@@ -779,7 +778,7 @@ public class LocalTargetDefinitionTests extends AbstractTargetTest {
* @throws Exception
*/
protected ITargetDefinition readOldTarget(String name) throws Exception {
- URL url = MacroPlugin.getBundleContext().getBundle().getEntry("/tests/targets/target-files/" + name + ".target");
+ URL url = PDETestsPlugin.getBundleContext().getBundle().getEntry("/tests/targets/target-files/" + name + ".target");
File file = new File(FileLocator.toFileURL(url).getFile());
ITargetDefinition target = getNewTarget();
FileInputStream stream = new FileInputStream(file);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java
index b439c45..945bafa 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java
@@ -23,7 +23,7 @@ import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.pde.core.plugin.TargetPlatform;
import org.eclipse.pde.core.target.*;
import org.eclipse.pde.internal.core.target.*;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.osgi.framework.ServiceReference;
/**
@@ -47,11 +47,11 @@ public class TargetDefinitionPersistenceTests extends TestCase {
* @return target platform service
*/
protected ITargetPlatformService getTargetService() {
- ServiceReference reference = MacroPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
+ ServiceReference reference = PDETestsPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
assertNotNull("Missing target platform service", reference);
if (reference == null)
return null;
- return (ITargetPlatformService) MacroPlugin.getBundleContext().getService(reference);
+ return (ITargetPlatformService) PDETestsPlugin.getBundleContext().getService(reference);
}
/**
@@ -272,7 +272,7 @@ public class TargetDefinitionPersistenceTests extends TestCase {
* @throws Exception
*/
protected ITargetDefinition readOldTarget(String name) throws Exception {
- URL url = MacroPlugin.getBundleContext().getBundle().getEntry("/tests/targets/target-files/" + name + ".trgt");
+ URL url = PDETestsPlugin.getBundleContext().getBundle().getEntry("/tests/targets/target-files/" + name + ".trgt");
File file = new File(FileLocator.toFileURL(url).getFile());
ITargetDefinition target = getTargetService().newTarget();
FileInputStream stream = new FileInputStream(file);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java
index efe93bc..86321e2 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java
@@ -20,7 +20,7 @@ import junit.framework.*;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.pde.internal.core.XMLDefaultHandler;
import org.eclipse.pde.internal.core.util.SAXParserWrapper;
-import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
+import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.eclipse.pde.ui.tests.util.DOMParserWrapper;
import org.osgi.framework.Bundle;
import org.xml.sax.SAXException;
@@ -39,7 +39,7 @@ public class ParserWrapperTestCase extends TestCase {
protected void setUp() throws Exception {
super.setUp();
- MacroPlugin plugin = MacroPlugin.getDefault();
+ PDETestsPlugin plugin = PDETestsPlugin.getDefault();
if (plugin == null)
throw new Exception("ERROR: Macro plug-in uninitialized"); //$NON-NLS-1$
Bundle bundle = plugin.getBundle();