Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2003-03-05 18:08:48 +0000
committerVeronika Irvine2003-03-05 18:08:48 +0000
commit5f0a43f5b96ff1bf18fe8995d1b162bd6a21031c (patch)
tree9a1e83e7cfeb5b708432975c6b7735159ea70492 /examples/org.eclipse.swt.examples.launcher
parent8d95651bd484e1f1f2a8817b538fa6ab423708e4 (diff)
downloadeclipse.platform.swt-5f0a43f5b96ff1bf18fe8995d1b162bd6a21031c.tar.gz
eclipse.platform.swt-5f0a43f5b96ff1bf18fe8995d1b162bd6a21031c.tar.xz
eclipse.platform.swt-5f0a43f5b96ff1bf18fe8995d1b162bd6a21031c.zip
Converting Binary files to ASCII
Diffstat (limited to 'examples/org.eclipse.swt.examples.launcher')
-rw-r--r--examples/org.eclipse.swt.examples.launcher/.project60
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/build.properties24
-rw-r--r--examples/org.eclipse.swt.examples.launcher/doc-html/hglegal2002.htm28
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html90
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.properties78
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.xml160
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java2
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java750
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java450
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java24
10 files changed, 833 insertions, 833 deletions
diff --git a/examples/org.eclipse.swt.examples.launcher/.project b/examples/org.eclipse.swt.examples.launcher/.project
index 3aa0f07860..bcb6941eaa 100644
--- a/examples/org.eclipse.swt.examples.launcher/.project
+++ b/examples/org.eclipse.swt.examples.launcher/.project
@@ -1,30 +1,30 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.swt.examples.launcher</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.swt</project>
- <project>org.eclipse.swt.examples</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.swt.examples.launcher</name>
+ <comment></comment>
+ <projects>
+ <project>org.eclipse.swt</project>
+ <project>org.eclipse.swt.examples</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/org.eclipse.swt.examples.launcher/build.properties b/examples/org.eclipse.swt.examples.launcher/build.properties
index 8d7ddf74e0..a5438fcbe1 100755
--- a/examples/org.eclipse.swt.examples.launcher/build.properties
+++ b/examples/org.eclipse.swt.examples.launcher/build.properties
@@ -1,12 +1,12 @@
-bin.includes = doc/,\
- doc-html/,\
- icons/,\
- schema/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.launcher.jar = src/
+bin.includes = doc/,\
+ doc-html/,\
+ icons/,\
+ schema/,\
+ plugin.properties,\
+ plugin.xml,\
+ about.html,\
+ *.jar
+
+src.includes = about.html
+
+source.launcher.jar = src/
diff --git a/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal2002.htm b/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal2002.htm
index 74393f08f3..5df454d51a 100644
--- a/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal2002.htm
+++ b/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal2002.htm
@@ -1,14 +1,14 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
-</body>
-</html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
+ <title>Legal Notices</title>
+</head>
+<body>
+
+<h3>
+<a NAME="Notices"></a>Notices</h3>
+(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
+</body>
+</html>
diff --git a/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html b/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html
index 6ed28916dc..8e134ddd8c 100755
--- a/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html
+++ b/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html
@@ -1,45 +1,45 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>SWT - Example Launcher</title>
-</head>
-<body>
-
-<h2>SWT Example Launcher</h2>
-
-<p>
-The Example Launcher is used to launch SWT examples which can either be Workbench Views,
-or Standalone applications.
-</p>
-
-<ul>
-<li>Workbench Views are examples that are integrated into Eclipse. When the Launcher
-starts a Workbench View, it is opened in the currently active perspective.
-<li>Standalone applications are launched in a separate window.
-</ul>
-
-<h3>Running the Example Launcher</h3>
-
-<p>
-From the Window menu, select Show View --> Other.
-In the Show View dialog, expand SWT Examples and select the SWT Example Launcher view.
-A view containing a list of examples will appear in your current perspective.
-Select an example from the list. A brief description of the example is displayed.
-Click on the Run button to launch the example.
-</p>
-
-
-<h3>Details</h3>
-<p>The example launcher view contains a tree list, a text area, and a button.
-The tree list contains a list of all the SWT examples you can choose
-to run. When an example is selected from the tree, the text area
-displays a short description of the example. The selected example can
-be launched by clicking on the Run button. Standalone examples are run in the
-same thread as the workbench's UI but they are not integrated into the perspective.
-The launcher invokes the <code>open()</code> method of the standalone example.
-</p>
-
-<p><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation and others 2000, 2002. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
-</body>
-</html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>SWT - Example Launcher</title>
+</head>
+<body>
+
+<h2>SWT Example Launcher</h2>
+
+<p>
+The Example Launcher is used to launch SWT examples which can either be Workbench Views,
+or Standalone applications.
+</p>
+
+<ul>
+<li>Workbench Views are examples that are integrated into Eclipse. When the Launcher
+starts a Workbench View, it is opened in the currently active perspective.
+<li>Standalone applications are launched in a separate window.
+</ul>
+
+<h3>Running the Example Launcher</h3>
+
+<p>
+From the Window menu, select Show View --> Other.
+In the Show View dialog, expand SWT Examples and select the SWT Example Launcher view.
+A view containing a list of examples will appear in your current perspective.
+Select an example from the list. A brief description of the example is displayed.
+Click on the Run button to launch the example.
+</p>
+
+
+<h3>Details</h3>
+<p>The example launcher view contains a tree list, a text area, and a button.
+The tree list contains a list of all the SWT examples you can choose
+to run. When an example is selected from the tree, the text area
+displays a short description of the example. The selected example can
+be launched by clicking on the Run button. Standalone examples are run in the
+same thread as the workbench's UI but they are not integrated into the perspective.
+The launcher invokes the <code>open()</code> method of the standalone example.
+</p>
+
+<p><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation and others 2000, 2002. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
+</body>
+</html>
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.properties b/examples/org.eclipse.swt.examples.launcher/plugin.properties
index 05c328a5f7..28db6584d6 100755
--- a/examples/org.eclipse.swt.examples.launcher/plugin.properties
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.properties
@@ -1,39 +1,39 @@
-providerName = Eclipse.org
-plugin.SWTLauncherExample.name = SWT Launcher Example Plugin
-category.SWTExamples.name = SWT Examples
-view.LauncherExample.name = SWT Example Launcher
-
-extension-point.launchItems.name = Launch Items
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.LauncherExample.name = Launcher
-launchitem.LauncherExample.description = \
- The Example Launcher is used to launch SWT examples which can either be \
- Workbench Views, or Standalone applications.\n\n\
- Workbench Views are examples that are integrated into Eclipse. When the Launcher \
- starts a Workbench View, it is opened in the currently active perspective.\n\n\
- Standalone applications are launched in a separate window.
-
-error.CouldNotLoadResources = Unable to load resources
-error.CouldNotFindRegisteredExtensions = Could Not Find Registered Extensions
-error.IncompleteProgramLaunchItem = Incomplete XML ProgramLaunchItem definition, id = {0}
-error.IncompleteViewLaunchItem = Incomplete XML ViewLaunchItem definition, id = {0}
-error.IncompleteLaunchItem = Incomplete or unrecognized XML LaunchItem definition, id = {0}
-
-launchitem.Null.description = <<no item selected>>
-
-launchitem.Missing.name = <<unnamed>>
-launchitem.Missing.description = <<no description available>>
-
-view.launchGroup.text = Examples
-view.launchButton.text = Run
-view.descriptionGroup.text = Description
-
-run.error.Invocation = A fatal error occurred while launching the program.
-run.error.DoesNotImplementMethod = The class does not implement the open() method.
-run.error.CouldNotFindClass = Could not find the class to run.
-run.error.CouldNotInstantiateClass = Could not instantiate the class to run.
+providerName = Eclipse.org
+plugin.SWTLauncherExample.name = SWT Launcher Example Plugin
+category.SWTExamples.name = SWT Examples
+view.LauncherExample.name = SWT Example Launcher
+
+extension-point.launchItems.name = Launch Items
+
+launchcategory.SWTViewExamples.name = Workbench Views
+launchcategory.SWTViewExamples.description = \
+ A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
+ These examples will create a new View in the current Perspective.
+
+launchitem.LauncherExample.name = Launcher
+launchitem.LauncherExample.description = \
+ The Example Launcher is used to launch SWT examples which can either be \
+ Workbench Views, or Standalone applications.\n\n\
+ Workbench Views are examples that are integrated into Eclipse. When the Launcher \
+ starts a Workbench View, it is opened in the currently active perspective.\n\n\
+ Standalone applications are launched in a separate window.
+
+error.CouldNotLoadResources = Unable to load resources
+error.CouldNotFindRegisteredExtensions = Could Not Find Registered Extensions
+error.IncompleteProgramLaunchItem = Incomplete XML ProgramLaunchItem definition, id = {0}
+error.IncompleteViewLaunchItem = Incomplete XML ViewLaunchItem definition, id = {0}
+error.IncompleteLaunchItem = Incomplete or unrecognized XML LaunchItem definition, id = {0}
+
+launchitem.Null.description = <<no item selected>>
+
+launchitem.Missing.name = <<unnamed>>
+launchitem.Missing.description = <<no description available>>
+
+view.launchGroup.text = Examples
+view.launchButton.text = Run
+view.descriptionGroup.text = Description
+
+run.error.Invocation = A fatal error occurred while launching the program.
+run.error.DoesNotImplementMethod = The class does not implement the open() method.
+run.error.CouldNotFindClass = Could not find the class to run.
+run.error.CouldNotInstantiateClass = Could not instantiate the class to run.
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.xml b/examples/org.eclipse.swt.examples.launcher/plugin.xml
index 5f385382f3..3d7fbd737f 100755
--- a/examples/org.eclipse.swt.examples.launcher/plugin.xml
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.xml
@@ -1,80 +1,80 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="org.eclipse.swt.examples.launcher"
- name="%plugin.SWTLauncherExample.name"
- version="2.1.0"
- provider-name="%providerName"
- class="org.eclipse.swt.examples.launcher.LauncherPlugin">
-
-<!-- Runtime -->
-<!-- Runtime -->
-<!-- Runtime -->
-<!-- Runtime -->
- <runtime>
- <library name="launcher.jar">
- <packages prefixes="org.eclipse.swt.examples.launcher"/>
- </library>
- </runtime>
-<!-- Required plugins -->
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.swt"/>
- <import plugin="org.eclipse.jdt.launching"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.core.boot"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.swt.examples"/>
- </requires>
-
-
-<!-- Extension points -->
- <extension-point id="launchItems" name="%extension-point.launchItems.name" schema="schema/org.eclipse.swt.examples.launcher.launchItems.exsd"/>
-
-<!-- Extensions -->
- <extension
- id="application"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- name="%launchitem.LauncherApplication.name"
- class="org.eclipse.swt.examples.launcher.LauncherApplication">
- </run>
- </application>
- </extension>
- <extension
- point="org.eclipse.ui.views">
- <category
- name="%category.SWTExamples.name"
- id="org.eclipse.swt.examples.category">
- </category>
- <view
- name="%view.LauncherExample.name"
- icon="icons/launcher_example.gif"
- category="org.eclipse.swt.examples.category"
- class="org.eclipse.swt.examples.launcher.LauncherView"
- id="org.eclipse.swt.examples.launcher.view">
- </view>
- </extension>
- <extension
- point="org.eclipse.swt.examples.launcher.launchItems">
- <category
- name="%launchcategory.SWTViewExamples.name"
- description="%launchcategory.SWTViewExamples.description"
- id="org.eclipse.swt.examples.launchViewCategory">
- </category>
- <item
- name="%launchitem.LauncherExample.name"
- enabled="false"
- icon="icons/launcher_example.gif"
- description="%launchitem.LauncherExample.description"
- category="org.eclipse.swt.examples.launchViewCategory"
- id="org.eclipse.swt.examples.launcher.viewlauncher">
- <view
- viewId="org.eclipse.swt.examples.launcher.view">
- </view>
- </item>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin
+ id="org.eclipse.swt.examples.launcher"
+ name="%plugin.SWTLauncherExample.name"
+ version="2.1.0"
+ provider-name="%providerName"
+ class="org.eclipse.swt.examples.launcher.LauncherPlugin">
+
+<!-- Runtime -->
+<!-- Runtime -->
+<!-- Runtime -->
+<!-- Runtime -->
+ <runtime>
+ <library name="launcher.jar">
+ <packages prefixes="org.eclipse.swt.examples.launcher"/>
+ </library>
+ </runtime>
+<!-- Required plugins -->
+ <requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.swt"/>
+ <import plugin="org.eclipse.jdt.launching"/>
+ <import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.core.boot"/>
+ <import plugin="org.eclipse.jdt.core"/>
+ <import plugin="org.eclipse.swt.examples"/>
+ </requires>
+
+
+<!-- Extension points -->
+ <extension-point id="launchItems" name="%extension-point.launchItems.name" schema="schema/org.eclipse.swt.examples.launcher.launchItems.exsd"/>
+
+<!-- Extensions -->
+ <extension
+ id="application"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run
+ name="%launchitem.LauncherApplication.name"
+ class="org.eclipse.swt.examples.launcher.LauncherApplication">
+ </run>
+ </application>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%category.SWTExamples.name"
+ id="org.eclipse.swt.examples.category">
+ </category>
+ <view
+ name="%view.LauncherExample.name"
+ icon="icons/launcher_example.gif"
+ category="org.eclipse.swt.examples.category"
+ class="org.eclipse.swt.examples.launcher.LauncherView"
+ id="org.eclipse.swt.examples.launcher.view">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.swt.examples.launcher.launchItems">
+ <category
+ name="%launchcategory.SWTViewExamples.name"
+ description="%launchcategory.SWTViewExamples.description"
+ id="org.eclipse.swt.examples.launchViewCategory">
+ </category>
+ <item
+ name="%launchitem.LauncherExample.name"
+ enabled="false"
+ icon="icons/launcher_example.gif"
+ description="%launchitem.LauncherExample.description"
+ category="org.eclipse.swt.examples.launchViewCategory"
+ id="org.eclipse.swt.examples.launcher.viewlauncher">
+ <view
+ viewId="org.eclipse.swt.examples.launcher.view">
+ </view>
+ </item>
+ </extension>
+
+</plugin>
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
index 11ff9372b0..11ebb38e50 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
@@ -3,7 +3,7 @@ package org.eclipse.swt.examples.launcher; /* * Copyright (c) 2000, 2002 IBM C
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html */ import org.eclipse.swt.graphics.*;
/** * ItemDescriptor collects information about a launch item. */
-class ItemDescriptor {
+class ItemDescriptor {
private String id;
private String name;
private String description; private Image icon; private String view; private String mainType; private String pluginId;
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
index 21a680140a..ed1b30cd3a 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
@@ -1,379 +1,379 @@
-package org.eclipse.swt.examples.launcher;
-
-/*
+package org.eclipse.swt.examples.launcher;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is 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
- */
-
-import java.io.*; import java.net.*; import java.text.*; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.swt.graphics.*; import org.eclipse.ui.plugin.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class LauncherPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static LauncherPlugin plugin;
- private static ResourceBundle resourceBundle;
-
- private static final String
- LAUNCH_ITEMS_POINT_ID = "org.eclipse.swt.examples.launcher.launchItems",
- LAUNCH_ITEMS_XML_CATEGORY = "category",
- LAUNCH_ITEMS_XML_ITEM = "item",
- LAUNCH_ITEMS_XML_ITEM_ICON = "icon",
- LAUNCH_ITEMS_XML_ITEM_DESCRIPTION = "description",
- LAUNCH_ITEMS_XML_PROGRAM = "program",
- LAUNCH_ITEMS_XML_PROGRAM_PLUGIN = "pluginId",
- LAUNCH_ITEMS_XML_PROGRAM_CLASS = "mainClass",
- LAUNCH_ITEMS_XML_VIEW = "view",
- LAUNCH_ITEMS_XML_VIEW_VIEWID = "viewId",
- LAUNCH_ITEMS_XML_ATTRIB_ID = "id",
- LAUNCH_ITEMS_XML_ATTRIB_NAME = "name",
- LAUNCH_ITEMS_XML_ATTRIB_ENABLED = "enabled",
- LAUNCH_ITEMS_XML_ATTRIB_CATEGORY = "category",
- LAUNCH_ITEMS_XML_VALUE_TRUE = "true",
- LAUNCH_ITEMS_XML_VALUE_FALSE = "false";
-
- static final int
- liClosedFolder = 0,
- liOpenFolder = 1,
- liGenericExample = 2;
- static final String[] imageLocations = {
- "icons/closedFolder.gif",
- "icons/openFolder.gif",
- "icons/generic_example.gif" };
- static Image images[];
-
- /**
- * Constructs the LauncherPlugin.
- */
- public LauncherPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- resourceBundle = descriptor.getResourceBundle();
- }
-
- /**
- * Clean up
- */
- public void shutdown() throws CoreException {
- super.shutdown();
- freeResources();
- }
-
- /**
- * Returns the shared instance.
- */
- public static LauncherPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Loads the resources
- */
- public static void initResources() {
- if (images == null) {
- images = new Image[imageLocations.length];
-
- for (int i = 0; i < imageLocations.length; ++i) {
- images[i] = getImageFromPlugin(plugin.getDescriptor(), imageLocations[i]);
- if (images[i] == null) {
- freeResources();
- logError(getResourceString("error.CouldNotLoadResources"), null);
- throw new IllegalStateException();
- }
- }
- }
- }
-
- /**
- * Frees the resources
- */
- public static void freeResources() {
- if (images != null) {
- for (int i = 0; i < images.length; ++i) {
- final Image image = images[i];
- if (image != null) image.dispose();
- }
- images = null;
- }
- }
-
- /**
- * Log an error to the ILog for this plugin
- *
- * @param message the localized error message text
- * @param exception the associated exception, or null
- */
- public static void logError(String message, Throwable exception) {
- plugin.getLog().log(new Status(IStatus.ERROR, plugin.getDescriptor().getUniqueIdentifier(),
- 0, message, exception));
- }
-
- /**
- * Returns a string from the resource bundle.
- * We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String getResourceString(String key) {
- try {
- return resourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Returns a string from the resource bundle and binds it
- * with the given arguments. If the key is not found,
- * return the key.
- */
- public static String getResourceString(String key, Object[] args) {
- try {
- return MessageFormat.format(getResourceString(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Constructs a list of available programs from registered extensions.
- *
- * @return an ItemTreeNode representing the root of a tree of items (the root is not to be displayed)
- */
- public static ItemTreeNode getLaunchItemTree() {
- ItemTreeNode categoryTree =
- new ItemTreeNode(new ItemDescriptor("<<Root>>", "<<Root>>", null, null, null, null, null));
-
- // get the platform's public plugin registry
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- // retrieve all configuration elements registered at our launchItems extension-point
- IConfigurationElement[] configurationElements =
- pluginRegistry.getConfigurationElementsFor(LAUNCH_ITEMS_POINT_ID);
-
- if (configurationElements == null || configurationElements.length == 0) {
- logError(getResourceString("error.CouldNotFindRegisteredExtensions"), null);
- return categoryTree;
- }
-
- /* Collect all launch categories -- coalesce those with same ID */
- HashMap idMap = new HashMap();
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (idMap.containsKey(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- final String attribName = getItemName(ce);
- ItemDescriptor theDescriptor = new ItemDescriptor(attribId, attribName,
- getItemDescription(ce), null, null, null, null);
- idMap.put(attribId, new ItemTreeNode(theDescriptor));
- }
- }
-
- /* Generate launch category hierarchy */
- Set tempIdSet = new HashSet(); // used to prevent duplicates from being entered into the tree
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (tempIdSet.contains(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- final ItemTreeNode theNode = (ItemTreeNode) idMap.get(attribId);
- addItemByCategory(ce, categoryTree, theNode, idMap);
- tempIdSet.add(attribId);
- }
- }
-
- /* Generate program tree */
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (idMap.containsKey(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- // ignore
- } else if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_ITEM)) {
- final String enabled = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ENABLED,
- LAUNCH_ITEMS_XML_VALUE_TRUE);
- if (enabled.equalsIgnoreCase(LAUNCH_ITEMS_XML_VALUE_FALSE)) continue;
- ItemDescriptor theDescriptor = createItemDescriptor(ce, attribId);
-
- if (theDescriptor != null) {
- final ItemTreeNode theNode = new ItemTreeNode(theDescriptor);
- addItemByCategory(ce, categoryTree, theNode, idMap);
- idMap.put(attribId, theNode);
- }
- }
- }
- return categoryTree;
- }
-
-
- /**
- * Adds an item to the category tree.
- */
- private static void addItemByCategory(IConfigurationElement ce, ItemTreeNode root,
- ItemTreeNode theNode, HashMap idMap) {
- final String attribCategory = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_CATEGORY, null);
-
- // locate the parent node
- ItemTreeNode parentNode = null;
- if (attribCategory != null) {
- parentNode = (ItemTreeNode) idMap.get(attribCategory);
- }
- if (parentNode == null) parentNode = root;
-
- // add the item
- parentNode.addSortedNode(theNode);
- }
-
- /**
- * Creates an ItemDescriptor from an XML definition.
- *
- * @param ce the IConfigurationElement describing the item
- * @param attribId the attribute id
- * @return a new ItemDescriptor, or null if an error occurs
- */
- private static ItemDescriptor createItemDescriptor(IConfigurationElement ce, String attribId) {
- final String attribName = getItemName(ce);
- final Image attribIcon = getItemIcon(ce);
- final String attribDescription = getItemDescription(ce);
-
- IConfigurationElement viewCE = getItemElement(ce, LAUNCH_ITEMS_XML_VIEW);
- if (viewCE != null) {
- //Item is a view
- final String attribView = getItemAttribute(viewCE, LAUNCH_ITEMS_XML_VIEW_VIEWID, null);
- if (attribView == null) {
- logError(getResourceString("error.IncompleteViewLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, attribView, null, null);
- } else {
- //Item is a standalone
- IConfigurationElement programCE = getItemElement(ce, LAUNCH_ITEMS_XML_PROGRAM);
- if (programCE != null) {
- final String attribPluginId = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_PLUGIN, null);
- final String attribClass = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_CLASS, null);
- if (attribClass == null || attribPluginId == null) {
- logError(getResourceString("error.IncompleteProgramLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, null, attribClass, attribPluginId);
- } else {
- logError(getResourceString("error.IncompleteLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- }
- }
-
- /**
- * Returns the first instance of a particular child XML element.
- *
- * @param ce the IConfigurationElement parent
- * @param element the name of the element to fetch
- * @return the element's IConfigurationElement, or null if not found
- */
- private static IConfigurationElement getItemElement(IConfigurationElement ce, String element) {
- IConfigurationElement[] elementCEs = ce.getChildren(element);
- return (elementCEs != null && elementCEs.length != 0) ? elementCEs[0] : null;
- }
-
- /**
- * Returns the value of an XML attribute for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @param attribute the attribute to fetch
- * @param defaultValue the value to return if the attribute is not found
- * @return the attribute value
- */
- private static String getItemAttribute(IConfigurationElement ce, String attribute, String defaultValue) {
- String value = ce.getAttribute(attribute);
- return (value != null) ? value : defaultValue;
- }
-
- /**
- * Returns the description string given the IConfigurationElement for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return a newline-delimited string that describes this item, or null if none
- */
- private static String getItemDescription(IConfigurationElement ce) {
- String description = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_DESCRIPTION, "");
- return (description.length() == 0) ? null : description;
- }
-
- /**
- * Returns the name of an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return the attribute value
- */
- private static String getItemName(IConfigurationElement ce) {
- return getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_NAME,
- getResourceString("launchitem.Missing.name"));
- }
-
-
- /**
- * Returns the icon for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return an icon
- */
- private static Image getItemIcon(IConfigurationElement ce) {
- String iconPath = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_ICON, "");
- if (iconPath.length() != 0) {
- Image icon = getImageFromPlugin(ce.getDeclaringExtension().getDeclaringPluginDescriptor(),
- iconPath);
- if (icon != null) {
- Image[] newImages = new Image[images.length + 1];
- System.arraycopy(images, 0, newImages, 0, images.length);
- newImages[images.length] = icon;
- images = newImages;
- return icon;
- }
- }
- return images[liGenericExample];
- }
-
- /**
- * Gets an image from a path relative to the plugin install directory.
- *
- * @param pd the plugin descriptor for the plugin with the image
- * @param iconPath the path relative to the install directory
- * @return the image, or null if not found
- */
- private static Image getImageFromPlugin(IPluginDescriptor pd, String iconPath) {
- InputStream is = null;
- try {
- URL installUrl = pd.getInstallURL();
- URL url = new URL(installUrl, iconPath);
- is = url.openConnection().getInputStream();
- ImageData source = new ImageData(is);
- ImageData mask = source.getTransparencyMask();
- Image image = new Image(null, source, mask);
- return image;
- } catch (Throwable ex) {
- return null;
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e) {
- }
- }
- }
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*; import java.net.*; import java.text.*; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.swt.graphics.*; import org.eclipse.ui.plugin.*;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class LauncherPlugin extends AbstractUIPlugin {
+ //The shared instance.
+ private static LauncherPlugin plugin;
+ private static ResourceBundle resourceBundle;
+
+ private static final String
+ LAUNCH_ITEMS_POINT_ID = "org.eclipse.swt.examples.launcher.launchItems",
+ LAUNCH_ITEMS_XML_CATEGORY = "category",
+ LAUNCH_ITEMS_XML_ITEM = "item",
+ LAUNCH_ITEMS_XML_ITEM_ICON = "icon",
+ LAUNCH_ITEMS_XML_ITEM_DESCRIPTION = "description",
+ LAUNCH_ITEMS_XML_PROGRAM = "program",
+ LAUNCH_ITEMS_XML_PROGRAM_PLUGIN = "pluginId",
+ LAUNCH_ITEMS_XML_PROGRAM_CLASS = "mainClass",
+ LAUNCH_ITEMS_XML_VIEW = "view",
+ LAUNCH_ITEMS_XML_VIEW_VIEWID = "viewId",
+ LAUNCH_ITEMS_XML_ATTRIB_ID = "id",
+ LAUNCH_ITEMS_XML_ATTRIB_NAME = "name",
+ LAUNCH_ITEMS_XML_ATTRIB_ENABLED = "enabled",
+ LAUNCH_ITEMS_XML_ATTRIB_CATEGORY = "category",
+ LAUNCH_ITEMS_XML_VALUE_TRUE = "true",
+ LAUNCH_ITEMS_XML_VALUE_FALSE = "false";
+
+ static final int
+ liClosedFolder = 0,
+ liOpenFolder = 1,
+ liGenericExample = 2;
+ static final String[] imageLocations = {
+ "icons/closedFolder.gif",
+ "icons/openFolder.gif",
+ "icons/generic_example.gif" };
+ static Image images[];
+
+ /**
+ * Constructs the LauncherPlugin.
+ */
+ public LauncherPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ plugin = this;
+ resourceBundle = descriptor.getResourceBundle();
+ }
+
+ /**
+ * Clean up
+ */
+ public void shutdown() throws CoreException {
+ super.shutdown();
+ freeResources();
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static LauncherPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Loads the resources
+ */
+ public static void initResources() {
+ if (images == null) {
+ images = new Image[imageLocations.length];
+
+ for (int i = 0; i < imageLocations.length; ++i) {
+ images[i] = getImageFromPlugin(plugin.getDescriptor(), imageLocations[i]);
+ if (images[i] == null) {
+ freeResources();
+ logError(getResourceString("error.CouldNotLoadResources"), null);
+ throw new IllegalStateException();
+ }
+ }
+ }
+ }
+
+ /**
+ * Frees the resources
+ */
+ public static void freeResources() {
+ if (images != null) {
+ for (int i = 0; i < images.length; ++i) {
+ final Image image = images[i];
+ if (image != null) image.dispose();
+ }
+ images = null;
+ }
+ }
+
+ /**
+ * Log an error to the ILog for this plugin
+ *
+ * @param message the localized error message text
+ * @param exception the associated exception, or null
+ */
+ public static void logError(String message, Throwable exception) {
+ plugin.getLog().log(new Status(IStatus.ERROR, plugin.getDescriptor().getUniqueIdentifier(),
+ 0, message, exception));
+ }
+
+ /**
+ * Returns a string from the resource bundle.
+ * We don't want to crash because of a missing String.
+ * Returns the key if not found.
+ */
+ public static String getResourceString(String key) {
+ try {
+ return resourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!";
+ }
+ }
+
+ /**
+ * Returns a string from the resource bundle and binds it
+ * with the given arguments. If the key is not found,
+ * return the key.
+ */
+ public static String getResourceString(String key, Object[] args) {
+ try {
+ return MessageFormat.format(getResourceString(key), args);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!";
+ }
+ }
+
+ /**
+ * Constructs a list of available programs from registered extensions.
+ *
+ * @return an ItemTreeNode representing the root of a tree of items (the root is not to be displayed)
+ */
+ public static ItemTreeNode getLaunchItemTree() {
+ ItemTreeNode categoryTree =
+ new ItemTreeNode(new ItemDescriptor("<<Root>>", "<<Root>>", null, null, null, null, null));
+
+ // get the platform's public plugin registry
+ IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
+ // retrieve all configuration elements registered at our launchItems extension-point
+ IConfigurationElement[] configurationElements =
+ pluginRegistry.getConfigurationElementsFor(LAUNCH_ITEMS_POINT_ID);
+
+ if (configurationElements == null || configurationElements.length == 0) {
+ logError(getResourceString("error.CouldNotFindRegisteredExtensions"), null);
+ return categoryTree;
+ }
+
+ /* Collect all launch categories -- coalesce those with same ID */
+ HashMap idMap = new HashMap();
+ for (int i = 0; i < configurationElements.length; ++i) {
+ final IConfigurationElement ce = configurationElements[i];
+ final String ceName = ce.getName();
+ final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
+
+ if (idMap.containsKey(attribId)) continue;
+ if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
+ final String attribName = getItemName(ce);
+ ItemDescriptor theDescriptor = new ItemDescriptor(attribId, attribName,
+ getItemDescription(ce), null, null, null, null);
+ idMap.put(attribId, new ItemTreeNode(theDescriptor));
+ }
+ }
+
+ /* Generate launch category hierarchy */
+ Set tempIdSet = new HashSet(); // used to prevent duplicates from being entered into the tree
+ for (int i = 0; i < configurationElements.length; ++i) {
+ final IConfigurationElement ce = configurationElements[i];
+ final String ceName = ce.getName();
+ final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
+
+ if (tempIdSet.contains(attribId)) continue;
+ if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
+ final ItemTreeNode theNode = (ItemTreeNode) idMap.get(attribId);
+ addItemByCategory(ce, categoryTree, theNode, idMap);
+ tempIdSet.add(attribId);
+ }
+ }
+
+ /* Generate program tree */
+ for (int i = 0; i < configurationElements.length; ++i) {
+ final IConfigurationElement ce = configurationElements[i];
+ final String ceName = ce.getName();
+ final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
+
+ if (idMap.containsKey(attribId)) continue;
+ if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
+ // ignore
+ } else if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_ITEM)) {
+ final String enabled = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ENABLED,
+ LAUNCH_ITEMS_XML_VALUE_TRUE);
+ if (enabled.equalsIgnoreCase(LAUNCH_ITEMS_XML_VALUE_FALSE)) continue;
+ ItemDescriptor theDescriptor = createItemDescriptor(ce, attribId);
+
+ if (theDescriptor != null) {
+ final ItemTreeNode theNode = new ItemTreeNode(theDescriptor);
+ addItemByCategory(ce, categoryTree, theNode, idMap);
+ idMap.put(attribId, theNode);
+ }
+ }
+ }
+ return categoryTree;
+ }
+
+
+ /**
+ * Adds an item to the category tree.
+ */
+ private static void addItemByCategory(IConfigurationElement ce, ItemTreeNode root,
+ ItemTreeNode theNode, HashMap idMap) {
+ final String attribCategory = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_CATEGORY, null);
+
+ // locate the parent node
+ ItemTreeNode parentNode = null;
+ if (attribCategory != null) {
+ parentNode = (ItemTreeNode) idMap.get(attribCategory);
+ }
+ if (parentNode == null) parentNode = root;
+
+ // add the item
+ parentNode.addSortedNode(theNode);
+ }
+
+ /**
+ * Creates an ItemDescriptor from an XML definition.
+ *
+ * @param ce the IConfigurationElement describing the item
+ * @param attribId the attribute id
+ * @return a new ItemDescriptor, or null if an error occurs
+ */
+ private static ItemDescriptor createItemDescriptor(IConfigurationElement ce, String attribId) {
+ final String attribName = getItemName(ce);
+ final Image attribIcon = getItemIcon(ce);
+ final String attribDescription = getItemDescription(ce);
+
+ IConfigurationElement viewCE = getItemElement(ce, LAUNCH_ITEMS_XML_VIEW);
+ if (viewCE != null) {
+ //Item is a view
+ final String attribView = getItemAttribute(viewCE, LAUNCH_ITEMS_XML_VIEW_VIEWID, null);
+ if (attribView == null) {
+ logError(getResourceString("error.IncompleteViewLaunchItem",
+ new Object[] { attribId } ), null);
+ return null;
+ }
+ return new ItemDescriptor(attribId, attribName, attribDescription,
+ attribIcon, attribView, null, null);
+ } else {
+ //Item is a standalone
+ IConfigurationElement programCE = getItemElement(ce, LAUNCH_ITEMS_XML_PROGRAM);
+ if (programCE != null) {
+ final String attribPluginId = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_PLUGIN, null);
+ final String attribClass = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_CLASS, null);
+ if (attribClass == null || attribPluginId == null) {
+ logError(getResourceString("error.IncompleteProgramLaunchItem",
+ new Object[] { attribId } ), null);
+ return null;
+ }
+ return new ItemDescriptor(attribId, attribName, attribDescription,
+ attribIcon, null, attribClass, attribPluginId);
+ } else {
+ logError(getResourceString("error.IncompleteLaunchItem",
+ new Object[] { attribId } ), null);
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Returns the first instance of a particular child XML element.
+ *
+ * @param ce the IConfigurationElement parent
+ * @param element the name of the element to fetch
+ * @return the element's IConfigurationElement, or null if not found
+ */
+ private static IConfigurationElement getItemElement(IConfigurationElement ce, String element) {
+ IConfigurationElement[] elementCEs = ce.getChildren(element);
+ return (elementCEs != null && elementCEs.length != 0) ? elementCEs[0] : null;
+ }
+
+ /**
+ * Returns the value of an XML attribute for an item.
+ *
+ * @param ce the IConfigurationElement describing the item
+ * @param attribute the attribute to fetch
+ * @param defaultValue the value to return if the attribute is not found
+ * @return the attribute value
+ */
+ private static String getItemAttribute(IConfigurationElement ce, String attribute, String defaultValue) {
+ String value = ce.getAttribute(attribute);
+ return (value != null) ? value : defaultValue;
+ }
+
+ /**
+ * Returns the description string given the IConfigurationElement for an item.
+ *
+ * @param ce the IConfigurationElement describing the item
+ * @return a newline-delimited string that describes this item, or null if none
+ */
+ private static String getItemDescription(IConfigurationElement ce) {
+ String description = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_DESCRIPTION, "");
+ return (description.length() == 0) ? null : description;
+ }
+
+ /**
+ * Returns the name of an item.
+ *
+ * @param ce the IConfigurationElement describing the item
+ * @return the attribute value
+ */
+ private static String getItemName(IConfigurationElement ce) {
+ return getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_NAME,
+ getResourceString("launchitem.Missing.name"));
+ }
+
+
+ /**
+ * Returns the icon for an item.
+ *
+ * @param ce the IConfigurationElement describing the item
+ * @return an icon
+ */
+ private static Image getItemIcon(IConfigurationElement ce) {
+ String iconPath = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_ICON, "");
+ if (iconPath.length() != 0) {
+ Image icon = getImageFromPlugin(ce.getDeclaringExtension().getDeclaringPluginDescriptor(),
+ iconPath);
+ if (icon != null) {
+ Image[] newImages = new Image[images.length + 1];
+ System.arraycopy(images, 0, newImages, 0, images.length);
+ newImages[images.length] = icon;
+ images = newImages;
+ return icon;
+ }
+ }
+ return images[liGenericExample];
+ }
+
+ /**
+ * Gets an image from a path relative to the plugin install directory.
+ *
+ * @param pd the plugin descriptor for the plugin with the image
+ * @param iconPath the path relative to the install directory
+ * @return the image, or null if not found
+ */
+ private static Image getImageFromPlugin(IPluginDescriptor pd, String iconPath) {
+ InputStream is = null;
+ try {
+ URL installUrl = pd.getInstallURL();
+ URL url = new URL(installUrl, iconPath);
+ is = url.openConnection().getInputStream();
+ ImageData source = new ImageData(is);
+ ImageData mask = source.getTransparencyMask();
+ Image image = new Image(null, source, mask);
+ return image;
+ } catch (Throwable ex) {
+ return null;
+ } finally {
+ try {
+ if (is != null) is.close();
+ } catch (IOException e) {
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
index 8177538056..33beeee555 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
@@ -1,229 +1,229 @@
-package org.eclipse.swt.examples.launcher;
-
-/*
+package org.eclipse.swt.examples.launcher;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is 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
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.part.*;
-import java.lang.reflect.*;
-
-/**
- * Launcher uses <code>org.eclipse.swt</code>
- * to launch the other registered examples.
- *
- * @see ViewPart
- */
-public class LauncherView extends ViewPart {
- private Shell workbenchShell;
-
- private Tree launchTree;
- private Text descriptionText;
- private Button runButton;
-
- /**
- * Constructs a LauncherView.
- */
- public LauncherView() {
- LauncherPlugin.initResources();
- }
-
- /**
- * Creates the example.
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite parent) {
- workbenchShell = getSite().getShell();
- parent.setLayout(new SplitLayout());
-
- Group launchGroup = new Group(parent, SWT.NULL);
- launchGroup.setText(LauncherPlugin.getResourceString("view.launchGroup.text"));
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- launchGroup.setLayout(gridLayout);
-
- launchTree = new Tree(launchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- gridData.horizontalSpan = 2;
- launchTree.setLayoutData(gridData);
- launchTree.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- final ItemDescriptor item = getSelectedItem();
- setDescriptionByItem(item);
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- final ItemDescriptor item = getSelectedItem();
- setDescriptionByItem(item);
- launchItem(getSelectedItem());
- }
- });
- launchTree.addTreeListener(new TreeListener() {
- public void treeCollapsed(TreeEvent event) {
- final TreeItem item = (TreeItem) event.item;
- if (item == null) return;
- item.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
- }
- public void treeExpanded(TreeEvent event) {
- final TreeItem item = (TreeItem) event.item;
- if (item == null) return;
- item.setImage(LauncherPlugin.images[LauncherPlugin.liOpenFolder]);
- }
- });
-
- runButton = new Button(launchGroup, SWT.PUSH);
- runButton.setText(LauncherPlugin.getResourceString("view.launchButton.text"));
- runButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- launchItem(getSelectedItem());
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- }
- });
-
- Group descriptionGroup = new Group(parent, SWT.NULL);
- descriptionGroup.setText(LauncherPlugin.getResourceString("view.descriptionGroup.text"));
- descriptionGroup.setLayout(new FillLayout());
-
- descriptionText = new Text(descriptionGroup, SWT.MULTI | SWT.BORDER |
- SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
-
- setDescriptionByItem(null);
- setItemDescriptors(LauncherPlugin.getLaunchItemTree());
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- launchTree.setFocus();
- runButton.getShell().setDefaultButton(runButton);
- }
-
- /**
- * Called when the View is to be disposed
- */
- public void dispose() {
- workbenchShell = null;
- launchTree = null;
- descriptionText = null;
- runButton = null;
- super.dispose();
- }
-
- /**
- * Installs a new launch list.
- *
- * @param newRoot the new tree of launch items for the UI
- */
- public void setItemDescriptors(final ItemTreeNode newRoot) {
- if (workbenchShell == null) return;
- workbenchShell.getDisplay().syncExec(new Runnable() {
- public void run() {
- if ((launchTree == null) || (launchTree.isDisposed())) return;
- launchTree.removeAll();
-
- for (ItemTreeNode node = newRoot.getFirstChild(); node != null;
- node = node.getNextSibling()) {
- doNode(node, new TreeItem(launchTree, SWT.NONE)); // top-level TreeItem
- }
- }
- private void addGroup(TreeItem parent, ItemTreeNode node) {
- for (;node != null; node = node.getNextSibling()) {
- doNode(node, new TreeItem(parent, SWT.NONE)); // TreeItem at depth > 0
- }
- }
- private void doNode(ItemTreeNode node, TreeItem treeItem) {
- final ItemDescriptor item = node.getDescriptor();
- treeItem.setText(item.getName());
- treeItem.setData(item);
- if (node.getDescriptor().isFolder()) {
- treeItem.setExpanded(false);
- treeItem.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
- } else {
- treeItem.setImage(node.getDescriptor().getIcon());
- }
- addGroup(treeItem, node.getFirstChild());
- }
- });
- }
-
- /**
- * Runs the specified launch item.
- *
- * @param itemDescriptor the launch item to execute
- */
- private void launchItem(ItemDescriptor itemDescriptor) {
- /* Case 1: The launch item is a view */
- String pluginViewId = itemDescriptor.getView ();
- if (pluginViewId != null) {
- final IWorkbenchPart workbenchPart = this;
- final IWorkbenchPartSite workbenchPartSite = workbenchPart.getSite();
- final IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
- try {
- workbenchPage.showView(pluginViewId);
- } catch (PartInitException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.Invocation"), e);
- }
- return;
- }
- /* Case 2: The launch item is a standalone program */
- if (workbenchShell == null) return;
- try {
- Class cl = Class.forName(itemDescriptor.getMainType());
- Display display = workbenchShell.getDisplay();
- Object exampleInstance = cl.newInstance();
- Method openMethod = cl.getDeclaredMethod("open", new Class[] {Display.class});
- openMethod.invoke(exampleInstance, new Object[] {display});
- } catch (NoSuchMethodException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.DoesNotImplementMethod"), null);
- } catch (ClassNotFoundException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotFindClass"), e);
- } catch (Exception e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotInstantiateClass"), e);
- }
- }
-
- /**
- * Obtains the selected launch item.
- *
- * @return the currently selected ItemDescriptor
- */
- private ItemDescriptor getSelectedItem() {
- final TreeItem[] selections = launchTree.getSelection();
- if (selections.length == 0) return null;
- final ItemDescriptor itemDescriptor = (ItemDescriptor) selections[0].getData();
- return itemDescriptor;
- }
-
- /**
- * Sets the currently visible description text to reflect that of a particular ItemDescriptor.
- *
- * @param itemDescriptor the launch item whose description is to be displayed, or null if none
- */
- private void setDescriptionByItem(ItemDescriptor itemDescriptor) {
- String description;
- if (itemDescriptor == null) {
- description = LauncherPlugin.getResourceString("launchitem.Null.description");
- if (runButton != null) runButton.setEnabled(false);
- } else {
- description = itemDescriptor.getDescription();
- if (description == null)
- description = LauncherPlugin.getResourceString("launchitem.Missing.description");
- if (runButton != null) {
- runButton.setEnabled(itemDescriptor.getView() != null || itemDescriptor.getMainType() != null);
- }
- }
- descriptionText.setText(description);
- }
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.part.*;
+import java.lang.reflect.*;
+
+/**
+ * Launcher uses <code>org.eclipse.swt</code>
+ * to launch the other registered examples.
+ *
+ * @see ViewPart
+ */
+public class LauncherView extends ViewPart {
+ private Shell workbenchShell;
+
+ private Tree launchTree;
+ private Text descriptionText;
+ private Button runButton;
+
+ /**
+ * Constructs a LauncherView.
+ */
+ public LauncherView() {
+ LauncherPlugin.initResources();
+ }
+
+ /**
+ * Creates the example.
+ *
+ * @see ViewPart#createPartControl
+ */
+ public void createPartControl(Composite parent) {
+ workbenchShell = getSite().getShell();
+ parent.setLayout(new SplitLayout());
+
+ Group launchGroup = new Group(parent, SWT.NULL);
+ launchGroup.setText(LauncherPlugin.getResourceString("view.launchGroup.text"));
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ launchGroup.setLayout(gridLayout);
+
+ launchTree = new Tree(launchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
+ gridData.horizontalSpan = 2;
+ launchTree.setLayoutData(gridData);
+ launchTree.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent event) {
+ final ItemDescriptor item = getSelectedItem();
+ setDescriptionByItem(item);
+ }
+ public void widgetDefaultSelected(SelectionEvent event) {
+ final ItemDescriptor item = getSelectedItem();
+ setDescriptionByItem(item);
+ launchItem(getSelectedItem());
+ }
+ });
+ launchTree.addTreeListener(new TreeListener() {
+ public void treeCollapsed(TreeEvent event) {
+ final TreeItem item = (TreeItem) event.item;
+ if (item == null) return;
+ item.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
+ }
+ public void treeExpanded(TreeEvent event) {
+ final TreeItem item = (TreeItem) event.item;
+ if (item == null) return;
+ item.setImage(LauncherPlugin.images[LauncherPlugin.liOpenFolder]);
+ }
+ });
+
+ runButton = new Button(launchGroup, SWT.PUSH);
+ runButton.setText(LauncherPlugin.getResourceString("view.launchButton.text"));
+ runButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent event) {
+ launchItem(getSelectedItem());
+ }
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ Group descriptionGroup = new Group(parent, SWT.NULL);
+ descriptionGroup.setText(LauncherPlugin.getResourceString("view.descriptionGroup.text"));
+ descriptionGroup.setLayout(new FillLayout());
+
+ descriptionText = new Text(descriptionGroup, SWT.MULTI | SWT.BORDER |
+ SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
+
+ setDescriptionByItem(null);
+ setItemDescriptors(LauncherPlugin.getLaunchItemTree());
+ }
+
+ /**
+ * Called when we must grab focus.
+ *
+ * @see org.eclipse.ui.part.ViewPart#setFocus
+ */
+ public void setFocus() {
+ launchTree.setFocus();
+ runButton.getShell().setDefaultButton(runButton);
+ }
+
+ /**
+ * Called when the View is to be disposed
+ */
+ public void dispose() {
+ workbenchShell = null;
+ launchTree = null;
+ descriptionText = null;
+ runButton = null;
+ super.dispose();
+ }
+
+ /**
+ * Installs a new launch list.
+ *
+ * @param newRoot the new tree of launch items for the UI
+ */
+ public void setItemDescriptors(final ItemTreeNode newRoot) {
+ if (workbenchShell == null) return;
+ workbenchShell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if ((launchTree == null) || (launchTree.isDisposed())) return;
+ launchTree.removeAll();
+
+ for (ItemTreeNode node = newRoot.getFirstChild(); node != null;
+ node = node.getNextSibling()) {
+ doNode(node, new TreeItem(launchTree, SWT.NONE)); // top-level TreeItem
+ }
+ }
+ private void addGroup(TreeItem parent, ItemTreeNode node) {
+ for (;node != null; node = node.getNextSibling()) {
+ doNode(node, new TreeItem(parent, SWT.NONE)); // TreeItem at depth > 0
+ }
+ }
+ private void doNode(ItemTreeNode node, TreeItem treeItem) {
+ final ItemDescriptor item = node.getDescriptor();
+ treeItem.setText(item.getName());
+ treeItem.setData(item);
+ if (node.getDescriptor().isFolder()) {
+ treeItem.setExpanded(false);
+ treeItem.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
+ } else {
+ treeItem.setImage(node.getDescriptor().getIcon());
+ }
+ addGroup(treeItem, node.getFirstChild());
+ }
+ });
+ }
+
+ /**
+ * Runs the specified launch item.
+ *
+ * @param itemDescriptor the launch item to execute
+ */
+ private void launchItem(ItemDescriptor itemDescriptor) {
+ /* Case 1: The launch item is a view */
+ String pluginViewId = itemDescriptor.getView ();
+ if (pluginViewId != null) {
+ final IWorkbenchPart workbenchPart = this;
+ final IWorkbenchPartSite workbenchPartSite = workbenchPart.getSite();
+ final IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
+ try {
+ workbenchPage.showView(pluginViewId);
+ } catch (PartInitException e) {
+ LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.Invocation"), e);
+ }
+ return;
+ }
+ /* Case 2: The launch item is a standalone program */
+ if (workbenchShell == null) return;
+ try {
+ Class cl = Class.forName(itemDescriptor.getMainType());
+ Display display = workbenchShell.getDisplay();
+ Object exampleInstance = cl.newInstance();
+ Method openMethod = cl.getDeclaredMethod("open", new Class[] {Display.class});
+ openMethod.invoke(exampleInstance, new Object[] {display});
+ } catch (NoSuchMethodException e) {
+ LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.DoesNotImplementMethod"), null);
+ } catch (ClassNotFoundException e) {
+ LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotFindClass"), e);
+ } catch (Exception e) {
+ LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotInstantiateClass"), e);
+ }
+ }
+
+ /**
+ * Obtains the selected launch item.
+ *
+ * @return the currently selected ItemDescriptor
+ */
+ private ItemDescriptor getSelectedItem() {
+ final TreeItem[] selections = launchTree.getSelection();
+ if (selections.length == 0) return null;
+ final ItemDescriptor itemDescriptor = (ItemDescriptor) selections[0].getData();
+ return itemDescriptor;
+ }
+
+ /**
+ * Sets the currently visible description text to reflect that of a particular ItemDescriptor.
+ *
+ * @param itemDescriptor the launch item whose description is to be displayed, or null if none
+ */
+ private void setDescriptionByItem(ItemDescriptor itemDescriptor) {
+ String description;
+ if (itemDescriptor == null) {
+ description = LauncherPlugin.getResourceString("launchitem.Null.description");
+ if (runButton != null) runButton.setEnabled(false);
+ } else {
+ description = itemDescriptor.getDescription();
+ if (description == null)
+ description = LauncherPlugin.getResourceString("launchitem.Missing.description");
+ if (runButton != null) {
+ runButton.setEnabled(itemDescriptor.getView() != null || itemDescriptor.getMainType() != null);
+ }
+ }
+ descriptionText.setText(description);
+ }
} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java
index 6eee1cdb9d..f7be09acfb 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java
@@ -1,15 +1,15 @@
package org.eclipse.swt.examples.launcher; /* * (c) Copyright IBM Corp. 2000, 2002.
* This file is 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 */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; /** * A Layout class that automatically switches from a horizontal split to a vertical * split layout to accomodate changing size conditions. * * Later on we might improve this class to take into account the "preferred" size of * the widgets. */
-public class SplitLayout extends Layout { private static final int splitHorizontally = 0, splitVertically = 1; private int splitDirection = splitHorizontally; public int spacing = 3; public int marginTop = 3;
- public int marginLeft = 3; public int marginRight = 3; public int marginBottom = 3; /**
- * Creates a new layout
- */
- public SplitLayout() { }
- /** * @see Layout#computeSize(Composite, int, int, boolean) */ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { if (wHint == SWT.DEFAULT) { if (hHint == SWT.DEFAULT) { Point hSplitSize = computeHSplitSize(composite, wHint, hHint, flushCache); Point vSplitSize = computeVSplitSize(composite, wHint, hHint, false); int hSplitArea = hSplitSize.x * hSplitSize.y; int vSplitArea = vSplitSize.x * vSplitSize.y; // Choose direction consuming least area if (hSplitArea < vSplitArea) { splitDirection = splitHorizontally; return hSplitSize; } else { splitDirection = splitVertically; return vSplitSize; } } else { // Constrained in height: split vertically splitDirection = splitVertically; return computeVSplitSize(composite, wHint, hHint, flushCache); } } else { if (hHint == SWT.DEFAULT) { // Constrained in width: split horizontally splitDirection = splitHorizontally; return computeHSplitSize(composite, wHint, hHint, flushCache); } else { if (hHint < wHint) { splitDirection = splitVertically; return computeVSplitSize(composite, wHint, hHint, flushCache); } else { splitDirection = splitHorizontally; return computeHSplitSize(composite, wHint, hHint, flushCache); } } } }
- /**
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) { Rectangle clientArea = composite.getClientArea(); computeSize(composite, clientArea.width, clientArea.height, false); Control[] children = composite.getChildren(); clientArea.x += marginLeft; clientArea.y += marginTop; clientArea.width -= marginRight + marginLeft; clientArea.height -= marginBottom + marginTop; Point position = new Point(clientArea.x, clientArea.y); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; final Rectangle bounds; if (splitDirection == splitHorizontally) { int height = clientArea.height / children.length; bounds = new Rectangle(position.x, position.y, clientArea.width, height); position.y += height + spacing; } else { int width = clientArea.width / children.length; bounds = new Rectangle(position.x, position.y, width, clientArea.height); position.x += width + spacing; } bounds.width = Math.max(bounds.width, 0); bounds.height = Math.max(bounds.height, 0); child.setBounds(bounds); } }
- private Point computeHSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; Point childSize = child.computeSize(wHint, hHint, flushCache); size.x = Math.max(size.x, childSize.x); size.y += childSize.y + spacing; } return size; } private Point computeVSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; Point childSize = child.computeSize(wHint, hHint, flushCache); size.x += childSize.x + spacing; size.y = Math.max(size.y, childSize.y); } return size; } }
+ * http://www.eclipse.org/legal/cpl-v10.html */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; /** * A Layout class that automatically switches from a horizontal split to a vertical * split layout to accomodate changing size conditions. * * Later on we might improve this class to take into account the "preferred" size of * the widgets. */
+public class SplitLayout extends Layout { private static final int splitHorizontally = 0, splitVertically = 1; private int splitDirection = splitHorizontally; public int spacing = 3; public int marginTop = 3;
+ public int marginLeft = 3; public int marginRight = 3; public int marginBottom = 3; /**
+ * Creates a new layout
+ */
+ public SplitLayout() { }
+ /** * @see Layout#computeSize(Composite, int, int, boolean) */ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { if (wHint == SWT.DEFAULT) { if (hHint == SWT.DEFAULT) { Point hSplitSize = computeHSplitSize(composite, wHint, hHint, flushCache); Point vSplitSize = computeVSplitSize(composite, wHint, hHint, false); int hSplitArea = hSplitSize.x * hSplitSize.y; int vSplitArea = vSplitSize.x * vSplitSize.y; // Choose direction consuming least area if (hSplitArea < vSplitArea) { splitDirection = splitHorizontally; return hSplitSize; } else { splitDirection = splitVertically; return vSplitSize; } } else { // Constrained in height: split vertically splitDirection = splitVertically; return computeVSplitSize(composite, wHint, hHint, flushCache); } } else { if (hHint == SWT.DEFAULT) { // Constrained in width: split horizontally splitDirection = splitHorizontally; return computeHSplitSize(composite, wHint, hHint, flushCache); } else { if (hHint < wHint) { splitDirection = splitVertically; return computeVSplitSize(composite, wHint, hHint, flushCache); } else { splitDirection = splitHorizontally; return computeHSplitSize(composite, wHint, hHint, flushCache); } } } }
+ /**
+ * @see Layout#layout(Composite, boolean)
+ */
+ protected void layout(Composite composite, boolean flushCache) { Rectangle clientArea = composite.getClientArea(); computeSize(composite, clientArea.width, clientArea.height, false); Control[] children = composite.getChildren(); clientArea.x += marginLeft; clientArea.y += marginTop; clientArea.width -= marginRight + marginLeft; clientArea.height -= marginBottom + marginTop; Point position = new Point(clientArea.x, clientArea.y); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; final Rectangle bounds; if (splitDirection == splitHorizontally) { int height = clientArea.height / children.length; bounds = new Rectangle(position.x, position.y, clientArea.width, height); position.y += height + spacing; } else { int width = clientArea.width / children.length; bounds = new Rectangle(position.x, position.y, width, clientArea.height); position.x += width + spacing; } bounds.width = Math.max(bounds.width, 0); bounds.height = Math.max(bounds.height, 0); child.setBounds(bounds); } }
+ private Point computeHSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; Point childSize = child.computeSize(wHint, hHint, flushCache); size.x = Math.max(size.x, childSize.x); size.y += childSize.y + spacing; } return size; } private Point computeVSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (int i = 0; i < children.length; ++i) { final Control child = children[i]; Point childSize = child.computeSize(wHint, hHint, flushCache); size.x += childSize.x + spacing; size.y = Math.max(size.y, childSize.y); } return size; } }

Back to the top