Jellytools - New Window System Migration Guide
Author: Jiri
Skrivanek
Last update: November 12, 2003
This document should help test developers to update their test cases
in order to work with new window system introduced in NetBeans IDE.
Look at Quick
guide to the new window system to know what was
changed and how to work with the new UI. Detailed description of the
new window system can be found in UI
specification. Task and issues related to its implementation are
covered under the umbrella issue 29836.
First version of jellytools library compatible with the new window
system is 2.2.1. Sources and builds of jellytools can be found in CVS
repository or at download
page.
The most significant changes
Concept of internal frames in IDE has been changed. In the new
window system is everything TopComponent (let's say almost everything).
TopComponents resides in the main window area. This area is split into
several parts and split layout can be customized by user. TopComponents
can be attached to "tab-like" panes. In separated mode (as known as
SDI)
are these panes each in a single frame.
From already said it should be clear that NbFrameOperator
which was used both for JFrame (in SDI) and for JInternalFrame (in MDI)
is in the new window system useless. Instead of NbFrameOperator is
recommended to use TopComponentOperator
or an operator designated for the component you want to test. For
example:
// instead this to locate Filesystems
panel
new NbFrameOperator("Filesystems");
// use this to find top component by name
new TopComponentOperator("Filesystems");
// or even better use existing operator
new RepositoryTabOperator();
Next one of big changes is that workspaces were abandoned. In this
connection there were removed methods from MainWindowOperator
handling workspaces: switchToWorkspace(String),
switchToGUIEditingWorkspace(), switchToDebuggingWorkspace(),
switchToEditingWorkspace(), getTabControl(), getTabCount(),
getSelectedIndex(), getTabIndex(String ), clickOnTab(int), pushMenuOnTab(String, int).
Also the output window has been changed. It is a top component which
contains one or more terminal panes. If there is more than one term
opened, they are placed in JTabbedPane container. To work with output
top compomponent it has been created OutputOperator
which extends TopComponentOperator. It should replace former
OutputWindowOperator which is now deprecated. Use it for example this
way:
// find Output window top component
OutputOperator oo = new OutputOperator();
// close it
oo.close();
A particular terminals can be handled by TermOperator.
It enables to get text from terminal and call a context action
available on this component:
//
find output terminal
TermOperator to = new
TermOperator("MyName");
// get text or so
System.out.println("LINE COUNT="+to.getLineCount());
System.out.println("TEXT="+to.getText().substring(0,
10)+"<<<<<");
// call some actions
to.clearOutput();
to.startRedirection();
// close this term
to.close();
The editor area is a place where to find primarily documents opened
for editing but also other components. There is no special operator for
the editor area, so it is recommended to use directly EditorOperator. EditorOperator allows to work
with text in editor, to call context menu items and to do other
necessary operation. Simple example of its functionality follows:
// find editor by name
EditorOperator eo = new EditorOperator("MyClass");
// do operations in editor
eo.setCaretPositionToLine(10);
eo.insert("// My new comment\n");
// close the way you like
// discard changes and close
eo.close(false);
// save changes and close
eo.close(true);
// try to close all opened documents
(confirmation dialog may appear)
eo.closeAllDocuments();
// close all opened documents and discard
all changes
eo.closeDiscardAll();
The component which should reside outside of the main window area is
wrapped into a dialog. For example, it is a case of properties or
options. There can exist several non-modal dialogs with property sheets
of particular object. But global property sheet is placed in main
window
area and can be open from main menu "Window|Properties". Below
are examples how to work with property sheets in different situations:
a) Global property sheet
// open global property sheet
new PropertiesAction().perform();
// find it
PropertySheetOperator globalPso = new PropertySheetOperator();
// find property "Name" in it
Property globalP = new Property(globalPso, "Name");
// do whatever you want with the property
System.out.println("Name="+globalP.getName());
// close property sheet
globalPso.close();
b) Particular property sheet
// find a node
Node node = new Node(new RepositoryTabOperator().getRootNode(), "|");
// open property sheet for the node (it is
opened in a dialog)
new PropertiesAction().perform(node);
// find it
PropertySheetOperator pso = new PropertySheetOperator("Properties of
"+node.getText());
// find property "Name" in it
Property p = new Property(pso, "Name");
// do whatever you want with the property
System.out.println("Name="+p.getName());
// close property sheet
pso.close();
c) Options
// open Options
OptionsOperator optionsOper = OptionsOperator.invoke();
// select a node and find property sheet
String optionPath = "Building|Ant Settings";
PropertySheetOperator pso1 = optionsOper.getPropertySheet(optionPath);
// find property in it
Property p1 = new Property(pso1, "Ant Home");
//do whatever you want with the property
System.out.println("Ant Home="+p1.getValue());
// close Options
optionsOper.close();
Changed files
Removed:
- actions
- DockingAction
- UndockAction
- modules
- form
- actions
- FormEditorOperator
- PerimeterPaneOperator
Added:
- actions
- AttachWindowAction
- CloseAllDocumentsAction
- DiscardAllOutputsAction
- DiscardOutputAction
- DocumentsAction
- MaximizeWindowAction
- RestoreWindowAction
- modules
- form
- actions
- InspectorAction
- PaletteAction
- FormEditorOperator
- OutputOperator
- DocumentsDialogOperator
Modified:
- actions
- Action
- CloneViewAction
- CloseViewAction
- FilesystemsViewAction
- PasteCopyAction
- ProjectViewAction
- PropertiesAction
- RuntimeViewAction
- modules
- form
- ComponentInspectorOperator
- ComponentPaletteOperator
- FormDesignerOperator
- properties
- Property
- PropertySheetOperator
- EditorOperator
- EditorWindowOperator
- ExplorerOperator
- HelpOperator
- MainWindowOperator
- NbFrameOperator
- OptionsOperator
- OutputWindowOperator
- ProjectsTabOperator
- RepositoryTabOperator
- RuntimeTabOperator
- SearchResultsOperator
- TermOperator
- TopComponentOperator