public abstract class CdmFilteredItemsSelectionDialog
extends org.eclipse.ui.dialogs.SelectionStatusDialog
Modifier and Type | Class and Description |
---|---|
protected class |
CdmFilteredItemsSelectionDialog.AbstractContentProvider
An interface to content providers for
FilterItemsSelectionDialog . |
protected class |
CdmFilteredItemsSelectionDialog.ItemsFilter
Filters elements using SearchPattern by comparing the names of items with
the filter pattern.
|
protected class |
CdmFilteredItemsSelectionDialog.ItemsListSeparator
Used in ItemsListContentProvider, separates history and non-history
items.
|
protected static class |
CdmFilteredItemsSelectionDialog.SelectionHistory
History stores a list of key, object pairs.
|
Modifier and Type | Field and Description |
---|---|
static int |
CARET_BEGINNING
Pattern input field selection where caret is at the beginning (used only
for initial pattern).
|
static int |
FULL_SELECTION
Represents a full selection in the pattern input field (used only for
initial pattern).
|
static int |
NONE
Represents an empty selection in the pattern input field (used only for
initial pattern).
|
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
Constructor and Description |
---|
CdmFilteredItemsSelectionDialog(org.eclipse.swt.widgets.Shell shell)
Creates a new instance of the class.
|
CdmFilteredItemsSelectionDialog(org.eclipse.swt.widgets.Shell shell,
boolean multi)
Creates a new instance of the class.
|
Modifier and Type | Method and Description |
---|---|
protected void |
accessedHistoryItem(java.lang.Object item)
Adds item to history.
|
protected void |
addListFilter(org.eclipse.jface.viewers.ViewerFilter filter)
Adds viewer filter to the dialog items list.
|
protected void |
applyFilter()
Applies the filter created by
createFilter() method to the
items list. |
boolean |
close() |
protected void |
computeResult() |
void |
create() |
protected org.eclipse.swt.widgets.Control |
createDialogArea(org.eclipse.swt.widgets.Composite parent) |
protected abstract org.eclipse.swt.widgets.Control |
createExtendedContentArea(org.eclipse.swt.widgets.Composite parent)
Creates an extra content area, which will be located above the details.
|
protected abstract CdmFilteredItemsSelectionDialog.ItemsFilter |
createFilter()
Creates an instance of a filter.
|
protected abstract void |
fillContentProvider(CdmFilteredItemsSelectionDialog.AbstractContentProvider contentProvider,
CdmFilteredItemsSelectionDialog.ItemsFilter itemsFilter,
org.eclipse.core.runtime.IProgressMonitor progressMonitor)
Fills the content provider with matching items.
|
protected void |
fillContextMenu(org.eclipse.jface.action.IMenuManager menuManager)
Hook that allows to add actions to the context menu.
|
protected void |
fillViewMenu(org.eclipse.jface.action.IMenuManager menuManager)
Fills the menu of the dialog.
|
java.lang.Object[] |
getCurrentSelection() |
protected org.eclipse.jface.dialogs.IDialogSettings |
getDialogBoundsSettings() |
protected abstract org.eclipse.jface.dialogs.IDialogSettings |
getDialogSettings()
Returns the dialog settings.
|
abstract java.lang.String |
getElementName(java.lang.Object item)
Returns name for then given object.
|
protected java.lang.String |
getInitialPattern()
Gets initial pattern.
|
protected abstract java.util.Comparator |
getItemsComparator()
Returns comparator to sort items inside content provider.
|
org.eclipse.jface.viewers.TableViewer |
getList() |
org.eclipse.swt.widgets.Control |
getPatternControl()
Get the control where the search pattern is entered.
|
protected org.eclipse.jface.viewers.StructuredSelection |
getSelectedItems()
Returns the current selection.
|
protected CdmFilteredItemsSelectionDialog.SelectionHistory |
getSelectionHistory()
Returns the history of selected elements.
|
protected void |
handleDoubleClick()
This method is a hook for subclasses to override default dialog behavior.
|
protected void |
handleSelected(org.eclipse.jface.viewers.StructuredSelection selection)
Handle selection in the items list by updating labels of selected and
unselected items and refresh the details field using the selection.
|
protected abstract void |
initModel()
CDM IMPLEMENTATION
we have to call the initModel() method in the applyFilter method, so we had to add this abstract method (moved from AbstractFilteredCdmResourceSelectionDialog)
|
boolean |
isDuplicateElement(java.lang.Object item)
Indicates whether the given item is a duplicate.
|
boolean |
isHistoryElement(java.lang.Object item)
Indicates whether the given item is a history item.
|
protected void |
okPressed() |
void |
refresh()
Refreshes the dialog - has to be called in UI thread.
|
void |
reloadCache(boolean checkDuplicates,
org.eclipse.core.runtime.IProgressMonitor monitor)
Notifies the content provider - fires filtering of content provider
elements.
|
protected java.lang.Object |
removeHistoryItem(java.lang.Object item)
Removes an item from history.
|
protected void |
restoreDialog(org.eclipse.jface.dialogs.IDialogSettings settings)
Restores dialog using persisted settings.
|
void |
scheduleProgressMessageRefresh()
Schedules progress message refresh.
|
void |
scheduleRefresh()
Schedule refresh job.
|
void |
setCurrentSelection(java.lang.Object[] currentSelection) |
void |
setDetailsLabelProvider(org.eclipse.jface.viewers.ILabelProvider detailsLabelProvider)
Sets label provider for the details field.
|
void |
setInitialPattern(java.lang.String text)
Sets the initial pattern used by the filter.
|
void |
setInitialPattern(java.lang.String text,
int selectionMode)
Sets the initial pattern used by the filter.
|
void |
setList(org.eclipse.jface.viewers.TableViewer list) |
void |
setListLabelProvider(org.eclipse.jface.viewers.ILabelProvider listLabelProvider)
Sets a new label provider for items in the list.
|
void |
setListSelectionLabelDecorator(org.eclipse.jface.viewers.ILabelDecorator listSelectionLabelDecorator)
Sets the label decorator for selected items in the list.
|
protected void |
setSelectionHistory(CdmFilteredItemsSelectionDialog.SelectionHistory selectionHistory)
Sets new history.
|
void |
setSeparatorLabel(java.lang.String separatorLabel)
Sets separator label
|
protected static boolean |
showColoredLabels() |
protected void |
storeDialog(org.eclipse.jface.dialogs.IDialogSettings settings)
Stores dialog settings.
|
void |
updateProgressLabel()
Deprecated.
|
protected void |
updateStatus(org.eclipse.core.runtime.IStatus status) |
protected abstract org.eclipse.core.runtime.IStatus |
validateItem(java.lang.Object item)
Validates the item.
|
configureShell, createButtonBar, getFirstResult, setImage, setResult, setStatusLineAboveButtons, updateButtonsEnableState
createButtonsForButtonBar, createMessageArea, getDialogBoundsStrategy, getInitialElementSelections, getInitialSelections, getMessage, getOkButton, getResult, isResizable, setDialogBoundsSettings, setInitialElementSelections, setInitialSelections, setMessage, setResult, setSelectionResult, setTitle
closeTray, createHelpControl, getLayout, getTray, handleShellCloseEvent, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailable
applyDialogFont, buttonPressed, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, createButton, createContents, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
public static final int NONE
public static final int CARET_BEGINNING
public static final int FULL_SELECTION
public CdmFilteredItemsSelectionDialog(org.eclipse.swt.widgets.Shell shell, boolean multi)
shell
- shell to parent the dialog onmulti
- indicates whether dialog allows to select more than one
position in its list of itemspublic CdmFilteredItemsSelectionDialog(org.eclipse.swt.widgets.Shell shell)
shell
- shell to parent the dialog onprotected void addListFilter(org.eclipse.jface.viewers.ViewerFilter filter)
filter
- the new filterpublic void setListLabelProvider(org.eclipse.jface.viewers.ILabelProvider listLabelProvider)
.IStyledLabelProvider
, the style text labels provided by it will be used
provided that the corresponding preference is set.listLabelProvider
- the label provider for items in the listIWorkbenchPreferenceConstants.USE_COLORED_LABELS
public void setListSelectionLabelDecorator(org.eclipse.jface.viewers.ILabelDecorator listSelectionLabelDecorator)
listSelectionLabelDecorator
- the label decorator for selected items in the listpublic void setDetailsLabelProvider(org.eclipse.jface.viewers.ILabelProvider detailsLabelProvider)
ILabelProvider.getImage(Object)
and
ILabelProvider.getText(Object)
is the selected object, for
multiple selection a String
with amount of selected items is the
element.detailsLabelProvider
- the label provider for the details fieldgetSelectedItems() can be used to retrieve
selected items and get the items count.
public void create()
create
in class org.eclipse.ui.dialogs.SelectionStatusDialog
protected void restoreDialog(org.eclipse.jface.dialogs.IDialogSettings settings)
settings
- settings used to restore dialogpublic boolean close()
close
in class org.eclipse.jface.dialogs.Dialog
protected void storeDialog(org.eclipse.jface.dialogs.IDialogSettings settings)
settings
- settings used to store dialogprotected void fillViewMenu(org.eclipse.jface.action.IMenuManager menuManager)
menuManager
- the menu managerprotected void fillContextMenu(org.eclipse.jface.action.IMenuManager menuManager)
Subclasses may extend in order to add other actions.
menuManager
- the context menu managerprotected abstract org.eclipse.swt.widgets.Control createExtendedContentArea(org.eclipse.swt.widgets.Composite parent)
parent
- parent to create the dialog widgets inprotected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
createDialogArea
in class org.eclipse.jface.dialogs.Dialog
protected void handleDoubleClick()
handleDoubleClick()
method handles double clicks on
the list of filtered elements.
Current implementation makes double-clicking on the list do the same as
pressing OK
button on the dialog.
protected void handleSelected(org.eclipse.jface.viewers.StructuredSelection selection)
selection
- the new selectionprotected org.eclipse.jface.dialogs.IDialogSettings getDialogBoundsSettings()
getDialogBoundsSettings
in class org.eclipse.ui.dialogs.SelectionDialog
protected abstract org.eclipse.jface.dialogs.IDialogSettings getDialogSettings()
public void refresh()
@Deprecated public void updateProgressLabel()
public void reloadCache(boolean checkDuplicates, org.eclipse.core.runtime.IProgressMonitor monitor)
This is a long running operation and should be called in a job.
checkDuplicates
- true
if data concerning elements duplication
should be computed - it takes much more time than the standard
filteringmonitor
- a progress monitor or null
if no monitor is
availablepublic void scheduleRefresh()
public void scheduleProgressMessageRefresh()
protected void computeResult()
computeResult
in class org.eclipse.ui.dialogs.SelectionStatusDialog
protected void updateStatus(org.eclipse.core.runtime.IStatus status)
updateStatus
in class org.eclipse.ui.dialogs.SelectionStatusDialog
protected void okPressed()
okPressed
in class org.eclipse.ui.dialogs.SelectionStatusDialog
public void setInitialPattern(java.lang.String text)
text
- initial pattern for the filterFilteredItemsSelectionDialog.FULL_SELECTION
public void setInitialPattern(java.lang.String text, int selectionMode)
selectionMode
is used
to choose selection type for the input field.text
- initial pattern for the filterselectionMode
- one of: FilteredItemsSelectionDialog.NONE
,
FilteredItemsSelectionDialog.CARET_BEGINNING
,
FilteredItemsSelectionDialog.FULL_SELECTION
protected java.lang.String getInitialPattern()
null
if initial pattern is not
setprotected org.eclipse.jface.viewers.StructuredSelection getSelectedItems()
protected abstract org.eclipse.core.runtime.IStatus validateItem(java.lang.Object item)
item
- an item to be checkedprotected abstract CdmFilteredItemsSelectionDialog.ItemsFilter createFilter()
null
,
no filtering will be applied then, causing no item to be shown in
the list.protected void applyFilter()
createFilter()
method to the
items list. When new filter is different than previous one it will cause
refiltering.protected abstract java.util.Comparator getItemsComparator()
compare(java.lang.Object, java.lang.Object)
are going to
be the same type as the one used in the content provider.protected abstract void fillContentProvider(CdmFilteredItemsSelectionDialog.AbstractContentProvider contentProvider, CdmFilteredItemsSelectionDialog.ItemsFilter itemsFilter, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws org.eclipse.core.runtime.CoreException
contentProvider
- collector to add items to.
FilteredItemsSelectionDialog.AbstractContentProvider#add(Object, FilteredItemsSelectionDialog.ItemsFilter)
only adds items that pass the given itemsFilter
.itemsFilter
- the items filterprogressMonitor
- must be used to report search progress. The state of this
progress monitor reflects the state of the filtering process.org.eclipse.core.runtime.CoreException
protected java.lang.Object removeHistoryItem(java.lang.Object item)
item
- an item to removeprotected void accessedHistoryItem(java.lang.Object item)
item
- the item to be addedprotected CdmFilteredItemsSelectionDialog.SelectionHistory getSelectionHistory()
null
if it is not
setprotected void setSelectionHistory(CdmFilteredItemsSelectionDialog.SelectionHistory selectionHistory)
selectionHistory
- the historypublic boolean isHistoryElement(java.lang.Object item)
item
- the item to be investigatedtrue
if the given item exists in history,
false
otherwisepublic boolean isDuplicateElement(java.lang.Object item)
item
- the item to be investigatedtrue
if the item is duplicate, false
otherwisepublic void setSeparatorLabel(java.lang.String separatorLabel)
separatorLabel
- the label showed on separatorpublic abstract java.lang.String getElementName(java.lang.Object item)
item
- an object from the content provider. Subclasses should pay
attention to the passed argument. They should either only pass
objects of a known type (one used in content provider) or make
sure that passed parameter is the expected one (by type
checking like instanceof
inside the method).protected static boolean showColoredLabels()
public org.eclipse.swt.widgets.Control getPatternControl()
CdmFilteredItemsSelectionDialog.ItemsFilter
. This control should only be
accessed for listeners that wish to handle events that do not affect
filtering such as custom traversal.null
if the pattern control has not
been created.protected abstract void initModel()
initModel
public java.lang.Object[] getCurrentSelection()
public void setCurrentSelection(java.lang.Object[] currentSelection)
public org.eclipse.jface.viewers.TableViewer getList()
public void setList(org.eclipse.jface.viewers.TableViewer list)
Copyright © 2007-2018. All Rights Reserved.