Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'visualizer')
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer-feature/.project17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/ABOUT.txt359
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer-feature/build.properties17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/eclipse_update_120.jpgbin0 -> 21695 bytes
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/epl-v10.html328
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/feature.properties166
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer-feature/feature.xml34
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/license.html108
-rw-r--r--visualizer/org.eclipse.cdt.visualizer-feature/pom.xml18
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/.classpath8
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/.project28
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/.settings/org.eclipse.jdt.core.prefs8
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/ABOUT.txt17
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/META-INF/MANIFEST.MF15
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.core/about.html24
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/build.properties17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.core/plugin.properties17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.core/pom.xml17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.core/resources/messages.properties14
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/Extension.java92
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ExtensionElement.java160
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ResourceManager.java195
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/plugin/CDTVisualizerCorePlugin.java126
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/.classpath8
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/.project28
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/.settings/org.eclipse.jdt.core.prefs8
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/ABOUT.txt17
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/META-INF/MANIFEST.MF20
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/about.html24
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/build.properties23
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/icons/full/view16/visualizer_view.pngbin0 -> 2921 bytes
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/plugin.properties19
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/plugin.xml41
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/pom.xml17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/resources/messages.properties17
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/schema/org.eclipse.cdt.visualizer.ui.visualizer.exsd123
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizer.java171
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizerViewer.java111
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/Visualizer.java275
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerAction.java79
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerView.java415
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java540
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java201
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvas.java167
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java123
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicObject.java278
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/IGraphicObject.java49
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/IVisualizerViewerListener.java31
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/VisualizerViewerEvent.java79
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/plugin/CDTVisualizerUIPlugin.java159
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvas.java106
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvasVisualizer.java114
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Colors.java127
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Event.java107
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java127
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/ListenerList.java148
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/MouseMonitor.java383
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/RunnableWithResult.java159
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionManager.java166
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionProviderAdapter.java97
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionUtils.java280
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Timer.java100
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Todo.java99
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/UIResourceManager.java375
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/WorkbenchSelectionAdapter.java220
65 files changed, 7416 insertions, 0 deletions
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/.project b/visualizer/org.eclipse.cdt.visualizer-feature/.project
new file mode 100755
index 00000000000..085bc9060c2
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.visualizer-feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/ABOUT.txt b/visualizer/org.eclipse.cdt.visualizer-feature/ABOUT.txt
new file mode 100644
index 00000000000..7184727dae9
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/ABOUT.txt
@@ -0,0 +1,359 @@
+###############################################################################
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+###############################################################################
+
+Visualizer View Framework
+=========================
+Version: 1.0
+Last updated: 1/19/12
+
+Overview
+--------
+
+- The Visualizer framework supports the addition of visual (i.e. graphical)
+ representations of run/debug launches to the Eclipse workbench.
+ It provides interfaces and default implementations to be used by
+ integrators in adding their own graphical views to Eclipse.
+
+- The Visualizer framework is an optional feature of CDT.
+
+- The Visualizer framework consists of the following features/plugins:
+ - org.eclipse.cdt.visualizer-feature:
+ - org.eclipse.cdt.visualizer.core -- non-UI interface and utilities
+ - org.eclipse.cdt.visualizer.ui -- UI classes and utilities
+
+- The Visualizer framework has the following goals:
+ - make it easy to present multiple graphical presentations of
+ a running/debugging launch, and allow the user to select between them
+ - provide a pluggable infrastructure that does not limit an integrator
+ to a specific model, event, or graphic "canvas" in creating such presentations
+ - provide sufficient default implementations to make creating a new
+ custom presentation as simple as possible
+
+- The framework consists of the following set of interfaces and classes:
+
+ ==========================
+ | VisualizerView |
+ ==========================
+ | VisualizerViewer |
+ | |
+ | -------------------- | ------------------
+ | | | | | |
+ | | IVisualizer's | <=== | IVisualizer | ===> (Model Object)
+ | | graphic | | | implementation |
+ | | control | | | |
+ | | | | ------------------
+ | -------------------- |
+ | |
+ ==========================
+
+ - VisualizerView -- a top-level Eclipse workbench view that
+ contains and presents a VisualizerViewer
+
+ The VisualizerView also provides support for a toolbar and
+ context menu, which can be populated by IVisualizers when
+ they are selected.
+
+ - VisualierViewer -- a container control that manages one or more
+ IVisualizers and their corresponding graphic controls.
+
+ The VisualizerViewer automatically switches between its available
+ IVisualizers based on the current workbench selection.
+
+ The viewer also mediates between its parent View and child IVisualizers
+ on things like:
+ - content selection (workbench selection <==> IVisulizer selection)
+ - toolbar population and updating
+ - context menu events and updating
+
+ - IVisualizer -- an API for a class that encapsulates:
+ - a graphic representation of one or more model object types
+ - a top-level graphic display control (e.g. an SWT canvas, GEF canvas, etc.)
+ that is used to present this graphic representation in the VisualizerViewer
+
+ - the "model" class -- this is not a specific class type,
+ it's basically any top-level Object that can be selected and
+ used to obtain the state to be presented by an IVisualizer
+ (for example, a Launch in the Debug View, or a text selection
+ in an editor)
+
+- The framework provides default implementations of VisualizerView,
+ and VisualizerViewer, and base classes that can be used to
+ create IVisualizer implementations.
+
+- The framework provides an extension point by which IVisualizer implementations
+ can be registered. This is read by the default VisualizerViewer,
+ and used to populate its initial set of IVisualizer views
+
+
+Extension Points:
+-----------------
+
+The base class VisualizerViewer checks the following extension point
+for plugin contributions of IVisualizer implementations:
+
+- org.eclipse.cdt.visualizer.ui.vizualizer
+ - id: unique ID of this visualizer type
+ - class: implementation of IVisualizer interface
+
+ Examples:
+
+ <!-- Visualizer declarations -->
+
+ <extension
+ point="org.eclipse.cdt.visualizer.ui.visualizer">
+
+ <!-- "Grid View" visualizer -->
+ <visualizer
+ id="com.tilera.ide.views.grid.visualizer"
+ class="com.tilera.ide.views.grid.GridViewVisualizer">
+ </visualizer>
+
+ <!-- "Test Canvas" visualizer -->
+ <visualizer
+ id="org.eclipse.cdt.visualizer.ui.test.TestCanvasVisualizer"
+ class="org.eclipse.cdt.visualizer.ui.test.TestCanvasVisualizer">
+ </visualizer>
+
+ </extension>
+
+
+Package/Class hierarchy:
+------------------------
+
+- feature: org.eclipse.cdt.visualizer
+
+ - plugin: org.eclipse.cdt.visualizer.core
+
+ - org.eclipse.cdt.visualizer.core.plugin
+
+ - CDTVisualizerCorePlugin -- plugin activator class (mainly used to access ResourceManager)
+
+ - org.eclipse.cdt.visualizer.core
+
+ - ResourceManager -- resource manager, handles strings only (see UIResourceManager below)
+ - Extension -- utility class for dealing with extension points
+ - ExtensionElement -- utility class for dealing with extension definitions
+
+ - plugin: org.eclipse.cdt.visualizer.ui
+
+ - org.eclipse.cdt.visualizer.ui.plugin
+
+ - CDTVisualizerUIPlugin -- plugin activator class (mainly used for logging and UIResourceManager)
+
+ - org.eclipse.cdt.visualizer.ui
+
+ - VisualizerView -- base class for top-level Visualizer "view" in Eclipse workbench
+ - handles:
+ - display of single IVisualizerViewer
+ - boilerplate code for workbench views
+
+ - IVisualizerViewer -- visualizer "viewer" container interface
+ - VisualizerViewer -- base class for IVisualizerViewer implementations
+ - handles:
+ - loading and managing a list of IVisualizers
+ - routing of selection
+ - from workbench into current IVisualizer
+ - from current IVisualizer back to workbench
+ - manages viewer toolbar and content menu,
+ asks current IVisualizer to populate these as needed
+
+ - IVisualizer -- interface for visualizer (graphic representation, like Grid View)
+ - Visualizer -- base class for IVisualizer implementations
+ - handles:
+ - creating and painting a graphic component
+ - management of selection for that component
+ - populating toolbar and context menu content on demand
+
+ - VisualizerAction -- base class for toolbar/menu actions (convenience wrapper for Action class)
+
+ - org.eclipse.cdt.visualizer.ui.events
+
+ - VisualizerViewerEvent -- event raised by VisualizerViewer (visualizer changed, context menu event)
+ - IVisualizerViewerListener -- listener interface for VisualizerViewerEvent listeners
+
+ - org.eclipse.cdt.visualizer.ui.canvas
+
+ - GraphicCanvasVisualizer -- base class for visualizers based on GraphicCanvas component
+ - GraphicCanvas -- simple canvas that paints a list of GraphicObjects
+ - IGraphicObject -- interface for objects to be drawn on GraphicCanvas
+ - GraphicObject -- base class implementation of IGraphicObject
+ - BufferedCanvas -- base class for GraphicCanvas (or any canvas component with back-buffering)
+
+ - org.eclipse.cdt.visualizer.ui.test
+
+ - TestCanvasVisualizer -- IVisualizer wrapper for TestCanvas
+ - TestCanvas -- simple canvas example that displays current selection as text
+
+ - org.eclipse.cdt.visualizer.ui.util
+
+ - GUIUtils -- assorted UI utility methods
+ - UIResourceManager -- resource manager, includes strings, images, fonts, colors
+ - Colors -- SWT color resource manager, used with UIResourceManager
+ - SelectionUtils -- ISelection manipulation utilities
+ - SelectionManager -- ISelectionProvider implementation, manages selection for a containing class
+ - SelectionProviderAdapter -- ISelectionProvider wrapper for classes that don't implement it
+ - ListenerList -- listener manager class
+ - Event -- event base class
+ - MouseMonitor -- mouse event tracking utility class
+ - RunnableWithResult -- Runnable that returns a result
+ - Timer -- UI timer class
+ - Todo -- work tracking utility class
+ - WorkbenchSelectionAdapter -- manages interaction between workbench selection and a specified IViewPart
+
+
+Creating a Visualizer
+---------------------
+
+This is a summary of the steps to take in developing a visualizer.
+(For a specific example of this, see the Multicore Debug Visualizer,
+defined in the org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui plugin.)
+
+- Add the VisualizerView to the workbench.
+ Note: this implicitly creates a VisualizerViewer instance.
+
+ NOTE: This is currently done by the Visualizer framework itself,
+ with the following plugin.xml extension markup:
+
+ For example:
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.debug.ui"
+ class="org.eclipse.cdt.visualizer.ui.VisualizerView"
+ icon="icons/full/view16/visualizer_view.gif"
+ id="org.eclipse.cdt.visualizer.view"
+ name="%view.visualizer.name">
+ </view>
+ </extension>
+
+
+- declare your visualizer class via the extension point
+ (described below under Extension Points)
+
+ <extension
+ point="org.eclipse.cdt.visualizer.ui.visualizer">
+ <!-- "Multicore View" visualizer -->
+ <visualizer
+ id="org.eclipse.cdt.dsf.gdb.multicorevisualizer.visualizer"
+ class="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizer">
+ </visualizer>
+ </extension>
+
+
+- Define your IVisualizer class, either:
+
+ - completely from scratch, implementing IVisualizer
+
+ - derived from the Visualizer base class
+
+ - if you want to use the supplied GraphicCanvas as your control,
+ use the GraphicCanvasVisualizer base class instead
+
+
+- Implement the IVisualizer interface:
+
+ - implement getName(), getDisplayName(), and getDescription()
+ to provide a UI-visible name and tooltip for your visualizer
+
+ - implement createControl() to return the UI control to be
+ displayed for your visualizer in the VisualizerView
+ (if you're using the GraphicCanvasVisualizer base class,
+ override createCanvas() and initializeCanvas() instead)
+
+ - implement handlesSelection() to determine whether your
+ visualizer can display the current selection
+ (your visualizer is only selected if it returns a higher
+ value from this call than any other visualizer)
+
+ - implement visualizerSelected()/visualizerDeselected()
+ to handle any setup/cleanup when your visualizer becomes
+ active or inactive
+
+ - implement workbenchSelectionChanged() to handle changes in
+ the workbench selection (typically, this means updating the
+ visualizer's displayed content, and/or mapping the current
+ selection to selected item(s) in the visualizer display)
+
+ - implement the selection-management methods
+ (getSelection(), setSelection() and add/removeSelectionChangedListener())
+ to handle exposing the visualizer's selection to the workbench
+ (typically, these methods can be delegated to an instance of
+ the SelectionManager utility class, and then your visualizer
+ just needs to keep the SelectionManager's content up to date)
+
+ - when your visualizer's selection changes (i.e. by the user clicking
+ or dragging on the visualizer's control, update the exposed
+ selection (i.e. update the SelectionManager instance)
+
+ - optionally, to enable toolbar/menu support:
+ - implement createActions()/updateActions() to create and
+ update the enabling of your actions
+ - implement populateToolbar() to add actions to the visualizer toolbar
+ (note: the toolbar is initially empty each time this is called)
+ - implement populateMenu() to add actions to the toolbar's menu
+ - implement populateContextMenu() to add actions to the
+ VisualizerView's context menu
+ - whenever the selection changes (workbench or visualizer),
+ invoke updateActions() to keep your toolbar/menu actions
+ enabled properly
+
+- If you use the GraphicCanvasVisualizer, here's some additional hints:
+
+ - create an internal "model" class for your canvas, if you don't
+ already have such a model
+
+ - when the workbench selection changes update this model
+ with any needed changes; this allows you to decouple the
+ canvas repaint step from workbench events,
+
+ - have your GraphicCanvas implementation create and update instances
+ of GraphicObject classes associated with your model objects;
+ also cache GraphicObjects for model state that doesn't
+ change on every repaint
+
+ - don't repaint your visualizer canvas on every event;
+ use a Timer instance and "batch up" requests that come in
+ during the timer interval (for example, start the timer when
+ the first update request comes in, and when the timer goes off,
+ display the current state, effectively "rolling up" any update
+ requests that came in during the timer interval)
+
+ - add selection support to your canvas (i.e. let the user click-
+ and drag-select items in the visualization), and use the
+ selection-management interface of the IVisualizer class to
+ expose this to the workbench
+
+ - remember that the IVisualizerViewer/IVisualizer API provides
+ support for a context menu on the visualizer, so you don't need
+ to provide one for your canvas control
+
+- Remember the goal of the visualizer: to provide a clear, high-level
+ view of the selected object -- for example, the hierarchy of processes
+ and threads in a running program. You can provide options or overlays
+ for additional detail, but keep the basic picture simple.
+
+
+Current State, Future Plans
+---------------------------
+
+- In the initial implementation, the IVisualizer implementation
+ is required to use the selection to locate the object (i.e. the current launch)
+ that it is to represent visually, and to construct and maintain
+ a graphic representation of it.
+
+- In future, the Visualizer framework will want to provide APIs
+ that factor out and simplify common aspects of interaction with
+ launches and launch targets. For example:
+
+ - a service-based target introspection layer, which can be used by
+ IPresentation implementations to discover details of the current
+ launch target in a platform-neutral way
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/build.properties b/visualizer/org.eclipse.cdt.visualizer-feature/build.properties
new file mode 100755
index 00000000000..7a4864dbb62
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+###############################################################################
+bin.includes = feature.xml,\
+ feature.properties,\
+ license.html,\
+ epl-v10.html,\
+ eclipse_update_120.jpg,\
+ About.txt
+ \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/eclipse_update_120.jpg b/visualizer/org.eclipse.cdt.visualizer-feature/eclipse_update_120.jpg
new file mode 100644
index 00000000000..bfdf708ad61
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/eclipse_update_120.jpg
Binary files differ
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/epl-v10.html b/visualizer/org.eclipse.cdt.visualizer-feature/epl-v10.html
new file mode 100644
index 00000000000..ed4b196655e
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/epl-v10.html
@@ -0,0 +1,328 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 9">
+<meta name=Originator content="Microsoft Word 9">
+<link rel=File-List
+href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
+<title>Eclipse Public License - Version 1.0</title>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+ <o:Revision>2</o:Revision>
+ <o:TotalTime>3</o:TotalTime>
+ <o:Created>2004-03-05T23:03:00Z</o:Created>
+ <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
+ <o:Pages>4</o:Pages>
+ <o:Words>1626</o:Words>
+ <o:Characters>9270</o:Characters>
+ <o:Lines>77</o:Lines>
+ <o:Paragraphs>18</o:Paragraphs>
+ <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
+ <o:Version>9.4402</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:TrackRevisions/>
+ </w:WordDocument>
+</xml><![endif]-->
+<style>
+<!--
+ /* Font Definitions */
+@font-face
+ {font-family:Tahoma;
+ panose-1:2 11 6 4 3 5 4 4 2 4;
+ mso-font-charset:0;
+ mso-generic-font-family:swiss;
+ mso-font-pitch:variable;
+ mso-font-signature:553679495 -2147483648 8 0 66047 0;}
+ /* Style Definitions */
+p.MsoNormal, li.MsoNormal, div.MsoNormal
+ {mso-style-parent:"";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p
+ {margin-right:0in;
+ mso-margin-top-alt:auto;
+ mso-margin-bottom-alt:auto;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p.BalloonText, li.BalloonText, div.BalloonText
+ {mso-style-name:"Balloon Text";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:8.0pt;
+ font-family:Tahoma;
+ mso-fareast-font-family:"Times New Roman";}
+@page Section1
+ {size:8.5in 11.0in;
+ margin:1.0in 1.25in 1.0in 1.25in;
+ mso-header-margin:.5in;
+ mso-footer-margin:.5in;
+ mso-paper-source:0;}
+div.Section1
+ {page:Section1;}
+-->
+</style>
+</head>
+
+<body lang=EN-US style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
+</p>
+
+<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and<br clear=left>
+b) in the case of each subsequent Contributor:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+changes to the Program, and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+additions to the Program;</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
+entity that distributes the Program.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
+distributed in accordance with this Agreement.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
+receives the Program under this Agreement, including all Contributors.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license to<span
+style='color:red'> </span>reproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder. </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement. </span></p>
+
+<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:</span>
+</p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it complies with the terms and conditions of this Agreement; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+its license agreement:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
+
+<p><span style='font-size:10.0pt'>When the Program is made available in source
+code form:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it must be made available under this Agreement; and </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
+copy of this Agreement must be included with each copy of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
+copyright notices contained within the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution. </span></p>
+
+<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
+
+<p><span style='font-size:10.0pt'>Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor (&quot;Commercial
+Contributor&quot;) hereby agrees to defend and indemnify every other
+Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
+costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.</span> </p>
+
+<p><span style='font-size:10.0pt'>For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations. </span></p>
+
+<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
+
+<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.</span> </p>
+
+<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed. </span></p>
+
+<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive. </span></p>
+
+<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.</span> </p>
+
+<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.</span> </p>
+
+<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
+
+</div>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/feature.properties b/visualizer/org.eclipse.cdt.visualizer-feature/feature.properties
new file mode 100644
index 00000000000..41c07c9a829
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/feature.properties
@@ -0,0 +1,166 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Feature string resources
+# -----------------------------------------------------------------------------
+
+# "featureName" property - name of the feature
+featureName=CDT Visualizer Framework
+
+# "providerName" property - name of the company that provides the feature
+providerName=Eclipse CDT
+
+# "updateSiteName" property - label for the update site
+updateSiteName=Eclipse CDT Update Site
+
+# "description" property - description of the feature
+description=Visualizer View and Framework that allows to build custom visualizers.
+
+# copyright
+copyright=\
+Copyright (c) 2012 Tilera Corporation and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/legal/epl-v10.html
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+February 1, 2011\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+ - Content may be structured and packaged into modules to facilitate delivering,\n\
+ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+ plug-in fragments ("Fragments"), and features ("Features").\n\
+ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+ in a directory named "plugins".\n\
+ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+ Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+ - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+ - The top-level (root) directory\n\
+ - Plug-in and Fragment directories\n\
+ - Inside Plug-ins and Fragments packaged as JARs\n\
+ - Sub-directories of the directory named "src" of certain Plug-ins\n\
+ - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+ - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+ extending or updating the functionality of an Eclipse-based product.\n\
+ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+ govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+ with the Specification. Such Installable Software Agreement must inform the user of the\n\
+ terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+ indication of agreement by the user, the provisioning Technology will complete installation\n\
+ of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/feature.xml b/visualizer/org.eclipse.cdt.visualizer-feature/feature.xml
new file mode 100755
index 00000000000..532b8663439
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/feature.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.cdt.visualizer"
+ label="%featureName"
+ version="1.0.0.qualifier"
+ provider-name="%providerName">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <plugin
+ id="org.eclipse.cdt.visualizer.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.cdt.visualizer.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/license.html b/visualizer/org.eclipse.cdt.visualizer-feature/license.html
new file mode 100644
index 00000000000..f19c483b9c8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/license.html
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>February 1, 2011</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/visualizer/org.eclipse.cdt.visualizer-feature/pom.xml b/visualizer/org.eclipse.cdt.visualizer-feature/pom.xml
new file mode 100644
index 00000000000..9dc4a21f830
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer-feature/pom.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.eclipse.cdt.features</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.visualizer</artifactId>
+ <packaging>eclipse-feature</packaging>
+</project>
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/.classpath b/visualizer/org.eclipse.cdt.visualizer.core/.classpath
new file mode 100755
index 00000000000..31db9a91174
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/.project b/visualizer/org.eclipse.cdt.visualizer.core/.project
new file mode 100755
index 00000000000..77747f8e3ea
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.visualizer.core</name>
+ <comment></comment>
+ <projects>
+ </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.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/.settings/org.eclipse.jdt.core.prefs b/visualizer/org.eclipse.cdt.visualizer.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 00000000000..743b93d39ff
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Fri Jul 01 09:20:33 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/ABOUT.txt b/visualizer/org.eclipse.cdt.visualizer.core/ABOUT.txt
new file mode 100755
index 00000000000..ad3ea21360a
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/ABOUT.txt
@@ -0,0 +1,17 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+This plugin defines the non-UI components of the CDT Visualizer feature.
+
+For an overview of the Visualizer feature, see the following file:
+
+ /org.eclipse.cdt.visualizer-feature/ABOUT.txt.
+ \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/META-INF/MANIFEST.MF b/visualizer/org.eclipse.cdt.visualizer.core/META-INF/MANIFEST.MF
new file mode 100755
index 00000000000..6fec5fa40a4
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin.name
+Bundle-SymbolicName: org.eclipse.cdt.visualizer.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.visualizer.core.plugin.CDTVisualizerCorePlugin
+Bundle-Vendor: %provider.name
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.cdt.visualizer.core,
+ org.eclipse.cdt.visualizer.core.plugin
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/about.html b/visualizer/org.eclipse.cdt.visualizer.core/about.html
new file mode 100644
index 00000000000..cb740ae8bc8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/build.properties b/visualizer/org.eclipse.cdt.visualizer.core/build.properties
new file mode 100755
index 00000000000..07409e935ad
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+###############################################################################
+source.. = src/,\
+ resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/plugin.properties b/visualizer/org.eclipse.cdt.visualizer.core/plugin.properties
new file mode 100644
index 00000000000..43181240cd1
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/plugin.properties
@@ -0,0 +1,17 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Plugin string resources
+# -----------------------------------------------------------------------------
+
+plugin.name=CDT Visualizer Core Plug-in
+provider.name=Eclipse CDT
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/pom.xml b/visualizer/org.eclipse.cdt.visualizer.core/pom.xml
new file mode 100644
index 00000000000..bde189daa95
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.visualizer.core</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/resources/messages.properties b/visualizer/org.eclipse.cdt.visualizer.core/resources/messages.properties
new file mode 100644
index 00000000000..70fa2ec9226
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/resources/messages.properties
@@ -0,0 +1,14 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Application string resources
+# -----------------------------------------------------------------------------
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/Extension.java b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/Extension.java
new file mode 100644
index 00000000000..10aac2651c2
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/Extension.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+
+// ---------------------------------------------------------------------------
+// Extension
+// ---------------------------------------------------------------------------
+
+/** Facade/utility class for dealing with Eclipse extensions. */
+public class Extension extends ExtensionElement
+{
+ // --- static methods ---
+
+ /** Gets extension point declaration with specified full ID (including plugin ID prefix). */
+ public static IExtensionPoint getExtensionPoint(String extensionPointID)
+ {
+ IExtensionPoint extensionPoint =
+ Platform.getExtensionRegistry().getExtensionPoint(
+ extensionPointID);
+ return extensionPoint;
+ }
+
+ /** Gets extension point declaration with specified name defined by specified plugin. */
+ public static IExtensionPoint getExtensionPoint(String pluginID, String extensionPointName)
+ {
+ IExtensionPoint extensionPoint =
+ Platform.getExtensionRegistry().getExtensionPoint(
+ pluginID, extensionPointName);
+ return extensionPoint;
+ }
+
+ /** Gets list of extensions for specified extension point ID (including plugin ID prefix). */
+ public static List<Extension> getExtensions(String extensionPointID)
+ {
+ IExtensionPoint extensionPoint = getExtensionPoint(extensionPointID);
+ return getExtensions(extensionPoint);
+ }
+
+ /** Gets list of extensions for specified plugin and extension point name. */
+ public static List<Extension> getExtensions(String pluginID, String extensionPointName)
+ {
+ IExtensionPoint extensionPoint = getExtensionPoint(pluginID, extensionPointName);
+ return getExtensions(extensionPoint);
+ }
+
+ /** Gets list of extensions for specified plugin and extension point name. */
+ public static List<Extension> getExtensions(IExtensionPoint extensionPoint)
+ {
+ return (extensionPoint == null) ? null :
+ Extension.wrapExtensions(extensionPoint.getConfigurationElements());
+ }
+
+ /** Wraps list of raw extension declarations. */
+ public static List<Extension> wrapExtensions(IConfigurationElement[] elements)
+ {
+ int count = (elements == null) ? 0 : elements.length;
+ List<Extension> result = new ArrayList<Extension>(count);
+ for (int i=0; i<count; ++i) {
+ result.add(new Extension(elements[i]));
+ }
+ return result;
+ }
+
+ // --- members ---
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public Extension(IConfigurationElement element) {
+ super(element);
+ }
+
+ // --- methods ---
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ExtensionElement.java b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ExtensionElement.java
new file mode 100755
index 00000000000..ca547894127
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ExtensionElement.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.core;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.lang.model.type.NullType;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+
+// ---------------------------------------------------------------------------
+// ExtensionElement
+// ---------------------------------------------------------------------------
+
+/** Facade/utility class for dealing with Eclipse extensions. */
+public class ExtensionElement {
+
+ // --- static methods ---
+
+ /** Wraps list of raw extension declarations. */
+ public static List<ExtensionElement> wrapExtensionElements(IConfigurationElement[] elements)
+ {
+ int count = (elements == null) ? 0 : elements.length;
+ List<ExtensionElement> result = new ArrayList<ExtensionElement>(count);
+ for (int i=0; i<count; ++i) {
+ result.add(new ExtensionElement(elements[i]));
+ }
+ return result;
+ }
+
+
+ // --- members ---
+
+ /** Actual extension description loaded from extension point. */
+ protected IConfigurationElement m_element = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public ExtensionElement(IConfigurationElement element) {
+ m_element = element;
+ }
+
+
+ // --- methods ---
+
+ /** Gets string value of specified attribute. */
+ public String getAttribute(String attributeName)
+ {
+ return m_element.getAttribute(attributeName);
+ }
+
+ /** Creates and returns instance of implementing class, using class name found in "class" attribute. */
+ public <T> T getClassAttribute()
+ {
+ return getClassAttribute("class");
+ }
+
+ /** Creates and returns instance of implementing class, using class name found in specified attribute. */
+ @SuppressWarnings("unchecked")
+ public <T> T getClassAttribute(String attributeName)
+ {
+ T result = null;
+ try {
+ // TODO: Hmm... is there a right way to do this, without an unchecked cast?
+ result = (T) m_element.createExecutableExtension(attributeName);
+ }
+ catch (ClassCastException ex) {
+ // For now, eat it, and don't return this extension.
+ // TODO: decide how to log this
+ }
+ catch (CoreException ex) {
+ // For now, eat it, and don't return this extension.
+ // TODO: decide how to log this
+ }
+ return result;
+ }
+
+ /** Creates and returns instance of implementing class, using class name found in specified attribute. */
+ @SuppressWarnings("unchecked")
+ public <T> T getClassAttribute(String attributeName, Object... arguments)
+ {
+ // Make sure we default to zero-argument form if we can.
+ if (arguments == null || arguments.length == 0)
+ return getClassAttribute(attributeName);
+
+ // If we have arguments, have to do a little extra work.
+ T result = null;
+ try {
+ // Get name of class we're trying to load from attribute.
+ String className = getAttribute(attributeName);
+
+ // Attempt to load class using the source plugin's class loader.
+ // TODO: is there a better way?
+ IContributor contributor = m_element.getContributor();
+ String pluginID = contributor.getName();
+ Bundle plugin = Platform.getBundle(pluginID);
+ Class<?> instance = plugin.loadClass(className);
+
+ // Select appropriate constructor for provided argument(s).
+ int argumentsLength = (arguments == null) ? 0 : arguments.length;
+ Class<?>[] argumentTypes = new Class<?>[argumentsLength];
+ for (int i=0; i<argumentsLength; ++i) {
+ argumentTypes[i] =
+ (arguments[i] == null) ? NullType.class : arguments[i].getClass();
+ }
+ Constructor<?> constructor = (Constructor<?>)
+ instance.getConstructor(argumentTypes);
+
+ // Invoke the constructor.
+ result = (T) constructor.newInstance(arguments);
+ }
+ catch (ClassNotFoundException ex) {
+ // TODO: decide how to log this
+ }
+ catch (NoSuchMethodException ex) {
+ // TODO: decide how to log this
+ }
+ catch (InvocationTargetException ex) {
+ // TODO: decide how to log this
+ }
+ catch (IllegalAccessException ex) {
+ // TODO: decide how to log this
+ }
+ catch (InstantiationException ex) {
+ // TODO: decide how to log this
+ }
+ catch (ClassCastException ex) {
+ // TODO: decide how to log this
+ }
+ catch (Exception ex) {
+ // TODO: decide how to log this
+ }
+ return result;
+ }
+
+ /** Returns child elements of this element. */
+ public List<ExtensionElement> getChildren()
+ {
+ return wrapExtensionElements(m_element.getChildren());
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ResourceManager.java b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ResourceManager.java
new file mode 100755
index 00000000000..91e4c54377f
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/ResourceManager.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.core;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.Plugin;
+
+
+// ---------------------------------------------------------------------------
+// ResourceManager
+// ---------------------------------------------------------------------------
+
+/**
+ * Plugin resource manager.
+ * This class should be instanced in the plugin's "start()" method,
+ * and disposed in the "stop()" method.
+ */
+public class ResourceManager{
+
+ // --- members ---
+
+ /** Plugin ID */
+ protected String m_pluginID = null;
+
+ /** Plugin */
+ protected Plugin m_plugin = null;
+
+ /** Parent resource manager, if any */
+ protected ResourceManager m_parentManager = null;
+
+ /** String resource manager */
+ protected ResourceBundle m_stringResources = null;
+
+ /** String resource property file name */
+ protected String m_stringResourceFilename = null;
+
+
+ // --- constructors/destructors ---
+
+ /**
+ * Constructor,
+ * Assumes string resources are in the file "messages.properties".
+ */
+ public ResourceManager(Plugin plugin) {
+ this(plugin, "messages.properties");
+ }
+
+ /** Constructor */
+ public ResourceManager(Plugin plugin, String stringResourceFilename) {
+ m_pluginID = plugin.getBundle().getSymbolicName();
+ m_plugin = plugin;
+ m_stringResourceFilename = stringResourceFilename;
+ getStringRegistry(); // creates registry object
+ }
+
+ /** Dispose method */
+ public void dispose() {
+ disposeStringRegistry();
+ m_stringResourceFilename = null;
+ m_plugin = null;
+ m_pluginID = null;
+ }
+
+
+ // --- accessors ---
+
+ /** Returns plugin we're associated with */
+ public Plugin getPlugin() {
+ return m_plugin;
+ }
+
+
+ // --- parent manager management ---
+
+ /** Sets parent resource manager, if any */
+ public void setParentManager(ResourceManager parentManager) {
+ m_parentManager = parentManager;
+ }
+
+ /** Gets parent resource manager, if any */
+ public ResourceManager getParentManager() {
+ return m_parentManager;
+ }
+
+
+ // --- string resource management ---
+
+ /** Creates/returns string registry */
+ protected ResourceBundle getStringRegistry() {
+ if (m_stringResources == null) {
+ String filename = m_stringResourceFilename;
+
+ // The ".properties" extension is assumed, so we trim it here
+ String propertiesExtension = ".properties";
+ if (filename.endsWith(propertiesExtension)) {
+ filename = filename.substring(0, filename.length() -
+ propertiesExtension.length());
+ }
+
+ // NOTE: We have to be careful to pick up the class loader
+ // from the plugin class, otherwise we default to the classloader
+ // of the ResourceManager class, which is the classloader
+ // for the plugin the ResourceManager comes from.
+ ClassLoader classLoader = m_plugin.getClass().getClassLoader();
+ Locale locale = Locale.getDefault();
+
+ // we'll check for .properties file first
+ // in the same directory as the plugin activator class
+ String propertyFileName1 = m_pluginID + ".plugin." + filename;
+ try {
+ m_stringResources =
+ ResourceBundle.getBundle(propertyFileName1,
+ locale, classLoader);
+ }
+ catch (MissingResourceException e) {
+ // TODO: log this exception (probably a .properties file is missing)
+ m_stringResources = null;
+ }
+
+ // if not found, we try in the default package
+ // (that is, the top-level "src" or "resources" folder)
+ String propertyFileName2 = filename;
+ if (m_stringResources == null) {
+ try {
+ m_stringResources =
+ ResourceBundle.getBundle(propertyFileName2,
+ locale, classLoader);
+ }
+ catch (MissingResourceException e) {
+ // TODO: log this exception (probably a .properties file is missing)
+ m_stringResources = null;
+ }
+ }
+ }
+ return m_stringResources;
+ }
+
+ /** Disposes of string registry */
+ protected void disposeStringRegistry() {
+ m_stringResources = null;
+ }
+
+ /** Returns string resource for specified key */
+ public String getString(String key) {
+ String result = null;
+ if (key == null) return "(null resource)";
+
+ // get string registry, look up key
+ ResourceBundle strings = getStringRegistry();
+ if (strings == null) {
+ // if we can't get the registry, display the key instead,
+ // so we know what's missing (e.g. the .properties file)
+ result = "(" + key + ")";
+ }
+ else {
+ try {
+ result = strings.getString(key);
+ }
+ catch (MissingResourceException e) {
+ // we fail, but don't throw an exception
+ // so we don't screw any UI setup that depends
+ // on this string resource
+ result = null;
+ }
+ }
+
+ // if we fail, try the parent manager if there is one
+ if (result == null && m_parentManager != null) {
+ result = m_parentManager.getString(key);
+ }
+
+ // if we still fail, display the key instead,
+ // so we know what's missing
+ if (result == null) result = "[" + key + "]";
+ return result;
+ }
+
+ /** Formats string resource with specified argument(s) */
+ public String getString(String key, Object... arguments) {
+ return MessageFormat.format(getString(key), arguments);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/plugin/CDTVisualizerCorePlugin.java b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/plugin/CDTVisualizerCorePlugin.java
new file mode 100755
index 00000000000..5b6b7e44881
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.core/src/org/eclipse/cdt/visualizer/core/plugin/CDTVisualizerCorePlugin.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.core.plugin;
+
+import org.eclipse.cdt.visualizer.core.ResourceManager;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+// ----------------------------------------------------------------------------
+// CDTVisualizerCorePlugin
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT visualizer core plugin class.
+ *
+ * This plugin contains the non-UI components of the visualizer framework.
+ */
+public class CDTVisualizerCorePlugin extends AbstractUIPlugin
+{
+ // --- constants ---
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.cdt.visualizer.core"; //$NON-NLS-1$
+
+
+ // --- static members ---
+
+ /** Singleton instance */
+ protected static CDTVisualizerCorePlugin s_plugin;
+
+ /** Returns the singleton instance */
+ public static CDTVisualizerCorePlugin getDefault() {
+ return s_plugin;
+ }
+
+ /** Resource manager */
+ protected static ResourceManager s_resources = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor */
+ public CDTVisualizerCorePlugin() {
+ }
+
+
+ // --- plugin startup/shutdown methods ---
+
+ /** Invoked when plugin is loaded. */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ s_plugin = this;
+
+ // touch activator classes of any plugins we depend on,
+ // to ensure their start() methods are called first
+ // (None for now.)
+
+ // initialize resource management (strings, images, fonts, colors, etc.)
+ getPluginResources();
+ }
+
+ /** Invoked when plugin is stopped. */
+ public void stop(BundleContext context) throws Exception {
+ // clean up resource management
+ cleanupPluginResources();
+
+ s_plugin = null;
+ super.stop(context);
+ }
+
+
+ // --- logging ---
+
+ /**
+ * Writes message to Eclipse log.
+ * Severity can be one of:
+ * Status.OK, Status.ERROR, Status.INFO, Status.WARNING, Status.CANCEL
+ */
+ public static void log(int severity, String text)
+ {
+ Status status = new Status(severity, PLUGIN_ID, text);
+ ResourcesPlugin.getPlugin().getLog().log(status);
+ }
+
+
+ // --- resource management ---
+
+ /** Returns resource manager for this plugin */
+ public ResourceManager getPluginResources() {
+ if (s_resources == null) {
+ s_resources = new ResourceManager(this);
+ }
+ return s_resources;
+ }
+
+ /** Releases resource manager for this plugin. */
+ public void cleanupPluginResources() {
+ s_resources.dispose();
+ }
+
+ /** Convenience method for getting plugin resource manager */
+ public static ResourceManager getResources() {
+ return getDefault().getPluginResources();
+ }
+
+ /** Convenience method for looking up string resources */
+ public static String getString(String key) {
+ return getDefault().getPluginResources().getString(key);
+ }
+ /** Convenience method for looking up string resources */
+ public static String getString(String key, Object... arguments) {
+ return getDefault().getPluginResources().getString(key, arguments);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/.classpath b/visualizer/org.eclipse.cdt.visualizer.ui/.classpath
new file mode 100755
index 00000000000..31db9a91174
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/.project b/visualizer/org.eclipse.cdt.visualizer.ui/.project
new file mode 100755
index 00000000000..a76968ea1d3
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.visualizer.ui</name>
+ <comment></comment>
+ <projects>
+ </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.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/.settings/org.eclipse.jdt.core.prefs b/visualizer/org.eclipse.cdt.visualizer.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 00000000000..a2d0967c487
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Fri Jul 01 09:07:15 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/ABOUT.txt b/visualizer/org.eclipse.cdt.visualizer.ui/ABOUT.txt
new file mode 100755
index 00000000000..ed483c41987
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/ABOUT.txt
@@ -0,0 +1,17 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+This plugin defines the UI components of the CDT Visualizer feature.
+
+For an overview of the Visualizer feature, see the following file:
+
+ /org.eclipse.cdt.visualizer-feature/ABOUT.txt.
+
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/META-INF/MANIFEST.MF b/visualizer/org.eclipse.cdt.visualizer.ui/META-INF/MANIFEST.MF
new file mode 100755
index 00000000000..baacda0774b
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin.name
+Bundle-SymbolicName: org.eclipse.cdt.visualizer.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.visualizer.ui.plugin.CDTVisualizerUIPlugin
+Bundle-Vendor: %provider.name
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.cdt.visualizer.core,
+ org.eclipse.core.resources
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.cdt.visualizer.ui,
+ org.eclipse.cdt.visualizer.ui.canvas,
+ org.eclipse.cdt.visualizer.ui.events,
+ org.eclipse.cdt.visualizer.ui.plugin,
+ org.eclipse.cdt.visualizer.ui.test,
+ org.eclipse.cdt.visualizer.ui.util
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/about.html b/visualizer/org.eclipse.cdt.visualizer.ui/about.html
new file mode 100644
index 00000000000..cb740ae8bc8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/build.properties b/visualizer/org.eclipse.cdt.visualizer.ui/build.properties
new file mode 100755
index 00000000000..cd7654a8664
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/build.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+###############################################################################
+source.. = src/,\
+ resources/
+src.includes = schema/,\
+ about.html
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html,\
+ icons/,\
+ plugin.xml
+src.includes = about.html
+ \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/icons/full/view16/visualizer_view.png b/visualizer/org.eclipse.cdt.visualizer.ui/icons/full/view16/visualizer_view.png
new file mode 100755
index 00000000000..c7d0e9f44a5
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/icons/full/view16/visualizer_view.png
Binary files differ
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/plugin.properties b/visualizer/org.eclipse.cdt.visualizer.ui/plugin.properties
new file mode 100644
index 00000000000..9e0a6a8cdc8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/plugin.properties
@@ -0,0 +1,19 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Plugin string resources
+# -----------------------------------------------------------------------------
+
+plugin.name=CDT Visualizer UI Plug-in
+provider.name=Eclipse CDT
+
+view.visualizer.name=Visualizer
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/plugin.xml b/visualizer/org.eclipse.cdt.visualizer.ui/plugin.xml
new file mode 100755
index 00000000000..5b5ea5e7d9c
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/plugin.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org.eclipse.cdt.visualizer.ui.visualizer" name="Visualizer" schema="schema/org.eclipse.cdt.visualizer.ui.visualizer.exsd"/>
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Views -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+
+ <!-- Visualizer View to host actual visualizers -->
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.debug.ui"
+ class="org.eclipse.cdt.visualizer.ui.VisualizerView"
+ icon="icons/full/view16/visualizer_view.png"
+ id="org.eclipse.cdt.visualizer.view"
+ name="%view.visualizer.name">
+ </view>
+ </extension>
+
+ <!-- Debug Perspective -->
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.debug.ui.DebugPerspective">
+
+ <!-- add Visualizer View in same "slot" as outline view -->
+ <view
+ relative="org.eclipse.ui.views.ContentOutline"
+ visible="true"
+ relationship="stack"
+ id="org.eclipse.cdt.visualizer.view">
+ </view>
+ <viewShortcut
+ id="org.eclipse.cdt.visualizer.view">
+ </viewShortcut>
+ </perspectiveExtension>
+ </extension>
+</plugin>
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/pom.xml b/visualizer/org.eclipse.cdt.visualizer.ui/pom.xml
new file mode 100644
index 00000000000..b52eb491215
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>8.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.visualizer.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/resources/messages.properties b/visualizer/org.eclipse.cdt.visualizer.ui/resources/messages.properties
new file mode 100644
index 00000000000..56de5d40b3b
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/resources/messages.properties
@@ -0,0 +1,17 @@
+# =============================================================================
+# Copyright (c) 2012 Tilera Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# William R. Swanson (Tilera Corporation)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Application string resources
+# -----------------------------------------------------------------------------
+
+# Visualizer viewer
+VisualizerViewer.no.visualizers.defined=No visualizers defined.
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/schema/org.eclipse.cdt.visualizer.ui.visualizer.exsd b/visualizer/org.eclipse.cdt.visualizer.ui/schema/org.eclipse.cdt.visualizer.ui.visualizer.exsd
new file mode 100644
index 00000000000..3f7e5e5f788
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/schema/org.eclipse.cdt.visualizer.ui.visualizer.exsd
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+-->
+<schema targetNamespace="org.eclipse.cdt.visualizer.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.cdt.visualizer.ui" id="org.eclipse.cdt.visualizer.visualizer" name="Visualizer"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="visualizer"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="visualizer">
+ <annotation>
+ <documentation>
+ IVisualizer type definition.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ IVisualizer unique ID.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ IVisualizer implementing class.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.visualizer.IVisualizer"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizer.java
new file mode 100644
index 00000000000..7f5f63b84a3
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizer.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+// ----------------------------------------------------------------------------
+// IVisualizer
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT Visualizer interface.
+ *
+ * An IVisualizer encapsulates a specific graphic presentation of the
+ * currently selected object (launch, target, etc.).
+ *
+ * It knows how to create a Control to draw on, which is displayed by
+ * the Visualizer Viewer, and also knows how to draw its presentation on
+ * that control.
+ *
+ * A visualizer can be generic (e.g. knows how to draw any kind of
+ * launch) or specific (e.g. specialized for a particular type of
+ * launch or execution target). The viewer automatically chooses
+ * the most specific IVisualizer that reports it is able to render
+ * the current selection.
+ */
+public interface IVisualizer
+ extends ISelectionProvider
+{
+ // --- init methods ---
+
+ /** Invoked when visualizer is created, to permit any initialization. */
+ public void initializeVisualizer();
+
+ /** Invoked when visualizer is disposed, to permit any cleanup. */
+ public void disposeVisualizer();
+
+
+ // --- accessors ---
+
+ /** Sets non-localized name. */
+ public void setName(String name);
+ /** Gets non-localized name. */
+
+ public String getName();
+
+ /** Sets localized display name. */
+ public void setDisplayName(String displayName);
+
+ /** Gets localized display name. */
+ public String getDisplayName();
+
+ /** Sets localized description string. */
+ public void setDescription(String description);
+
+ /** Gets localized description string. */
+ public String getDescription();
+
+
+ // --- viewer management ---
+
+ /** Called by viewer when visualizer is added to it. */
+ public void setViewer(IVisualizerViewer viewer);
+
+ /** Returns viewer control for this visualizer. */
+ public IVisualizerViewer getViewer();
+
+
+ // --- visualizer selection management ---
+
+ /** Invoked when visualizer has been selected. */
+ public void visualizerSelected();
+
+ /** Invoked when another visualizer has been selected, hiding this one. */
+ public void visualizerDeselected();
+
+
+ // --- control management ---
+
+ /** Creates and returns visualizer's UI control on specified parent control. */
+ public Control createControl(Composite parent);
+
+ /** Gets visualizer control.
+ * Returns null if createControl() has not yet been called.
+ */
+ public Control getControl();
+
+
+ // --- menu/toolbar management ---
+
+ /**
+ * Invoked when visualizer is selected, to populate the toolbar.
+ * The toolbar starts in a completely cleared state.
+ * The Visualizer can add/edit actions as desired.
+ * There is no need to invoke update on the toolbar, the viewer handles that.
+ */
+ public void populateToolBar(IToolBarManager toolBarManager);
+
+ /**
+ * Invoked when visualizer is selected, to populate the toolbar's menu.
+ * The toolbar starts in a completely cleared state.
+ * The Visualizer can add/edit actions as desired.
+ * There is no need to invoke update on the toolbar, the viewer handles that.
+ */
+ public void populateMenu(IMenuManager menuManager);
+
+ /**
+ * Invoked when visualizer view's context menu is invoked, to populate it.
+ * The toolbar starts in a completely cleared state.
+ * The Visualizer can add/edit actions as desired.
+ * There is no need to invoke update on the toolbar, the viewer handles that.
+ */
+ public void populateContextMenu(IMenuManager menuManager);
+
+
+ // --- workbench selection management ---
+
+ /**
+ * Tests whether if the IVisualizer can display the selection
+ * (or something reachable from it).
+ *
+ * Returns a positive "weight" if true, and zero otherwise.
+ * If multiple visualizers can handle a given selection,
+ * the one reporting the highest weight value "wins".
+ * In case of ties, an arbitrary visualizer is selected.
+ *
+ * The weight should reflect the specificity of the visualizer;
+ * in other words, a "default" visualization for a given selection
+ * should have a low weight, and a special case should have
+ * a higher weight; this allows the visualizer view to "fall back"
+ * to the default visualization in the general case.
+ */
+ public int handlesSelection(ISelection selection);
+
+ /**
+ * Invoked by VisualizerViewer when workbench selection changes.
+ */
+ public void workbenchSelectionChanged(ISelection selection);
+
+
+ // --- selection changed event handling ---
+
+ /** Adds external listener for selection change events. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener);
+
+ /** Removes external listener for selection change events. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener);
+
+ /** Gets current externally-visible selection. */
+ public ISelection getSelection();
+
+ /** Sets current externally-visible selection. */
+ public void setSelection(ISelection selection);
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizerViewer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizerViewer.java
new file mode 100644
index 00000000000..5cdda14cc78
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/IVisualizerViewer.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui;
+
+import org.eclipse.cdt.visualizer.ui.events.IVisualizerViewerListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+
+
+// ----------------------------------------------------------------------------
+// IVisualizerViewer
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT Visualizer Viewer interface.
+ *
+ * An IVisualizerViewer is a simple container for multiple
+ * IVisualizers, where the currently selected IVisualizer
+ * determines which IVisualizer control is displayed in the viewer.
+ */
+public interface IVisualizerViewer
+{
+ // --- accessors ---
+
+ /** Gets containing view. */
+ public VisualizerView getView();
+
+ /** Returns non-localized unique name for selected visualizer. */
+ public String getVisualizerName();
+
+ /** Returns localized name to display for selected visualizer. */
+ public String getVisualizerDisplayName();
+
+ /** Returns localized tooltip text to display for selected visualizer. */
+ public String getVisualizerDescription();
+
+
+
+ // --- control management ---
+
+ /** Gets viewer control. */
+ public Control getControl();
+
+
+ // --- focus handling ---
+
+ /**
+ * Invoked by VisualizerView when currently selected presentation,
+ * if any, should take the focus.
+ */
+ public boolean setFocus();
+
+
+ // --- menu/toolbar management ---
+
+ /** Invoked when visualizer is selected, to populate the toolbar. */
+ public void populateToolBar(IToolBarManager toolBarManager);
+
+ /** Invoked when visualizer is selected, to populate the toolbar's menu. */
+ public void populateMenu(IMenuManager menuManager);
+
+
+ // --- context menu handling ---
+
+ /** Invoked when context menu is about to be shown. */
+ public void populateContextMenu(IMenuManager m);
+
+ /** Gets context menu location. */
+ public Point getContextMenuLocation();
+
+
+ // --- selection handling ---
+
+ /**
+ * Invoked by VisualizerView when workbench selection changes,
+ * and the change was made by some other view.
+ */
+ public void workbenchSelectionChanged(ISelection selection);
+
+ /** Adds external listener for selection change events. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener);
+
+ /** Removes external listener for selection change events. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener);
+
+ /** Gets current externally-visible selection. */
+ public ISelection getSelection();
+
+
+ // --- events ---
+
+ /** Adds listener for viewer events. */
+ public void addVisualizerViewerListener(IVisualizerViewerListener listener);
+
+ /** Removes listener for viewer events. */
+ public void removeVisualizerViewerListener(IVisualizerViewerListener listener);
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/Visualizer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/Visualizer.java
new file mode 100755
index 00000000000..a2b110b60c5
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/Visualizer.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui;
+
+import org.eclipse.cdt.visualizer.ui.util.SelectionManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+// ---------------------------------------------------------------------------
+// Visualizer
+// ---------------------------------------------------------------------------
+
+/**
+ * Base class for IVisualizer implementations.
+ */
+abstract public class Visualizer
+ implements IVisualizer, ISelectionProvider, ISelectionChangedListener
+{
+ // --- members ---
+
+ /** Visualizer's non-localized name. */
+ protected String m_name;
+
+ /** Visualizer's localized, displayable name. */
+ protected String m_displayName;
+
+ /** Visualizer's localized, displayable description. */
+ protected String m_description;
+
+ /** The parent view control. */
+ protected IVisualizerViewer m_viewer;
+
+ /** The visualizer control. */
+ protected Control m_control;
+
+ /** Externally visible selection manager. */
+ protected SelectionManager m_selectionManager;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public Visualizer() {
+ // TODO: internationalize these strings.
+ this("visualizer", "Visualizer", "Displays graphic representation of selection.");
+ }
+
+ /** Constructor. */
+ public Visualizer(String name, String displayName, String description) {
+ setName(name);
+ setDisplayName(displayName);
+ setDescription(description);
+ m_selectionManager = new SelectionManager(this, "Visualizer selection manager");
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_name = null;
+ m_displayName = null;
+ m_description = null;
+ disposeControl();
+ m_viewer = null;
+ if (m_selectionManager != null) {
+ m_selectionManager.dispose();
+ m_selectionManager = null;
+ }
+ }
+
+
+ // --- init methods ---
+
+ /** Invoked when visualizer is created, to permit any initialization.
+ * Intended to be overridden. Default implementation does nothing.
+ */
+ public void initializeVisualizer()
+ {
+ }
+
+ /** Invoked when visualizer is disposed, to permit any cleanup.
+ * Intended to be overridden. Default implementation calls dispose().
+ */
+ public void disposeVisualizer()
+ {
+ dispose();
+ }
+
+
+ // --- accessors ---
+
+ /** Sets non-localized name. */
+ public void setName(String name) {
+ m_name = name;
+ }
+ /** Gets non-localized name. */
+ public String getName() {
+ return m_name;
+ }
+
+ /** Sets localized display name. */
+ public void setDisplayName(String displayName) {
+ m_displayName = displayName;
+ }
+ /** Gets localized display name. */
+ public String getDisplayName() {
+ return m_displayName;
+ }
+
+ /** Sets localized description string. */
+ public void setDescription(String description) {
+ m_description = description;
+ }
+ /** Gets localized description string. */
+ public String getDescription() {
+ return m_description;
+ }
+
+
+ // --- viewer management ---
+
+ /** Sets viewer we're associated with. */
+ public void setViewer(IVisualizerViewer viewer) {
+ m_viewer = viewer;
+ }
+
+ /** Gets viewer we're associated with. */
+ public IVisualizerViewer getViewer() {
+ return m_viewer;
+ }
+
+
+ // --- visualizer selection management ---
+
+ /** Invoked when visualizer has been selected. */
+ public void visualizerSelected() {
+ };
+
+ /** Invoked when another visualizer has been selected, hiding this one. */
+ public void visualizerDeselected() {
+ };
+
+
+ // --- control management ---
+
+ /** Creates and returns visualizer's UI control on specified parent control. */
+ abstract public Control createControl(Composite parent);
+
+ /** Invoked when visualizer control should be disposed. */
+ abstract public void disposeControl();
+
+ /**
+ * Sets visualizer control.
+ * Intended to be called from createControl();
+ */
+ protected void setControl(Control control) {
+ m_control = control;
+ }
+
+ /** Gets visualizer control.
+ * Returns null if createControl() has not yet been called.
+ */
+ public Control getControl() {
+ return m_control;
+ }
+
+
+ // --- menu/toolbar management ---
+
+ /** Invoked by VisualizerViewer when toolbar needs to be populated. */
+ public void populateToolBar(IToolBarManager toolBarManager) {
+ }
+
+ /** Invoked by VisualizerViewer when toolbar menu needs to be populated. */
+ public void populateMenu(IMenuManager menuManager) {
+ }
+
+
+ // --- context menu handling ---
+
+ /** Invoked by VisualizerViewer when context menu needs to be populated. */
+ public void populateContextMenu(IMenuManager menuManager) {
+ }
+
+
+ // --- workbench selection management ---
+
+ /**
+ * Tests whether if the IVisualizer can display the selection
+ * (or something reachable from it).
+ */
+ public int handlesSelection(ISelection selection)
+ {
+ // Default implementation doesn't know how to display anything.
+ return 0;
+ }
+
+ /**
+ * Invoked by VisualizerViewer when workbench selection changes.
+ */
+ public void workbenchSelectionChanged(ISelection selection)
+ {
+ // Default implementation does nothing.
+ }
+
+
+ // --- ISelectionProvider implementation ---
+
+ // Delegate to selection manager.
+
+ /** Adds external listener for selection change events. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionManager.addSelectionChangedListener(listener);
+ }
+
+ /** Removes external listener for selection change events. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionManager.removeSelectionChangedListener(listener);
+ }
+
+ /** Raises selection changed event. */
+ public void raiseSelectionChangedEvent() {
+ m_selectionManager.raiseSelectionChangedEvent();
+ }
+
+ /** Gets current externally-visible selection. */
+ public ISelection getSelection()
+ {
+ return m_selectionManager.getSelection();
+ }
+
+ /** Sets externally-visible selection. */
+ public void setSelection(ISelection selection)
+ {
+ m_selectionManager.setSelection(selection);
+ }
+
+ /** Sets externally-visible selection. */
+ public void setSelection(ISelection selection, boolean raiseEvent)
+ {
+ m_selectionManager.setSelection(selection, raiseEvent);
+ }
+
+ /** Returns true if we currently have a non-empty selection. */
+ public boolean hasSelection()
+ {
+ return m_selectionManager.hasSelection();
+ }
+
+
+ // --- ISelectionChangedListener implementation ---
+
+ /**
+ * Intended to be invoked when visualizer control's selection changes.
+ * Sets control selection as its own selection,
+ * and raises selection changed event for any listeners.
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ setSelection(event.getSelection());
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerAction.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerAction.java
new file mode 100755
index 00000000000..0098d84854d
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerAction.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Event;
+
+
+// ---------------------------------------------------------------------------
+// VisualizerAction
+// ---------------------------------------------------------------------------
+
+/** Base class for visualizer actions.
+ * (Viewers are not required to use this class. This is simply a
+ * convenience wrapper for the standard Action class.)
+ */
+public class VisualizerAction extends Action
+{
+ // --- members ---
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ protected VisualizerAction() {
+ // NOTE: this constructor is only intended for deriving classes
+ // that need to construct the text/description/image attributes
+ // programmatically.
+ }
+
+ /** Constructor. */
+ public VisualizerAction(String text, String description) {
+ super(text);
+ setDescription(description);
+ }
+
+ /** Constructor. */
+ public VisualizerAction(String text, String description,
+ ImageDescriptor image) {
+ super(text, image);
+ setDescription(description);
+ }
+
+ /** Constructor. */
+ public VisualizerAction(String text, String description,
+ ImageDescriptor enabledImage, ImageDescriptor disabledImage) {
+ super(text, enabledImage);
+ setDescription(description);
+ setDisabledImageDescriptor(disabledImage);
+ }
+
+ /** Dispose method. */
+ public void dispose()
+ {
+ }
+
+
+ // --- methods ---
+
+ /** Invoked when action is triggered. */
+ public void run() {
+ }
+
+ /** Invoked when action is triggered,
+ * with the event that caused it.
+ */
+ public void runWithEvent(Event event) {
+ run();
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerView.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerView.java
new file mode 100644
index 00000000000..ec5ce2d73db
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerView.java
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+// Package declaration
+package org.eclipse.cdt.visualizer.ui;
+
+// Java classes
+import java.util.List;
+
+// SWT/JFace classes
+import org.eclipse.jface.action.IMenuListener2;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.jface.action.IToolBarManager;
+
+// Eclipse/CDT classes
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.IActionBars;
+
+// Custom classes
+import org.eclipse.cdt.visualizer.ui.events.IVisualizerViewerListener;
+import org.eclipse.cdt.visualizer.ui.events.VisualizerViewerEvent;
+import org.eclipse.cdt.visualizer.ui.util.SelectionProviderAdapter;
+import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
+import org.eclipse.cdt.visualizer.ui.util.WorkbenchSelectionAdapter;
+
+
+// ----------------------------------------------------------------------------
+// VisualizerView
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT Visualizer View class.
+ *
+ * This is the default implementation of the Visualizer View.
+ * It can also serve as a base class for custom visualizer views.
+ *
+ * The Visualizer View is a simple container with a toolbar,
+ * which presents an instance of an IVisualizerViewer,
+ * and mediates passing of selections to and from the viewer.
+ *
+ * The intent of the VisualizerView class is to encapsulate the
+ * standard Eclipse workbench view support, so the viewer does
+ * not have to worry about such things.
+ */
+public class VisualizerView
+ extends ViewPart
+ implements IVisualizerViewerListener,
+ ISelectionChangedListener
+{
+ // --- members ---
+
+ /** Whether view has been initialized */
+ protected boolean m_initialized = false;
+
+ /** Parent control of view. */
+ protected Composite m_parentControl = null;
+
+ /** Contained IVisualizerViewer control. */
+ protected IVisualizerViewer m_viewer = null;
+
+ /** Selection change event manager */
+ protected WorkbenchSelectionAdapter m_workbenchSelectionAdapter = null;
+
+ /** Context menu manager. */
+ protected MenuManager m_contextMenuManager = null;
+
+ /** Last context menu display location. */
+ protected Point m_contextMenuLocation = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor */
+ public VisualizerView() {
+ super();
+ }
+
+ /** Dispose method */
+ public void dispose() {
+ super.dispose();
+ setViewer(null);
+ disposeSelectionHandling();
+ }
+
+
+ // --- accessors ---
+
+ /** Returns whether view has been initialized. */
+ public boolean isInitialized()
+ {
+ return m_initialized;
+ }
+
+ /** Gets contained viewer control. */
+ public IVisualizerViewer getViewer()
+ {
+ return m_viewer;
+ }
+
+ /** Sets contained viewer control. */
+ public void setViewer(IVisualizerViewer viewer)
+ {
+ if (m_viewer != null) {
+ m_viewer.removeSelectionChangedListener(this);
+ m_viewer.removeVisualizerViewerListener(this);
+ }
+
+ m_viewer = viewer;
+
+ if (m_viewer != null)
+ {
+ m_viewer.addVisualizerViewerListener(this);
+ m_viewer.addSelectionChangedListener(this);
+ updateUI();
+ }
+ }
+
+
+ // --- ViewPart implementation ---
+
+ // IMPORTANT: a view may be loaded before the plugins, etc.
+ // that its content depends on, since Eclipse loads saved workbench "memento" state,
+ // including current perspective and view layout, before loading dependent plugins,
+ // and lazily loads plugins based on classes that get touched.
+ //
+ // Hence, a view class should invoke setInitialized(true) at the end
+ // of its createPartControl() method, and any methods that touch/repaint/update
+ // the view's controls, etc. should call isInitialized() to be sure
+ // these controls have been created.
+
+ /** Invoked when UI controls need to be created */
+ public void createPartControl(Composite parent) {
+ m_parentControl = parent;
+
+ // Reminder: Don't muck with the toolbar or toolbar menu here.
+ // (I.e. don't try to clean them out or set initial items.)
+ // VisualizerViewer's selection handling code
+ // allows the selected visualizer to set their content, and
+ // any fiddling you do here will only interfere with that.
+
+ // set up context menu support
+ initializeContextMenu();
+
+ // set up selection handling
+ initializeSelectionHandling();
+
+ // initialize viewer control
+ initializeViewer();
+
+ m_initialized = true;
+ }
+
+ /** Invoked when view should take the focus.
+ * Note: this can be invoked before the view is fully initialized
+ * (for example, when loading views from workspace memento information),
+ * in which case it should silently do nothing.
+ */
+ public void setFocus() {
+ if (m_viewer != null) m_viewer.setFocus();
+ }
+
+
+ // --- initialization support ---
+
+ /**
+ * Creates and returns VisualizerViewer control.
+ * Intended to be overridden by derived types.
+ */
+ protected IVisualizerViewer createViewer(Composite parent)
+ {
+ return (m_viewer != null) ? m_viewer : new VisualizerViewer(this, parent);
+ }
+
+ /**
+ * Invoked by createPartControl() method when view instance is created.
+ * Intended to be overridden by derived classes.
+ */
+ protected void initializeViewer() {
+ IVisualizerViewer viewer = createViewer(m_parentControl);
+ setViewer(viewer);
+ }
+
+
+ // --- tab name management ---
+
+ /** Sets displayed tab name and description for this view. */
+ public void setTabName(String displayName)
+ {
+ setPartName(displayName);
+ }
+
+ /** Sets displayed tab name and description for this view. */
+ public void setTabDescription(String description)
+ {
+ setTitleToolTip(description);
+ }
+
+
+ // --- selection handling ---
+
+ /** Initializes selection handling for this view. */
+ protected void initializeSelectionHandling() {
+ // create workbench selection change adapter,
+ // to hook us into the workbench selection event mechanism
+ m_workbenchSelectionAdapter = new WorkbenchSelectionAdapter(this);
+ m_workbenchSelectionAdapter.addSelectionChangedListener(this);
+ }
+
+ /** Disposes selection handling for this view. */
+ protected void disposeSelectionHandling() {
+ if (m_workbenchSelectionAdapter != null) {
+ m_workbenchSelectionAdapter.dispose();
+ m_workbenchSelectionAdapter = null;
+ }
+ }
+
+ /** Gets current workbench selection. */
+ public ISelection getWorkbenchSelection() {
+ return m_workbenchSelectionAdapter.getSelection();
+ }
+
+ /** Sets current workbench selection, and raises selection changed event. */
+ public void setWorkbenchSelection(ISelection selection) {
+ m_workbenchSelectionAdapter.setSelection(this, selection);
+ }
+
+ /** Sets current workbench selection, and raises selection changed event. */
+ public void setWorkbenchSelection(List<?> selection) {
+ ISelection iselection = SelectionUtils.toSelection(selection);
+ m_workbenchSelectionAdapter.setSelection(this, iselection);
+ }
+
+ // --- ISelectionChangedListener implementation ---
+
+ /** Invoked by WorkbenchSelectionAdapter when selection changes,
+ * and by viewer when visualizer selection changes.
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object source = event.getSource();
+ if (source instanceof SelectionProviderAdapter) {
+ source = ((SelectionProviderAdapter) source).getActualSource();
+ }
+ // if the source is the current VisualizerViewer,
+ // it's a user selection in the viewer, so we want to pass
+ // the selection change on to the workbench
+ if (source == m_viewer) {
+ // tell viewer about workbench selection
+ ISelection selection = event.getSelection();
+ setWorkbenchSelection(selection);
+
+ // update toolbar/menu to reflect changed selection
+ updateUI();
+ }
+ // if the source is this view, it's an echo of a workbench
+ // event we sent out, so ignore it.
+ else if (source == this) {
+ // Do nothing.
+ }
+ // else this is a selection change from some other view
+ // in the workbench, which we should pass down to the viewer
+ else {
+ ISelection selection = event.getSelection();
+ workbenchSelectionChanged(selection);
+
+ // update toolbar/menu to reflect changed selection
+ updateUI();
+ }
+ }
+
+ /**
+ * Invoked from selectionChanged() when workbench's selection changes,
+ * but only if the selection change did not come from this view.
+ */
+ public void workbenchSelectionChanged(ISelection selection) {
+ if (m_viewer != null) {
+ m_viewer.workbenchSelectionChanged(selection);
+ }
+ }
+
+
+ // --- IVisulizerViewerListener implementation ---
+
+ /** Invoked when visualizer in view has changed. */
+ public void visualizerEvent(IVisualizerViewer source, VisualizerViewerEvent event) {
+ switch (event.getType()) {
+ case VisualizerViewerEvent.VISUALIZER_CHANGED:
+ updateUI();
+ break;
+ case VisualizerViewerEvent.VISUALIZER_CONTEXT_MENU:
+ showContextMenu(event.x, event.y);
+ }
+ }
+
+
+ // --- update methods ---
+
+ /** Updates tab name, toolbar, etc. from viewer. */
+ public void updateUI() {
+
+ // Update tab name/tooltip
+ // TODO: internationalize these default strings
+ String name = "Visualizer View";
+ String description = "Displays visualizations of launches.";
+ if (m_viewer != null) {
+ name = m_viewer.getVisualizerDisplayName();
+ description = m_viewer.getVisualizerDescription();
+
+ }
+ setTabName(name);
+ setTabDescription(description);
+
+ // Update toolbar & toolbar menu
+ if (m_viewer != null) {
+ IActionBars actionBars = getViewSite().getActionBars();
+
+ // Allow presentation to set the displayed toolbar content, if any
+ IToolBarManager toolBarManager = actionBars.getToolBarManager();
+ toolBarManager.removeAll();
+ m_viewer.populateToolBar(toolBarManager);
+ toolBarManager.update(true);
+
+ // Allow presentation to set the toolbar's menu content, if any
+ IMenuManager menuManager = actionBars.getMenuManager();
+ menuManager.removeAll();
+ m_viewer.populateMenu(menuManager);
+ menuManager.update(true);
+
+ // Note: when context menu is invoked,
+ // the poplateContextMenu() method is called by the view,
+ // which in turn delegates to the current visualizer
+ // to populate the context menu.
+
+ // Propagate the changes
+ actionBars.updateActionBars();
+ }
+ }
+
+
+ // --- context menu support ---
+
+ /** Sets up context menu support. */
+ protected void initializeContextMenu() {
+ m_contextMenuManager = new MenuManager();
+ m_contextMenuManager.addMenuListener(new IMenuListener2() {
+ public void menuAboutToShow(IMenuManager m) {
+ VisualizerView.this.contextMenuShow(m);
+ }
+ public void menuAboutToHide(IMenuManager m) {
+ VisualizerView.this.contextMenuHide(m);
+ }
+ });
+
+ // We associate the view's context menu with the parent control.
+ // Viewer has the option of calling showContextMenu()
+ // to display the view's context menu.
+ Menu menu= m_contextMenuManager.createContextMenu(m_parentControl);
+ m_parentControl.setMenu(menu);
+ }
+
+ /** Invoked when context menu is about to be shown. */
+ protected void contextMenuShow(IMenuManager m)
+ {
+ m.removeAll();
+ m_viewer.populateContextMenu(m);
+ m.update();
+ }
+
+ /** Invoked when context menu is about to be hidden. */
+ protected void contextMenuHide(IMenuManager m)
+ {
+ }
+
+ /** Shows view's context menu at specified position. */
+ public void showContextMenu(int x, int y)
+ {
+ Menu menu = m_parentControl.getMenu();
+ if (menu != null) {
+ menu.setLocation(x, y);
+
+ // capture context menu location in relative coordinates
+ m_contextMenuLocation = m_parentControl.toControl(x,y);
+
+ // Note: showing menu implicitly invokes populateContextMenu()
+ // to populate context menu items.
+ menu.setVisible(true);
+
+ // Make sure we have the focus now
+ // so we'll still have it when the menu goes away,
+ // and user doesn't have to click twice.
+ setFocus();
+ }
+ }
+
+ /** Gets context menu location. */
+ public Point getContextMenuLocation() {
+ // Just asking the menu for its own location doesn't work,
+ // so we have to capture it above and return it here.
+ return m_contextMenuLocation;
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java
new file mode 100644
index 00000000000..a9c71c2d1b3
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/VisualizerViewer.java
@@ -0,0 +1,540 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.visualizer.core.Extension;
+import org.eclipse.cdt.visualizer.ui.events.IVisualizerViewerListener;
+import org.eclipse.cdt.visualizer.ui.events.VisualizerViewerEvent;
+import org.eclipse.cdt.visualizer.ui.plugin.CDTVisualizerUIPlugin;
+import org.eclipse.cdt.visualizer.ui.util.ListenerList;
+import org.eclipse.cdt.visualizer.ui.util.SelectionManager;
+import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuDetectEvent;
+import org.eclipse.swt.events.MenuDetectListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.part.PageBook;
+
+
+// ----------------------------------------------------------------------------
+// VisualizerViewer
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT Visualizer Viewer class.
+ *
+ * This is the default implementation of IVisualizerViewer.
+ * It can also serve as a base class for custom visualizer viewers.
+ *
+ * The Visualizer Viewer is a simple container for multiple
+ * IVisualizers, where the currently selected IVisualizer
+ * determines which IVisualizer control is displayed in the viewer.
+ *
+ * The base implementation simply displays a single IVisualizer at a time.
+ * One can programmatically switch selections, but there are no user
+ * controls for doing so. (The intent is that derived types can add
+ * various kinds of switching controls, like a combo box, etc.)
+ */
+public class VisualizerViewer extends PageBook
+ implements IVisualizerViewer, MenuDetectListener,
+ ISelectionProvider, ISelectionChangedListener
+{
+ // --- constants ---
+
+ /** Extension point name for list of IVisualizer types. */
+ public static final String VISUALIZER_EXTENSION_POINT_NAME = "visualizer"; //$NON-NLS-1$
+
+
+ // --- members ---
+
+ /** Containing view. */
+ protected VisualizerView m_view = null;
+
+ /** Parent control. */
+ protected Composite m_parent = null;
+
+ /** List of registered visualizer types. */
+ protected Map<String, IVisualizer> m_visualizers = null;
+
+ /** Currently selected visualizer. */
+ protected IVisualizer m_currentVisualizer = null;
+
+ /** Event listeners. */
+ protected ListenerList m_listeners = null;
+
+ /** Viewer selection manager. */
+ protected SelectionManager m_selectionManager = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public VisualizerViewer(VisualizerView view, Composite parent) {
+ super(parent, SWT.NONE);
+ initVisualizerViewer(view, parent);
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ cleanupVisualizerViewer();
+ super.dispose();
+ }
+
+ /** Overridden to permit subclassing of SWT component */
+ protected void checkSubclass() {
+ // Do nothing.
+ // (Superclass implementation throws "Subclassing not allowed" exception.)
+ }
+
+
+ // --- init methods ---
+
+ /** Initializes control */
+ protected void initVisualizerViewer(VisualizerView view, Composite parent) {
+ m_view = view;
+ m_parent = parent;
+
+ // Event listener support
+ m_listeners = new ListenerList(this, "VisualizerViewer event listeners")
+ {
+ public void raise(Object listener, Object event) {
+ if (listener instanceof IVisualizerViewerListener &&
+ event instanceof VisualizerViewerEvent)
+ {
+ IVisualizerViewerListener typedListener = (IVisualizerViewerListener) listener;
+ VisualizerViewerEvent typedEvent = (VisualizerViewerEvent) event;
+ typedListener.visualizerEvent(VisualizerViewer.this, typedEvent);
+ }
+ }
+ };
+
+ // Selection change listener support
+ m_selectionManager = new SelectionManager(this, "Visualizer Viewer selection manager");
+
+ // Set default colors for empty viewer.
+ Display display = getDisplay();
+ setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
+
+ // Listen to paint event to draw "No visualizers" warning if needed.
+ this.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ VisualizerViewer.this.paint(e.gc);
+ }
+ });
+
+ // Load any visualizers defined through extension point.
+ loadVisualizers();
+ }
+
+ /** Cleans up control */
+ protected void cleanupVisualizerViewer() {
+ // perform any cleanup here
+ disposeVisualizers();
+ if (m_selectionManager != null) {
+ m_selectionManager.dispose();
+ m_selectionManager = null;
+ }
+ }
+
+
+ // --- accessors ---
+
+ /** Gets containing view. */
+ public VisualizerView getView() {
+ return m_view;
+ }
+
+ /** Returns non-localized unique name for selected visualizer. */
+ public String getVisualizerName()
+ {
+ String result = "visualizer";
+ if (m_currentVisualizer != null) result = m_currentVisualizer.getName();
+ return result;
+ }
+
+ /** Returns localized name to display for selected visualizer. */
+ public String getVisualizerDisplayName()
+ {
+ String result = "Visualizer";
+ if (m_currentVisualizer != null) result = m_currentVisualizer.getDisplayName();
+ return result;
+ }
+
+ /** Returns localized tooltip text to display for selected visualizer. */
+ public String getVisualizerDescription()
+ {
+ String result = "Visualizer";
+ if (m_currentVisualizer != null) result = m_currentVisualizer.getDescription();
+ return result;
+ }
+
+
+ // --- control management ---
+
+ /** Gets viewer control. */
+ public Control getControl() {
+ return this;
+ }
+
+
+ // --- focus handling ---
+
+ /**
+ * Invoked by VisualizerView when currently selected presentation,
+ * if any, should take the focus.
+ */
+ public boolean setFocus()
+ {
+ boolean result = false;
+ if (m_currentVisualizer != null) {
+ // Tell current visualizer's control to take the focus.
+ m_currentVisualizer.getControl().setFocus();
+ }
+ else {
+ // Otherwise, let viewer take the focus.
+ result = super.setFocus();
+ }
+ return result;
+ }
+
+
+ // --- viewer events ---
+
+ /** Adds listener for viewer events. */
+ public void addVisualizerViewerListener(IVisualizerViewerListener listener)
+ {
+ m_listeners.addListener(listener);
+ }
+
+ /** Removes listener for viewer events. */
+ public void removeVisualizerViewerListener(IVisualizerViewerListener listener)
+ {
+ m_listeners.removeListener(listener);
+ }
+
+ /** Raises change event for all listeners. */
+ public void raiseVisualizerChangedEvent()
+ {
+ VisualizerViewerEvent event =
+ new VisualizerViewerEvent(this, VisualizerViewerEvent.VISUALIZER_CHANGED);
+ m_listeners.raise(event);
+ }
+
+ /** Raises context menu event for all listeners. */
+ public void raiseContextMenuEvent(int x, int y)
+ {
+ VisualizerViewerEvent event =
+ new VisualizerViewerEvent(this, VisualizerViewerEvent.VISUALIZER_CONTEXT_MENU, x, y);
+ m_listeners.raise(event);
+ }
+
+
+ // --- visualizer management ---
+
+ /** Loads initial set of visualizers and constructs viewer controls. */
+ protected void loadVisualizers()
+ {
+ // TODO: add error checking, logging for errors in extension declarations
+ // TODO: do we need to worry about this being called more than once?
+
+ m_visualizers = new Hashtable<String, IVisualizer>();
+
+ List<Extension> visualizers = Extension.getExtensions(
+ CDTVisualizerUIPlugin.FEATURE_ID, VISUALIZER_EXTENSION_POINT_NAME);
+
+ if (visualizers != null) {
+ for(Extension e : visualizers) {
+ String id = e.getAttribute("id");
+ IVisualizer visualizerInstance = e.getClassAttribute();
+ if (id != null && visualizerInstance != null) {
+ // Add visualizer's control to viewer's "pagebook" of controls.
+ visualizerInstance.setViewer(this);
+ visualizerInstance.initializeVisualizer();
+ visualizerInstance.createControl(this);
+ m_visualizers.put(id, visualizerInstance);
+ }
+ }
+ }
+
+ // select initial visualization
+ selectDefaultVisualizer();
+ }
+
+ /** Cleans up visualizers. */
+ protected void disposeVisualizers()
+ {
+ for (String id : m_visualizers.keySet()) {
+ IVisualizer v = m_visualizers.get(id);
+ Control c = v.getControl();
+ c.dispose();
+ v.disposeVisualizer();
+ }
+ m_visualizers.clear();
+ }
+
+
+ /** Selects default visualizer.
+ * Default implementation displays visualizer that can handle
+ * the current selection.
+ */
+ public void selectDefaultVisualizer()
+ {
+ // fake a workbench selection changed event
+ updateVisualizerFromWorkbenchSelection();
+ }
+
+ /** Selects specified visualizer, makes its control visible. */
+ public void selectVisualizer(IVisualizer visualizer)
+ {
+ if (visualizer == null) return;
+ if (visualizer == m_currentVisualizer) return;
+
+ if (m_currentVisualizer != null) {
+ // let the visualizer know it's being hidden
+ m_currentVisualizer.visualizerDeselected();
+
+ // stop listening for context menu events
+ m_currentVisualizer.getControl().removeMenuDetectListener(this);
+
+ // stop listening for selection changed events
+ m_currentVisualizer.removeSelectionChangedListener(this);
+ }
+
+ m_currentVisualizer = visualizer;
+
+ if (m_currentVisualizer != null) {
+ // We've added visualizer's control in loadVisualizers(),
+ // so all we need to do here is select it.
+ showPage(visualizer.getControl());
+
+ // start listening for context menu events
+ m_currentVisualizer.getControl().addMenuDetectListener(this);
+
+ // start listening for selection changed events
+ m_currentVisualizer.addSelectionChangedListener(this);
+
+ // raise visualizer changed event, so view knows
+ // it should update tab name, toolbar, etc.
+ raiseVisualizerChangedEvent();
+
+ // make sure workbench knows about current visualizer selection
+ updateWorkbenchFromVisualizerSelection();
+
+ // no need to update visualizer from workbench selection,
+ // we already do that whenever the workbench selection changes
+
+ // let the visualizer know it's been shown
+ m_currentVisualizer.visualizerDeselected();
+ }
+ }
+
+ /** Gets current visualizer. */
+ public IVisualizer getVisualizer()
+ {
+ return m_currentVisualizer;
+ }
+
+
+ // --- menu/toolbar management ---
+
+ /** Invoked when visualizer is selected, to populate the toolbar. */
+ public void populateToolBar(IToolBarManager toolBarManager)
+ {
+ if (m_currentVisualizer != null)
+ m_currentVisualizer.populateToolBar(toolBarManager);
+ }
+
+ /** Invoked when visualizer is selected, to populate the toolbar's menu. */
+ public void populateMenu(IMenuManager menuManager)
+ {
+ if (m_currentVisualizer != null)
+ m_currentVisualizer.populateMenu(menuManager);
+ }
+
+
+ // --- context menu handling ---
+
+ /** Invoked when context menu gesture happens on current
+ * visualizer control.
+ */
+ public void menuDetected(MenuDetectEvent e) {
+ // raise event to allow view to show context menu
+ raiseContextMenuEvent(e.x, e.y);
+ }
+
+ /** Invoked when context menu is about to be shown. */
+ public void populateContextMenu(IMenuManager m)
+ {
+ if (m_currentVisualizer != null) {
+ m_currentVisualizer.populateContextMenu(m);
+ }
+ }
+
+ /** Gets context menu location. */
+ public Point getContextMenuLocation() {
+ return m_view.getContextMenuLocation();
+ }
+
+
+ // --- paint methods ---
+
+ /**
+ * Invoked when viewer needs to be repainted.
+ * May be overridden by derived classes.
+ * Default implementation displays "No visualizers defined." message
+ */
+ public void paint(GC gc)
+ {
+ gc.fillRectangle(getClientArea());
+ if (m_visualizers == null || m_visualizers.size() == 0) {
+ String noVisualizersMessage =
+ CDTVisualizerUIPlugin.getString("VisualizerViewer.no.visualizers.defined");
+ gc.drawString("(" + noVisualizersMessage + ")", 10, 10);
+ }
+ }
+
+
+ // --- ISelectionProvider implementation ---
+
+ // Delegate to selection manager.
+
+ /** Adds external listener for selection change events. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionManager.addSelectionChangedListener(listener);
+ }
+
+ /** Removes external listener for selection change events. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionManager.removeSelectionChangedListener(listener);
+ }
+
+ /** Raises selection changed event. */
+ public void raiseSelectionChangedEvent() {
+ m_selectionManager.raiseSelectionChangedEvent();
+ }
+
+ /** Gets current externally-visible selection. */
+ public ISelection getSelection()
+ {
+ return m_selectionManager.getSelection();
+ }
+
+ /** Sets externally-visible selection. */
+ public void setSelection(ISelection selection)
+ {
+ m_selectionManager.setSelection(selection);
+ }
+
+
+ // --- workbench selection handling ---
+
+ /**
+ * Updates visualizer from current workbench selection.
+ * NOTE: normally VisulizerView keeps the viewer in synch
+ * with the selection, so this should not need to be called
+ * except in special cases.
+ */
+ public void updateVisualizerFromWorkbenchSelection() {
+ ISelection selection = SelectionUtils.getWorkbenchSelection();
+ workbenchSelectionChanged(selection);
+ }
+
+ /**
+ * Invoked by VisualizerView when workbench selection changes,
+ * and change's source is not this view.
+ *
+ * Selects visualizer (if any) that knows how to display current
+ * selection. Also invokes workbenchSelectionChanged() on visualizer
+ * so it can update itself accordingly.
+ */
+ public void workbenchSelectionChanged(ISelection selection)
+ {
+ // See if we need to change visualizers to handle selection type.
+ IVisualizer handles = null;
+ int weight = 0;
+
+ // First, see if the current visualizer can handle the new selection.
+ // (This gives it automatic precedence if there's a tie.)
+ if (m_currentVisualizer != null) {
+ int w = m_currentVisualizer.handlesSelection(selection);
+ if (w > weight) {
+ handles = m_currentVisualizer;
+ weight = w;
+ }
+ }
+
+ // Next, check the list of other visualizers, to see if any
+ // of them is more specific than the current one.
+ for (IVisualizer v : m_visualizers.values()) {
+ if (v == m_currentVisualizer) continue; // already checked
+ int w = v.handlesSelection(selection);
+ if (w > weight) {
+ handles = v;
+ weight = w;
+ }
+ }
+
+ // If NOBODY claims ownership, and we don't have a visualizer yet,
+ // then pick somebody and let them take a whack at it.
+ if (handles == null && m_visualizers.size() > 0) {
+ handles = m_visualizers.values().iterator().next();
+ }
+
+ // If we need to change visualizers, select the new one.
+ // Note: this also reports the new visualizer's selection to the workbench
+ if (handles != null && handles != m_currentVisualizer) {
+ selectVisualizer(handles);
+ }
+
+ // Notify current visualizer that workbench selection has changed.
+ // (This means a visualizer is only notified of workbench selection changes
+ // if the selection is something it has reported that it can display.)
+ if (m_currentVisualizer != null) {
+ m_currentVisualizer.workbenchSelectionChanged(selection);
+ }
+ }
+
+
+ // --- visualizer selection handling ---
+
+ /** Updates workbench selection from current visualizer selection.
+ * Note: normally the viewer keeps the selection in synch,
+ * so you should not need to call this method except in special cases.
+ */
+ public void updateWorkbenchFromVisualizerSelection() {
+ // fake a selection changed event
+ m_selectionManager.raiseSelectionChangedEvent();
+ }
+
+ /** Invoked when visualizer's selection changes. */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Publish changed visualizer selection to any listeners.
+ setSelection(event.getSelection());
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java
new file mode 100755
index 00000000000..b4f2778cef4
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/BufferedCanvas.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.canvas;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+
+// ---------------------------------------------------------------------------
+// BufferedCanvas
+// ---------------------------------------------------------------------------
+
+/** Canvas control with double-buffering support. */
+public class BufferedCanvas extends Canvas
+ implements PaintListener, ControlListener
+{
+ // --- members ---
+
+ /** double-buffering image */
+ protected Image m_doubleBuffer = null;
+
+ /** buffer GC */
+ protected GC m_doubleBufferGC = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public BufferedCanvas(Composite parent) {
+ super(parent,
+ SWT.NO_BACKGROUND | // don't automatically clear background on paint event
+ SWT.NO_REDRAW_RESIZE // don't automatically repaint on resize event
+ );
+ initBufferedCanvas();
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ super.dispose();
+ cleanupBufferedCanvas();
+ }
+
+ // --- init methods ---
+
+ /** Initializes control. */
+ protected void initBufferedCanvas() {
+ addControlListener(this);
+ addPaintListener(this);
+ }
+
+ /** Cleans up control. */
+ protected void cleanupBufferedCanvas() {
+ removePaintListener(this);
+ removeControlListener(this);
+ if (m_doubleBuffer != null) {
+ m_doubleBuffer.dispose();
+ m_doubleBuffer = null;
+ }
+ }
+
+
+ // --- event handlers ---
+
+ /** Invoked when control is moved/resized */
+ public void controlMoved(ControlEvent e) {
+ // do nothing, we don't care
+ }
+
+ /** Invoked when control is resized */
+ public void controlResized(ControlEvent e) {
+ resized(getBounds());
+ }
+
+
+ // --- resize methods ---
+
+ /** Invoked when control is resized.
+ * Default implementation does nothing,
+ * intended to be overridden by derived types.
+ */
+ public void resized(Rectangle bounds) {
+
+ }
+
+
+ // --- GC management ---
+
+ /** Gets/creates GC for current background buffer.
+ * NOTE: The GC is disposed whenever the canvas size changes,
+ * so caller should not retain a reference to this GC.
+ */
+ protected synchronized GC getBufferedGC() {
+ if (m_doubleBufferGC == null) {
+
+ m_doubleBufferGC = new GC(m_doubleBuffer);
+ }
+ return m_doubleBufferGC;
+ }
+
+ /** Disposes of current background buffer GC. */
+ protected synchronized void disposeBufferedGC() {
+ if (m_doubleBufferGC != null) {
+ m_doubleBufferGC.dispose();
+ m_doubleBufferGC = null;
+ }
+ }
+
+
+ // --- paint methods ---
+
+ /** Invoked when control needs to be repainted */
+ public void paintControl(PaintEvent e) {
+ // Handle last paint event of a cluster.
+ if (e.count<=1) {
+ Display display = e.display;
+ GC gc = e.gc;
+ paintDoubleBuffered(display, gc);
+ }
+ }
+
+ /** Internal -- handles double-buffering support, calls paintCanvas() */
+ // NOTE: need display to create image buffer, not for painting code
+ protected void paintDoubleBuffered(Display display, GC gc) {
+ // get/create background image buffer
+ Rectangle clientArea = getClientArea();
+ int width = clientArea.width;
+ int height = clientArea.height;
+ if (m_doubleBuffer == null
+ || m_doubleBuffer.getBounds().width < width
+ || m_doubleBuffer.getBounds().height < height)
+ {
+ m_doubleBuffer = new Image(display, width, height);
+ disposeBufferedGC();
+ }
+
+ // create graphics context for buffer
+ GC bgc = getBufferedGC();
+
+ // copy current GC properties into it as defaults
+ bgc.setBackground(gc.getBackground());
+ bgc.setForeground(gc.getForeground());
+ bgc.setFont(gc.getFont());
+ bgc.setAlpha(255);
+
+ // invoke paintCanvas() method to paint into the buffer
+ try {
+ paintCanvas(bgc);
+ }
+ catch (Throwable t) {
+ // Throwing an exception in painting code can hang Eclipse,
+ // so catch any exceptions here.
+ System.err.println("BufferedCanvas: Exception thrown in painting code: \n" + t);
+ }
+
+ // then copy image buffer to actual canvas (reduces repaint flickering)
+ gc.drawImage(m_doubleBuffer, 0,0);
+ }
+
+ /** Invoked when canvas repaint event is raised.
+ * Default implementation clears canvas to background color.
+ */
+ public void paintCanvas(GC gc) {
+ clearCanvas(gc);
+ }
+
+ /** Clears canvas to background color. */
+ public void clearCanvas(GC gc) {
+ Rectangle bounds = getClientArea();
+ gc.fillRectangle(bounds);
+ }
+
+
+ // --- update methods ---
+
+ /** Redraws control */
+ public void update() {
+ // guard against update events that happen
+ // after app has shut down
+ if (! isDisposed()) {
+ redraw();
+ }
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvas.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvas.java
new file mode 100755
index 00000000000..1fbf1a4c590
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvas.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.canvas;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Composite;
+
+
+// ---------------------------------------------------------------------------
+// GraphicCanvas
+// ---------------------------------------------------------------------------
+
+/**
+ * Viewer canvas -- base class for canvas that displays a collection
+ * of persistent, repositionable graphic objects.
+ *
+ * Note: painting is done in order objects were added,
+ * so objects added last are drawn "on top" of others.
+ * Use raise/lower methods to change the object z-ordering, if needed.
+ */
+public class GraphicCanvas extends BufferedCanvas
+{
+ // --- members ---
+
+ /** Viewer elements. */
+ protected ArrayList<IGraphicObject> m_objects = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public GraphicCanvas(Composite parent) {
+ super(parent);
+ m_objects = new ArrayList<IGraphicObject>();
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ if (m_objects != null) {
+ m_objects.clear();
+ m_objects = null;
+ }
+ super.dispose();
+ }
+
+
+ // --- object management methods ---
+
+ /** Removes all elements */
+ public void clear() {
+ m_objects.clear();
+ }
+
+ /** Adds an element */
+ public IGraphicObject add(IGraphicObject element) {
+ if (! m_objects.contains(element)) {
+ m_objects.add(element);
+ }
+ return element;
+ }
+
+ /** Removes an element */
+ public void remove(IGraphicObject element) {
+ m_objects.remove(element);
+ }
+
+ /** Raises an element to top of repaint z-ordering */
+ public void raiseToFront(IGraphicObject element) {
+ if (m_objects.contains(element)) {
+ m_objects.remove(element);
+ m_objects.add(element);
+ }
+ }
+
+ /** Lowers an element to bottom of repaint z-ordering */
+ public void lowerToBack(IGraphicObject element) {
+ if (m_objects.contains(element)) {
+ m_objects.remove(element);
+ m_objects.add(0, element);
+ }
+ }
+
+
+ // --- painting methods ---
+
+ /** Paints elements on canvas. */
+ public void paintCanvas(GC gc) {
+ // paint background first
+ clearCanvas(gc);
+
+ // we paint object list from start to end,
+ // so end of the list is "top" in z-ordering
+
+ // allow objects to draw themselves
+ for (IGraphicObject gobj : m_objects) {
+ gobj.paint(gc, false);
+ }
+
+ // allow objects to paint any "decorations" on top of other stuff
+ for (IGraphicObject gobj : m_objects) {
+ if (gobj.hasDecorations())
+ gobj.paint(gc, true);
+ }
+ }
+
+
+ // --- point-to-object accessors ---
+
+ /** Returns first graphic object found under specified point */
+ public IGraphicObject getGraphicObject(int x, int y) {
+ return getGraphicObject(null, x, y);
+ }
+
+ /** Returns first graphic object found under specified point.
+ * If type argument is non-null, returns first object assignable to specified type.
+ */
+ public IGraphicObject getGraphicObject(Class<?> type, int x, int y) {
+ IGraphicObject result = null;
+
+ // note: have to search list in reverse order we draw it,
+ // so we hit items "on top" in the z-ordering first
+ int count = (m_objects == null) ? 0 : m_objects.size();
+ for (int i=count-1; i>=0; i--) {
+ IGraphicObject gobj = m_objects.get(i);
+ if (gobj.contains(x, y)) {
+ if (type != null) {
+ Class<?> objType = gobj.getClass();
+ if (! type.isAssignableFrom(objType)) continue;
+ }
+ result = gobj;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ // --- model data accessors ---
+
+ /** Returns graphic object (if any) that has specified data value. */
+ public IGraphicObject getGraphicObjectFor(Object value) {
+ IGraphicObject result = null;
+ for (IGraphicObject gobj : m_objects) {
+ if (gobj.getData() == value) {
+ result = gobj;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /** Returns data value (if any) for the specified graphic element. */
+ public Object getDataFor(IGraphicObject IGraphicObject) {
+ return (IGraphicObject == null) ? null : IGraphicObject.getData();
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java
new file mode 100644
index 00000000000..5fcef0d92d8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicCanvasVisualizer.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.canvas;
+
+import org.eclipse.cdt.visualizer.ui.Visualizer;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+// ---------------------------------------------------------------------------
+// GraphicCanvasVisualizer
+// ---------------------------------------------------------------------------
+
+/**
+ * Viewer canvas -- base class for canvas that displays a collection
+ * of persistent, repositionable graphic objects.
+ *
+ * Note: painting is done in order objects were added,
+ * so objects added last are drawn "on top" of others.
+ * Use raise/lower methods to change the object z-ordering, if needed.
+ */
+public class GraphicCanvasVisualizer extends Visualizer
+{
+ // --- members ---
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public GraphicCanvasVisualizer()
+ {
+ // TODO: internationalize these strings.
+ super("canvas", "Canvas Visualizer", "Displays graphic representation of selection.");
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ super.dispose();
+ }
+
+
+ // --- control management ---
+
+ /** Creates and returns visualizer control on specified parent. */
+ public Control createControl(Composite parent)
+ {
+ if (m_control == null) {
+ GraphicCanvas canvas = createCanvas(parent);
+ canvas.setMenu(parent.getMenu());
+ setControl(canvas);
+ initializeCanvas(canvas);
+ }
+ return getControl();
+ }
+
+ /** Invoked when visualizer control should be disposed. */
+ public void disposeControl()
+ {
+ if (m_control != null) {
+ disposeCanvas();
+ m_control.dispose();
+ setControl(null);
+ }
+ }
+
+
+ // --- canvas management ---
+
+ /** Creates and returns visualizer canvas control. */
+ public GraphicCanvas createCanvas(Composite parent)
+ {
+ return new GraphicCanvas(parent);
+ }
+
+ /** Invoked when canvas control should be disposed. */
+ public void disposeCanvas()
+ {
+
+ }
+
+ /** Invoked after visualizer control creation,
+ * to allow derived classes to do any initialization of canvas.
+ */
+ protected void initializeCanvas(GraphicCanvas canvas)
+ {
+ }
+
+ /** Gets downcast reference to canvas control. */
+ public GraphicCanvas getCanvas()
+ {
+ return (GraphicCanvas) getControl();
+ }
+
+
+ // --- menu/toolbar management ---
+
+ /** Invoked when visualizer is selected, to populate the toolbar. */
+ public void populateToolBar(IToolBarManager toolBarManager)
+ {}
+
+ /** Invoked when visualizer is selected, to populate the toolbar's menu. */
+ public void populateMenu(IMenuManager menuManager)
+ {}
+
+
+ // --- context menu handling ---
+
+ /** Invoked when visualizer view's context menu is invoked, to populate it. */
+ public void populateContextMenu(IMenuManager menuManager)
+ {}
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicObject.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicObject.java
new file mode 100755
index 00000000000..e89ad65bd23
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/GraphicObject.java
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.canvas;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+
+// ---------------------------------------------------------------------------
+// GraphicObject
+// ---------------------------------------------------------------------------
+
+/**
+ * Graphic object base class.
+ * Base class for objects that can be displayed and manipulated on a GraphicCanvas.
+ */
+public class GraphicObject
+ implements IGraphicObject
+{
+ // --- members ---
+
+ /** Data object, if any, associated with this graphic object. */
+ protected Object m_data = null;
+
+ /** Bounding rectangle of this element. */
+ protected Rectangle m_bounds = new Rectangle(0,0,0,0);
+
+ /** Whether this element is visible. */
+ protected boolean m_visible = true;
+
+ /** Whether this element is selected. */
+ protected boolean m_selected = false;
+
+ /** Foreground color (null means inherit from canvas) */
+ protected Color m_foreground = null;
+
+ /** Background color (null means inherit from canvas) */
+ protected Color m_background = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public GraphicObject() {
+ }
+
+ /** Constructor. */
+ public GraphicObject(int x, int y, int width, int height) {
+ m_bounds.x = x;
+ m_bounds.y = y;
+ m_bounds.width = width;
+ m_bounds.height = height;
+ }
+
+ /** Constructor. */
+ public GraphicObject(Rectangle bounds) {
+ m_bounds.x = bounds.x;
+ m_bounds.y = bounds.y;
+ m_bounds.width = bounds.width;
+ m_bounds.height = bounds.height;
+ }
+
+ /** Constructor. */
+ public GraphicObject(Object data) {
+ m_data = data;
+ }
+
+ /** Constructor. */
+ public GraphicObject(int x, int y, int width, int height, Object data) {
+ m_bounds.x = x;
+ m_bounds.y = y;
+ m_bounds.width = width;
+ m_bounds.height = height;
+ m_data = data;
+ }
+
+
+ /** Constructor. */
+ public GraphicObject(Rectangle bounds, Object data)
+ {
+ m_bounds.x = bounds.x;
+ m_bounds.y = bounds.y;
+ m_bounds.width = bounds.width;
+ m_bounds.height = bounds.height;
+ m_data = data;
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_data = null;
+ }
+
+
+ // --- accessors ---
+
+ /** Gets data object associated with this view element. */
+ public Object getData() {
+ return m_data;
+ }
+ /** Sets data object associated with this view element. */
+ public void setData(Object data) {
+ m_data = data;
+ }
+
+
+ /** Gets x location of this element */
+ public int getX() { return m_bounds.x; }
+ /** Sets x location of this element */
+ public void setX(int x) {
+ m_bounds.x = x;
+ }
+
+ /** Gets y location of this element */
+ public int getY() { return m_bounds.y; }
+ /** Sets y location of this element */
+ public void setY(int y) { m_bounds.y = y; }
+
+ /** Sets x/y position of this element */
+ public void setPosition(int x, int y) {
+ m_bounds.x = x; m_bounds.y = y;
+ }
+
+
+ /** Gets width of this element */
+ public int getWidth() { return m_bounds.width; }
+ /** Sets width of this element */
+ public void setWidth(int w) { m_bounds.width = w; }
+
+ /** Gets y location of this element */
+ public int getHeight() { return m_bounds.height; }
+ /** Sets y location of this element */
+ public void setHeight(int h) { m_bounds.height = h; }
+
+ /** Sets width/height of this element */
+ public void setSize(int w, int h) {
+ m_bounds.width = w; m_bounds.height = h;
+ }
+
+ /** Gets bounding rectangle of this element. */
+ public Rectangle getBounds() {
+ return m_bounds;
+ }
+ /** Sets bounding rectangle of this element. */
+ public void setBounds(int x, int y, int w, int h) {
+ m_bounds.x = x;
+ m_bounds.y = y;
+ m_bounds.width = w;
+ m_bounds.height = h;
+ }
+ /** Sets bounding rectangle of this element. */
+ public void setBounds(Rectangle bounds) {
+ m_bounds.x = bounds.x;
+ m_bounds.y = bounds.y;
+ m_bounds.width = bounds.width;
+ m_bounds.height = bounds.height;
+ }
+
+ /** Returns true if element bounds contains point. */
+ public boolean contains(int x, int y) {
+ return m_bounds.contains(x,y);
+ }
+ /** Returns true if element bounds are within specified rectangle. */
+ public boolean isWithin(Rectangle region) {
+ return (region.x <= m_bounds.x &&
+ region.y <= m_bounds.y &&
+ region.x + region.width >= m_bounds.x + m_bounds.width &&
+ region.y + region.height >= m_bounds.y + m_bounds.height);
+ }
+
+ /** Gets whether this element is visible. */
+ public boolean isVisible() {
+ return m_visible;
+ }
+
+ /** Sets whether this element is visible. */
+ public void setVisible(boolean visible) {
+ m_visible = visible;
+ }
+
+ /** Gets whether this element is selected. */
+ public boolean isSelected() {
+ return m_selected;
+ }
+
+ /** Sets whether this element is selected. */
+ public void setSelected(boolean selected) {
+ m_selected = selected;
+ }
+
+ /** Sets foreground color (null means inherit from container) */
+ public void setForeground(Color color) {
+ m_foreground = color;
+ }
+ /** Gets foreground color (null means inherit from container) */
+ public Color getForeground() {
+ return m_foreground;
+ }
+
+ /** Sets foreground color (null means inherit from container) */
+ public void setBackground(Color color) {
+ m_background = color;
+ }
+ /** Gets background color (null means inherit from container) */
+ public Color getBackground() {
+ return m_background;
+ }
+
+
+ // --- methods ---
+
+ /** Invoked to allow element to paint itself on the viewer canvas */
+ public void paint(GC gc, boolean decorations) {
+ if (isVisible()) {
+ // Set GC to reflect object properties, if set.
+ Color oldForeground = null;
+ Color oldBackground = null;
+ if (m_foreground != null) {
+ oldForeground = gc.getForeground();
+ gc.setForeground(m_foreground);
+ }
+ if (m_background != null) {
+ oldBackground = gc.getBackground();
+ gc.setBackground(m_background);
+ }
+
+ // Paint the object.
+ if (! decorations)
+ paintContent(gc);
+ else
+ paintDecorations(gc);
+
+ // Restore old state.
+ if (m_foreground != null) gc.setForeground(oldForeground);
+ if (m_background != null) gc.setBackground(oldBackground);
+ }
+ }
+
+ /**
+ * Paints content of graphic object.
+ * GC has already been set to this object's
+ * current foreground/background colors.
+ * Default implementation draws object's bounding box.
+ */
+ public void paintContent(GC gc) {
+ // Draw boundary rectangle of object.
+ gc.drawRectangle(m_bounds);
+
+ // Display selection as thicker boundary.
+ if (isSelected()) {
+ int x = m_bounds.x + 1;
+ int y = m_bounds.y + 1;
+ int width = m_bounds.width - 2; if (width < 0) width = 0;
+ int height = m_bounds.height - 2; if (height < 0) height = 0;
+ gc.drawRectangle(x,y,width,height);
+ }
+ }
+
+ /** Returns true if object has decorations to paint. */
+ public boolean hasDecorations() {
+ return false;
+ }
+
+ /** Invoked to allow element to paint decorations
+ * on top of other items drawn on top of it.
+ */
+ public void paintDecorations(GC gc) {
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/IGraphicObject.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/IGraphicObject.java
new file mode 100755
index 00000000000..dc9c5f18df5
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/canvas/IGraphicObject.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.canvas;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+
+// ---------------------------------------------------------------------------
+// IGraphicObject
+// ---------------------------------------------------------------------------
+
+/**
+ * An object that can be displayed and manipulated on a GraphicCanvas.
+ */
+public interface IGraphicObject
+{
+ // --- methods ---
+
+ /** Paints object using specified graphics context.
+ * If decorations is false, draws ordinary object content.
+ * If decorations is true, paints optional "decorations" layer.
+ */
+ public void paint(GC gc, boolean decorations);
+
+ /** Returns true if object has decorations to paint. */
+ public boolean hasDecorations();
+
+ /** Gets model data (if any) associated with this graphic object */
+ public Object getData();
+
+ /** Sets model data (if any) associated with this graphic object */
+ public void setData(Object data);
+
+ /** Whether graphic object contains the specified point. */
+ public boolean contains(int x, int y);
+
+ /** Returns true if element bounds are within specified rectangle. */
+ public boolean isWithin(Rectangle region);
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/IVisualizerViewerListener.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/IVisualizerViewerListener.java
new file mode 100644
index 00000000000..82e20d0c3c8
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/IVisualizerViewerListener.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.events;
+
+import org.eclipse.cdt.visualizer.ui.IVisualizerViewer;
+
+
+// ---------------------------------------------------------------------------
+// IVisualizerViewerListener
+// ---------------------------------------------------------------------------
+
+/**
+ * IVisualizerViewer event listener.
+ */
+public interface IVisualizerViewerListener
+{
+ // --- methods ---
+
+ /** Invoked when VisualizerViewer's selected IVisualizer changes. */
+ public void visualizerEvent(IVisualizerViewer source, VisualizerViewerEvent event);
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/VisualizerViewerEvent.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/VisualizerViewerEvent.java
new file mode 100644
index 00000000000..825d24d0305
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/events/VisualizerViewerEvent.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.events;
+
+import org.eclipse.cdt.visualizer.ui.IVisualizerViewer;
+import org.eclipse.cdt.visualizer.ui.util.Event;
+
+
+// ---------------------------------------------------------------------------
+// VisualizerViewerEvent
+// ---------------------------------------------------------------------------
+
+/**
+ * IVisualizerViewer event
+ */
+public class VisualizerViewerEvent extends Event
+{
+ // --- event types ---
+
+ /** Event type constant */
+ public static final int VISUALIZER_CHANGED = 1;
+
+ /** Event type constant */
+ public static final int VISUALIZER_CONTEXT_MENU = 2;
+
+
+ // --- members ---
+
+ /** X coordinate, for menu events. */
+ public int x;
+
+ /** Y coordinate, for menu events. */
+ public int y;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public VisualizerViewerEvent(IVisualizerViewer source, int eventType) {
+ super(source, eventType);
+ }
+
+ /** Constructor. */
+ public VisualizerViewerEvent(IVisualizerViewer source, int eventType, int x, int y) {
+ super(source, eventType);
+ this.x = x;
+ this.y = y;
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ super.dispose();
+ }
+
+ // --- Object methods ---
+
+ /** Converts event type to string */
+ public String typeToString(int type) {
+ String result = "";
+ switch (type) {
+ case VISUALIZER_CHANGED:
+ result = "VISUALIZER_CHANGED"; break;
+ default:
+ result = super.typeToString(type);
+ break;
+ }
+ return result;
+ }
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/plugin/CDTVisualizerUIPlugin.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/plugin/CDTVisualizerUIPlugin.java
new file mode 100755
index 00000000000..3d47d69ea1f
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/plugin/CDTVisualizerUIPlugin.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.plugin;
+
+import org.eclipse.cdt.visualizer.core.plugin.CDTVisualizerCorePlugin;
+import org.eclipse.cdt.visualizer.ui.util.Colors;
+import org.eclipse.cdt.visualizer.ui.util.UIResourceManager;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+// ----------------------------------------------------------------------------
+// CDTVisualizerUIPlugin
+// ----------------------------------------------------------------------------
+
+/**
+ * CDT visualizer UI plugin class.
+ *
+ * This plugin contains the UI components of the visualizer framework.
+ */
+public class CDTVisualizerUIPlugin extends AbstractUIPlugin
+{
+ // --- constants ---
+
+ /** Feature ID (used as prefix for extension points, etc). */
+ public static final String FEATURE_ID = "org.eclipse.cdt.visualizer.ui"; //$NON-NLS-1$
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.cdt.visualizer.ui"; //$NON-NLS-1$
+
+
+ // --- static members ---
+
+ /** Singleton instance */
+ protected static CDTVisualizerUIPlugin s_plugin;
+
+ /** Returns the singleton instance */
+ public static CDTVisualizerUIPlugin getDefault() {
+ return s_plugin;
+ }
+
+ /** Resource manager */
+ protected static UIResourceManager s_resources = null;
+
+
+ // --- constructors/destructors ---
+
+ /**
+ * Constructor
+ */
+ public CDTVisualizerUIPlugin() {
+ }
+
+
+ // --- plugin startup/shutdown methods ---
+
+ /** Invoked when plugin is loaded. */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ s_plugin = this;
+
+ // touch activator classes of any plugins we depend on,
+ // to ensure their start() methods are called first
+ // (None for now.)
+
+ // initialize resource management (strings, images, fonts, colors, etc.)
+ getPluginResources();
+ }
+
+ /** Invoked when plugin is stopped. */
+ public void stop(BundleContext context) throws Exception {
+ // clean up resource management
+ cleanupPluginResources();
+
+ s_plugin = null;
+ super.stop(context);
+ }
+
+
+ // --- logging ---
+
+ /**
+ * Writes message to Eclipse log.
+ * Severity can be one of:
+ * Status.OK, Status.ERROR, Status.INFO, Status.WARNING, Status.CANCEL
+ */
+ public static void log(int severity, String text)
+ {
+ Status status = new Status(severity, PLUGIN_ID, text);
+ ResourcesPlugin.getPlugin().getLog().log(status);
+ }
+
+
+ // --- resource management ---
+
+ /** Returns resource manager for this plugin */
+ public UIResourceManager getPluginResources() {
+ if (s_resources == null) {
+ s_resources = new UIResourceManager(this);
+ s_resources.setParentManager(CDTVisualizerCorePlugin.getResources());
+
+ // initialize Colors class, now that UIResources object is available.
+ Colors.initialize(s_resources);
+ }
+
+ return s_resources;
+ }
+
+ /** Releases resource manager for this plugin. */
+ public void cleanupPluginResources() {
+ s_resources.dispose();
+ }
+
+ /** Convenience method for getting plugin resource manager */
+ public static UIResourceManager getResources() {
+ return getDefault().getPluginResources();
+ }
+
+ /** Convenience method for looking up string resources */
+ public static String getString(String key) {
+ return getDefault().getPluginResources().getString(key);
+ }
+ /** Convenience method for looking up string resources */
+ public static String getString(String key, Object... arguments) {
+ return getDefault().getPluginResources().getString(key, arguments);
+ }
+
+ /** Convenience method for looking up image resources */
+ public static Image getImage(String key) {
+ return getDefault().getPluginResources().getImage(key);
+ }
+ /** Convenience method for looking up image resources */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return getDefault().getPluginResources().getImageDescriptor(key);
+ }
+
+ /** Convenience method for looking up font resources */
+ public static Font getFont(String fontName, int height) {
+ return getDefault().getPluginResources().getFont(fontName, height);
+ }
+ /** Convenience method for looking up font resources */
+ public static Font getFont(String fontName, int height, int style) {
+ return getDefault().getPluginResources().getFont(fontName, height, style);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvas.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvas.java
new file mode 100755
index 00000000000..13ea52d2e7a
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvas.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.test;
+
+import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Composite;
+
+
+// ---------------------------------------------------------------------------
+// TestCanvas
+// ---------------------------------------------------------------------------
+
+/**
+ * Default canvas control, used by TestCanvasVisualizer.
+ */
+public class TestCanvas extends GraphicCanvas
+{
+ // --- members ---
+
+ /** Text string to display. */
+ String m_text = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public TestCanvas(Composite parent) {
+ super(parent);
+ initDefaultCanvas(parent);
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ cleanupDefaultCanvas();
+ super.dispose();
+ }
+
+
+ // --- init methods ---
+
+ /** Initializes control */
+ protected void initDefaultCanvas(Composite parent) {
+ // perform any initialization here
+ }
+
+ /** Cleans up control */
+ protected void cleanupDefaultCanvas() {
+ }
+
+
+ // --- accessors ---
+
+ /** Sets text string to display. */
+ public void setText(String text)
+ {
+ m_text = text;
+ }
+
+
+ // --- methods ---
+
+ /** Invoked when canvas repaint event is raised.
+ * Default implementation clears canvas to background color.
+ */
+ public void paintCanvas(GC gc) {
+ super.paintCanvas(gc);
+
+ int margin = 10;
+ drawStringWrapNewlines(gc, m_text, margin, margin);
+ }
+
+
+ // --- utilities ---
+
+ /** Gets line height of text, based on current font */
+ public static int getTextHeight(GC gc) {
+ return gc.getFontMetrics().getHeight();
+ }
+
+ /** Draw string, wrapping if there are any newline chars. */
+ public static void drawStringWrapNewlines(GC gc, String text, int x, int y) {
+ int lineHeight = getTextHeight(gc);
+ drawStringWrapNewlines(gc, text, x, y, lineHeight);
+ }
+
+ /** Draw string, wrapping if there are any newline chars. */
+ public static void drawStringWrapNewlines(GC gc, String text, int x, int y, int lineHeight) {
+ if (text != null) {
+ String[] lines = text.split("\n");
+ for (int i=0; i<lines.length; i++) {
+ gc.drawString(lines[i], x, y, true); // transparent
+ y += lineHeight;
+ }
+ }
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvasVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvasVisualizer.java
new file mode 100644
index 00000000000..2b2a1b331ce
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/test/TestCanvasVisualizer.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.test;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
+import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
+import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
+import org.eclipse.jface.viewers.ISelection;
+
+
+// ---------------------------------------------------------------------------
+// TestCanvasVisualizer
+// ---------------------------------------------------------------------------
+
+/**
+ * Default visualizer, used only for testing framework.
+ *
+ * This view uses the CDT Visualizer framework.
+ */
+public class TestCanvasVisualizer extends GraphicCanvasVisualizer
+{
+ // --- constants ---
+
+ /** Eclipse ID for this visualizer */
+ public static final String ECLIPSE_ID = "org.eclipse.cdt.visualizer.ui.test.TestCanvasVisualizer";
+
+
+ // --- members ---
+
+ /** Visualizer control. */
+ TestCanvas m_canvas = null;
+
+
+ // --- constructors/destructors ---
+
+
+ // --- accessors ---
+
+ /** Gets canvas control. */
+ public TestCanvas getDefaultCanvas()
+ {
+ return m_canvas;
+ }
+
+
+ // --- IVisualizer implementation ---
+
+ /** Returns non-localized unique name for this visualizer. */
+ public String getName() {
+ return "default";
+ }
+
+ /** Returns localized name to display for this visualizer. */
+ public String getDisplayName() {
+ // TODO: use a string resource here.
+ return "Test Visualizer";
+ }
+
+ /** Returns localized tooltip text to display for this visualizer. */
+ public String getDescription() {
+ // TODO: use a string resource here.
+ return "Test visualizer (for debugging only).";
+ }
+
+ /** Creates and returns visualizer canvas control. */
+ public GraphicCanvas createCanvas(Composite parent)
+ {
+ m_canvas = new TestCanvas(parent);
+ return m_canvas;
+ }
+
+ /** Invoked after visualizer control creation, */
+ protected void initializeCanvas(GraphicCanvas canvas)
+ {
+ m_canvas.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ m_canvas.setForeground(canvas.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ }
+
+
+ // --- workbench selection management ---
+
+ /**
+ * Tests whether if the IVisualizer can display the selection
+ * (or something reachable from it).
+ */
+ public int handlesSelection(ISelection selection)
+ {
+ // By default, we don't support anything.
+ // Changing this to return 1 enables the test canvas.
+ return 0;
+ }
+
+ /**
+ * Invoked by VisualizerViewer when workbench selection changes.
+ */
+ public void workbenchSelectionChanged(ISelection selection)
+ {
+ String text = SelectionUtils.toString(selection);
+ m_canvas.setText(text);
+ m_canvas.redraw();
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Colors.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Colors.java
new file mode 100755
index 00000000000..526342c36a9
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Colors.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+
+// ---------------------------------------------------------------------------
+// Colors
+// ---------------------------------------------------------------------------
+
+/**
+ * Standard color constants.
+ *
+ * This is basically a set of cached color resources
+ * for commonly-used colors.
+ * These are drawn from an associated UIResourceManager.
+ * The initialize() method should be called immediately
+ * after you create the resource manager.
+ */
+public class Colors {
+
+ // --- static members ---
+
+ /** UI Resource manager colors are drawn from */
+ protected static UIResourceManager s_resources = null;
+
+ // Color objects for all the standard "int" colors in the SWT class:
+ public static Color WHITE = null;
+ public static Color BLACK = null;
+ public static Color RED = null;
+ public static Color DARK_RED = null;
+ public static Color GREEN = null;
+ public static Color DARK_GREEN = null;
+ public static Color YELLOW = null;
+ public static Color DARK_YELLOW = null;
+ public static Color BLUE = null;
+ public static Color DARK_BLUE = null;
+ public static Color MAGENTA = null;
+ public static Color DARK_MAGENTA = null;
+ public static Color CYAN = null;
+ public static Color DARK_CYAN = null;
+ public static Color GRAY = null;
+ public static Color DARK_GRAY = null;
+
+ // Other "custom" Color objects:
+ public static Color ORANGE = null;
+ public static Color MEDIUM_GREEN = null;
+ public static Color DARK_ORANGE = null;
+ public static Color SEMI_DARK_YELLOW = null;
+ public static Color DARK_MUTED_YELLOW = null;
+ public static Color DARK_MUTED_GREEN = null;
+ public static Color DARKER_RED = null;
+ public static Color VERY_DARK_GRAY = null;
+ public static Color WIDGET_UNEDITABLE_BACKGROUND = null;
+ public static Color WIDGET_NORMAL_BACKGROUND = null;
+
+ public static void initialize(UIResourceManager resources) {
+
+ // set resource manager for future use
+ s_resources = resources;
+
+ // Color objects for all the standard "int" colors in the SWT class:
+ WHITE = getColor(SWT.COLOR_WHITE);
+ BLACK = getColor(SWT.COLOR_BLACK);
+ RED = getColor(SWT.COLOR_RED);
+ DARK_RED = getColor(SWT.COLOR_DARK_RED);
+ GREEN = getColor(SWT.COLOR_GREEN);
+ DARK_GREEN = getColor(SWT.COLOR_DARK_GREEN);
+ YELLOW = getColor(SWT.COLOR_YELLOW);
+ DARK_YELLOW = getColor(SWT.COLOR_DARK_YELLOW);
+ BLUE = getColor(SWT.COLOR_BLUE);
+ DARK_BLUE = getColor(SWT.COLOR_DARK_BLUE);
+ MAGENTA = getColor(SWT.COLOR_MAGENTA);
+ DARK_MAGENTA = getColor(SWT.COLOR_DARK_MAGENTA);
+ CYAN = getColor(SWT.COLOR_CYAN);
+ DARK_CYAN = getColor(SWT.COLOR_DARK_CYAN);
+ GRAY = getColor(SWT.COLOR_GRAY);
+ DARK_GRAY = getColor(SWT.COLOR_DARK_GRAY);
+
+ // Other "custom" Color objects:
+ ORANGE = getColor(255, 150, 90);
+ MEDIUM_GREEN = getColor( 0, 192, 0);
+ DARK_ORANGE = getColor(215, 128, 81);
+ SEMI_DARK_YELLOW = getColor(192, 192, 0);
+ DARK_MUTED_YELLOW = getColor( 90, 90, 50);
+ DARK_MUTED_GREEN = getColor( 18, 92, 18);
+ DARKER_RED = getColor(174, 25, 13);
+ VERY_DARK_GRAY = getColor( 60, 60, 60);
+
+ WIDGET_NORMAL_BACKGROUND = getColor(SWT.COLOR_WHITE);
+ WIDGET_UNEDITABLE_BACKGROUND = getColor(220,220,220);
+ }
+
+ // --- constructors/destructors ---
+
+ /** Constructor
+ * Private, since this is basically a bunch of constants.
+ */
+ private Colors() {}
+
+ /**
+ * Gets color for a given SWT color constant.
+ */
+ // final so this can be inlined where possible
+ public static final Color getColor(int colorID) {
+ return (s_resources == null) ? null : s_resources.getColor(colorID);
+ }
+
+ /**
+ * Gets color for given RGB values (0-255).
+ */
+ // final so this can be inlined where possible
+ public static final Color getColor(int red, int green, int blue) {
+ return (s_resources == null) ? null : s_resources.getColor(red, green, blue);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Event.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Event.java
new file mode 100755
index 00000000000..ecf3ec13957
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Event.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+
+// ---------------------------------------------------------------------------
+// Event
+// ---------------------------------------------------------------------------
+
+/**
+ * Base class for events
+ */
+public class Event
+{
+
+ // --- event types ---
+
+ /** Event type constant */
+ public static final int UNDEFINED = 0;
+
+
+ // --- members ---
+
+ /** Source of the event */
+ protected Object m_source = null;
+
+ /** Type of event */
+ protected int m_type = UNDEFINED;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor */
+ public Event(Object source) {
+ this(source, UNDEFINED);
+ }
+
+ /** Constructor */
+ public Event(Object source, int type) {
+ m_source = source;
+ m_type = type;
+ }
+
+ /** Dispose method */
+ public void dispose() {
+ m_source = null;
+ }
+
+
+ // --- Object methods ---
+
+ /** Returns string representation of event */
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(getClass().getSimpleName());
+ result.append("[");
+ if (m_type != UNDEFINED) {
+ result.append(typeToString(m_type));
+ }
+ result.append("]");
+ return result.toString();
+ }
+
+ /** Converts event type to string */
+ public String typeToString(int type) {
+ String result = "";
+ switch (type) {
+ case UNDEFINED:
+ result = "UNDEFINED"; break;
+ default:
+ result = "OTHER(" + type +")";
+ break;
+ }
+ return result;
+ }
+
+
+ // --- accessors ---
+
+ /** Gets source of the event */
+ public Object getSource() {
+ return m_source;
+ }
+
+ /**
+ * Gets type of event
+ */
+ public int getType() {
+ return m_type;
+ }
+
+ /**
+ * Returns true if event has specified type.
+ */
+ public boolean isType(int type) {
+ return (m_type == type);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java
new file mode 100755
index 00000000000..c778ccd83c6
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+
+//---------------------------------------------------------------------------
+// GUIUtils
+//---------------------------------------------------------------------------
+
+/**
+ * Assorted high-level UI utilities.
+ */
+public class GUIUtils {
+
+ // --- display methods ---
+
+ /** Gets current SWT display. */
+ static public Display getDisplay() {
+ Display display= Display.getCurrent();
+ if (display == null) {
+ display= Display.getDefault();
+ }
+ return display;
+ }
+
+
+ // --- delayed execution methods ---
+
+ /** Posts the specified runnable for execution by the UI thread.
+ * Nonblocking, returns immediately.
+ */
+ static public void exec(Runnable runnable) {
+ Display display = getDisplay();
+ exec(display, runnable, false);
+ }
+
+ /** Posts the specified runnable for execution by the UI thread.
+ * Nonblocking, returns immediately.
+ */
+ static public void exec(Runnable runnable, boolean blocking) {
+ Display display = getDisplay();
+ exec(display, runnable, blocking);
+ }
+
+ /** Posts the specified runnable for execution by the UI thread.
+ * If blocking is true, waits for completion, otherwise returns immediately.
+ */
+ static public void execAndWait(Runnable runnable) {
+ Display display = getDisplay();
+ exec(display, runnable, true);
+ }
+
+ /** Posts the specified runnable for execution by the UI thread.
+ * If blocking is true, waits for completion, otherwise returns immediately.
+ */
+ static protected void exec(Display display, Runnable runnable, boolean blocking) {
+ if (display != null && runnable != null) {
+ if (blocking) {
+ display.syncExec(runnable);
+ }
+ else {
+ display.asyncExec(runnable);
+ }
+ }
+ }
+
+
+ // --- drawing methods ---
+
+ /** Draws transparent text, with the default alignment (top/left). */
+ static public void drawText(GC gc, String text, int x, int y)
+ {
+ gc.drawText(text, x, y, SWT.DRAW_TRANSPARENT);
+ }
+
+ /** Draws transparent text, with the specified alignments. */
+ static public void drawTextAligned(GC gc, String text, int x, int y, boolean left, boolean top)
+ {
+ if (left && top) {
+ gc.drawText(text, x, y, SWT.DRAW_TRANSPARENT);
+ }
+ else {
+ Point te = gc.textExtent(text);
+ int dx = left ? 0 : te.x;
+ int dy = top ? 0 : te.y;
+ gc.drawText(text, x - dx, y - dy, SWT.DRAW_TRANSPARENT);
+ }
+ }
+
+ /** Draws transparent text, centered on the specified point. */
+ static public void drawTextCentered(GC gc, String text, int x, int y)
+ {
+ Point te = gc.textExtent(text);
+ // Rounding produces less "jumpy" display when graphics are resized.
+ gc.drawText(text, x - (int) Math.round(te.x / 2.0),
+ y - (int) Math.round(te.y / 2.0), SWT.DRAW_TRANSPARENT);
+ }
+
+
+ // --- graphic methods ---
+
+ /** Shrinks rectangle by specified margin on all edges. */
+ public static void inset(Rectangle rect, int margin)
+ {
+ rect.x += margin;
+ rect.y += margin;
+ rect.width -= margin * 2;
+ if (rect.width < 0) rect.width = 0;
+ rect.height -= margin * 2;
+ if (rect.height < 0) rect.height = 0;
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/ListenerList.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/ListenerList.java
new file mode 100755
index 00000000000..87205fa1cb3
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/ListenerList.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.util.ArrayList;
+
+
+// ---------------------------------------------------------------------------
+// ListenerList
+// ---------------------------------------------------------------------------
+
+/**
+ * Utility class for managing a list of event listeners.
+ * Maintains a list of listener instances, and dispatches events to them.
+ *
+ * To use this class, create a derived type that implements the raise(listener, event)
+ * method to appropriately delegate an event to a listener.
+ *
+ * Note: it is the responsibility of the user of this class to check types
+ * of listeners and events (for example, by having strongly-typed add/remove methods
+ * that delegate to the add/remove methods on this class).
+ */
+abstract public class ListenerList
+{
+ // --- members ---
+
+ /** Object that owns this listener list */
+ protected Object m_owner = null;
+
+ /** listener list display label */
+ protected String m_label = null;
+
+ /** listener list */
+ protected ArrayList<Object> m_listeners = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public ListenerList(Object owner, String label) {
+ m_owner = owner;
+ m_label = label;
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_owner = null;
+ m_label = null;
+ if (m_listeners != null) {
+ clear();
+ m_listeners = null;
+ }
+ }
+
+
+ // --- methods ---
+
+ /** Clears list of listeners */
+ public synchronized void clear() {
+ if (m_listeners != null) {
+ m_listeners.clear();
+ }
+ }
+
+ /** Returns count of current listeners. */
+ public synchronized int size() {
+ return (m_listeners == null) ? 0 : m_listeners.size();
+ }
+
+ /** Adds a listener */
+ public synchronized void addListener(Object listener) {
+ if (m_listeners == null) {
+ m_listeners = new ArrayList<Object>();
+ }
+ if (! m_listeners.contains(listener)) {
+ m_listeners.add(listener);
+ }
+ }
+
+ /** Removes a listener */
+ public synchronized void removeListener(Object listener) {
+ if (m_listeners != null) {
+ m_listeners.remove(listener);
+ }
+ }
+
+ /**
+ * Dispatches event to all attached listeners
+ * Invokes raise(listener, event) for each attached listener.
+ */
+ public void raise (final Object event)
+ {
+ // we can't use an iterator here, because
+ // the listener list might change while we're walking it,
+ // which would make the iterator throw a ConcurrentModificationException,
+ // hence we'll make a private copy of the listener list
+ ArrayList<Object> listeners = null;
+ synchronized (this) {
+ // keep the lock on the listener list as brief as possible
+ if (m_listeners != null) {
+ listeners = new ArrayList<Object>(m_listeners);
+ }
+ }
+ int count = (listeners == null) ? 0 : listeners.size();
+ for (int i=0; i<count; i++) {
+ Object listener = (Object) listeners.get(i);
+ try {
+ raise(listener, event);
+ }
+ catch (Throwable t) {
+ // TODO: decide how to log this
+ }
+ }
+ }
+
+ /**
+ * Dispatches typed event to specified listener
+ * Intended to be overloaded by derived class to cast listener and event
+ * to appropriate type and invoke appropriate listener method(s).
+ *
+ * For example:
+ *
+ * ListenerList m_listeners =
+ * new ListenerList(this, "VisualizerViewer event listeners")
+ * {
+ * public void raise(Object listener, Object event) {
+ * if (listener instanceof IVisualizerViewerListener &&
+ * event instanceof VisualizerViewerEvent)
+ * {
+ * IVisualizerViewerListener typedListener = (IVisualizerViewerListener) listener;
+ * VisualizerViewerEvent typedEvent = (VisualizerViewerEvent) event;
+ * typedListener.visualizerEvent(VisualizerViewer.this, typedEvent);
+ * }
+ * }
+ * };
+ *
+ */
+ abstract protected void raise(Object listener, Object event);
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/MouseMonitor.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/MouseMonitor.java
new file mode 100644
index 00000000000..90c44f7c98e
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/MouseMonitor.java
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+
+
+/**
+ * Monitors mouse down/move/up events on a specified control (e.g. a canvas)
+ * and converts them to semantic events (click, double-click, select, drag, etc.)
+ */
+public class MouseMonitor
+{
+ // --- constants ---
+
+ /** MouseEvent button ID for Left mouse button */
+ public static final int LEFT_BUTTON = 1;
+
+ /** MouseEvent button ID for Middle mouse button */
+ public static final int MIDDLE_BUTTON = 2;
+
+ /** MouseEvent button ID for Right mouse button */
+ public static final int RIGHT_BUTTON = 3;
+
+
+ /** Mouse drag state value */
+ public static final int MOUSE_DRAG_BEGIN = 0;
+
+ /** Mouse drag state value */
+ public static final int MOUSE_DRAG = 1;
+
+ /** Mouse drag state value */
+ public static final int MOUSE_DRAG_END = 2;
+
+ /** Distance mouse must move for a mouse-down to be treated as a drag */
+ public static final int MOUSE_DRAG_HYSTERESIS = 4;
+
+
+ // --- members ---
+
+ /** Control being monitored */
+ protected Control m_control = null;
+
+ /** Mouse button listener */
+ protected MouseListener m_mouseButtonListener = null;
+
+ /** Mouse move listener */
+ protected MouseMoveListener m_mouseMoveListener = null;
+
+ /** Mouse enter/exit event listener */
+ protected MouseTrackListener m_mouseTrackListener = null;
+
+ /** Whether mouse button is down. */
+ protected boolean m_mouseDown = false;
+
+ /** Whether mouse is being dragged. */
+ protected boolean m_mouseDrag = false;
+
+ /** Mouse-down point. */
+ protected Point m_mouseDownPoint = new Point(0,0);
+
+ /** Last button down. */
+ protected int m_mouseDownButton = 0;
+
+ /** Current mouse drag point. */
+ protected Point m_dragPoint = new Point(0,0);
+
+ /** Drag region. */
+ protected Rectangle m_dragRegion = new Rectangle(0,0,0,0);
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public MouseMonitor() {
+ }
+
+ /** Constructor. */
+ public MouseMonitor(Control control) {
+ this();
+ m_control = control;
+ attach(m_control);
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ detach(m_control);
+ }
+
+
+ // --- init methods ---
+
+ /** Attach event listeners to specified control. */
+ protected void attach(Control control) {
+ detach(m_control);
+ control.addMouseListener(
+ m_mouseButtonListener = new MouseListener() {
+ public void mouseDown(MouseEvent e) {
+ mouseDownHandler(e.button, e.x, e.y, e.stateMask);
+ }
+ public void mouseUp(MouseEvent e) {
+ mouseUpHandler(e.button, e.x, e.y, e.stateMask);
+ }
+ public void mouseDoubleClick(MouseEvent e) {
+ mouseDoubleClickHandler(e.button, e.x, e.y, e.stateMask);
+ }
+ }
+ );
+ control.addMouseMoveListener(
+ m_mouseMoveListener = new MouseMoveListener() {
+ public void mouseMove(MouseEvent e) {
+ mouseMoveHandler(e.x, e.y, e.stateMask);
+ }
+ }
+ );
+ control.addMouseTrackListener(
+ m_mouseTrackListener = new MouseTrackListener() {
+ public void mouseEnter(MouseEvent e) {
+ mouseEnterHandler(e.x, e.y);
+ }
+ public void mouseExit(MouseEvent e) {
+ mouseExitHandler(e.x, e.y);
+ }
+ public void mouseHover(MouseEvent e) {
+ mouseHoverHandler(e.x, e.y);
+ }
+ }
+ );
+ }
+
+ /** Detach event listeners from specified control. */
+ protected void detach(Control control) {
+ if (control == null) return;
+ if (m_control != null) {
+ if (m_mouseButtonListener != null) {
+ m_control.removeMouseListener(m_mouseButtonListener);
+ m_mouseButtonListener = null;
+ }
+ if (m_mouseMoveListener != null) {
+ m_control.removeMouseMoveListener(m_mouseMoveListener);
+ m_mouseMoveListener = null;
+ }
+ if (m_mouseTrackListener != null) {
+ m_control.removeMouseTrackListener(m_mouseTrackListener);
+ m_mouseTrackListener = null;
+ }
+ }
+ }
+
+
+ // --- accessors ---
+
+ /** Gets associated control */
+ public Control getControl() {
+ return m_control;
+ }
+
+ /** Sets associated control */
+ public void setControl(Control control) {
+ detach(m_control);
+ m_control = control;
+ attach(m_control);
+ }
+
+ /** Gets mouse down point of current drag, if any */
+ public Point getMouseDownPoint() {
+ return m_mouseDownPoint;
+ }
+
+ /** Gets current drag x,y point. */
+ public Point getDragPoint() {
+ return m_dragPoint;
+ }
+
+ /** Gets bounds of most recent drag region. */
+ public Rectangle getDragRegion() {
+ return m_dragRegion;
+ }
+
+
+ // --- utilities ---
+
+ /** Returns true if either Shift key is down in mouse event modifier key mask. */
+ public static boolean isShiftDown(int keys) {
+ return ((keys & SWT.SHIFT) != 0);
+ }
+
+ /** Returns true if either Control key is down in mouse event modifier key mask. */
+ public static boolean isControlDown(int keys) {
+ return ((keys & SWT.CONTROL) != 0);
+ }
+
+ /** Returns true if either Alt key is down in mouse event modifier key mask. */
+ public static boolean isAltDown(int keys) {
+ return ((keys & SWT.ALT) != 0);
+ }
+
+
+ // --- methods ---
+
+ /** Internal -- sets drag point */
+ protected void setDragPoint(int x, int y) {
+ m_dragPoint.x=x;
+ m_dragPoint.y=y;
+ }
+
+ /** Internal -- sets drag region explicitly */
+ protected void setDragRegion(int x, int y, int width, int height) {
+ m_dragRegion.x=x;
+ m_dragRegion.y=y;
+ m_dragRegion.width=width;
+ m_dragRegion.height=height;
+ }
+
+ /** Internal -- sets drag region from specified drag start/end points */
+ protected void setDragRegionFromPoints(int x1, int y1, int x2, int y2) {
+ if (x1 < x2) {
+ m_dragRegion.x = x1;
+ m_dragRegion.width = x2 - x1;
+ }
+ else {
+ m_dragRegion.x = x2;
+ m_dragRegion.width = x1 - x2;
+ }
+ if (y1 < y2) {
+ m_dragRegion.y = y1;
+ m_dragRegion.height = y2 - y1;
+ }
+ else {
+ m_dragRegion.y = y2;
+ m_dragRegion.height = y1 - y2;
+ }
+ }
+
+ /** Invoked when mouse button is pressed */
+ protected void mouseDownHandler(int button, int x, int y, int keys) {
+ if (! m_mouseDown) {
+ m_mouseDown = true;
+ m_mouseDownPoint.x = x;
+ m_mouseDownPoint.y = y;
+ m_mouseDownButton = button;
+ setDragPoint(x,y);
+ setDragRegion(x,y,0,0);
+ }
+ mouseDown(button, x, y, keys);
+ }
+
+ /** Invoked when mouse is moved */
+ protected void mouseMoveHandler(int x, int y, int keys) {
+ if (m_mouseDown) {
+ if (! m_mouseDrag) {
+ // allow a small hysteresis before we start dragging, so clicks with a little movement don't cause drags
+ int distance = Math.abs(x - m_mouseDownPoint.x) + Math.abs(y - m_mouseDownPoint.y);
+ if (distance > MOUSE_DRAG_HYSTERESIS) {
+ m_mouseDrag = true;
+
+ // initialize mouse drag
+ drag(m_mouseDownButton, m_mouseDownPoint.x, m_mouseDownPoint.y, keys, MOUSE_DRAG_BEGIN);
+ }
+ }
+ if (m_mouseDrag) {
+ // update mouse drag
+ int dx = x - m_mouseDownPoint.x;
+ int dy = y - m_mouseDownPoint.y;
+ setDragPoint(x,y);
+ setDragRegionFromPoints(m_mouseDownPoint.x, m_mouseDownPoint.y, x, y);
+ drag(m_mouseDownButton, dx, dy, keys, MOUSE_DRAG);
+ }
+ }
+ mouseMove(x, y, keys);
+ }
+
+ /** Invoked when mouse button is released */
+ protected void mouseUpHandler(int button, int x, int y, int keys) {
+ if (m_mouseDown) {
+ if (m_mouseDrag) {
+ // finish mouse drag
+ int dx = x - m_mouseDownPoint.x;
+ int dy = y - m_mouseDownPoint.y;
+ setDragPoint(x,y);
+ setDragRegionFromPoints(m_mouseDownPoint.x, m_mouseDownPoint.y, x, y);
+ drag(m_mouseDownButton, dx, dy, keys, MOUSE_DRAG_END);
+ m_mouseDrag = false;
+ }
+ else {
+ if (button == RIGHT_BUTTON) {
+ contextMenu(x, y, keys);
+ }
+ else {
+ select(x, y, keys);
+ }
+ }
+ m_mouseDown = false;
+ }
+ mouseUp(button, x, y, keys);
+ }
+
+ /** Invoked when mouse button is double-clicked */
+ protected void mouseDoubleClickHandler(int button, int x, int y, int keys) {
+ mouseDoubleClick(button, x, y, keys);
+ }
+
+ /** Invoked when mouse pointer enters control region */
+ protected void mouseEnterHandler(int x, int y) {
+ if (! m_mouseDown) {
+ mouseEnter(x, y);
+ }
+ }
+
+ /** Invoked when mouse pointer exits control region */
+ protected void mouseExitHandler(int x, int y) {
+ if (! m_mouseDown) {
+ mouseExit(x, y);
+ }
+ }
+
+ /** Invoked when mouse pointer hovers over control */
+ protected void mouseHoverHandler(int x, int y) {
+ if (! m_mouseDown) {
+ mouseHover(x, y);
+ }
+ }
+
+
+ // --- event handlers ---
+
+ // These are intended to be overridden by derived types.
+ // A user of this class need only override methods for events
+ // that need to be tracked.
+
+ /** Invoked when mouse button is pressed */
+ public void mouseDown(int button, int x, int y, int keys) {}
+
+ /** Invoked when mouse is moved */
+ public void mouseMove(int x, int y, int keys) {}
+
+ /** Invoked when mouse button is released */
+ public void mouseUp(int button, int x, int y, int keys) {}
+
+ /** Invoked for a selection click at the specified point. */
+ public void select(int x, int y, int keys) {}
+
+ /** Invoked for a context menu click at the specified point. */
+ public void contextMenu(int x, int y, int keys) {}
+
+ /** Invoked when mouse button is double-clicked */
+ public void mouseDoubleClick(int button, int x, int y, int keys) {}
+
+ /** Invoked when mouse is dragged (moved with mouse button down).
+ * Drag state indicates stage of drag:
+ * - MOUSE_DRAG_BEGIN -- dx, dy offset from initial mouse down point (initial mouse down)
+ * - MOUSE_DRAG -- dx, dy of intermediate drag offset (initial mouse down, then each mouse move)
+ * - MOUSE_DRAG_END -- dx, dy of final drag offset (mouse up)
+ * The pattern of calls is always: BEGIN, DRAG(+), END.
+ */
+ public void drag(int button, int x, int y, int keys, int dragState) {}
+
+ /** Invoked when mouse pointer enters control region */
+ public void mouseEnter(int x, int y) {}
+
+ /** Invoked when mouse pointer exits control region */
+ public void mouseExit(int x, int y) {}
+
+ /** Invoked when mouse pointer hovers over control */
+ public void mouseHover(int x, int y) {}
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/RunnableWithResult.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/RunnableWithResult.java
new file mode 100644
index 00000000000..952d17730da
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/RunnableWithResult.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.util.concurrent.Callable;
+
+
+/**
+ * Runnable object that returns a result object.
+ *
+ * This is like Future<V> from the concurrent package,
+ * but with a few less bells and whistles.
+ *
+ * Intended to be used, for example, as follows:
+ *
+ * RunnableWithResult<X> runnable = new RunnableWithResult<X>() {
+ * public X call() {
+ * ... do work, return an X object ...
+ * }
+ * }
+ *
+ * Thread thread = new Thread(runnable);
+ * thread.start();
+ * X result = runnable.getResult(0);
+ *
+ * or, to run it on the UI thread...
+ *
+ * GUIUtils.execAndWait(runnable);
+ * X result = runnable.getResult(0);
+ *
+ * Note: if you're invoking this from the UI thread,
+ * it's important to use execAndWait(), so that the runnable
+ * gets a turn on the event loop, otherwise you'll hang the UI!
+ *
+ */
+public class RunnableWithResult<V>
+ implements Runnable, Callable<V>
+{
+ // --- members ---
+
+ /** Result to return */
+ protected V m_result = null;
+
+ /** Whether run() has completed */
+ protected boolean m_done = false;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public RunnableWithResult() {
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_result = null;
+ }
+
+
+ // --- accessors ---
+
+ /** Sets result value */
+ public void setResult(V result) {
+ m_result = result;
+ }
+
+ /** Gets result value. */
+ public V getResult() {
+ return m_result;
+ }
+
+
+ // --- Runnable implementation ---
+
+ /** Run method.
+ * Derived types should override call() rather than this method.
+ */
+ public void run() {
+ m_done = false;
+ setResult(call());
+ m_done = true;
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+
+
+ // --- Callable implementation ---
+
+ /** Method that returns the value.
+ * Default implementation returns null.
+ */
+ public V call() {
+ return null;
+ }
+
+
+ // --- methods ---
+
+ /** Waits for result and returns it. */
+ public V waitForResult() {
+ return waitForResult(0, null);
+ }
+
+ /** Waits for result and returns it. */
+ public V waitForResult(long timeout) {
+ return waitForResult(timeout, null);
+ }
+
+ /** Waits for result and returns it.
+ * Returns null if specified timeout is exceeded.
+ */
+ public V waitForResult(long timeout, V defaultValue) {
+ V result = defaultValue;
+ try {
+ if (timeout == 0) {
+ // wait forever
+ // (guard against spurious thread wakeup -- see wait() Javadoc)
+ while (! m_done) {
+ synchronized (this) {
+ this.wait(0);
+ }
+ }
+ }
+ else {
+ // wait until specified timeout
+ // (guard against spurious thread wakeup -- see wait() Javadoc)
+ long then = now();
+ long waitstep = timeout / 10;
+ if (waitstep == 0) waitstep = 1;
+ do {
+ synchronized (this) {
+ this.wait(waitstep);
+ }
+ }
+ while (! m_done && ((now() - then) < timeout));
+ }
+ }
+ catch (InterruptedException e) {
+ }
+ if (m_done) result = getResult();
+ return result;
+ }
+
+ /** Returns current time in milliseconds. */
+ protected static long now() {
+ return System.currentTimeMillis();
+ }
+}
+
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionManager.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionManager.java
new file mode 100755
index 00000000000..0609d566243
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionManager.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+
+// ---------------------------------------------------------------------------
+// SelectionManager
+// ---------------------------------------------------------------------------
+
+/**
+ * Selection management utility class
+ */
+public class SelectionManager
+ implements ISelectionProvider
+{
+ // --- members ---
+
+ /** Actual source to report for selection change events. */
+ protected ISelectionProvider m_source = null;
+
+ /** Manager label, also used on listener list. */
+ protected String m_label = null;
+
+ /** Current selection, if any. */
+ protected ISelection m_selection = SelectionUtils.EMPTY_SELECTION;
+
+ /** Selection changed listeners */
+ protected ListenerList m_selectionListeners = null;
+
+ /** Whether selection events are enabled */
+ protected boolean m_selectionEventsEnabled = true;
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public SelectionManager(ISelectionProvider source, String label)
+ {
+ m_source = (source == null) ? this : source;
+ m_label = label;
+ m_selectionListeners = new ListenerList(this, label + ", listener list") {
+ public void raise(Object listener, Object event) {
+ if (listener instanceof ISelectionChangedListener &&
+ event instanceof SelectionChangedEvent)
+ {
+ ISelectionChangedListener typedListener = (ISelectionChangedListener) listener;
+ SelectionChangedEvent typedEvent = (SelectionChangedEvent) event;
+ typedListener.selectionChanged(typedEvent);
+ }
+ }
+ };
+ }
+
+ /** Dispose method. */
+ public void dispose()
+ {
+ m_selectionEventsEnabled = false;
+ m_selection = SelectionUtils.EMPTY_SELECTION;
+ if (m_selectionListeners != null) {
+ m_selectionListeners.clear();
+ m_selectionListeners = null;
+ }
+ // m_label = null; // leave label, to aid in debugging cleanup
+ m_source = null;
+ }
+
+ // --- ISelectionProvider implementation ---
+
+ /** Adds selection changed listener. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ if (listener == null) return;
+ m_selectionListeners.addListener(listener);
+ // fake a selection changed event so new listener can update itself properly
+ listener.selectionChanged(new SelectionChangedEvent(m_source, getSelection()));
+ }
+
+ /** Removes selection changed listener. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ if (listener == null) return;
+ m_selectionListeners.removeListener(listener);
+ }
+
+ /** Returns current selection. */
+ public ISelection getSelection()
+ {
+ return m_selection;
+ }
+
+ /** Sets selection, and raises change event. */
+ public void setSelection(ISelection selection)
+ {
+ setSelection(selection, true);
+ }
+
+ /** Sets selection, and raises change event with specified provider as the source. */
+ public void setSelection(ISelectionProvider provider, ISelection selection)
+ {
+ setSelection(provider, selection, true);
+ }
+
+ /** Sets selection, and raises change event
+ * if raiseEvent is true. */
+ public void setSelection(ISelection selection, boolean raiseEvent)
+ {
+ if (selection == null)
+ selection = SelectionUtils.EMPTY_SELECTION;
+ m_selection = selection;
+ if (raiseEvent) raiseSelectionChangedEvent();
+ }
+
+ /** Sets selection, and raises change event with specified provider as the source
+ * if raiseEvent is true. */
+ public void setSelection(ISelectionProvider provider, ISelection selection, boolean raiseEvent)
+ {
+ if (selection == null)
+ selection = SelectionUtils.EMPTY_SELECTION;
+ m_selection = selection;
+ if (raiseEvent) raiseSelectionChangedEvent(provider);
+ }
+
+ /** Returns true if we currently have a non-emptr selection. */
+ public boolean hasSelection()
+ {
+ return (SelectionUtils.getSelectionSize(m_selection) > 0);
+ }
+
+
+ // --- methods ---
+
+ /** Gets whether selection events are enabled. */
+ public boolean getSelectionEventsEnabled() {
+ return m_selectionEventsEnabled;
+ }
+
+ /** Sets whether selection events are enabled. */
+ public void setSelectionEventsEnabled(boolean enabled) {
+ m_selectionEventsEnabled = enabled;
+ }
+
+ /** Raises selection changed event. */
+ public void raiseSelectionChangedEvent() {
+ if (m_selectionEventsEnabled)
+ m_selectionListeners.raise(new SelectionChangedEvent(m_source, getSelection()));
+ }
+
+ /** Raises selection changed event with specified provider as source. */
+ public void raiseSelectionChangedEvent(ISelectionProvider provider) {
+ if (m_selectionEventsEnabled)
+ m_selectionListeners.raise(new SelectionChangedEvent(provider, getSelection()));
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionProviderAdapter.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionProviderAdapter.java
new file mode 100755
index 00000000000..522700edb60
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionProviderAdapter.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+
+
+// ---------------------------------------------------------------------------
+// SelectionProviderAdapter
+// ---------------------------------------------------------------------------
+
+/**
+ * Wrapper for selection "providers" that don't happen to implement
+ * ISelectionProvider interface.
+ */
+public class SelectionProviderAdapter
+ implements ISelectionProvider
+{
+ // --- members ---
+
+ /** Real source object. */
+ protected Object m_source = null;
+
+ /** Selection manager. */
+ protected SelectionManager m_selectionManager = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public SelectionProviderAdapter(Object source) {
+ m_source = source;
+ m_selectionManager = new SelectionManager(this, "SelectionProviderAdapter for source " + m_source.toString());
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_source = null;
+ if (m_selectionManager != null) {
+ m_selectionManager.dispose();
+ m_selectionManager = null;
+ }
+ }
+
+
+ // --- accessors ---
+
+ /** Gets wrapped selection source. */
+ public Object getActualSource() {
+ return m_source;
+ }
+
+
+ // --- ISelectionProvider implementation ---
+
+ /** Adds selection change listener.
+ * Default implementation does nothing.
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ m_selectionManager.addSelectionChangedListener(listener);
+ }
+
+ /** Removes selection change listener.
+ * Default implementation does nothing.
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ m_selectionManager.removeSelectionChangedListener(listener);
+ }
+
+ /** Gets selection.
+ * Default implementation does nothing.
+ */
+ public ISelection getSelection() {
+ return m_selectionManager.getSelection();
+ }
+
+ /** Sets selection.
+ * Default implementation does nothing.
+ */
+ public void setSelection(ISelection selection)
+ {
+ m_selectionManager.setSelection(selection);
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionUtils.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionUtils.java
new file mode 100644
index 00000000000..fd6f9a5b637
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/SelectionUtils.java
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+//----------------------------------------------------------------------------
+// SelectionUtils
+//----------------------------------------------------------------------------
+
+/** Eclipse ISelection munging utilities. */
+public class SelectionUtils
+{
+ // --- constants ---
+
+ /** Special value for an "empty" selection,
+ * since selection cannot be null.
+ */
+ public static final ISelection EMPTY_SELECTION = new EmptySelection();
+
+ /** "Empty" or undefined selection. */
+ public static class EmptySelection
+ implements ISelection, IStructuredSelection
+ {
+ public boolean isEmpty() {
+ return true;
+ }
+
+ public Iterator<Object> iterator() {
+ return new ArrayList<Object>().iterator();
+ }
+
+ public List<Object> toList() {
+ return new ArrayList<Object>();
+ }
+
+ public int size() {
+ return 0;
+ }
+
+ public Object getFirstElement() {
+ return null;
+ }
+
+ public Object[] toArray() {
+ return new Object[0];
+ }
+ }
+
+
+ // --- selection utilities ---
+
+ /**
+ * Returns workbench selection, if any.
+ */
+ public static ISelection getWorkbenchSelection() {
+ ISelection result = null;
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page != null) {
+ result = page.getSelection();
+ }
+ return result;
+ }
+
+ /** Creates an ISelection from a collection of objects */
+ public static ISelection toSelection(Collection<?> objects) {
+ return (objects == null) ? null : new StructuredSelection(toList(objects));
+ }
+
+ /** Creates an ISelection from a list of objects */
+ public static ISelection toSelection(List<?> objects) {
+ return (objects == null) ? null : new StructuredSelection(objects);
+ }
+
+ /** Creates an ISelection from the specified object(s) */
+ public static <T> ISelection toSelection(T... objects) {
+ return (objects == null) ? null : new StructuredSelection(objects);
+ }
+
+ /**
+ * Gets number of top-level object(s) from an Eclipse ISelection.
+ */
+ public static int getSelectionSize(ISelection selection) {
+ int result = 0;
+ if (selection == EMPTY_SELECTION) {
+ // nothing to do
+ }
+ else if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ result = structuredSelection.size();
+ }
+ else if (selection instanceof ISelection) {
+ result = ((ISelection) selection).isEmpty() ? 0 : 1;
+ }
+ // collections are not ISelections, this just makes the method a little more generic
+ else if (selection instanceof Collection) {
+ Collection<?> collection = (Collection<?>) selection;
+ result = collection.size();
+ }
+ else if (selection != null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ /**
+ * Gets selected object(s) from an Eclipse ISelection as a List.
+ * If selection is a multiple selection (an IStructuredSelection or Collection),
+ * the list contains the top-level elements of the selection.
+ * Otherwise the list contains the ISelection itself.
+ */
+ public static List<Object> getSelectedObjects(ISelection selection) {
+ List<Object> result = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ result = new ArrayList<Object>((List<?>) structuredSelection.toList());
+ }
+ else if (selection instanceof Collection) {
+ Collection<?> collection = (Collection<?>) selection;
+ result = new ArrayList<Object>(collection);
+ }
+ else {
+ List<Object> list = new ArrayList<Object>();
+ list.add(selection);
+ result = list;
+ }
+ return result;
+ }
+
+ /**
+ * Gets single selected object from an Eclipse ISelection.
+ * If selection is a single selection, returns it.
+ * If selection is multiple selection, returns first selected item.
+ */
+ public static Object getSelectedObject(ISelection selection) {
+ Object result = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ result = structuredSelection.getFirstElement();
+ }
+ else if (selection instanceof Collection) {
+ Collection<?> collection = (Collection<?>) selection;
+ Iterator<?> i = collection.iterator();
+ if (i.hasNext()) result = i.next();
+ }
+ else {
+ result = selection;
+ }
+ return result;
+ }
+
+ /**
+ * Creates Eclipse ISelection from a list.
+ */
+ public static ISelection toISelection(List<?> items) {
+ return new StructuredSelection(items);
+ }
+
+ /**
+ * Creates Eclipse ISelection from one or more items or an array of items.
+ */
+ public static <T> ISelection toISelection(T... items) {
+ return new StructuredSelection(items);
+ }
+
+ /**
+ * Gets iterator for an ISelection.
+ * Note: returns null if ISelection is not an IStructuredSelection,
+ * which is the only interface that currently defines an Iterator.
+ */
+ public static Iterator<?> getSelectionIterator(ISelection iselection) {
+ Iterator<?> result = null;
+ if (iselection instanceof IStructuredSelection) {
+ result = ((IStructuredSelection) iselection).iterator();
+ }
+ return result;
+ }
+
+
+ // --- debugging tools ---
+
+ /** Converts selection to string, for debug display. */
+ public static String toString(ISelection selection) {
+ String result = null;
+ // convert selection to text string
+ if (selection == null) {
+ result = "No selection";
+ }
+ else if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ List<?> elements = structuredSelection.toList();
+ int size = elements.size();
+ if (size == 0) {
+ result = "Empty selection";
+ }
+ else {
+ result = "Selection: ";
+ for (int i=0; i<size; i++) {
+ if (i>0) result += "\n";
+ Object o = elements.get(i);
+ String type = o.getClass().getName();
+ String value = o.toString();
+ result += "[" + i + "]: type= + " + type + ", value='" + value + "'";
+ }
+ }
+ }
+ else {
+ String type = selection.getClass().getName();
+ String value = selection.toString();
+ result = "Selection: (type = " + type + ") " + value;
+ }
+ return result;
+ }
+
+ // --- utilities ---
+
+ /** Creates list from array/set of elements */
+ public static List<Object> toList(Collection<?> collection) {
+ int size = (collection == null) ? 0 : collection.size();
+ List<Object> result = new ArrayList<Object>(size);
+ if (collection != null) result.addAll(collection);
+ return result;
+ }
+
+ /** Gets current Eclipse workbench */
+ public static IWorkbench getWorkbench() {
+ IWorkbench result = null;
+ try {
+ result = PlatformUI.getWorkbench();
+ }
+ catch (IllegalStateException e) {
+ // Workbench is not defined for some reason. Oh well.
+ }
+ return result;
+ }
+
+ /** Gets current Eclipse workbench window.
+ * Returns null if workbench does not exist.
+ */
+ public static IWorkbenchWindow getWorkbenchWindow() {
+ IWorkbenchWindow result = null;
+ IWorkbench workbench = getWorkbench();
+ if (workbench != null) {
+ result = workbench.getActiveWorkbenchWindow();
+ if (result == null) {
+ if (workbench.getWorkbenchWindowCount() > 0) {
+ result = (IWorkbenchWindow) workbench.getWorkbenchWindows()[0];
+ }
+ }
+ }
+ return result;
+ }
+
+ /** Gets current Eclipse workbench page */
+ public static IWorkbenchPage getWorkbenchPage() {
+ IWorkbenchWindow window = getWorkbenchWindow();
+ return (window == null) ? null : window.getActivePage();
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Timer.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Timer.java
new file mode 100755
index 00000000000..28b31bd3267
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Timer.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+
+// ---------------------------------------------------------------------------
+// Timer
+// ---------------------------------------------------------------------------
+
+/**
+ * Periodic event timer class.
+ */
+public class Timer
+ implements ActionListener, Runnable
+{
+ // --- members ---
+
+ /** Actual timer */
+ // NOTE: we delegate rather than subclassing, because
+ // Timer class implements ISerializable, so every derived type
+ // must either declare a serialization ID, or suppress the warning.
+ protected javax.swing.Timer m_timer = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public Timer(int intervalMilliseconds) {
+ m_timer = new javax.swing.Timer(intervalMilliseconds, null);
+ m_timer.addActionListener(this);
+ m_timer.setRepeats(true);
+ m_timer.setCoalesce(true);
+ m_timer.start();
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ if (m_timer != null) {
+ if (m_timer.isRunning()) {
+ m_timer.stop();
+ }
+ m_timer = null;
+ }
+ }
+
+
+ // --- methods ---
+
+ /** Gets whether timer repeatedly fires events. */
+ public boolean isRepeating() {
+ return m_timer.isRepeats();
+ }
+
+ /** Sets whether timer repeatedly fires events. */
+ public void setRepeating(boolean repeats) {
+ m_timer.setRepeats(repeats);
+ }
+
+ /** Starts/restarts timer.
+ * Has no effect if timer is already running
+ */
+ public void start() {
+ if (! m_timer.isRunning()) m_timer.start();
+ }
+
+ /** Stops timer.
+ * Has no effect if timer is already stopped.
+ */
+ public void stop() {
+ if (m_timer.isRunning()) m_timer.stop();
+ }
+
+
+ // --- ActionListener implementation ---
+
+ /**
+ * Invoked each time the timer fires.
+ * Default implementation invokes the run() method on the UI thread.
+ */
+ public void actionPerformed(ActionEvent e) {
+ GUIUtils.exec(this);
+ }
+
+ /** Invoked each time the timer fires. */
+ public void run() {
+ }
+
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Todo.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Todo.java
new file mode 100644
index 00000000000..3dfdec2d8a9
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/Todo.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+/** Counter for objects that need to track asynchronous progress. */
+public class Todo {
+
+ // --- members ---
+
+ /** Count of things left to do. */
+ int m_count = 0;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public Todo() {
+ }
+
+ /** Constructor. */
+ public Todo(int count) {
+ m_count = count;
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ m_count = 0;
+ }
+
+
+ // --- accessors ---
+
+ /** Gets count. */
+ public int get() {
+ return m_count;
+ }
+
+ /** Sets count. */
+ public void set(int count) {
+ m_count = count;
+ }
+
+ /** Returns true if count has reached zero. */
+ public boolean isDone() {
+ return m_count <= 0;
+ }
+
+ /** Increments count, returns new value. */
+ public int increment(int n) {
+ return (m_count += n);
+ }
+
+ /** Increments count, returns new value. */
+ public int increment() {
+ return (m_count += 1);
+ }
+
+ /** Decrements count, returns new value. */
+ public int decrement(int n) {
+ return (m_count -= n);
+ }
+
+ /** Decrements count, returns new value. */
+ public int decrement() {
+ return (m_count -= 1);
+ }
+
+
+ // --- methods ---
+
+ /** Adds completion steps to count. */
+ public void add(int n) {
+ increment(n);
+ }
+
+ /** Adds completion step to count. */
+ public void add() {
+ increment(1);
+ }
+
+ /** Decrements count, returns true when it's reached zero. */
+ public boolean done(int n) {
+ return decrement(n) <= 0;
+ }
+
+ /** Decrements count, returns true when it's reached zero. */
+ public boolean done() {
+ return decrement() <= 0;
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/UIResourceManager.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/UIResourceManager.java
new file mode 100755
index 00000000000..353481b2d7b
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/UIResourceManager.java
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.net.URL;
+
+import org.eclipse.cdt.visualizer.core.ResourceManager;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+// ---------------------------------------------------------------------------
+// UIResourceManager
+// ---------------------------------------------------------------------------
+
+/**
+ * Plugin resource manager.
+ * Provides one-stop-shopping for UI plugin resources
+ * (strings, images, fonts, colors).
+ * This class should be instanced in the UI plugin's "start()" method,
+ * and disposed in the "stop()" method.
+ */
+public class UIResourceManager extends ResourceManager
+{
+ // --- members ---
+
+ /** UI Plugin */
+ protected AbstractUIPlugin m_UIplugin = null;
+
+ /** Parent resource manager, if any */
+ protected UIResourceManager m_parentUIManager = null;
+
+ /** Image resource manager */
+ protected ImageRegistry m_images = null;
+
+ /** Font resource manager */
+ protected FontRegistry m_fonts = null;
+
+ /** Color resource manager */
+ protected ColorRegistry m_colors = null;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor
+ * Note: the plugin ID is assumed to also be the parent package name
+ * of the plugin, for example "com.tilera.ide.core"; it's assumed that string
+ * resources are found in the plugin directory in "messages.properties".
+ */
+ public UIResourceManager(AbstractUIPlugin plugin) {
+ super(plugin);
+ m_UIplugin = plugin;
+ getImageRegistry(); // creates registry object
+ getFontRegistry(); // creates registry object
+ getColorRegistry(); // creates registry object
+ }
+
+ /** Dispose method */
+ public void dispose() {
+ disposeImageRegistry();
+ disposeFontRegistry();
+ disposeColorRegistry();
+ }
+
+
+ // --- parent manager management ---
+
+ /** Sets parent resource manager, if any */
+ public void setParentManager(ResourceManager parentManager) {
+ super.setParentManager(parentManager);
+ if (parentManager instanceof UIResourceManager) {
+ m_parentUIManager = (UIResourceManager) parentManager;
+ }
+ else {
+ m_parentUIManager = null;
+ }
+ }
+
+ /** Gets parent UI resource manager, if any */
+ public UIResourceManager getParentManager() {
+ return m_parentUIManager;
+ }
+
+
+ // --- image resource management ---
+
+ /** Creates/returns image registry */
+ protected ImageRegistry getImageRegistry() {
+ if (m_images == null) {
+ // use the plugin's image registry
+ m_images = m_UIplugin.getImageRegistry();
+ }
+ return m_images;
+ }
+
+ /** Disposes image registry */
+ protected void disposeImageRegistry() {
+ if (m_images != null) {
+ // we're using the plugin's image registry, so it will dispose of it
+ //m_images.dispose();
+ m_images = null;
+ }
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ */
+ public ImageDescriptor getImageDescriptor(String path) {
+ ImageDescriptor result = null;
+ if (path == null) return result;
+
+ // get image registry, look up path
+ ImageRegistry images = getImageRegistry();
+ result = images.getDescriptor(path);
+
+ // if we don't find it, see if it exists as a file in this plugin
+ if (result == null) {
+ URL url = m_UIplugin.getBundle().getEntry(path);
+ if (url != null) {
+ // if so, we'll add an entry for it to this resource manager
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ images.put(path, desc);
+ result = images.getDescriptor(path);
+ }
+ else {
+ // if not, see if we can find it in the parent manager
+ // NOTE: this may be in a different plugin, so the path will be
+ // resolved relative to that plugin's base directory
+ UIResourceManager parent = getParentManager();
+ if (parent != null) {
+ result = parent.getImageDescriptor(path);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Gets specified image from plugin directory.
+ * Caches images so subsequent requests will be faster.
+ */
+ public Image getImage(String path) {
+ Image result = null;
+ if (path == null) return result;
+
+ // get image registry, look up path
+ ImageRegistry images = getImageRegistry();
+ result = images.get(path);
+
+ // if we don't find it, see if it exists as a file in this plugin
+ if (result == null) {
+ URL url = m_UIplugin.getBundle().getEntry(path);
+ if (url != null) {
+ // if so, we'll add an entry for it to this resource manager
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ images.put(path, desc);
+ result = images.get(path);
+ }
+ else {
+ // if not, see if we can find it in the parent manager
+ // NOTE: this may be in a different plugin, so the path will be
+ // resolved relative to that plugin's base directory
+ UIResourceManager parent = getParentManager();
+ if (parent != null) {
+ result = parent.getImage(path);
+ }
+ }
+ }
+ return result;
+ }
+
+
+ // --- font registry ---
+
+ /** Creates/returns font registry */
+ protected FontRegistry getFontRegistry() {
+ if (m_fonts == null) {
+ Display display = getDisplay();
+ m_fonts = new FontRegistry(display);
+ }
+ return m_fonts;
+ }
+
+ /** Disposes font registry */
+ protected void disposeFontRegistry() {
+ if (m_fonts != null) {
+ // doesn't appear to be a way to flush the registry cache
+ // so let finalizer handle it
+ m_fonts = null;
+ }
+ }
+
+ /** Sets cached font for specified ID */
+ public void setFont(String fontID, String fontName, int height, int style) {
+ setCachedFont(fontID, fontName, height, style);
+ }
+
+ /** Gets cached font for specified ID */
+ public Font getFont(String fontID) {
+ return getCachedFont(fontID);
+ }
+
+ /** Gets/creates font with specified properties */
+ public Font getFont(String fontName, int height) {
+ return getCachedFont(fontName, height, SWT.NORMAL);
+ }
+
+ /** Gets/creates font with specified properties */
+ public Font getFont(String fontName, int height, int style) {
+ return getCachedFont(fontName, height, style);
+ }
+
+ /** Sets cached font for specified ID */
+ protected void setCachedFont(String fontID, String fontName, int height, int style) {
+ FontData[] fontData = new FontData[1];
+ fontData[0] = new FontData(fontName, height, style);
+ FontRegistry fonts = getFontRegistry();
+ fonts.put(fontID, fontData);
+ }
+
+ /** Gets cached font, if any, for specified ID */
+ protected Font getCachedFont(String fontID) {
+ Font result = null;
+
+ // get font registry, look up font ID
+ FontRegistry fonts = getFontRegistry();
+ if (fonts.hasValueFor(fontID)) {
+ result = fonts.get(fontID);
+ }
+ else {
+ // if we don't find it, see if parent manager has it
+ UIResourceManager parent = getParentManager();
+ if (parent != null) {
+ result = parent.getCachedFont(fontID);
+ }
+ }
+ return result;
+ }
+
+ /** Gets/creates font with specified properties */
+ protected Font getCachedFont(String fontName, int height, int style) {
+ Font result = null;
+ String fontID = fontName + "," + height + "," + style;
+
+ // look for the cached font (this checks the parent manager too)
+ result = getCachedFont(fontID);
+
+ // if we didn't find it, add an entry to this resource manager
+ if (result == null) {
+ setCachedFont(fontID, fontName, height, style);
+ result = getCachedFont(fontID);
+ }
+ return result;
+ }
+
+
+ // --- color registry ---
+
+ /** Creates/returns color registry */
+ protected ColorRegistry getColorRegistry() {
+ if (m_colors == null) {
+ Display display = getDisplay();
+ m_colors = new ColorRegistry(display);
+ }
+ return m_colors;
+ }
+
+ /** Disposes color registry */
+ protected void disposeColorRegistry() {
+ if (m_colors != null) {
+ // doesn't appear to be a way to flush the registry cache
+ // so let finalizer handle it
+ m_colors = null;
+ }
+ }
+
+ /** Gets cached color with specified SWT color ID */
+ public Color getColor(int colorID) {
+ // NOTE: we don't cache these colors, we just look them up every time
+ return getDisplay().getSystemColor(colorID);
+ }
+
+ /** Gets cached color with specified ID */
+ public Color getColor(String colorID) {
+ return getCachedColor(colorID);
+ }
+
+ /** Gets/creates color with specified properties */
+ public Color getColor(int red, int green, int blue) {
+ return getCachedColor(red, green, blue);
+ }
+
+ /** Sets cached color for specified ID */
+ protected void setCachedColor(String colorID, int red, int green, int blue) {
+ RGB rgb = new RGB(red, green, blue);
+ ColorRegistry colors = getColorRegistry();
+ colors.put(colorID, rgb);
+ }
+
+ /** Gets cached color with specified ID */
+ protected Color getCachedColor(String colorID) {
+ Color result = null;
+ ColorRegistry colors = getColorRegistry();
+ if (colors.hasValueFor(colorID)) {
+ result = colors.get(colorID);
+ }
+ else {
+ // if we don't find it, see if parent manager has it
+ UIResourceManager parent = getParentManager();
+ if (parent != null) {
+ result = parent.getCachedColor(colorID);
+ }
+ }
+ return result;
+ }
+
+ /** Gets/creates color with specified properties */
+ protected Color getCachedColor(int red, int green, int blue) {
+ Color result = null;
+ String colorID = "Color[R=" + red + ",G=" + green + ",B=" + blue + "]";
+
+ // look for the cached color (this checks the parent manager too)
+ result = getCachedColor(colorID);
+
+ // if we don't find it, create an entry in this resource manager
+ if (result == null) {
+ setCachedColor(colorID, red, green, blue);
+ result = getCachedColor(colorID);
+ }
+ return result;
+ }
+
+
+ // --- utilities ---
+
+ /**
+ * Returns the current SWT display.
+ *
+ * The method first checks whether the caller already has
+ * an associated display. If so, this display is returned.
+ * Otherwise the method returns the default display.
+ *
+ * This allows GUIUtils to work in contexts like tests
+ * where the SWT display has not already been defined.
+ *
+ * (Credit: Borrowed from DebugUIPlugin.)
+ */
+ public static Display getDisplay() {
+ Display display= Display.getCurrent();
+ if (display == null) {
+ display= Display.getDefault();
+ }
+ return display;
+ }
+}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/WorkbenchSelectionAdapter.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/WorkbenchSelectionAdapter.java
new file mode 100755
index 00000000000..0c268491f51
--- /dev/null
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/WorkbenchSelectionAdapter.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tilera Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William R. Swanson (Tilera Corporation)
+ *******************************************************************************/
+
+package org.eclipse.cdt.visualizer.ui.util;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+// ---------------------------------------------------------------------------
+// WorkbenchSelectionAdapter
+// ---------------------------------------------------------------------------
+
+/**
+ * Selection change event manager
+ */
+public class WorkbenchSelectionAdapter
+ implements ISelectionListener, ISelectionProvider
+{
+ // --- members ---
+
+ /** Workbench part (view) this adapter is associated with. */
+ protected IViewPart m_view = null;
+
+ /** Current selection */
+ protected ISelection m_selection = null;
+
+ /** Listeners for selection changed events. */
+ protected ListenerList m_selectionListeners = null;
+
+ /** Whether selection events are reported */
+ protected boolean m_trackSelection = true;
+
+
+ // --- constructors/destructors ---
+
+ /** Constructor. */
+ public WorkbenchSelectionAdapter(IViewPart view) {
+ m_view = view;
+ m_selection = null;
+ m_selectionListeners = new ListenerList(view, "WorkbenchSelectionAdapter for view " + view.getClass().getSimpleName())
+ {
+ /** Dispatches event to listeners */
+ public void raise(Object listener, Object event) {
+ if (listener instanceof ISelectionChangedListener &&
+ event instanceof SelectionChangedEvent)
+ {
+ ISelectionChangedListener typedListener = (ISelectionChangedListener) listener;
+ SelectionChangedEvent typedEvent = (SelectionChangedEvent) event;
+ typedListener.selectionChanged(typedEvent);
+ }
+ }
+ };
+
+ // listen for external selection changed events
+ m_view.getSite().getPage().addSelectionListener(this);
+
+ // set selection provider for this view
+ m_view.getSite().setSelectionProvider(this);
+
+ // initialize selection
+ setSelection(m_view.getSite().getPage().getSelection());
+
+ }
+
+ /** Dispose method. */
+ public void dispose() {
+ if (m_view != null) {
+ m_view.getSite().getPage().removeSelectionListener(this);
+ m_view.getViewSite().setSelectionProvider(null);
+ m_view = null;
+ }
+ m_selection = null;
+ if (m_selectionListeners != null) {
+ m_selectionListeners.clear();
+ m_selectionListeners = null;
+ }
+ }
+
+
+ // --- accessors ---
+
+ /** Gets whether selection change events are reported. */
+ public boolean getTrackSelection() {
+ return m_trackSelection;
+ }
+
+ /** Sets whether selection change events are reported. */
+ public void setTrackSelection(boolean trackSelection) {
+ m_trackSelection = trackSelection;
+ }
+
+
+ // --- ISelectionListener implementation ---
+
+ /** Invoked when selection changes externally. */
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ // ignore selection change events that came from us
+ if (part == m_view) return;
+ if (m_trackSelection) {
+ workbenchSelectionChanged(part, selection);
+ }
+ }
+
+ /** Invoked when selection changes.
+ * Intended to be overloaded by derived implementations.
+ */
+ public void workbenchSelectionChanged(ISelection selection) {
+ setSelection(selection);
+ }
+
+ /** Invoked when selection changes.
+ * Intended to be overloaded by derived implementations.
+ */
+ public void workbenchSelectionChanged(ISelectionProvider provider, ISelection selection) {
+ setSelection(provider, selection);
+ }
+
+ /** Invoked when selection changes.
+ * Intended to be overloaded by derived implementations.
+ */
+ public void workbenchSelectionChanged(Object provider, ISelection selection) {
+ setSelection(provider, selection);
+ }
+
+
+ // --- ISelectionProvider implementation ---
+
+ /** Gets current selection. */
+ public ISelection getSelection() {
+ return m_selection;
+ }
+
+ /** Sets current selection, and raises selection changed event. */
+ public void setSelection(ISelection selection) {
+ // for some reason, SelectionChangedEvent can't stand a null selection
+ if (selection == null) selection = StructuredSelection.EMPTY;
+ m_selection = selection;
+ m_selectionListeners.raise(new SelectionChangedEvent(this, m_selection));
+ }
+
+ /** Sets current selection, and raises selection changed event. */
+ public void setSelection(ISelectionProvider source, ISelection selection) {
+ // for some reason, SelectionChangedEvent can't stand a null selection
+ if (selection == null) selection = StructuredSelection.EMPTY;
+ m_selection = selection;
+ m_selectionListeners.raise(new SelectionChangedEvent(source, m_selection));
+ }
+
+ /** Sets current selection, and raises selection changed event. */
+ public void setSelection(Object source, ISelection selection) {
+ // for some reason, SelectionChangedEvent can't stand a null selection
+ if (selection == null) selection = StructuredSelection.EMPTY;
+ m_selection = selection;
+ m_selectionListeners.raise(new SelectionChangedEvent(new SelectionProviderAdapter(source), m_selection));
+ }
+
+ /** Adds external listener for selection change events. */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionListeners.addListener(listener);
+ }
+
+ /** Removes external listener for selection change events. */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ m_selectionListeners.removeListener(listener);
+ }
+
+
+ // --- utilities ---
+
+ /** Converts selection to string, for debug display. */
+ protected String selectionToString(ISelection selection) {
+ String result = null;
+ // convert selection to text string
+ if (m_selection == null) {
+ result = "No Selection";
+ }
+ else if (m_selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) m_selection;
+ List<?> elements = structuredSelection.toList();
+ int size = elements.size();
+ if (size == 0) {
+ result = "Empty Selection";
+ }
+ else {
+ result = "";
+ for (int i=0; i<size; i++) {
+ if (i>0) result += "\n";
+ Object o = elements.get(i);
+ String type = o.getClass().getName();
+ String value = o.toString();
+ result += "[" + i + "]: type= + " + type + ", value='" + value + "'";
+ }
+ }
+ }
+ else {
+ String type = m_selection.getClass().getName();
+ String value = m_selection.toString();
+ result = "type=" + type + ", value='" + value + "'";
+ }
+ return result;
+ }
+}

Back to the top