Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-12-27 12:10:13 -0500
committerAndrey Loskutov2017-12-27 12:10:13 -0500
commit9918ee7e4b95e09fded8c210ad3d5e0f046f1045 (patch)
tree749d700ed68ad141b68c7ff397cd58a9fc085183 /org.eclipse.ui.console
parente323d5f8870d7c4788f5812ef6a349abe1ddba52 (diff)
downloadeclipse.platform.debug-9918ee7e4b95e09fded8c210ad3d5e0f046f1045.tar.gz
eclipse.platform.debug-9918ee7e4b95e09fded8c210ad3d5e0f046f1045.tar.xz
eclipse.platform.debug-9918ee7e4b95e09fded8c210ad3d5e0f046f1045.zip
fixed Separated semantically different "New Console" contribution from other console *page* contributions by placing it on top and adding a separator after it. Additionally added a "Console" icon to it and sorted remaining contributions alphabetically. Change-Id: I2bfb18753637fe84c668f7a93dcd7c878a19d7f7 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/plugin.xml1
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java21
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java49
3 files changed, 42 insertions, 29 deletions
diff --git a/org.eclipse.ui.console/plugin.xml b/org.eclipse.ui.console/plugin.xml
index cef75eac1..c2d548e66 100644
--- a/org.eclipse.ui.console/plugin.xml
+++ b/org.eclipse.ui.console/plugin.xml
@@ -75,6 +75,7 @@ M4 = Platform-specific fourth key
point="org.eclipse.ui.console.consoleFactories">
<consoleFactory
label="%consoleViewConsoleFactory.name"
+ icon="$nl$/icons/full/cview16/console_view.png"
class="org.eclipse.ui.internal.console.ConsoleViewConsoleFactory"/>
</extension>
<extension
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
index 874f3f9fe..bb2191907 100644
--- 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
@@ -17,15 +17,12 @@ 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.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Path;
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;
@@ -46,17 +43,19 @@ public class ConsoleFactoryExtension implements IPluginContribution {
fConfig = config;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPluginContribution#getLocalId()
+ /**
+ *
+ * @return {@code true} if this is a "New Console" contribution
*/
+ public boolean isNewConsoleExtenson() {
+ return ConsoleViewConsoleFactory.class.getName().equals(fConfig.getAttribute("class")); //$NON-NLS-1$
+ }
+
@Override
public String getLocalId() {
return fConfig.getAttribute("id"); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPluginContribution#getPluginId()
- */
@Override
public String getPluginId() {
return fConfig.getContributor().getName();
@@ -89,10 +88,16 @@ public class ConsoleFactoryExtension implements IPluginContribution {
return fEnablementExpression;
}
+ /**
+ * @return console label, never null
+ */
public String getLabel() {
if (fLabel == null) {
fLabel = fConfig.getAttribute("label"); //$NON-NLS-1$
}
+ if (fLabel == null) {
+ fLabel = "?"; //$NON-NLS-1$
+ }
return fLabel;
}
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
index d3ed73344..0927e14a2 100644
--- 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
@@ -10,10 +10,14 @@
*******************************************************************************/
package org.eclipse.ui.internal.console;
+import java.util.Arrays;
+import java.util.Comparator;
+
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.action.Separator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -35,7 +39,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
private Menu fMenu;
public OpenConsoleAction() {
- fFactoryExtensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions();
+ fFactoryExtensions = getSortedFactories();
setText(ConsoleMessages.OpenConsoleAction_0);
setToolTipText(ConsoleMessages.OpenConsoleAction_1);
setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON));
@@ -44,18 +48,31 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_CONSOLE_ACTION);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuCreator#dispose()
- */
+ private ConsoleFactoryExtension[] getSortedFactories() {
+ ConsoleFactoryExtension[] factoryExtensions = ((ConsoleManager) ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions();
+ Arrays.sort(factoryExtensions, new Comparator<ConsoleFactoryExtension>() {
+
+ @Override
+ public int compare(ConsoleFactoryExtension e1, ConsoleFactoryExtension e2) {
+ if (e1.isNewConsoleExtenson()) {
+ return -1;
+ }
+ if (e2.isNewConsoleExtenson()) {
+ return 1;
+ }
+ String first = e1.getLabel();
+ String second = e2.getLabel();
+ return first.compareTo(second);
+ }
+ });
+ return factoryExtensions;
+ }
+
@Override
public void dispose() {
fFactoryExtensions = null;
}
- /*
- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
- * @since 3.5
- */
@Override
public void runWithEvent(Event event) {
if (event.widget instanceof ToolItem) {
@@ -70,9 +87,6 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
- */
@Override
public Menu getMenu(Control parent) {
if (fMenu != null) {
@@ -88,6 +102,9 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
ImageDescriptor image = extension.getImageDescriptor();
addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension), accel);
accel++;
+ if (extension.isNewConsoleExtenson()) {
+ new Separator("new").fill(fMenu, -1); //$NON-NLS-1$
+ }
}
}
return fMenu;
@@ -108,9 +125,6 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
item.fill(parent, -1);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
- */
@Override
public Menu getMenu(Menu parent) {
return null;
@@ -129,10 +143,6 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
fConfig = extension;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
@Override
public void run() {
try {
@@ -146,9 +156,6 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
- */
@Override
public void runWithEvent(Event event) {
run();

Back to the top