Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.ui.console/plugin.properties4
-rw-r--r--org.eclipse.ui.console/plugin.xml3
-rw-r--r--org.eclipse.ui.console/schema/consoleFactory.exsd118
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java5
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java16
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java8
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java6
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java120
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java17
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java4
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java118
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java1
12 files changed, 414 insertions, 6 deletions
diff --git a/org.eclipse.ui.console/plugin.properties b/org.eclipse.ui.console/plugin.properties
index 88f531090..d7846b2ea 100644
--- a/org.eclipse.ui.console/plugin.properties
+++ b/org.eclipse.ui.console/plugin.properties
@@ -20,4 +20,6 @@ ConsoleFontDefinition.description= The console text font is used by the generic
ConsoleFontDefinition.label= Console Text Font
ConsolePatternMatchListenerName= Console Pattern Match Listener
-ConsolePageParticipantName= Console Page Participant \ No newline at end of file
+ConsolePageParticipantName= Console Page Participant
+
+ConsoleFactoryName= Console Factory \ No newline at end of file
diff --git a/org.eclipse.ui.console/plugin.xml b/org.eclipse.ui.console/plugin.xml
index 7dda5e4da..e7451718d 100644
--- a/org.eclipse.ui.console/plugin.xml
+++ b/org.eclipse.ui.console/plugin.xml
@@ -19,8 +19,9 @@
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.expressions"/>
</requires>
- <extension-point id="consolePatternMatchListener" name="%ConsolePatternMatchListenerName" schema="schema/ConsolePatternMatchListener.exsd"/>
+ <extension-point id="consolePatternMatchListener" name="%ConsolePatternMatchListenerName" schema="schema/consolePatternMatchListener.exsd"/>
<extension-point id="consolePageParticipant" name="%ConsolePageParticipantName" schema="schema/consolePageParticipant.exsd"/>
+ <extension-point id="consoleFactory" name="%ConsoleFactoryName" schema="schema/consoleFactory.exsd"/>
<extension
diff --git a/org.eclipse.ui.console/schema/consoleFactory.exsd b/org.eclipse.ui.console/schema/consoleFactory.exsd
new file mode 100644
index 000000000..8e7a1002e
--- /dev/null
+++ b/org.eclipse.ui.console/schema/consoleFactory.exsd
@@ -0,0 +1,118 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.console">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui.console" id="consoleFactory" name="%ConsoleFactoryName"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="consoleFactory"/>
+ </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>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="consoleFactory">
+ <complexType>
+ <sequence>
+ <element ref="enablement"/>
+ </sequence>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="image" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </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>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
index 68ceb0dd6..76fcd8354 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
@@ -80,4 +80,9 @@ public interface IConsoleConstants {
* @since 3.1
*/
public static final String EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANT = "consolePageParticipant"; //$NON-NLS-1$
+
+ /**
+ * @since 3.1
+ */
+ public static final String EXTENSION_POINT_CONSOLE_FACTORY = "consoleFactory"; //$NON-NLS-1$
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java
new file mode 100644
index 000000000..657171ecd
--- /dev/null
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.console;
+
+public interface IConsoleFactory {
+ public void openConsole();
+
+}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java
index ad166d3a9..60b889537 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.ui.console;
+import org.eclipse.ui.internal.console.ConsoleFactoryExtension;
+
/**
* Manages consoles.
@@ -94,4 +96,10 @@ public interface IConsoleManager {
* @since 3.1
*/
public IConsolePageParticipantDelegate[] getPageParticipants(IConsole console);
+
+ /**
+ *
+ * @since 3.1
+ */
+ public ConsoleFactoryExtension[] getConsoleFactoryExtensions();
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
index b800728ab..fca1b2662 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
@@ -156,14 +156,14 @@ public class IOConsole extends AbstractConsole implements IDocumentListener {
/**
* @return Returns the attribute matching the specified key.
*/
- public String getAttribute(String key) {
- return (String)attributes.get(key);
+ public Object getAttribute(String key) {
+ return attributes.get(key);
}
/**
* @param key The key used to store the attribute
* @param value The attribute to set.
*/
- public void setAttribute(String key, String value) {
+ public void setAttribute(String key, Object value) {
synchronized(attributes) {
attributes.put(key, value);
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java
new file mode 100644
index 000000000..08b201b25
--- /dev/null
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.console;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.expressions.ExpressionTagNames;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPluginContribution;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsoleFactory;
+import org.osgi.framework.Bundle;
+
+/**
+ * @since 3.1
+ */
+public class ConsoleFactoryExtension implements IPluginContribution {
+
+ private IConfigurationElement fConfig;
+ private Expression fEnablementExpression;
+ private String fLabel;
+ private ImageDescriptor fImageDescriptor;
+ private IConsoleFactory fFactory;
+
+ ConsoleFactoryExtension(IConfigurationElement config) {
+ fConfig = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPluginContribution#getLocalId()
+ */
+ public String getLocalId() {
+ return fConfig.getAttribute("id"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPluginContribution#getPluginId()
+ */
+ public String getPluginId() {
+ return fConfig.getDeclaringExtension().getNamespace();
+ }
+
+ public boolean isEnabled() {
+ try {
+ EvaluationContext context = new EvaluationContext(null, this);
+ EvaluationResult evaluationResult = getEnablementExpression().evaluate(context);
+ return evaluationResult == EvaluationResult.TRUE;
+ } catch (CoreException e) {
+ ConsolePlugin.log(e);
+ return false;
+ }
+ }
+
+ public Expression getEnablementExpression() throws CoreException {
+ if (fEnablementExpression == null) {
+ IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT);
+ IConfigurationElement enablement = elements.length > 0 ? elements[0] : null;
+
+ if (enablement != null) {
+ fEnablementExpression = ExpressionConverter.getDefault().perform(enablement);
+ }
+ }
+ return fEnablementExpression;
+ }
+
+ public String getLabel() {
+ if (fLabel == null) {
+ fLabel = fConfig.getAttribute("label"); //$NON-NLS-1$
+ }
+ return fLabel;
+ }
+
+ /**
+ * @return
+ */
+ public ImageDescriptor getImageDescriptor() {
+ if (fImageDescriptor == null) {
+ try {
+ String path = fConfig.getAttributeAsIs("image"); //$NON-NLS-1$
+ if (path != null) {
+ Bundle bundle = Platform.getBundle(getPluginId());
+ URL url = bundle.getEntry("/"); //$NON-NLS-1$
+ url = new URL(url, path); //$NON-NLS-1$
+ fImageDescriptor = ImageDescriptor.createFromURL(url);
+ }
+
+ } catch (MalformedURLException e) {
+ ConsolePlugin.log(e);
+ }
+ }
+ return fImageDescriptor;
+ }
+
+ /**
+ * @return
+ * @throws CoreException
+ */
+ public IConsoleFactory createFactory() throws CoreException {
+ if (fFactory == null) {
+ fFactory = (IConsoleFactory) fConfig.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ return fFactory;
+ }
+}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
index 17eb9a790..02da542e4 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
@@ -61,6 +61,8 @@ public class ConsoleManager implements IConsoleManager {
private List fPatternMatchListeners;
private List fPageParticipants;
+
+ private List fConsoleFactoryExtensions;
/**
* Notifies a console listener of additions or removals
@@ -311,5 +313,20 @@ public class ConsoleManager implements IConsoleManager {
}
return (IConsolePageParticipantDelegate[]) list.toArray(new IConsolePageParticipantDelegate[0]);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.IConsoleManager#getConsoleFactories()
+ */
+ public ConsoleFactoryExtension[] getConsoleFactoryExtensions() {
+ if (fConsoleFactoryExtensions == null) {
+ fConsoleFactoryExtensions = new ArrayList();
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_FACTORY);
+ IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
+ for (int i = 0; i < configurationElements.length; i++) {
+ fConsoleFactoryExtensions.add(new ConsoleFactoryExtension(configurationElements[i]));
+ }
+ }
+ return (ConsoleFactoryExtension[]) fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]);
+ }
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
index e58b735fc..7cac797c3 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
@@ -74,6 +74,8 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
// actions
private PinConsoleAction fPinAction = null;
private ConsoleDropDownAction fDisplayConsoleAction = null;
+
+ private OpenConsoleAction fOpenConsoleAction = null;
private boolean isAvailable() {
return getPageBook() != null && !getPageBook().isDisposed();
@@ -293,6 +295,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
protected void createActions() {
fPinAction = new PinConsoleAction(this);
fDisplayConsoleAction = new ConsoleDropDownAction(this);
+ fOpenConsoleAction = new OpenConsoleAction();
}
protected void configureToolBar(IToolBarManager mgr) {
@@ -301,6 +304,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
mgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
mgr.add(fPinAction);
mgr.add(fDisplayConsoleAction);
+// mgr.add(fOpenConsoleAction);
}
/* (non-Javadoc)
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
new file mode 100644
index 000000000..1f8d1d257
--- /dev/null
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.console;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleFactory;
+
+/**
+ * @since 3.1
+ */
+public class OpenConsoleAction extends Action implements IMenuCreator {
+
+ private ConsoleFactoryExtension[] fFactoryExtensions;
+ private Menu fMenu;
+
+ public OpenConsoleAction() {
+ fFactoryExtensions = ConsolePlugin.getDefault().getConsoleManager().getConsoleFactoryExtensions();
+ setText("Open Console");
+ setToolTipText("Open Console");
+ setImageDescriptor(ConsolePluginImages.getImageDescriptor(IConsoleConstants.IMG_VIEW_CONSOLE));
+ setMenuCreator(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#dispose()
+ */
+ public void dispose() {
+ fFactoryExtensions = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+ */
+ public Menu getMenu(Control parent) {
+ if (fMenu != null) {
+ fMenu.dispose();
+ }
+
+ fMenu= new Menu(parent);
+ for (int i = 0; i < fFactoryExtensions.length; i++) {
+ ConsoleFactoryExtension extension = fFactoryExtensions[i];
+ if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) {
+ String label = extension.getLabel();
+ ImageDescriptor image = extension.getImageDescriptor();
+ addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension));
+ }
+ }
+ return fMenu;
+ }
+
+ protected void addActionToMenu(Menu parent, Action action) {
+ ActionContributionItem item= new ActionContributionItem(action);
+ item.fill(parent, -1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+ */
+ public Menu getMenu(Menu parent) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private class ConsoleFactoryAction extends Action {
+
+ private ConsoleFactoryExtension fConfig;
+ private IConsoleFactory fFactory;
+
+ public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) {
+ setText(label);
+ if (image != null) {
+ setImageDescriptor(image);
+ }
+ fConfig = extension;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ try {
+ if (fFactory == null) {
+ fFactory = fConfig.createFactory();
+ }
+
+ fFactory.openConsole();
+ } catch (CoreException e) {
+ ConsolePlugin.log(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent(Event event) {
+ run();
+ }
+ }
+}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java
index f04b7709e..e63e46dec 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java
@@ -1,4 +1,3 @@
-
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials

Back to the top