Class PaletteCustomizerDialog
- All Implemented Interfaces:
EntryPageContainer
,IShellProvider
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The unique ID for the Apply Button.protected static final int
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
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, dialogArea, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK, resizeHasOccurred
-
Constructor Summary
ConstructorsConstructorDescriptionPaletteCustomizerDialog
(Shell shell, PaletteCustomizer customizer, PaletteRoot root) Constructs a new customizer dialog. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
buttonPressed
(int buttonId) This method will be invoked whenever anyButton
created usingcreateButton(Composite, int, String, int, ImageDescriptor)
orDialog.createButton(Composite, int, String, boolean)
is selected.void
This method should be invoked by EntryPages when an error that they had earlier reported (usingshowProblem(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 buttonsprotected Control
createDialogArea
(Composite parent) The dialog area contains the following: Outline (createOutline(Composite)
) Properties Panel (createPropertiesPanel(Composite)
)protected Control
createOutline
(Composite container) Creates the outline part of the dialog.protected List
Creates the actions that manipulate the palette model.protected Menu
Uses aMenuManager
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; ornull
if none was found.protected PaletteCustomizer
protected EntryPage
getEntryPage
(PaletteEntry entry) Returns theEntryPage
for the givenPaletteEntry
.protected final List
Provides access to the actions that are used to manipulate the model.protected PaletteRoot
Provides sub-classes with access to the PaletteRootprotected PaletteEntry
protected TreeItem
protected Widget
getWidget
(int id) TheWidget
s that were created with a unique ID and added to this class' internal map can be retrieved through this method.protected final void
This method is invoked when the Apply button is pressedprotected void
This method is called when the "Delete" action is run (either through the context menu or the toolbar).protected void
This method is called when the "Move Down" action is run (either through the context menu or the toolbar).protected void
This method is called when the "Move Up" action is run (either through the context menu or the toolbar).protected void
This is the method that is called everytime the selection in the outline (treeviewer) changes.protected void
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
Updates the actions created increateOutlineActions()
, enabling or disabling them as necessary.Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, createButtonBar, createContents, dialogFontIsDefault, getBlockedHandler, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, isResizable, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
-
Field Details
-
APPLY_ID
protected static final int APPLY_IDThe unique ID for the Apply Button. It can be used to retrieve that widget from the internal map (usinggetWidget(int)
orgetButton(int)
), or to identify that widget inbuttonPressed(int)
.- See Also:
-
CLIENT_ID
protected static final int CLIENT_IDSub-classes that need to create their own unique IDs should do so by adding to this ID.- See Also:
-
-
Constructor Details
-
PaletteCustomizerDialog
Constructs a new customizer dialog.- Parameters:
shell
- the parent Shellcustomizer
- the customizerroot
- the palette root
-
-
Method Details
-
buttonPressed
protected void buttonPressed(int buttonId) This method will be invoked whenever anyButton
created usingcreateButton(Composite, int, String, int, ImageDescriptor)
orDialog.createButton(Composite, int, String, boolean)
is selected.- Overrides:
buttonPressed
in classDialog
- See Also:
-
clearProblem
public void clearProblem()This method should be invoked by EntryPages when an error that they had earlier reported (usingshowProblem(String)
) is fixed. This will hide the error message, enable the OK and Apply buttons and re-allow changing selection in the outline tree.- Specified by:
clearProblem
in interfaceEntryPageContainer
- See Also:
-
close
public boolean close()NOTE: This dialog can be re-opened.
-
configureShell
- Overrides:
configureShell
in classWindow
- See Also:
-
createButton
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. UseDialog.createButton(Composite, int, String, boolean)
for that. This method can be used to create any other button in the dialog. The parentComposite
must have a GridLayout. These buttons will be available throughgetButton(int)
andgetWidget(int)
. Ensure that the various buttons created by this method are given unique IDs. Pass in anull
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).- Parameters:
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
orSWT.CHECK
)descriptor
- The ImageDescriptor from which the image/icon for this button should be created- Returns:
- The newly created button for convenience
-
createButtonsForButtonBar
Creates the OK, Cancel and Apply buttons- Overrides:
createButtonsForButtonBar
in classDialog
- See Also:
-
createDialogArea
The dialog area contains the following:- Outline (
createOutline(Composite)
) - Properties Panel (
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.
- Overrides:
createDialogArea
in classDialog
- See Also:
- Outline (
-
createOutline
Creates the outline part of the dialog.The outline creates the following:
- ToolBar (
createOutlineToolBar(Composite)
) - TreeViewer (
createOutlineTreeViewer(Composite)
) - Context menu (
createOutlineContextMenu()
)
- Parameters:
container
- The Composite within which the outline has to be created- Returns:
- The newly created Control that has the outline
- ToolBar (
-
createOutlineActions
Creates the actions that manipulate the palette model. These actions will populate the toolbar and the outline's context menu.IMPORTANT: All the elements in the returned List MUST be
PaletteCustomizationAction
s.- Returns:
- A List of
PaletteCustomizationActions
-
createOutlineContextMenu
Uses aMenuManager
to create the context menu for the outline. TheIActions
used to create the context menu are those created increateOutlineActions()
.- Returns:
- The newly created Menu
-
createOutlineToolBar
Uses a ToolBarManager to create the ToolBar in the outline part of the dialog. The Actions used in the ToolBarManager are those that are created increateOutlineActions()
.- Parameters:
parent
- The Composite to which the ToolBar is to be added- Returns:
- The newly created ToolBar
-
createOutlineTreeViewer
Creates the TreeViewer that is the outline of the model.- Parameters:
composite
- The Composite to which the ToolBar is to be added- Returns:
- The newly created TreeViewer
-
createPropertiesPanel
Creates the part of the dialog where the properties of the element selected in the outline will be displayed.The properties panel contains the following:
The rest of the panel is constructed in this method.- Parameters:
container
- The Composite to which this part is to be added- Returns:
- The properties panel
-
createPropertiesPanelTitle
Creates the title for the properties panel. It is a PageBook that can switch between showing the regular title (the selected entry's label and icon) and an error message if an error has occured.- Parameters:
parent
- The parent composite- Returns:
- The newly created PageBook title
-
createSectionTitle
A convenient method to create CLabel titles (like the ones used in the Preferences dialog in the Eclipse workbench) throughout the dialog.- Parameters:
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- Returns:
- The newly created CLabel for convenience
-
getButton
Returns the Button with the given id; ornull
if none was found. -
getCustomizer
- Returns:
- The customizer that is responsible for handling the various tasks and updating the model.
-
getEntryPage
Returns theEntryPage
for the givenPaletteEntry
. TheEntryPage
is retrieved from the customizer. If the given entry isnull
,null
will be returned. If the customizer returnsnull
for the valid entry, a default page will be created and returned.- Parameters:
entry
- The PaletteEntry whose properties need to be displayed- Returns:
- The EntryPage with the properties of the given PaletteEntry
-
getOutlineActions
Provides access to the actions that are used to manipulate the model. The actions will be created, if they haven't been yet.- Returns:
- the list of
PaletteCustomizationAction
s - See Also:
-
getPaletteRoot
Provides sub-classes with access to the PaletteRoot- Returns:
- the palette root
-
getSelectedPaletteEntry
- Returns:
- The PaletteEntry that is currently selected in the Outline Tree;
null
if none is selected
-
getSelectedTreeItem
- Returns:
- The TreeItem that is currently selected in the Outline Tree;
null
if none is selected
-
getWidget
TheWidget
s that were created with a unique ID and added to this class' internal map can be retrieved through this method.- Parameters:
id
- The unique ID of the Widget that you wish to retrieve- Returns:
- The Widget, if one with the given id exists;
null
otherwise
-
handleApplyPressed
protected final void handleApplyPressed()This method is invoked when the Apply button is pressedIMPORTANT: 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()
. Overridesave()
andrevertToSaved()
to add to what needs to be done when saving or cancelling. -
handleDelete
protected void handleDelete()This method is called when the "Delete" action is run (either through the context menu or the toolbar). It deletes the selected palette entry. -
handleMoveDown
protected void handleMoveDown()This method is called when the "Move Down" action is run (either through the context menu or the toolbar). It moves the selected palette entry down. -
handleMoveUp
protected void handleMoveUp()This method is called when the "Move Up" action is run (either through the context menu or the toolbar). It moves the selected entry up. -
handleOutlineSelectionChanged
protected void handleOutlineSelectionChanged()This is the method that is called everytime the selection in the outline (treeviewer) changes. -
revertToSaved
protected void revertToSaved()This method is invoked when the changes made since the last save need to be cancelled. -
save
protected void save()This method is invoked when the changes made since the last save need to be saved. -
setActiveEntry
This methods sets the active entry. Based on the selection, this method will appropriately enable or disable the ToolBar items, will change the CLabel heading of the propreties panel, and will show the properties of the selected item in the properties panel.- Parameters:
entry
- The new active entry, i.e., the new selected entry (it can benull
)
-
setActiveEntryPage
Sets the given EntryPage as the top page in the PageBook that shows the properties of the item selected in the Outline. If the given EntryPage is null, nothing will be shown.- Parameters:
page
- The EntryPage to be shown
-
setDefaultSelection
Sets the given PaletteEntry as the one to be selected when the dialog opens. It is discarded when the dialog is closed.- Parameters:
entry
- The PaletteEntry that should be selected when the dialog is opened
-
showProblem
This method should be invoked by EntryPages when there is an error. It will show the given error in the title of the properties panel. OK and Apply buttons will be disabled. Selecting some other entry in the outline tree will not be allowed until the error is fixed.- Specified by:
showProblem
in interfaceEntryPageContainer
- Parameters:
error
- A description of the problem. Should be as brief as possible.- See Also:
-
updateActions
protected void updateActions()Updates the actions created increateOutlineActions()
, enabling or disabling them as necessary.
-