|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.window.Window | +--org.eclipse.jface.dialogs.Dialog | +--org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog
This class implements a default dialog that allows customization of the different entries/items on a GEF palette, i.e. the model behind the palette.
The construction of the dialog is broken down into different methods in order to allow clients to further customize the appearance of the dialog, if so desired.
This dialog can be re-used, i.e., it can be re-opened once closed. There is no need to
create a new PaletteCustomizerDialog
everytime a palette needs to be
customized.
PaletteEntry
,
PaletteCustomizer
Field Summary | |
protected static int |
APPLY_ID
The unique ID for the Apply Button. |
protected static int |
CLIENT_ID
Sub-classes that need to create their own unique IDs should do so by adding to this ID. |
Fields inherited from class org.eclipse.jface.dialogs.Dialog |
buttonBar, dialogArea, DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING |
Fields inherited from class org.eclipse.jface.window.Window |
CANCEL, OK |
Constructor Summary | |
PaletteCustomizerDialog(Shell shell,
PaletteCustomizer customizer,
PaletteRoot root)
Constructs a new customizer dialog. |
Method Summary | |
protected void |
buttonPressed(int buttonId)
This method will be invoked whenever any Button created using
createButton(Composite, int, String, int, ImageDescriptor) or
Dialog.createButton(Composite, int, String, boolean) is selected. |
void |
clearProblem()
This method should be invoked by EntryPages when an error that they had earlier reported (using showProblem(String) ) is fixed. |
boolean |
close()
NOTE: This dialog can be re-opened. |
protected void |
configureShell(Shell newShell)
|
protected Button |
createButton(Composite parent,
int id,
String label,
int stylebits,
ImageDescriptor descriptor)
This method should not be used to create buttons for the button bar. |
protected void |
createButtonsForButtonBar(Composite parent)
Creates the OK, Cancel and Apply buttons |
protected Control |
createDialogArea(Composite parent)
The dialog area contains the following: Outline ( createOutline(Composite) )
Properties Panel (createPropertiesPanel(Composite) )
It is recommended that this method not be overridden. |
protected Control |
createOutline(Composite container)
Creates the outline part of the dialog. |
protected List |
createOutlineActions()
Creates the actions that manipulate the palette model. |
protected Menu |
createOutlineContextMenu()
Uses a MenuManager to create the context menu for the outline. |
protected Control |
createOutlineToolBar(Composite parent)
Uses a ToolBarManager to create the ToolBar in the outline part of the dialog. |
protected TreeViewer |
createOutlineTreeViewer(Composite composite)
Creates the TreeViewer that is the outline of the model. |
protected Control |
createPropertiesPanel(Composite container)
Creates the part of the dialog where the properties of the element selected in the outline will be displayed. |
protected PageBook |
createPropertiesPanelTitle(Composite parent)
Creates the title for the properties panel. |
protected CLabel |
createSectionTitle(Composite composite,
String text)
A convenient method to create CLabel titles (like the ones used in the Preferences dialog in the Eclipse workbench) throughout the dialog. |
protected Button |
getButton(int id)
Returns the Button with the given id; or null if none was found. |
protected PaletteCustomizer |
getCustomizer()
|
protected EntryPage |
getEntryPage(PaletteEntry entry)
Returns the EntryPage for the given PaletteEntry . |
protected List |
getOutlineActions()
Provides access to the actions that are used to manipulate the model. |
protected PaletteRoot |
getPaletteRoot()
Provides sub-classes with access to the PaletteRoot |
protected PaletteEntry |
getSelectedPaletteEntry()
|
protected TreeItem |
getSelectedTreeItem()
|
protected Widget |
getWidget(int id)
The Widget s that were created with a unique ID and added to this class'
internal map can be retrieved through this method. |
protected void |
handleApplyPressed()
This method is invoked when the Apply button is pressed IMPORTANT: It is recommended that you not override this method. |
protected void |
handleDelete()
This method is called when the "Delete" action is run (either through the context menu or the toolbar). |
protected void |
handleMoveDown()
This method is called when the "Move Down" action is run (either through the context menu or the toolbar). |
protected void |
handleMoveUp()
This method is called when the "Move Up" action is run (either through the context menu or the toolbar). |
protected void |
handleOutlineSelectionChanged()
This is the method that is called everytime the selection in the outline (treeviewer) changes. |
protected void |
revertToSaved()
This method is invoked when the changes made since the last save need to be cancelled. |
protected void |
save()
This method is invoked when the changes made since the last save need to be saved. |
protected void |
setActiveEntry(PaletteEntry entry)
This methods sets the active entry. |
protected void |
setActiveEntryPage(EntryPage page)
Sets the given EntryPage as the top page in the PageBook that shows the properties of the item selected in the Outline. |
void |
setDefaultSelection(PaletteEntry entry)
Sets the given PaletteEntry as the one to be selected when the dialog opens. |
void |
showProblem(String error)
This method should be invoked by EntryPages when there is an error. |
protected void |
updateActions()
Updates the actions created in createOutlineActions() , enabling or
disabling them as necessary. |
Methods inherited from class org.eclipse.jface.window.Window |
canHandleShellCloseEvent, create, createShell, getContents, getDefaultImage, getInitialLocation, getInitialSize, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int APPLY_ID
getWidget(int)
or
getButton(int)
), or to identify that widget in buttonPressed(int)
.
protected static final int CLIENT_ID
Constructor Detail |
public PaletteCustomizerDialog(Shell shell, PaletteCustomizer customizer, PaletteRoot root)
shell
- the parent Shellcustomizer
- the customizerroot
- the palette rootMethod Detail |
protected void buttonPressed(int buttonId)
Button
created using
createButton(Composite, int, String, int, ImageDescriptor)
or
Dialog.createButton(Composite, int, String, boolean)
is selected.
buttonPressed
in class Dialog
Dialog.buttonPressed(int)
public void clearProblem()
showProblem(String)
) is fixed. This will hide the error
message, enable the OK and Apply buttons and re-allow changing selection in the outline
tree.
clearProblem
in interface EntryPageContainer
EntryPageContainer.clearProblem()
,
showProblem(String)
public boolean close()
NOTE: This dialog can be re-opened.
close
in class Dialog
Window.close()
protected void configureShell(Shell newShell)
configureShell
in class Dialog
Window.configureShell(Shell)
protected Button createButton(Composite parent, int id, String label, int stylebits, ImageDescriptor descriptor)
Dialog.createButton(Composite, int, String, boolean)
for that. This method
can be used to create any other button in the dialog. The parent
Composite
must have a GridLayout. These buttons will be available
through getButton(int)
and getWidget(int)
. Ensure that the various
buttons created by this method are given unique IDs. Pass in a null
image
descriptor if you don't want the button to have an icon. This method will take care
of disposing the images that it creates. buttonPressed(int)
will be called
when any of the buttons created by this method are clicked (selected).
parent
- The composite in which the button is to be createdid
- The button's unique IDlabel
- The button's textstylebits
- The style bits for creating the button (eg.,
SWT.PUSH
or SWT.CHECK
)descriptor
- The ImageDescriptor from which the image/icon for this
button should be created
protected void createButtonsForButtonBar(Composite parent)
createButtonsForButtonBar
in class Dialog
Dialog.createButtonsForButtonBar(Composite)
protected Control createDialogArea(Composite parent)
createOutline(Composite)
)createPropertiesPanel(Composite)
)It is recommended that this method not be overridden. Override one of the methods that this method calls in order to customize the appearance of the dialog.
createDialogArea
in class Dialog
Dialog.createDialogArea(Composite)
protected Control createOutline(Composite container)
The outline creates the following:
createOutlineToolBar(Composite)
)createOutlineTreeViewer(Composite)
)createOutlineContextMenu()
)
container
- The Composite within which the outline has to be created
protected List createOutlineActions()
IMPORTANT: All the elements in the returned List MUST be
PaletteCustomizationAction
s.
PaletteCustomizationActions
protected Menu createOutlineContextMenu()
MenuManager
to create the context menu for the outline. The
IActions
used to create the context menu are those created in
createOutlineActions()
.
protected Control createOutlineToolBar(Composite parent)
createOutlineActions()
.
parent
- The Composite to which the ToolBar is to be added
protected TreeViewer createOutlineTreeViewer(Composite composite)
composite
- The Composite to which the ToolBar is to be added
protected Control createPropertiesPanel(Composite container)
The properties panel contains the following:
The rest of the panel is constructed in this method.
container
- The Composite to which this part is to be added
protected PageBook createPropertiesPanelTitle(Composite parent)
parent
- The parent composite
protected CLabel createSectionTitle(Composite composite, String text)
composite
- The composite in which the title is to be created (it must have a
GridLayout with two columns).text
- The title to be displayed
protected Button getButton(int id)
null
if none was found.
getButton
in class Dialog
Dialog.getButton(int)
protected PaletteCustomizer getCustomizer()
protected EntryPage getEntryPage(PaletteEntry entry)
EntryPage
for the given PaletteEntry
. The
EntryPage
is retrieved from the customizer. If the given entry is
null
, null
will be returned. If the customizer returns
null
for the valid entry, a default page will be created and returned.
entry
- The PaletteEntry whose properties need to be displayed
protected final List getOutlineActions()
PaletteCustomizationAction
screateOutlineActions()
protected PaletteRoot getPaletteRoot()
protected PaletteEntry getSelectedPaletteEntry()
null
if none is selectedprotected TreeItem getSelectedTreeItem()
null
if none is selectedprotected Widget getWidget(int id)
Widget
s that were created with a unique ID and added to this class'
internal map can be retrieved through this method.
id
- The unique ID of the Widget that you wish to retrieve
null
otherwiseprotected final void handleApplyPressed()
IMPORTANT: It is recommended that you not override this method. Closing the dialog
with the 'X' at the top right of the window, or by hitting 'Esc' or any other way,
corresponds to a "Cancel." That will, however, not result in this method being
invoked. To handle such cases, saving or rejecting the changes is handled in close()
. Override save()
and revertToSaved()
to add to what needs
to be done when saving or cancelling.
protected void handleDelete()
protected void handleMoveDown()
protected void handleMoveUp()
protected void handleOutlineSelectionChanged()
protected void revertToSaved()
protected void save()
protected void setActiveEntry(PaletteEntry entry)
entry
- The new active entry, i.e., the new selected entry (it can be
null
)protected void setActiveEntryPage(EntryPage page)
page
- The EntryPage to be shownpublic void setDefaultSelection(PaletteEntry entry)
entry
- The PaletteEntry that should be selected when the dialog is openedpublic void showProblem(String error)
showProblem
in interface EntryPageContainer
error
- A description of the problem. Should be as brief as possible.EntryPageContainer.showProblem(String)
protected void updateActions()
createOutlineActions()
, enabling or
disabling them as necessary.
|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |