Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Nebula XViewer Getting Started"

(Running XViewer examples)
(Running XViewer examples)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
XViewer was intended to be as close to a drop in replacement for the existing TreeViewer supplied by SWT with many advanced features.  Included in the XViewer source code is an "example" package with source code that provides examples for getting started.
+
XViewer was intended to be as close to a drop in replacement for the existing TreeViewer supplied by SWT with many advanced features.  Included is an "example" plugin with source code that provides examples for getting started.
  
 
== Running XViewer examples ==
 
== Running XViewer examples ==
* Checkout XViewer source code through Nebula CVS repository
+
 
  :pserver:anonymous@dev.eclipse.org:/cvsroot/technology (anonymous)
+
To View or Use XViewer example:
  NOTE: will need to traverse to org.eclipse.swt.nebula/org.eclipse.nebula.widgets.xwidget
+
 
 +
* Example can be seen using the nebula ExampleView. [http://eclipse.org/nebula/downloads.php Instructions here].
 +
* Or [http://wiki.eclipse.org/Nebula_XViewer_Getting_Started#Checkout_XViewer_source_code Checkout XViewer source code] and run example from workspace
 
* In Java Package Explorer, expand out org.eclipse.nebula.widgets.xviewer.example
 
* In Java Package Explorer, expand out org.eclipse.nebula.widgets.xviewer.example
 
* Select "MyXviewerTest.java" -> Right-click -> Run-As -> Java Application.  This will launch the XViewer example
 
* Select "MyXviewerTest.java" -> Right-click -> Run-As -> Java Application.  This will launch the XViewer example
 +
 +
== Checkout XViewer source code ==
 +
 +
* Connect your Eclipse to [http://eclipse.org/nebula/source.php Nebula GIT repository] and checkout the following plugins into your workspace
 +
** org.eclipse.nebula/Working Directory/widgets/xviewer/org.eclipse.nebula.widgets.xwidget
 +
** org.eclipse.nebula/Working Directory/widgets/xviewer/org.eclipse.nebula.widgets.xwidget.example
 +
** org.eclipse.nebula/Working Directory/examples/org.eclipse.nebula.examples (needed to compile)
  
 
== How to create your own XViewer ==
 
== How to create your own XViewer ==

Latest revision as of 16:46, 30 April 2012

XViewer was intended to be as close to a drop in replacement for the existing TreeViewer supplied by SWT with many advanced features. Included is an "example" plugin with source code that provides examples for getting started.

Running XViewer examples

To View or Use XViewer example:

  • Example can be seen using the nebula ExampleView. Instructions here.
  • Or Checkout XViewer source code and run example from workspace
  • In Java Package Explorer, expand out org.eclipse.nebula.widgets.xviewer.example
  • Select "MyXviewerTest.java" -> Right-click -> Run-As -> Java Application. This will launch the XViewer example

Checkout XViewer source code

  • Connect your Eclipse to Nebula GIT repository and checkout the following plugins into your workspace
    • org.eclipse.nebula/Working Directory/widgets/xviewer/org.eclipse.nebula.widgets.xwidget
    • org.eclipse.nebula/Working Directory/widgets/xviewer/org.eclipse.nebula.widgets.xwidget.example
    • org.eclipse.nebula/Working Directory/examples/org.eclipse.nebula.examples (needed to compile)

How to create your own XViewer

  • The model for the example is in the model package. It contains the SomeTask object and a ISomeTask interface. You would replace these with your own classes that are going to be set to input of the XViewer. They do not have to be the same object, but they do need to be handled in the corresponding ContentProvider and LabelProvider.
  • MyXViewer extends XViewer which extends TreeViewer. Your extension allows you to configure and modify XViewer and also still have access to all the default capabilities of the TreeViewer.
  • MyXviewerContentProvider implements ITreeContentProvider. This is the default content provider for any TreeViewer and should be implemented the same.
  • MyXViewerLabelProvider extends XViewerLabelProvider which implements ITableLabelProvider and ITableColorProvider. Your Label Provider MUST extend XViewerLabelProvider to get all off the features of XViewer as intended. This class provides the text, images and colors for the cells.
  • MyXViewerFactory provides the definition of the different columns available to the user. Any number of columns can be provided. Each column has settings, such as data type to be displayed, whether the column is visible by default and an id that is used to uniquely identify the column (use in customizations)
  • XViewer has the capability to save "customizations" to the layout, sorting, visible columns, filters and etc. Multiple of these customizations can be saved and the user can switch between them to see the data shown in different ways. This is an optional feature that is provided by extending XViewerCustomizations. Implementing these methods provides a storage mechanism to enable this feature to persist customizations between instances of a client running. MyXViewerCustomizations is an example that stores to the default file system. This can be changed to a database or whatever other storage mechanism is available.

How to implement your new XViewer.

MyXViewerTest provides an example of how to embed your XViewer in a Shell.

  • Instantiate your new MyXViewer
  myXviewer= new MyXViewer(Shell_1, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
  • Set your layout data to fill the composite
  myXviewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
  • Set your content provider, just like you would with any TreeViewer
  myXviewer.setContentProvider(new MyXViewerContentProvider());
  • Set your lable provider, just like any TreeViewer
  myXviewer.setLabelProvider(new MyXViewerLabelProvider(xViewerTest));
  • Set your input, just like any TreeViewer
  myXviewer.setInput(tasks);

Back to the top