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 SummaryNested classes/interfaces inherited from class org.eclipse.jface.window.WindowWindow.IExceptionHandler
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final intThe unique ID for the Apply Button.protected static final intSub-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.DialogblockedHandler, 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, ELLIPSISFields inherited from class org.eclipse.jface.window.WindowCANCEL, OK, resizeHasOccurred
- 
Constructor SummaryConstructorsConstructorDescriptionPaletteCustomizerDialog(Shell shell, PaletteCustomizer customizer, PaletteRoot root) Constructs a new customizer dialog.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidbuttonPressed(int buttonId) This method will be invoked whenever anyButtoncreated usingcreateButton(Composite, int, String, int, ImageDescriptor)orDialog.createButton(Composite, int, String, boolean)is selected.voidThis method should be invoked by EntryPages when an error that they had earlier reported (usingshowProblem(String)) is fixed.booleanclose()NOTE: This dialog can be re-opened.protected voidconfigureShell(Shell newShell) protected ButtoncreateButton(Composite parent, int id, String label, int stylebits, ImageDescriptor descriptor) This method should not be used to create buttons for the button bar.protected voidcreateButtonsForButtonBar(Composite parent) Creates the OK, Cancel and Apply buttonsprotected ControlcreateDialogArea(Composite parent) The dialog area contains the following: Outline (createOutline(Composite)) Properties Panel (createPropertiesPanel(Composite))protected ControlcreateOutline(Composite container) Creates the outline part of the dialog.protected List<PaletteCustomizationAction> Creates the actions that manipulate the palette model.protected MenuUses aMenuManagerto create the context menu for the outline.protected ControlcreateOutlineToolBar(Composite parent) Uses a ToolBarManager to create the ToolBar in the outline part of the dialog.protected TreeViewercreateOutlineTreeViewer(Composite composite) Creates the TreeViewer that is the outline of the model.protected ControlcreatePropertiesPanel(Composite container) Creates the part of the dialog where the properties of the element selected in the outline will be displayed.protected PageBookcreatePropertiesPanelTitle(Composite parent) Creates the title for the properties panel.protected CLabelcreateSectionTitle(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 ButtongetButton(int id) Returns the Button with the given id; ornullif none was found.protected PaletteCustomizerprotected EntryPagegetEntryPage(PaletteEntry entry) Returns theEntryPagefor the givenPaletteEntry.protected final List<PaletteCustomizationAction> Provides access to the actions that are used to manipulate the model.protected PaletteRootProvides sub-classes with access to the PaletteRootprotected PaletteEntryprotected TreeItemprotected WidgetgetWidget(int id) TheWidgets that were created with a unique ID and added to this class' internal map can be retrieved through this method.protected final voidThis method is invoked when the Apply button is pressedprotected voidThis method is called when the "Delete" action is run (either through the context menu or the toolbar).protected voidThis method is called when the "Move Down" action is run (either through the context menu or the toolbar).protected voidThis method is called when the "Move Up" action is run (either through the context menu or the toolbar).protected voidThis is the method that is called everytime the selection in the outline (treeviewer) changes.protected voidThis method is invoked when the changes made since the last save need to be cancelled.protected voidsave()This method is invoked when the changes made since the last save need to be saved.protected voidsetActiveEntry(PaletteEntry entry) This methods sets the active entry.protected voidsetActiveEntryPage(EntryPage page) Sets the given EntryPage as the top page in the PageBook that shows the properties of the item selected in the Outline.voidsetDefaultSelection(PaletteEntry entry) Sets the given PaletteEntry as the one to be selected when the dialog opens.voidshowProblem(String error) This method should be invoked by EntryPages when there is an error.protected voidUpdates the actions created increateOutlineActions(), enabling or disabling them as necessary.Methods inherited from class org.eclipse.jface.dialogs.DialogapplyDialogFont, 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, shortenTextMethods inherited from class org.eclipse.jface.window.WindowcanHandleShellCloseEvent, 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_IDprotected 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_IDprotected 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- 
PaletteCustomizerDialogConstructs a new customizer dialog.- Parameters:
- shell- the parent Shell
- customizer- the customizer
- root- the palette root
 
 
- 
- 
Method Details- 
buttonPressedprotected void buttonPressed(int buttonId) This method will be invoked whenever anyButtoncreated usingcreateButton(Composite, int, String, int, ImageDescriptor)orDialog.createButton(Composite, int, String, boolean)is selected.- Overrides:
- buttonPressedin class- Dialog
- See Also:
 
- 
clearProblempublic 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:
- clearProblemin interface- EntryPageContainer
- See Also:
 
- 
closepublic boolean close()NOTE: This dialog can be re-opened. 
- 
configureShell- Overrides:
- configureShellin class- Window
- See Also:
 
- 
createButtonprotected 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 parentCompositemust 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 anullimage 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 created
- id- The button's unique ID
- label- The button's text
- stylebits- The style bits for creating the button (eg.,- SWT.PUSHor- SWT.CHECK)
- descriptor- The ImageDescriptor from which the image/icon for this button should be created
- Returns:
- The newly created button for convenience
 
- 
createButtonsForButtonBarCreates the OK, Cancel and Apply buttons- Overrides:
- createButtonsForButtonBarin class- Dialog
- See Also:
 
- 
createDialogAreaThe 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:
- createDialogAreain class- Dialog
- See Also:
 
- Outline (
- 
createOutlineCreates 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 (
- 
createOutlineActionsCreates 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 PaletteCustomizationActions.- Returns:
- A List of PaletteCustomizationActions
 
- 
createOutlineContextMenuUses aMenuManagerto create the context menu for the outline. TheIActionsused to create the context menu are those created increateOutlineActions().- Returns:
- The newly created Menu
 
- 
createOutlineToolBarUses 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
 
- 
createOutlineTreeViewerCreates 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
 
- 
createPropertiesPanelCreates 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
 
- 
createPropertiesPanelTitleCreates 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
 
- 
createSectionTitleA 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
 
- 
getButtonReturns the Button with the given id; ornullif none was found.
- 
getCustomizer- Returns:
- The customizer that is responsible for handling the various tasks and updating the model.
 
- 
getEntryPageReturns theEntryPagefor the givenPaletteEntry. TheEntryPageis retrieved from the customizer. If the given entry isnull,nullwill be returned. If the customizer returnsnullfor 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
 
- 
getOutlineActionsProvides 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 PaletteCustomizationActions
- See Also:
 
- 
getPaletteRootProvides sub-classes with access to the PaletteRoot- Returns:
- the palette root
 
- 
getSelectedPaletteEntry- Returns:
- The PaletteEntry that is currently selected in the Outline Tree;
         nullif none is selected
 
- 
getSelectedTreeItem- Returns:
- The TreeItem that is currently selected in the Outline Tree;
         nullif none is selected
 
- 
getWidgetTheWidgets 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; nullotherwise
 
- 
handleApplyPressedprotected 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.
- 
handleDeleteprotected 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.
- 
handleMoveDownprotected 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.
- 
handleMoveUpprotected 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.
- 
handleOutlineSelectionChangedprotected void handleOutlineSelectionChanged()This is the method that is called everytime the selection in the outline (treeviewer) changes.
- 
revertToSavedprotected void revertToSaved()This method is invoked when the changes made since the last save need to be cancelled.
- 
saveprotected void save()This method is invoked when the changes made since the last save need to be saved.
- 
setActiveEntryThis 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 be- null)
 
- 
setActiveEntryPageSets 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
 
- 
setDefaultSelectionSets 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
 
- 
showProblemThis 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:
- showProblemin interface- EntryPageContainer
- Parameters:
- error- A description of the problem. Should be as brief as possible.
- See Also:
 
- 
updateActionsprotected void updateActions()Updates the actions created increateOutlineActions(), enabling or disabling them as necessary.
 
-