Package docking
Class DialogComponentProvider
java.lang.Object
docking.DialogComponentProvider
- All Implemented Interfaces:
ActionContextProvider,StatusListener,TaskListener
- Direct Known Subclasses:
AboutDialog,AbstractBSimSearchDialog,AbstractDataTreeDialog,AbstractNumberInputDialog,AbstractPathsDialog,ActionChooserDialog,AskAddrDialog,AskDialog,BatchImportDialog,BSimApplyResultsDisplayDialog,BSimSearchInfoDisplayDialog,BSimSearchResultsFilterDialog,BSimServerDialog,ChangedFilesDialog,CheckoutDialog,CheckoutDialog,CheckoutsDialog,ChooseColumnsDialog,ColumnFilterArchiveDialog,ComponentInfoDialog,CreateBsimServerInfoDialog,CreateThemeDialog,DataTypeSelectionDialog,EditFieldNameDialog,ExportThemeDialog,ExtensionTableProvider,FilterOptionsEditorDialog,FindCheckoutsDialog,ImageDialogProvider,ImporterDialog,ImporterLanguageDialog,InputDialog,InputWithChoicesDialog,KeyEntryDialog,ListSelectionDialog,ListSelectionTableDialog,MultiActionDialog,MultiChoiceSelectionDialog,MultiLineInputDialog,MultiLineMessageDialog,MultipleOptionsDialog,NumberRangeInputDialog,ObjectChooserDialog,OptionDialog,OptionsDialog,PasswordChangeDialog,PasswordDialog,PickToolDialog,PluginInstallerDialog,ProjectInfoDialog,ReadTextDialog,ReusableDialogComponentProvider,SaveDataDialog,SaveToolConfigDialog,SearchAndReplaceDialog,SelectChangedToolDialog,SelectColumnsDialog,SelectedFunctionsTableDialog,SelectFromListDialog,SelectLanguageDialog,SetEquateDialog,SettingsDialog,TableChooserDialog,TableChooserDialog,TableSelectionDialog,TaskDialog,ThemeChooserDialog,ThemeEditorDialog,UndoActionDialog,UserAgreementDialog,ValuesMapDialog,VersionControlDialog,VersionHistoryDialog,WizardDialog
public class DialogComponentProvider
extends Object
implements ActionContextProvider, StatusListener, TaskListener
Base class used for creating dialogs in Ghidra. Subclass this to create a dialog provider that has
all the gui elements to appear in the dialog, then use tool.showDialog() to display your dialog.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDialogComponentProvider(String title) Constructor for a DialogComponentProvider that will be modal and will include a status line and a button panel.protectedDialogComponentProvider(String title, boolean modal) Constructor for a DialogComponentProvider that will include a status line and a button panel.protectedDialogComponentProvider(String title, boolean modal, boolean includeStatus, boolean includeButtons, boolean canRunTasks) Constructs a new DialogComponentProvider. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(DockingActionIf action) Add an action to this dialog.protected voidAdds an "Apply" button to the button panel.protected voidAdds a button to the button panel at the bottom of the dialog.protected voidAdds a "Cancel" button to the button panel.protected voidAdds a "Dismiss" button to the button panel.protected voidAdds an "OK" button to the button panel.protected voidaddWorkPanel(JComponent comp) Used by derived classes to add dialog specific gui elementsprotected voidSignals for this dialog to visually draw the user's attention to the status textprotected voidalertMessage(Callback alertFinishedCallback) Signals for this dialog to visually draw the user's attention to the status textprotected voidThe callback method for when the "Apply" button is pressed.protected voidThe callback method for when the "Cancel" button is pressed.protected voidCancel the task that is running.protected voidvoidClears the text from the dialog's status line.voidclose()protected voidstatic voidcreateSharedActions(Tool tool, ToolActions toolActions, String owner) Called by the framework during startup to register actions that are shared throughout the tool.protected voidOverride this method if you want to do something when the dialog is made invisibleprotected voidOverride this method if you want to do something when the dialog is made visibleprotected voidThe callback method for when the "Dismiss" button is pressed.voiddispose()Disposes this dialog.protected voida callback mechanism for children to do workprotected voidThe callback method for when the escape key is pressed.protected voidexecuteProgressTask(Task task, int delay) Execute a non-modal task that has progress and can be cancelled.getActionContext(MouseEvent event) An optional extension point for subclasses to provider action context for the actions used by this provider.Gets the background color of this component.protected RectangleGets the bound of this dialog component.Returns the default button for the dialog.protected DimensionReturns the component that will receive focus when the dialog is shownprotected ComponentReturns the help location for this dialogintgetId()Returns the initial location for the dialog or null if none was setprotected PointGets the location of this provider on the screen.protected ComponentReturns the preferred size of this component.booleanReturns true if this dialog remembers its location from one invocation to the next.booleanReturns true if this dialog remembers its size from one invocation to the next.protected ColorgetStatusColor(MessageType type) protected JLabelReturns the current status in the dialogs status lineprotected TaskMonitorComponentprotected TaskSchedulerGet the task scheduler for the dialoggetTitle()Returns the title for this componentbooleanReturns true if this dialog uses shared location and size information.voidWill hide the progress panel if it was showing.protected booleanReturns true if the apply button is enabledprotected booleanReturns true if the cancel button is enabledbooleanReturns true if the given action is one that has been registered by this dialog.booleanisModal()Returns true if this component should be displayed in a modal dialogprotected booleanReturns true if the OK button is enabledbooleanbooleanReturns true if this dialog is running a task.booleanbooleanReturns true if this dialog is intended to be shown and hidden relatively quickly.booleanprotected voidSignals to this provider that it needs to updated the enabled state of its managed actions.protected voidThe callback method for when the "OK" button is pressed.voidremoveAction(DockingActionIf action) protected voidremoveButton(JButton button) Remove the given button from the dialogprotected voidprotected voidrepack()voidsetAccessibleDescription(String description) Sets a description of the dialog that will be read by screen readers when the dialog is made visible.protected voidsetApplyEnabled(boolean state) Sets the enablement state of the "Apply" button.protected voidsetApplyToolTip(String tooltip) Sets the Tooltip for the Apply buttonvoidsetBackground(Color color) Sets the background on this component.protected voidsetCancelButtonText(String text) protected voidsetCancelEnabled(boolean state) Sets the enablement state of the "CANCEL" button.protected voidsetCancelToolTip(String tooltip) Sets the Tooltip for the Cancel buttonvoidSets the cursor on the root panel for the dialog component.voidsetDefaultButton(JButton button) Sets the button to make "Default" when the dialog is shown.voidsetDefaultSize(int width, int height) protected voidprotected voidsetDismissToolTip(String tooltip) Sets the Tooltip for the Dismiss buttonvoidsetFocusComponent(Component focusComponent) Sets the component that should be given focus when the dialog is activated.protected voidsetGlassPane(Component component) voidsetHelpLocation(HelpLocation helpLocation) Set the help Location for this dialog.voidsetInitialLocation(int x, int y) Sets the initial location for the dialogvoidsetMinimumSize(int width, int height) voidsetMinimumSize(Dimension minSize) Sets the minimum size of the dialogprotected voidsetOkButtonText(String text) protected voidsetOkEnabled(boolean state) Sets the enablement state of the "OK" button.protected voidsetOkToolTip(String tooltip) Sets the Tooltip for the OK buttonvoidsetPreferredSize(int width, int height) Sets the preferred size of the dialog.voidsetRememberLocation(boolean rememberLocation) Sets this dialog to remember its location from one invocation to the next.voidsetRememberSize(boolean rememberSize) Sets this dialog to remember its size from one invocation to the next.voidsetResizable(boolean resizeable) Sets the resizable property for the corresponding dialog.voidsetStatusJustification(int justification) Sets the horizontal position of the status label.voidsetStatusText(String text) Sets the text in the dialog's status line using the default colorvoidsetStatusText(String message, MessageType type) Sets the text in the dialog's status line using the specified message type to control the color.voidsetStatusText(String message, MessageType type, boolean alert) Set the current status as the specified typevoidSets the title to be displayed in the dialogs title barvoidsetTransient(boolean isTransient) Sets this dialog to be transient (seeisTransient()voidsetUseSharedLocation(boolean useSharedLocation) Specifies whether or not this dialog component should use the same remembered location (and size) no matter which window this dialog is launched from.protected voidshowProgressBar(String localTitle, boolean hasProgress, boolean canCancel, int delay) showTaskMonitorComponent(String localTitle, boolean hasProgress, boolean canCancel) Shows the progress bar for this dialog.protected voidStop the timer if one was started to delay showing the progress bar.voidtaskCancelled(Task task) Notification that the task was canceled; the progress panel is removed.voidtaskCompleted(Task task) Notification that the given task completed so that the progress panel can be removed.voidtoFront()Moves the dialog associated with this provider to the front.toString()voidBlocks the calling thread until the current task has completed; used by JUnit tests.
-
Field Details
-
rootPanel
-
buttonPanel
-
okButton
-
applyButton
-
cancelButton
-
dismissButton
-
-
Constructor Details
-
DialogComponentProvider
Constructor for a DialogComponentProvider that will be modal and will include a status line and a button panel. Its title will be the same as its name.- Parameters:
title- the dialog title.
-
DialogComponentProvider
Constructor for a DialogComponentProvider that will include a status line and a button panel.- Parameters:
title- the title for this dialog.modal- true if this dialog should be modal.
-
DialogComponentProvider
protected DialogComponentProvider(String title, boolean modal, boolean includeStatus, boolean includeButtons, boolean canRunTasks) Constructs a new DialogComponentProvider.- Parameters:
title- the title for this dialog.modal- true if this dialog should be modal.includeStatus- true if this dialog should include a status line.includeButtons- true if this dialog will have a button panel at the bottom.canRunTasks- true means this dialog can execute tasks (executeProgressTask(Task, int)and it will show a progress monitor when doing so.
-
-
Method Details
-
doInitialize
protected void doInitialize()a callback mechanism for children to do work -
isDialogKeyBindingAction
Returns true if the given action is one that has been registered by this dialog.- Parameters:
action- the action- Returns:
- true if the given action is one that has been registered by this dialog
-
getId
public int getId() -
getComponent
-
repack
protected void repack() -
setDialogSize
-
getDialogSize
-
setBackground
Sets the background on this component.- Parameters:
color- The color to set.
-
getBackground
Gets the background color of this component.- Returns:
- The background color of this component.
-
setPreferredSize
public void setPreferredSize(int width, int height) Sets the preferred size of the dialog. Note that if you set the preferred size, the dialog will ignore any natural preferred size of your components.- Parameters:
width- the preferred widthheight- the preferred height;
-
setDefaultSize
public void setDefaultSize(int width, int height) -
getDefaultSize
-
setMinimumSize
public void setMinimumSize(int width, int height) -
setMinimumSize
Sets the minimum size of the dialog- Parameters:
minSize- the min size of the dialog
-
getBounds
Gets the bound of this dialog component. This is relative the parent of this provider.- Returns:
- the bound of this dialog component.
- See Also:
-
getLocationOnScreen
Gets the location of this provider on the screen. CallinggetBounds()provides a relative location. This method provides a location absolute on the screen.- Returns:
- the location of this provider on the screen.
- See Also:
-
getPreferredSize
Returns the preferred size of this component.- Returns:
- the preferred size of this component.
-
setCursor
Sets the cursor on the root panel for the dialog component.- Parameters:
cursor- the cursor to use.
-
addWorkPanel
Used by derived classes to add dialog specific gui elements- Parameters:
comp- the Component containing the derived class's components.
-
removeWorkPanel
protected void removeWorkPanel() -
addButton
Adds a button to the button panel at the bottom of the dialog. Buttons will be added from left to right.Implementation Note: Calling this method will set the given button as the default button on this dialog when:
- No button has yet been added, and
- No default button has been assigned
setDefaultButton(JButton)with the desired default button.- Parameters:
button- the button
-
removeButton
Remove the given button from the dialog- Parameters:
button- the button
-
executeProgressTask
Execute a non-modal task that has progress and can be cancelled.- Parameters:
task- task to execute; a progress bar is displayed next to the status field in this dialog if the task has progress; for indeterminate tasks, a "spinning globe" is displayed to indicate that something is happening.delay- number of milliseconds to delay until progress bar is displayed; a value less than or equal to 0 means to show the progress bar immediately- Throws:
IllegalArgumentException- if the given task is modal
-
clearScheduledTask
protected void clearScheduledTask() -
cancelCurrentTask
protected void cancelCurrentTask()Cancel the task that is running. -
waitForCurrentTask
public void waitForCurrentTask()Blocks the calling thread until the current task has completed; used by JUnit tests. -
isRunningTask
public boolean isRunningTask()Returns true if this dialog is running a task.- Returns:
- true if this dialog is running a task.
-
addOKButton
protected void addOKButton()Adds an "OK" button to the button panel. The protected method okCallback() will be invoked whenever the "OK" button is pressed. -
addCancelButton
protected void addCancelButton()Adds a "Cancel" button to the button panel. The protected method CancelCallback() will be invoked whenever the "Cancel" button is pressed. -
addDismissButton
protected void addDismissButton()Adds a "Dismiss" button to the button panel. The protected method dismissCallback() will be invoked whenever the "Dismiss" button is pressed. -
addApplyButton
protected void addApplyButton()Adds an "Apply" button to the button panel. The protected method applyCallback() will be invoked whenever the "Apply" button is pressed. -
setApplyToolTip
Sets the Tooltip for the Apply button- Parameters:
tooltip- the tooltip
-
setOkButtonText
-
setOkToolTip
Sets the Tooltip for the OK button- Parameters:
tooltip- the tooltip
-
setCancelToolTip
Sets the Tooltip for the Cancel button- Parameters:
tooltip- the tooltip
-
setCancelButtonText
-
setDismissToolTip
Sets the Tooltip for the Dismiss button- Parameters:
tooltip- the tooltip
-
setOkEnabled
protected void setOkEnabled(boolean state) Sets the enablement state of the "OK" button.- Parameters:
state- true to enable the button, false to disable the button.
-
setCancelEnabled
protected void setCancelEnabled(boolean state) Sets the enablement state of the "CANCEL" button.- Parameters:
state- true to enable the button, false to disable the button.
-
setApplyEnabled
protected void setApplyEnabled(boolean state) Sets the enablement state of the "Apply" button.- Parameters:
state- true to enable the button, false to disable the button.
-
isCancelEnabled
protected boolean isCancelEnabled()Returns true if the cancel button is enabled- Returns:
- true if the cancel button is enabled
-
isOKEnabled
protected boolean isOKEnabled()Returns true if the OK button is enabled- Returns:
- true if the OK button is enabled
-
isApplyEnabled
protected boolean isApplyEnabled()Returns true if the apply button is enabled- Returns:
- true if the apply button is enabled
-
setStatusText
Sets the text in the dialog's status line using the default color- Specified by:
setStatusTextin interfaceStatusListener- Parameters:
text- the text to display in the status line
-
setStatusText
Sets the text in the dialog's status line using the specified message type to control the color.- Specified by:
setStatusTextin interfaceStatusListener- Parameters:
message- the messagetype- the message type
-
setStatusText
Description copied from interface:StatusListenerSet the current status as the specified type- Specified by:
setStatusTextin interfaceStatusListener- Parameters:
message- status texttype- status typealert- true to grab the user's attention
-
setAccessibleDescription
Sets a description of the dialog that will be read by screen readers when the dialog is made visible.- Parameters:
description- a description of the dialog
-
alertMessage
protected void alertMessage()Signals for this dialog to visually draw the user's attention to the status text -
alertMessage
Signals for this dialog to visually draw the user's attention to the status text- Parameters:
alertFinishedCallback- this will be called when the alert is finished. This allows clients to perform work, like re-enabling buttons that were disabled before calling this method
-
getStatusColor
-
stopProgressTimer
protected void stopProgressTimer()Stop the timer if one was started to delay showing the progress bar. -
hideTaskMonitorComponent
public void hideTaskMonitorComponent()Will hide the progress panel if it was showing.- See Also:
-
showProgressBar
protected void showProgressBar(String localTitle, boolean hasProgress, boolean canCancel, int delay) -
clearStatusText
public void clearStatusText()Clears the text from the dialog's status line.- Specified by:
clearStatusTextin interfaceStatusListener
-
getStatusText
Returns the current status in the dialogs status line- Returns:
- the status text
-
getStatusLabel
-
getTaskScheduler
Get the task scheduler for the dialog- Returns:
- the task scheduler
-
getTaskMonitorComponent
-
showTaskMonitorComponent
public TaskMonitor showTaskMonitorComponent(String localTitle, boolean hasProgress, boolean canCancel) Shows the progress bar for this dialog.- Parameters:
localTitle- the name of the taskhasProgress- true if the progress bar should show progress; false to be indeterminatecanCancel- true if the task can be cancelled- Returns:
- the
TaskMonitorused by to communicate progress - See Also:
-
applyCallback
protected void applyCallback()The callback method for when the "Apply" button is pressed. -
okCallback
protected void okCallback()The callback method for when the "OK" button is pressed. -
cancelCallback
protected void cancelCallback()The callback method for when the "Cancel" button is pressed. The default behavior is to call setVisible(false) and dispose() on the dialog. -
close
public void close() -
closeDialog
protected void closeDialog() -
dispose
public void dispose()Disposes this dialog. Only call this when the dialog is no longer used. Calling this method will close the dialog if it is open. -
dismissCallback
protected void dismissCallback()The callback method for when the "Dismiss" button is pressed. The default behavior is to call the cancel Callback. -
escapeCallback
protected void escapeCallback()The callback method for when the escape key is pressed. The default behavior is the call setVisible(false) on the dialog. -
isModal
public boolean isModal()Returns true if this component should be displayed in a modal dialog- Returns:
- true if this component should be displayed in a modal dialog
-
setStatusJustification
public void setStatusJustification(int justification) Sets the horizontal position of the status label.- Parameters:
justification- One of the following constants defined inSwingConstants:LEFT,CENTER(the default for image-only labels),RIGHT,
-
taskCancelled
Notification that the task was canceled; the progress panel is removed.- Specified by:
taskCancelledin interfaceTaskListener- Parameters:
task- task that was canceled
-
taskCompleted
Notification that the given task completed so that the progress panel can be removed.- Specified by:
taskCompletedin interfaceTaskListener- Parameters:
task- task that completed
-
setFocusComponent
Sets the component that should be given focus when the dialog is activated.Implementation Note: If the given component is a JButton, then that component will be made the default button.
- Parameters:
focusComponent- the component that should receive default focus.- See Also:
-
getFocusComponent
Returns the component that will receive focus when the dialog is shown- Returns:
- the component
-
setHelpLocation
Set the help Location for this dialog.- Parameters:
helpLocation- the helpLocation for this dialog.
-
getHelpLocation
Returns the help location for this dialog- Returns:
- the help location
-
setDefaultButton
Sets the button to make "Default" when the dialog is shown. If no default button is desired, then passnullas thebuttonvalue.- Parameters:
button- the button to make default enabled.
-
getDefaultButton
Returns the default button for the dialog.- Returns:
- the button
-
setTitle
Sets the title to be displayed in the dialogs title bar- Parameters:
title- the title
-
getGlassPane
-
setGlassPane
-
getTitle
Returns the title for this component- Returns:
- the title
-
toFront
public void toFront()Moves the dialog associated with this provider to the front. -
getParent
-
isVisible
public boolean isVisible() -
isShowing
public boolean isShowing() -
dialogShown
protected void dialogShown()Override this method if you want to do something when the dialog is made visible -
dialogClosed
protected void dialogClosed()Override this method if you want to do something when the dialog is made invisible -
setInitialLocation
public void setInitialLocation(int x, int y) Sets the initial location for the dialog- Parameters:
x- the x coordinatey- the y coordinate
-
getInitialLocation
Returns the initial location for the dialog or null if none was set- Returns:
- the point
-
setResizable
public void setResizable(boolean resizeable) Sets the resizable property for the corresponding dialog.- Parameters:
resizeable- if false the user will not be able to resize the dialog.
-
isResizeable
public boolean isResizeable() -
getActionContext
An optional extension point for subclasses to provider action context for the actions used by this provider.- Specified by:
getActionContextin interfaceActionContextProvider- Parameters:
event- The mouse event used (may be null) to generate a popup menu
-
notifyContextChanged
protected void notifyContextChanged()Signals to this provider that it needs to updated the enabled state of its managed actions. -
getActions
-
addAction
Add an action to this dialog. Only actions with icons are added to the toolbar. Note, if you add an action to this dialog, do not also add the action to the tool, as this dialog will do that for you.- Parameters:
action- the action
-
removeAction
-
setRememberLocation
public void setRememberLocation(boolean rememberLocation) Sets this dialog to remember its location from one invocation to the next. The default is to remember location.- Parameters:
rememberLocation- true to remember, false otherwise.
-
getRememberLocation
public boolean getRememberLocation()Returns true if this dialog remembers its location from one invocation to the next.- Returns:
- true if this dialog remembers its location from one invocation to the next.
-
setRememberSize
public void setRememberSize(boolean rememberSize) Sets this dialog to remember its size from one invocation to the next. The default is to remember size.- Parameters:
rememberSize- true to remember, false otherwise.
-
getRememberSize
public boolean getRememberSize()Returns true if this dialog remembers its size from one invocation to the next.- Returns:
- true if this dialog remembers its size from one invocation to the next.
-
isTransient
public boolean isTransient()Returns true if this dialog is intended to be shown and hidden relatively quickly. This is used to determine if this dialog should be allowed to parent other components. The default is false.- Returns:
- true if this dialog is transient
-
setTransient
public void setTransient(boolean isTransient) Sets this dialog to be transient (seeisTransient()- Parameters:
isTransient- true for transient; false is the default
-
toString