Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDejan Gloszic2006-01-17 08:04:41 -0500
committerDejan Gloszic2006-01-17 08:04:41 -0500
commite473e78be29db77a2934fc3cd3bc0aca86752678 (patch)
treedd8859afb97abf6992f515e954f134e6b9d1900a /org.eclipse.ui.intro
parentcf27d0c9f82909089a6a348b54b9521d7fa9732d (diff)
downloadeclipse.platform.ua-e473e78b.tar.gz
eclipse.platform.ua-e473e78b.tar.xz
eclipse.platform.ua-e473e78b.zip
*** empty log message ***
Diffstat (limited to 'org.eclipse.ui.intro')
-rw-r--r--org.eclipse.ui.intro/schema/introContentFileSpec.html5
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java48
2 files changed, 53 insertions, 0 deletions
diff --git a/org.eclipse.ui.intro/schema/introContentFileSpec.html b/org.eclipse.ui.intro/schema/introContentFileSpec.html
index d0ea90ad1..f19e7a19f 100644
--- a/org.eclipse.ui.intro/schema/introContentFileSpec.html
+++ b/org.eclipse.ui.intro/schema/introContentFileSpec.html
@@ -119,6 +119,11 @@ The following predefined actions are included in the intro framework:
no parameters required<br>
<br>
+<b>execute</b> - executes the specified command. See the <code>serialize()</code> method on <code>org.eclipse.core.command.ParameterizedCommand</code> for details of the command serialization format. Since 3.2.<br>
+<i>command</i> - a serialized <code>ParameterizedCommand</code><br>
+<i>standby (optional) = ("true" | "false") "false"</i> - indicate whether to set the intro into standby mode after executing the command<br>
+<br>
+
<b>navigate</b> - navigate through the intro pages in a given direction or return to the home page<br>
<i>direction = ("backward" | "forward" | "home")</i> - specifies the direction to navigate<br>
<br>
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
index 57dea59f2..8285dbaff 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java
@@ -16,6 +16,8 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.CommandException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.util.Geometry;
@@ -24,9 +26,11 @@ import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.internal.RectangleAnimation;
import org.eclipse.ui.internal.intro.impl.IIntroConstants;
import org.eclipse.ui.internal.intro.impl.IntroPlugin;
@@ -83,6 +87,7 @@ public class IntroURL implements IIntroURL {
public static final String SHOW_MESSAGE = "showMessage"; //$NON-NLS-1$
public static final String NAVIGATE = "navigate"; //$NON-NLS-1$
public static final String SWITCH_TO_LAUNCH_BAR = "switchToLaunchBar"; //$NON-NLS-1$
+ public static final String EXECUTE = "execute"; //$NON-NLS-1$
/**
* Constants that represent valid action keys.
@@ -99,6 +104,7 @@ public class IntroURL implements IIntroURL {
public static final String KEY_EMBED = "embed"; //$NON-NLS-1$
public static final String KEY_EMBED_TARGET = "embedTarget"; //$NON-NLS-1$
public static final String KEY_DECODE = "decode"; //$NON-NLS-1$
+ public static final String KEY_COMAND = "command"; //$NON-NLS-1$
public static final String VALUE_BACKWARD = "backward"; //$NON-NLS-1$
@@ -185,6 +191,10 @@ public class IntroURL implements IIntroURL {
// the parameters and the standby state.
return runAction(getParameter(KEY_PLUGIN_ID),
getParameter(KEY_CLASS), parameters, getParameter(KEY_STANDBY));
+
+ else if (action.equals(EXECUTE))
+ // execute a serialized command
+ return executeCommand(getParameter(KEY_COMAND), getParameter(KEY_STANDBY));
else if (action.equals(SHOW_PAGE))
// display an Intro Page.
@@ -297,6 +307,44 @@ public class IntroURL implements IIntroURL {
return false;
}
}
+
+ /**
+ * Executes a serialized <code>ParameterizedCommand</code>. Uses
+ * {@link ICommandService#deserialize(String)} to convert the <code>command</code> argument
+ * into the parameterized command.
+ */
+ private boolean executeCommand(String command, String standbyState) {
+ ICommandService commandService = getCommandService();
+ if (commandService == null) {
+ Log.error("Could not get ICommandService while trying to execute: " + command, null); //$NON-NLS-1$
+ return false;
+ }
+
+ try {
+ ParameterizedCommand pCommand = commandService.deserialize(command);
+ pCommand.executeWithChecks(null, null);
+
+ // Executed command successfully. Now set intro standby if needed.
+ if (standbyState == null)
+ return true;
+ return setStandbyState(standbyState);
+ } catch (CommandException ex) {
+ Log.error("Could not execute command: " + command, ex); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ private ICommandService getCommandService() {
+ IWorkbench wb = PlatformUI.getWorkbench();
+ if (wb != null) {
+ Object serviceObject = wb.getAdapter(ICommandService.class);
+ if (serviceObject != null) {
+ ICommandService service = (ICommandService)serviceObject;
+ return service;
+ }
+ }
+ return null;
+ }
/**

Back to the top