Revision 8d5594ee
Added by Katja Luther over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/CdmFilteredItemsSelectionDialog.java | ||
---|---|---|
524 | 524 |
public void keyTraversed(TraverseEvent e) { |
525 | 525 |
if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { |
526 | 526 |
e.detail = SWT.TRAVERSE_NONE; |
527 |
list.getTable().setFocus();
|
|
527 |
getList().getTable().setFocus();
|
|
528 | 528 |
} |
529 | 529 |
} |
530 | 530 |
}); |
... | ... | |
612 | 612 |
* @since 3.5 |
613 | 613 |
*/ |
614 | 614 |
protected void fillContextMenu(IMenuManager menuManager) { |
615 |
List selectedElements= ((StructuredSelection)list.getSelection()).toList();
|
|
615 |
List selectedElements= ((StructuredSelection)getList().getSelection()).toList();
|
|
616 | 616 |
|
617 | 617 |
Object item= null; |
618 | 618 |
|
... | ... | |
645 | 645 |
} |
646 | 646 |
}); |
647 | 647 |
|
648 |
final Table table = list.getTable();
|
|
648 |
final Table table = getList().getTable();
|
|
649 | 649 |
Menu menu= contextMenuManager.createContextMenu(table); |
650 | 650 |
table.setMenu(menu); |
651 | 651 |
} |
... | ... | |
693 | 693 |
|
694 | 694 |
final Label listLabel = createLabels(content); |
695 | 695 |
|
696 |
list = new TableViewer(content, (multi ? SWT.MULTI : SWT.SINGLE)
|
|
697 |
| SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL); |
|
698 |
list.getTable().getAccessible().addAccessibleListener(
|
|
696 |
setList(new TableViewer(content, (multi ? SWT.MULTI : SWT.SINGLE)
|
|
697 |
| SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
|
|
698 |
getList().getTable().getAccessible().addAccessibleListener(
|
|
699 | 699 |
new AccessibleAdapter() { |
700 | 700 |
@Override |
701 | 701 |
public void getName(AccessibleEvent e) { |
... | ... | |
705 | 705 |
} |
706 | 706 |
} |
707 | 707 |
}); |
708 |
list.setContentProvider(contentProvider);
|
|
709 |
list.setLabelProvider(getItemsListLabelProvider());
|
|
710 |
list.setInput(new Object[0]);
|
|
711 |
list.setItemCount(contentProvider.getNumberOfElements());
|
|
708 |
getList().setContentProvider(contentProvider);
|
|
709 |
getList().setLabelProvider(getItemsListLabelProvider());
|
|
710 |
getList().setInput(new Object[0]);
|
|
711 |
getList().setItemCount(contentProvider.getNumberOfElements());
|
|
712 | 712 |
gd = new GridData(GridData.FILL_BOTH); |
713 |
applyDialogFont(list.getTable());
|
|
714 |
gd.heightHint= list.getTable().getItemHeight() * 15;
|
|
715 |
list.getTable().setLayoutData(gd);
|
|
713 |
applyDialogFont(getList().getTable());
|
|
714 |
gd.heightHint= getList().getTable().getItemHeight() * 15;
|
|
715 |
getList().getTable().setLayoutData(gd);
|
|
716 | 716 |
|
717 | 717 |
createPopupMenu(); |
718 | 718 |
|
... | ... | |
727 | 727 |
@Override |
728 | 728 |
public void keyPressed(KeyEvent e) { |
729 | 729 |
if (e.keyCode == SWT.ARROW_DOWN) { |
730 |
if (list.getTable().getItemCount() > 0) {
|
|
731 |
list.getTable().setFocus();
|
|
730 |
if (getList().getTable().getItemCount() > 0) {
|
|
731 |
getList().getTable().setFocus();
|
|
732 | 732 |
} |
733 | 733 |
} |
734 | 734 |
} |
735 | 735 |
}); |
736 | 736 |
|
737 |
list.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
737 |
getList().addSelectionChangedListener(new ISelectionChangedListener() {
|
|
738 | 738 |
@Override |
739 | 739 |
public void selectionChanged(SelectionChangedEvent event) { |
740 | 740 |
StructuredSelection selection = (StructuredSelection) event |
... | ... | |
743 | 743 |
} |
744 | 744 |
}); |
745 | 745 |
|
746 |
list.addDoubleClickListener(new IDoubleClickListener() {
|
|
746 |
getList().addDoubleClickListener(new IDoubleClickListener() {
|
|
747 | 747 |
@Override |
748 | 748 |
public void doubleClick(DoubleClickEvent event) { |
749 | 749 |
handleDoubleClick(); |
750 | 750 |
} |
751 | 751 |
}); |
752 | 752 |
|
753 |
list.getTable().addKeyListener(new KeyAdapter() {
|
|
753 |
getList().getTable().addKeyListener(new KeyAdapter() {
|
|
754 | 754 |
@Override |
755 | 755 |
public void keyPressed(KeyEvent e) { |
756 | 756 |
|
757 | 757 |
if (e.keyCode == SWT.DEL) { |
758 | 758 |
|
759 |
List selectedElements = ((StructuredSelection) list
|
|
759 |
List selectedElements = ((StructuredSelection) getList()
|
|
760 | 760 |
.getSelection()).toList(); |
761 | 761 |
|
762 | 762 |
Object item = null; |
... | ... | |
779 | 779 |
|
780 | 780 |
if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.SHIFT) != 0 |
781 | 781 |
&& (e.stateMask & SWT.CTRL) != 0) { |
782 |
StructuredSelection selection = (StructuredSelection) list
|
|
782 |
StructuredSelection selection = (StructuredSelection) getList()
|
|
783 | 783 |
.getSelection(); |
784 | 784 |
|
785 | 785 |
if (selection.size() == 1) { |
786 | 786 |
Object element = selection.getFirstElement(); |
787 |
if (element.equals(list.getElementAt(0))) {
|
|
787 |
if (element.equals(getList().getElementAt(0))) {
|
|
788 | 788 |
pattern.setFocus(); |
789 | 789 |
} |
790 |
if (list.getElementAt(list.getTable()
|
|
790 |
if (getList().getElementAt(getList().getTable()
|
|
791 | 791 |
.getSelectionIndex() - 1) instanceof ItemsListSeparator) { |
792 |
list.getTable().setSelection(
|
|
793 |
list.getTable().getSelectionIndex() - 1);
|
|
792 |
getList().getTable().setSelection(
|
|
793 |
getList().getTable().getSelectionIndex() - 1);
|
|
794 | 794 |
} |
795 |
list.getTable().notifyListeners(SWT.Selection,
|
|
795 |
getList().getTable().notifyListeners(SWT.Selection,
|
|
796 | 796 |
new Event()); |
797 | 797 |
|
798 | 798 |
} |
... | ... | |
802 | 802 |
&& (e.stateMask & SWT.SHIFT) != 0 |
803 | 803 |
&& (e.stateMask & SWT.CTRL) != 0) { |
804 | 804 |
|
805 |
if (list
|
|
806 |
.getElementAt(list.getTable().getSelectionIndex() + 1) instanceof ItemsListSeparator) {
|
|
807 |
list.getTable().setSelection(
|
|
808 |
list.getTable().getSelectionIndex() + 1);
|
|
805 |
if (getList()
|
|
806 |
.getElementAt(getList().getTable().getSelectionIndex() + 1) instanceof ItemsListSeparator) {
|
|
807 |
getList().getTable().setSelection(
|
|
808 |
getList().getTable().getSelectionIndex() + 1);
|
|
809 | 809 |
} |
810 |
list.getTable().notifyListeners(SWT.Selection, new Event());
|
|
810 |
getList().getTable().notifyListeners(SWT.Selection, new Event());
|
|
811 | 811 |
} |
812 | 812 |
|
813 | 813 |
} |
... | ... | |
891 | 891 |
IStatus status = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, |
892 | 892 |
IStatus.OK, EMPTY_STRING, null); |
893 | 893 |
|
894 |
Object[] lastSelection = currentSelection;
|
|
894 |
Object[] lastSelection = getCurrentSelection();
|
|
895 | 895 |
|
896 |
currentSelection = selection.toArray();
|
|
896 |
setCurrentSelection(selection.toArray());
|
|
897 | 897 |
|
898 | 898 |
if (selection.size() == 0) { |
899 | 899 |
status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, |
... | ... | |
901 | 901 |
|
902 | 902 |
if (lastSelection != null |
903 | 903 |
&& getListSelectionLabelDecorator() != null) { |
904 |
list.update(lastSelection, null);
|
|
904 |
getList().update(lastSelection, null);
|
|
905 | 905 |
} |
906 | 906 |
|
907 |
currentSelection = null;
|
|
907 |
setCurrentSelection(null);
|
|
908 | 908 |
|
909 | 909 |
} else { |
910 | 910 |
status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, |
... | ... | |
938 | 938 |
|
939 | 939 |
if (lastSelection != null |
940 | 940 |
&& getListSelectionLabelDecorator() != null) { |
941 |
list.update(lastSelection, null);
|
|
941 |
getList().update(lastSelection, null);
|
|
942 | 942 |
} |
943 | 943 |
|
944 | 944 |
if (getListSelectionLabelDecorator() != null) { |
945 |
list.update(currentSelection, null);
|
|
945 |
getList().update(getCurrentSelection(), null);
|
|
946 | 946 |
} |
947 | 947 |
} |
948 | 948 |
|
... | ... | |
978 | 978 |
* Refreshes the dialog - has to be called in UI thread. |
979 | 979 |
*/ |
980 | 980 |
public void refresh() { |
981 |
if (list != null && !list.getTable().isDisposed()) {
|
|
981 |
if (getList() != null && !getList().getTable().isDisposed()) {
|
|
982 | 982 |
|
983 |
List lastRefreshSelection = ((StructuredSelection) list
|
|
983 |
List lastRefreshSelection = ((StructuredSelection) getList()
|
|
984 | 984 |
.getSelection()).toList(); |
985 |
list.getTable().deselectAll();
|
|
985 |
getList().getTable().deselectAll();
|
|
986 | 986 |
|
987 |
list.setItemCount(contentProvider.getNumberOfElements());
|
|
988 |
list.refresh();
|
|
987 |
getList().setItemCount(contentProvider.getNumberOfElements());
|
|
988 |
getList().refresh();
|
|
989 | 989 |
|
990 |
if (list.getTable().getItemCount() > 0) {
|
|
990 |
if (getList().getTable().getItemCount() > 0) {
|
|
991 | 991 |
// preserve previous selection |
992 | 992 |
if (refreshWithLastSelection && lastRefreshSelection != null |
993 | 993 |
&& lastRefreshSelection.size() > 0) { |
994 |
list.setSelection(new StructuredSelection(
|
|
994 |
getList().setSelection(new StructuredSelection(
|
|
995 | 995 |
lastRefreshSelection)); |
996 | 996 |
} else { |
997 | 997 |
refreshWithLastSelection = true; |
998 |
list.getTable().setSelection(0);
|
|
999 |
list.getTable().notifyListeners(SWT.Selection, new Event());
|
|
998 |
getList().getTable().setSelection(0);
|
|
999 |
getList().getTable().notifyListeners(SWT.Selection, new Event());
|
|
1000 | 1000 |
} |
1001 | 1001 |
} else { |
1002 |
list.setSelection(StructuredSelection.EMPTY);
|
|
1002 |
getList().setSelection(StructuredSelection.EMPTY);
|
|
1003 | 1003 |
} |
1004 | 1004 |
|
1005 | 1005 |
} |
... | ... | |
1033 | 1033 |
* available |
1034 | 1034 |
*/ |
1035 | 1035 |
public void reloadCache(boolean checkDuplicates, IProgressMonitor monitor) { |
1036 |
if (list != null && !list.getTable().isDisposed()
|
|
1036 |
if (getList() != null && !getList().getTable().isDisposed()
|
|
1037 | 1037 |
&& contentProvider != null) { |
1038 | 1038 |
contentProvider.reloadCache(checkDuplicates, monitor); |
1039 | 1039 |
} |
... | ... | |
1065 | 1065 |
@Override |
1066 | 1066 |
protected void computeResult() { |
1067 | 1067 |
|
1068 |
List selectedElements = ((StructuredSelection) list.getSelection())
|
|
1068 |
List selectedElements = ((StructuredSelection) getList().getSelection())
|
|
1069 | 1069 |
.toList(); |
1070 | 1070 |
|
1071 | 1071 |
List objectsToReturn = new ArrayList(); |
... | ... | |
1151 | 1151 |
*/ |
1152 | 1152 |
protected StructuredSelection getSelectedItems() { |
1153 | 1153 |
|
1154 |
StructuredSelection selection = (StructuredSelection) list
|
|
1154 |
StructuredSelection selection = (StructuredSelection) getList()
|
|
1155 | 1155 |
.getSelection(); |
1156 | 1156 |
|
1157 | 1157 |
List selectedItems = selection.toList(); |
... | ... | |
1594 | 1594 |
*/ |
1595 | 1595 |
@Override |
1596 | 1596 |
public void run() { |
1597 |
List selectedElements = ((StructuredSelection) list.getSelection())
|
|
1597 |
List selectedElements = ((StructuredSelection) getList().getSelection())
|
|
1598 | 1598 |
.toList(); |
1599 | 1599 |
removeSelectedItems(selectedElements); |
1600 | 1600 |
} |
1601 | 1601 |
} |
1602 | 1602 |
|
1603 |
private static boolean showColoredLabels() {
|
|
1603 |
protected static boolean showColoredLabels() {
|
|
1604 | 1604 |
return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS); |
1605 | 1605 |
} |
1606 | 1606 |
|
... | ... | |
1695 | 1695 |
} |
1696 | 1696 |
|
1697 | 1697 |
private boolean isSelected(Object element) { |
1698 |
if (element != null && currentSelection != null) {
|
|
1699 |
for (int i = 0; i < currentSelection.length; i++) {
|
|
1700 |
if (element.equals(currentSelection[i])) {
|
|
1698 |
if (element != null && getCurrentSelection() != null) {
|
|
1699 |
for (int i = 0; i < getCurrentSelection().length; i++) {
|
|
1700 |
if (element.equals(getCurrentSelection()[i])) {
|
|
1701 | 1701 |
return true; |
1702 | 1702 |
} |
1703 | 1703 |
} |
... | ... | |
1762 | 1762 |
} |
1763 | 1763 |
|
1764 | 1764 |
private String getSeparatorLabel(String separatorLabel) { |
1765 |
Rectangle rect = list.getTable().getBounds();
|
|
1765 |
Rectangle rect = getList().getTable().getBounds();
|
|
1766 | 1766 |
|
1767 |
int borderWidth = list.getTable().computeTrim(0, 0, 0, 0).width;
|
|
1767 |
int borderWidth = getList().getTable().computeTrim(0, 0, 0, 0).width;
|
|
1768 | 1768 |
|
1769 | 1769 |
int imageWidth = WorkbenchImages.getImage( |
1770 | 1770 |
IWorkbenchGraphicConstants.IMG_OBJ_SEPARATOR).getBounds().width; |
1771 | 1771 |
|
1772 | 1772 |
int width = rect.width - borderWidth - imageWidth; |
1773 | 1773 |
|
1774 |
GC gc = new GC(list.getTable());
|
|
1775 |
gc.setFont(list.getTable().getFont());
|
|
1774 |
GC gc = new GC(getList().getTable());
|
|
1775 |
gc.setFont(getList().getTable().getFont());
|
|
1776 | 1776 |
|
1777 | 1777 |
int fSeparatorWidth = gc.getAdvanceWidth('-'); |
1778 | 1778 |
int fMessageLength = gc.textExtent(separatorLabel).x; |
... | ... | |
1897 | 1897 |
* Used in ItemsListContentProvider, separates history and non-history |
1898 | 1898 |
* items. |
1899 | 1899 |
*/ |
1900 |
private class ItemsListSeparator {
|
|
1900 |
protected class ItemsListSeparator {
|
|
1901 | 1901 |
|
1902 | 1902 |
private final String name; |
1903 | 1903 |
|
... | ... | |
2987 | 2987 |
@Override |
2988 | 2988 |
public void updateElement(int index) { |
2989 | 2989 |
|
2990 |
CdmFilteredItemsSelectionDialog.this.list.replace((lastFilteredItems
|
|
2990 |
CdmFilteredItemsSelectionDialog.this.getList().replace((lastFilteredItems
|
|
2991 | 2991 |
.size() > index) ? lastFilteredItems.get(index) : null, |
2992 | 2992 |
index); |
2993 | 2993 |
|
... | ... | |
3023 | 3023 |
|
3024 | 3024 |
// the TableViewer's root (the input) is treated as parent |
3025 | 3025 |
|
3026 |
lastFilteredItems = Arrays.asList(getFilteredItems(list.getInput(),
|
|
3026 |
lastFilteredItems = Arrays.asList(getFilteredItems(getList().getInput(),
|
|
3027 | 3027 |
monitor != null ? new SubProgressMonitor(monitor, 100) |
3028 | 3028 |
: null)); |
3029 | 3029 |
|
... | ... | |
3117 | 3117 |
if (filters != null && filteredElements != null) { |
3118 | 3118 |
for (Iterator iter = filters.iterator(); iter.hasNext();) { |
3119 | 3119 |
ViewerFilter f = (ViewerFilter) iter.next(); |
3120 |
filteredElements = f.filter(list, parent, filteredElements);
|
|
3120 |
filteredElements = f.filter(getList(), parent, filteredElements);
|
|
3121 | 3121 |
monitor.worked(ticks); |
3122 | 3122 |
} |
3123 | 3123 |
} |
... | ... | |
3423 | 3423 |
*/ |
3424 | 3424 |
abstract protected void initModel(); |
3425 | 3425 |
|
3426 |
public Object[] getCurrentSelection() { |
|
3427 |
return currentSelection; |
|
3428 |
} |
|
3429 |
|
|
3430 |
public void setCurrentSelection(Object[] currentSelection) { |
|
3431 |
this.currentSelection = currentSelection; |
|
3432 |
} |
|
3433 |
|
|
3434 |
public TableViewer getList() { |
|
3435 |
return list; |
|
3436 |
} |
|
3437 |
|
|
3438 |
public void setList(TableViewer list) { |
|
3439 |
this.list = list; |
|
3440 |
} |
|
3441 |
|
|
3426 | 3442 |
} |
3427 | 3443 |
|
3428 | 3444 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
|
13 | 13 |
|
14 |
import org.eclipse.core.runtime.Assert; |
|
15 |
import org.eclipse.core.runtime.ListenerList; |
|
16 |
import org.eclipse.jface.viewers.IColorProvider; |
|
17 |
import org.eclipse.jface.viewers.IFontProvider; |
|
18 |
import org.eclipse.jface.viewers.ILabelDecorator; |
|
19 |
import org.eclipse.jface.viewers.ILabelProvider; |
|
20 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
|
21 |
import org.eclipse.jface.viewers.LabelProvider; |
|
22 |
import org.eclipse.jface.viewers.LabelProviderChangedEvent; |
|
23 |
import org.eclipse.jface.viewers.StyledCellLabelProvider; |
|
24 |
import org.eclipse.jface.viewers.StyledString; |
|
25 |
import org.eclipse.jface.viewers.ViewerCell; |
|
26 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
|
27 |
import org.eclipse.swt.SWT; |
|
28 |
import org.eclipse.swt.graphics.Color; |
|
29 |
import org.eclipse.swt.graphics.Font; |
|
30 |
import org.eclipse.swt.graphics.GC; |
|
31 |
import org.eclipse.swt.graphics.Image; |
|
32 |
import org.eclipse.swt.graphics.Rectangle; |
|
14 | 33 |
import org.eclipse.swt.widgets.Control; |
34 |
import org.eclipse.swt.widgets.Display; |
|
15 | 35 |
import org.eclipse.swt.widgets.Shell; |
16 | 36 |
import org.eclipse.swt.widgets.Text; |
37 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
|
38 |
import org.eclipse.ui.internal.WorkbenchImages; |
|
17 | 39 |
|
18 | 40 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
19 | 41 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
20 | 42 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
21 | 43 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
44 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
22 | 45 |
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard; |
23 | 46 |
import eu.etaxonomy.taxeditor.newWizard.NewPersonWizard; |
24 | 47 |
import eu.etaxonomy.taxeditor.newWizard.NewTeamWizard; |
48 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
|
49 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
25 | 50 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
51 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog.FilteredCdmResourceLabelProvider; |
|
52 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsListSeparator; |
|
26 | 53 |
|
27 | 54 |
/** |
28 | 55 |
* @author k.luther |
... | ... | |
70 | 97 |
throw new IllegalArgumentException("Could not determine the desired wizard."); |
71 | 98 |
} |
72 | 99 |
} |
73 |
|
|
100 |
/** |
|
101 |
* |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
protected ILabelProvider createListLabelProvider() { |
|
106 |
return new FilteredCdmResourceAbbrevLabelProvider(); |
|
107 |
} |
|
74 | 108 |
|
75 | 109 |
/** |
76 | 110 |
* <p>select</p> |
... | ... | |
108 | 142 |
" supports cdmObject of type IIdentifiableEntity." + |
109 | 143 |
" Please implement specific method in subclass."); |
110 | 144 |
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
public class FilteredCdmResourceAbbrevLabelProvider extends LabelProvider { |
|
149 |
@Override |
|
150 |
public String getText(Object element) { |
|
151 |
if (element == null) { |
|
152 |
return null; |
|
153 |
} |
|
154 |
UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache) element; |
|
155 |
String titleCache = uuidAndTitleCache.getTitleCache(); |
|
156 |
String abbrevTitleCache = uuidAndTitleCache.getAbbrevTitleCache(); |
|
157 |
abbrevTitleCache += " - " + titleCache; |
|
158 |
if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){ |
|
159 |
abbrevTitleCache += " ["+uuidAndTitleCache.getId()+"]"; |
|
160 |
} |
|
161 |
return abbrevTitleCache; |
|
162 |
} |
|
163 |
}; |
|
111 | 164 |
|
112 | 165 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalReferenceSelectionDialog.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.ui.dialog.selection; |
2 | 2 |
|
3 |
import org.eclipse.core.runtime.Assert; |
|
4 |
import org.eclipse.core.runtime.ListenerList; |
|
5 |
import org.eclipse.jface.viewers.IColorProvider; |
|
6 |
import org.eclipse.jface.viewers.IFontProvider; |
|
7 |
import org.eclipse.jface.viewers.ILabelDecorator; |
|
8 |
import org.eclipse.jface.viewers.ILabelProvider; |
|
9 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
|
10 |
import org.eclipse.jface.viewers.LabelProvider; |
|
11 |
import org.eclipse.jface.viewers.LabelProviderChangedEvent; |
|
12 |
import org.eclipse.jface.viewers.StyledCellLabelProvider; |
|
13 |
import org.eclipse.jface.viewers.StyledString; |
|
14 |
import org.eclipse.jface.viewers.ViewerCell; |
|
15 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
|
16 |
import org.eclipse.swt.SWT; |
|
17 |
import org.eclipse.swt.graphics.Color; |
|
18 |
import org.eclipse.swt.graphics.Font; |
|
19 |
import org.eclipse.swt.graphics.GC; |
|
20 |
import org.eclipse.swt.graphics.Image; |
|
21 |
import org.eclipse.swt.graphics.Rectangle; |
|
3 | 22 |
import org.eclipse.swt.widgets.Control; |
23 |
import org.eclipse.swt.widgets.Display; |
|
4 | 24 |
import org.eclipse.swt.widgets.Shell; |
5 | 25 |
import org.eclipse.swt.widgets.Text; |
26 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
|
27 |
import org.eclipse.ui.internal.WorkbenchImages; |
|
6 | 28 |
|
7 | 29 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
8 | 30 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
9 | 31 |
import eu.etaxonomy.cdm.model.reference.Reference; |
10 | 32 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
33 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
|
34 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
11 | 35 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
12 | 36 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsFilter; |
37 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsListSeparator; |
|
13 | 38 |
|
14 | 39 |
public class NomenclaturalReferenceSelectionDialog extends |
15 | 40 |
ReferenceSelectionDialog { |
... | ... | |
37 | 62 |
model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern); |
38 | 63 |
} |
39 | 64 |
|
65 |
/** |
|
66 |
* |
|
67 |
* @return |
|
68 |
*/ |
|
69 |
@Override |
|
70 |
protected ILabelProvider createListLabelProvider() { |
|
71 |
return new FilteredCdmResourceAbbrevLabelProvider(); |
|
72 |
} |
|
73 |
|
|
40 | 74 |
/** |
41 | 75 |
* <p>select</p> |
42 | 76 |
* |
... | ... | |
86 | 120 |
|
87 | 121 |
}; |
88 | 122 |
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
public class FilteredCdmResourceAbbrevLabelProvider extends LabelProvider { |
|
127 |
@Override |
|
128 |
public String getText(Object element) { |
|
129 |
if (element == null) { |
|
130 |
return null; |
|
131 |
} |
|
132 |
UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache) element; |
|
133 |
String titleCache = uuidAndTitleCache.getTitleCache(); |
|
134 |
String abbrevTitleCache = uuidAndTitleCache.getAbbrevTitleCache(); |
|
135 |
abbrevTitleCache += " - " + titleCache; |
|
136 |
if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){ |
|
137 |
abbrevTitleCache += " ["+uuidAndTitleCache.getId()+"]"; |
|
138 |
} |
|
139 |
return abbrevTitleCache; |
|
140 |
} |
|
141 |
}; |
|
142 |
|
|
89 | 143 |
|
90 | 144 |
|
91 | 145 |
} |
Also available in: Unified diff
ref #5828 abbrevTitle and titlecache are displayed in nomenclatural selectionDialogs