34 |
34 |
import org.eclipse.jface.viewers.IColorProvider;
|
35 |
35 |
import org.eclipse.jface.viewers.IDoubleClickListener;
|
36 |
36 |
import org.eclipse.jface.viewers.IFontProvider;
|
37 |
|
import org.eclipse.jface.viewers.ILabelDecorator;
|
38 |
37 |
import org.eclipse.jface.viewers.ILabelProvider;
|
39 |
38 |
import org.eclipse.jface.viewers.ILabelProviderListener;
|
40 |
|
import org.eclipse.jface.viewers.ILazyContentProvider;
|
41 |
39 |
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
42 |
40 |
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
43 |
41 |
import org.eclipse.jface.viewers.LabelProvider;
|
... | ... | |
86 |
84 |
import org.eclipse.ui.internal.WorkbenchImages;
|
87 |
85 |
import org.eclipse.ui.internal.WorkbenchMessages;
|
88 |
86 |
import org.eclipse.ui.internal.WorkbenchPlugin;
|
89 |
|
import org.eclipse.ui.progress.UIJob;
|
90 |
87 |
|
91 |
88 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
92 |
89 |
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
... | ... | |
101 |
98 |
public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements IConversationEnabled{
|
102 |
99 |
|
103 |
100 |
private TableViewer list;
|
104 |
|
|
105 |
|
|
106 |
101 |
private Text searchField;
|
107 |
102 |
private String title;
|
|
103 |
private StructuredSelection currentSelection;
|
108 |
104 |
|
109 |
105 |
// message to show user
|
110 |
106 |
private String message = ""; //$NON-NLS-1$
|
111 |
107 |
|
112 |
108 |
protected final ContentProvider contentProvider;
|
113 |
|
|
114 |
|
private StructuredSelection currentSelection;
|
115 |
109 |
ItemsListLabelProvider itemsListLabelProvider;
|
116 |
110 |
|
117 |
111 |
private final RefreshCacheJob refreshCacheJob;
|
118 |
112 |
|
119 |
113 |
private ToolBar toolBar;
|
120 |
|
|
121 |
114 |
private ToolItem toolItem;
|
122 |
115 |
private MenuManager menuManager;
|
123 |
|
|
124 |
|
private ILabelProvider provider;
|
125 |
|
|
126 |
|
private ILabelDecorator selectionDecorator;
|
127 |
|
|
128 |
116 |
// Need to keep our own list of listeners
|
129 |
117 |
private final ListenerList listeners = new ListenerList();
|
130 |
118 |
|
... | ... | |
143 |
131 |
@Override
|
144 |
132 |
protected Control createDialogArea(Composite parent) {
|
145 |
133 |
Composite container = (Composite) super.createDialogArea(parent);
|
146 |
|
// Composite content = new Composite(container, SWT.NONE);
|
|
134 |
|
147 |
135 |
GridData gd = new GridData(GridData.FILL_BOTH);
|
148 |
136 |
container.setLayoutData(gd);
|
149 |
137 |
|
... | ... | |
182 |
170 |
gd_1.widthHint = 575;
|
183 |
171 |
searchField.setLayoutData(gd_1);
|
184 |
172 |
|
185 |
|
// final Label listLabel = createLabels(content);
|
186 |
|
|
187 |
173 |
setList(new TableViewer(container, SWT.SINGLE
|
188 |
174 |
| SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
|
189 |
|
// getList().getTable().getAccessible().addAccessibleListener(
|
190 |
|
// new AccessibleAdapter() {
|
191 |
|
// @Override
|
192 |
|
// public void getName(AccessibleEvent e) {
|
193 |
|
// if (e.childID == ACC.CHILDID_SELF) {
|
194 |
|
// e.result = LegacyActionTools
|
195 |
|
// .removeMnemonics(listLabel.getText());
|
196 |
|
// }
|
197 |
|
// }
|
198 |
|
// });
|
|
175 |
|
199 |
176 |
getList().setContentProvider(contentProvider);
|
200 |
177 |
getList().setLabelProvider(getItemsListLabelProvider());
|
201 |
178 |
getList().setInput(new Object[0]);
|
... | ... | |
258 |
235 |
new Label(header, SWT.NONE);
|
259 |
236 |
new Label(header, SWT.NONE);
|
260 |
237 |
|
261 |
|
Label headerLabel = new Label(header, SWT.NONE);
|
262 |
|
headerLabel.setText((getMessage() != null && getMessage().trim()
|
263 |
|
.length() > 0) ? getMessage()
|
264 |
|
: Messages.SearchDialog_patternLabel);
|
265 |
|
headerLabel.addTraverseListener(new TraverseListener() {
|
266 |
|
@Override
|
267 |
|
public void keyTraversed(TraverseEvent e) {
|
268 |
|
if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
|
269 |
|
e.detail = SWT.TRAVERSE_NONE;
|
270 |
|
searchField.setFocus();
|
271 |
|
}
|
272 |
|
}
|
273 |
|
});
|
274 |
|
GridData gd_headerLabel = new GridData(GridData.FILL_HORIZONTAL);
|
275 |
|
gd_headerLabel.horizontalAlignment = SWT.LEFT;
|
276 |
|
gd_headerLabel.grabExcessHorizontalSpace = false;
|
277 |
|
gd_headerLabel.verticalAlignment = SWT.BOTTOM;
|
278 |
|
gd_headerLabel.minimumHeight = 10;
|
279 |
|
headerLabel.setLayoutData(gd_headerLabel);
|
280 |
|
|
281 |
|
// createViewMenu(header);
|
282 |
|
|
283 |
|
return headerLabel;
|
|
238 |
Label headerLabel = new Label(header, SWT.NONE);
|
|
239 |
headerLabel.setText((getMessage() != null && getMessage().trim()
|
|
240 |
.length() > 0) ? getMessage()
|
|
241 |
: Messages.SearchDialog_patternLabel);
|
|
242 |
headerLabel.addTraverseListener(new TraverseListener() {
|
|
243 |
@Override
|
|
244 |
public void keyTraversed(TraverseEvent e) {
|
|
245 |
if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
|
|
246 |
e.detail = SWT.TRAVERSE_NONE;
|
|
247 |
searchField.setFocus();
|
|
248 |
}
|
|
249 |
}
|
|
250 |
});
|
|
251 |
GridData gd_headerLabel = new GridData(GridData.FILL_HORIZONTAL);
|
|
252 |
gd_headerLabel.horizontalAlignment = SWT.LEFT;
|
|
253 |
gd_headerLabel.grabExcessHorizontalSpace = false;
|
|
254 |
gd_headerLabel.verticalAlignment = SWT.BOTTOM;
|
|
255 |
gd_headerLabel.minimumHeight = 10;
|
|
256 |
headerLabel.setLayoutData(gd_headerLabel);
|
|
257 |
|
|
258 |
return headerLabel;
|
284 |
259 |
}
|
285 |
260 |
|
286 |
|
/**
|
287 |
|
* Returns the message for this dialog.
|
288 |
|
*
|
289 |
|
* @return the message for this dialog
|
290 |
|
*/
|
291 |
261 |
protected String getMessage() {
|
292 |
262 |
return message;
|
293 |
263 |
}
|
... | ... | |
305 |
275 |
this.searchField = searchField;
|
306 |
276 |
}
|
307 |
277 |
|
308 |
|
/**
|
309 |
|
* Returns the item list label provider.
|
310 |
|
*
|
311 |
|
* @return the item list label provider
|
312 |
|
*/
|
313 |
278 |
private ItemsListLabelProvider getItemsListLabelProvider() {
|
314 |
279 |
if (itemsListLabelProvider == null) {
|
315 |
280 |
itemsListLabelProvider = new ItemsListLabelProvider(
|
... | ... | |
317 |
282 |
}
|
318 |
283 |
return itemsListLabelProvider;
|
319 |
284 |
}
|
320 |
|
|
321 |
|
// /**
|
322 |
|
// * Create the labels for the list and the progress. Return the list label.
|
323 |
|
// *
|
324 |
|
// * @param parent
|
325 |
|
// * @return Label
|
326 |
|
// */
|
327 |
|
// private Label createLabels(Composite parent) {
|
328 |
|
// Composite labels = new Composite(parent, SWT.NONE);
|
329 |
|
//
|
330 |
|
// GridLayout layout = new GridLayout();
|
331 |
|
// layout.numColumns = 2;
|
332 |
|
// layout.marginWidth = 0;
|
333 |
|
// layout.marginHeight = 0;
|
334 |
|
// labels.setLayout(layout);
|
335 |
|
//
|
336 |
|
//// Label listLabel = new Label(labels, SWT.NONE);
|
337 |
|
//// listLabel
|
338 |
|
//// .setText(Messages.SearchDialog_listLabel);
|
339 |
|
//
|
340 |
|
// listLabel.addTraverseListener(new TraverseListener() {
|
341 |
|
// @Override
|
342 |
|
// public void keyTraversed(TraverseEvent e) {
|
343 |
|
// if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
|
344 |
|
// e.detail = SWT.TRAVERSE_NONE;
|
345 |
|
// getList().getTable().setFocus();
|
346 |
|
// }
|
347 |
|
// }
|
348 |
|
// });
|
349 |
|
// listLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
350 |
|
// new Label(labels, SWT.NONE);
|
351 |
|
//
|
352 |
|
//
|
353 |
|
// return listLabel;
|
354 |
|
// }
|
355 |
|
|
356 |
|
|
357 |
285 |
private void createViewMenu(Composite parent) {
|
358 |
286 |
toolBar = new ToolBar(parent, SWT.FLAT);
|
359 |
287 |
toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
|
... | ... | |
393 |
321 |
return null;
|
394 |
322 |
}
|
395 |
323 |
};
|
396 |
|
// showViewHandler = service.activateHandler(
|
397 |
|
// IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU, handler,
|
398 |
|
// new ActiveShellExpression(getShell()));
|
399 |
324 |
}
|
400 |
325 |
|
401 |
326 |
/**
|
... | ... | |
405 |
330 |
* the menu manager
|
406 |
331 |
*/
|
407 |
332 |
protected void fillViewMenu(IMenuManager menuManager) {
|
408 |
|
// toggleStatusLineAction = new ToggleStatusLineAction();
|
409 |
|
// menuManager.add(toggleStatusLineAction);
|
|
333 |
|
410 |
334 |
}
|
411 |
335 |
|
412 |
336 |
private void showViewMenu() {
|
... | ... | |
449 |
373 |
|
450 |
374 |
|
451 |
375 |
|
452 |
|
/**
|
453 |
|
* Collects filtered elements. Contains one synchronized, sorted set for
|
454 |
|
* collecting filtered elements. All collected elements are sorted using
|
455 |
|
* comparator. Comparator is returned by getElementComparator() method.
|
456 |
|
* Implementation of <code>ItemsFilter</code> is used to filter elements.
|
457 |
|
* The key function of filter used in to filtering is
|
458 |
|
* <code>matchElement(Object item)</code>.
|
459 |
|
* <p>
|
460 |
|
* The <code>ContentProvider</code> class also provides item filtering
|
461 |
|
* methods. The filtering has been moved from the standard TableView
|
462 |
|
* <code>getFilteredItems()</code> method to content provider, because
|
463 |
|
* <code>ILazyContentProvider</code> and virtual tables are used. This
|
464 |
|
* class is responsible for adding a separator below history items and
|
465 |
|
* marking each items as duplicate if its name repeats more than once on the
|
466 |
|
* filtered list.
|
467 |
|
*/
|
468 |
376 |
class ContentProvider implements
|
469 |
|
IStructuredContentProvider, ILazyContentProvider {
|
470 |
|
|
471 |
|
|
|
377 |
IStructuredContentProvider {
|
472 |
378 |
|
473 |
|
/**
|
474 |
|
* Raw result of the searching (unsorted, unfiltered).
|
475 |
|
* <p>
|
476 |
|
* Standard object flow:
|
477 |
|
* <code>items -> lastSortedItems -> lastFilteredItems</code>
|
478 |
|
*/
|
479 |
379 |
private List items;
|
480 |
380 |
|
481 |
|
|
482 |
381 |
/**
|
483 |
382 |
* Creates new instance of <code>ContentProvider</code>.
|
484 |
383 |
*/
|
... | ... | |
487 |
386 |
|
488 |
387 |
}
|
489 |
388 |
|
490 |
|
|
491 |
|
|
492 |
389 |
/**
|
493 |
390 |
* Removes all content items and resets progress message.
|
494 |
391 |
*/
|
... | ... | |
497 |
394 |
|
498 |
395 |
}
|
499 |
396 |
|
500 |
|
|
501 |
|
|
502 |
|
/**
|
503 |
|
* Adds filtered item.
|
504 |
|
*
|
505 |
|
* @param item
|
506 |
|
* @param itemsFilter
|
507 |
|
*/
|
508 |
|
|
509 |
397 |
public void add(Object item) {
|
510 |
398 |
this.items.add(item);
|
511 |
399 |
}
|
512 |
400 |
|
513 |
|
|
514 |
|
|
515 |
401 |
/**
|
516 |
402 |
* Refresh dialog.
|
517 |
403 |
*/
|
... | ... | |
527 |
413 |
refreshCacheJob.schedule();
|
528 |
414 |
}
|
529 |
415 |
|
530 |
|
|
531 |
416 |
/*
|
532 |
417 |
* (non-Javadoc)
|
533 |
418 |
*
|
... | ... | |
536 |
421 |
@Override
|
537 |
422 |
public Object[] getElements(Object inputElement) {
|
538 |
423 |
return items.toArray();
|
539 |
|
// return lastFilteredItems.toArray();
|
540 |
424 |
}
|
541 |
425 |
|
542 |
426 |
public int getNumberOfElements() {
|
543 |
|
|
544 |
427 |
return items.size();
|
545 |
428 |
}
|
546 |
429 |
|
... | ... | |
562 |
445 |
@Override
|
563 |
446 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
564 |
447 |
}
|
565 |
|
|
566 |
|
/*
|
567 |
|
* (non-Javadoc)
|
568 |
|
*
|
569 |
|
* @see org.eclipse.jface.viewers.ILazyContentProvider#updateElement(int)
|
570 |
|
*/
|
571 |
|
@Override
|
572 |
|
public void updateElement(int index) {
|
573 |
|
|
574 |
|
SearchDialog.this.getList().replace((items
|
575 |
|
.size() > index) ? items.get(index) : null,
|
576 |
|
index);
|
577 |
|
|
578 |
|
}
|
579 |
|
|
580 |
|
|
581 |
448 |
}
|
582 |
449 |
|
583 |
|
// protected static boolean showColoredLabels() {
|
584 |
|
// return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
|
585 |
|
// }
|
|
450 |
|
586 |
451 |
|
587 |
452 |
public StructuredSelection getCurrentSelection() {
|
588 |
453 |
return currentSelection;
|
... | ... | |
591 |
456 |
/**
|
592 |
457 |
* Fills the content provider with matching items.
|
593 |
458 |
*
|
594 |
|
* @param contentProvider
|
595 |
|
* collector to add items to.
|
596 |
|
* {@link FilteredItemsSelectionDialog.AbstractContentProvider#add(Object, FilteredItemsSelectionDialog.ItemsFilter)}
|
597 |
|
* only adds items that pass the given <code>itemsFilter</code>.
|
598 |
|
* @param itemsFilter
|
599 |
|
* the items filter
|
600 |
459 |
* @param progressMonitor
|
601 |
460 |
* must be used to report search progress. The state of this
|
602 |
461 |
* progress monitor reflects the state of the filtering process.
|
... | ... | |
634 |
493 |
}
|
635 |
494 |
|
636 |
495 |
}
|
637 |
|
|
638 |
|
// scheduleProgressMessageRefresh();
|
639 |
496 |
}
|
640 |
497 |
|
641 |
|
/**
|
642 |
|
* Only refreshes UI on the basis of an already sorted and filtered set of
|
643 |
|
* items.
|
644 |
|
* <p>
|
645 |
|
* Standard invocation scenario:
|
646 |
|
* <ol>
|
647 |
|
* <li>filtering job (<code>FilterJob</code> class extending
|
648 |
|
* <code>Job</code> class)</li>
|
649 |
|
* <li>cache refresh without checking for duplicates (<code>RefreshCacheJob</code>
|
650 |
|
* class extending <code>Job</code> class)</li>
|
651 |
|
* <li>UI refresh (<code>RefreshJob</code> class extending
|
652 |
|
* <code>UIJob</code> class)</li>
|
653 |
|
* <li>cache refresh with checking for duplicates (<cod>CacheRefreshJob</code>
|
654 |
|
* class extending <code>Job</code> class)</li>
|
655 |
|
* <li>UI refresh (<code>RefreshJob</code> class extending <code>UIJob</code>
|
656 |
|
* class)</li>
|
657 |
|
* </ol>
|
658 |
|
* The scenario is rather complicated, but it had to be applied, because:
|
659 |
|
* <ul>
|
660 |
|
* <li> refreshing cache is rather a long action and cannot be run in the UI -
|
661 |
|
* cannot be run in a UIJob</li>
|
662 |
|
* <li> refreshing cache checking for duplicates is twice as long as
|
663 |
|
* refreshing cache without checking for duplicates; results of the search
|
664 |
|
* could be displayed earlier</li>
|
665 |
|
* <li> refreshing the UI have to be run in a UIJob</li>
|
666 |
|
* </ul>
|
667 |
|
*
|
668 |
|
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.FilterJob
|
669 |
|
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.RefreshJob
|
670 |
|
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.RefreshCacheJob
|
671 |
|
*/
|
672 |
|
private class RefreshJob extends UIJob {
|
673 |
|
|
674 |
|
/**
|
675 |
|
* Creates a new instance of the class.
|
676 |
|
*/
|
677 |
|
public RefreshJob() {
|
678 |
|
super(SearchDialog.this.getParentShell()
|
679 |
|
.getDisplay(),
|
680 |
|
WorkbenchMessages.FilteredItemsSelectionDialog_refreshJob);
|
681 |
|
setSystem(true);
|
682 |
|
}
|
683 |
|
|
684 |
|
/*
|
685 |
|
* (non-Javadoc)
|
686 |
|
*
|
687 |
|
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
|
688 |
|
*/
|
689 |
|
@Override
|
690 |
|
public IStatus runInUIThread(IProgressMonitor monitor) {
|
691 |
|
if (monitor.isCanceled()) {
|
692 |
|
return new Status(IStatus.OK, WorkbenchPlugin.PI_WORKBENCH,
|
693 |
|
IStatus.OK, EMPTY_STRING, null);
|
694 |
|
}
|
695 |
|
|
696 |
|
if (SearchDialog.this != null) {
|
697 |
|
SearchDialog.this.refresh();
|
698 |
|
}
|
699 |
|
|
700 |
|
return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
|
701 |
|
EMPTY_STRING, null);
|
702 |
|
}
|
703 |
|
|
704 |
|
}
|
705 |
|
|
706 |
|
|
707 |
498 |
/**
|
708 |
499 |
* A job responsible for computing filtered items list presented using
|
709 |
500 |
* <code>RefreshJob</code>.
|
... | ... | |
713 |
504 |
*/
|
714 |
505 |
private class RefreshCacheJob extends Job {
|
715 |
506 |
|
716 |
|
private final RefreshJob refreshJob = new RefreshJob();
|
717 |
|
|
718 |
|
/**
|
719 |
|
* Creates a new instance of the class.
|
720 |
|
*/
|
721 |
507 |
public RefreshCacheJob() {
|
722 |
508 |
super(
|
723 |
509 |
WorkbenchMessages.FilteredItemsSelectionDialog_cacheRefreshJob);
|
... | ... | |
729 |
515 |
*/
|
730 |
516 |
public void cancelAll() {
|
731 |
517 |
cancel();
|
732 |
|
refreshJob.cancel();
|
733 |
518 |
}
|
734 |
519 |
|
735 |
520 |
/*
|
... | ... | |
754 |
539 |
}
|
755 |
540 |
}
|
756 |
541 |
|
757 |
|
if (!monitor.isCanceled()) {
|
758 |
|
refreshJob.schedule();
|
759 |
|
}
|
760 |
|
|
761 |
542 |
return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
|
762 |
543 |
EMPTY_STRING, null);
|
763 |
544 |
|
... | ... | |
771 |
552 |
@Override
|
772 |
553 |
protected void canceling() {
|
773 |
554 |
super.canceling();
|
774 |
|
// contentProvider.stopReloadingCache();
|
775 |
555 |
}
|
776 |
556 |
|
777 |
557 |
}
|
... | ... | |
791 |
571 |
public ItemsListLabelProvider(ILabelProvider provider) {
|
792 |
572 |
Assert.isNotNull(provider);
|
793 |
573 |
this.provider = provider;
|
794 |
|
|
795 |
|
|
796 |
|
// setOwnerDrawEnabled(showColoredLabels() && provider instanceof IStyledLabelProvider);
|
797 |
|
|
798 |
|
provider.addListener(this);
|
799 |
|
|
800 |
|
if (selectionDecorator != null) {
|
801 |
|
selectionDecorator.addListener(this);
|
802 |
|
}
|
803 |
|
}
|
804 |
|
|
805 |
|
/**
|
806 |
|
* Sets new selection decorator.
|
807 |
|
*
|
808 |
|
* @param newSelectionDecorator
|
809 |
|
* new label decorator for selected items in the list
|
810 |
|
*/
|
811 |
|
public void setSelectionDecorator(ILabelDecorator newSelectionDecorator) {
|
812 |
|
if (selectionDecorator != null) {
|
813 |
|
selectionDecorator.removeListener(this);
|
814 |
|
selectionDecorator.dispose();
|
815 |
|
}
|
816 |
|
|
817 |
|
selectionDecorator = newSelectionDecorator;
|
818 |
|
|
819 |
|
if (selectionDecorator != null) {
|
820 |
|
selectionDecorator.addListener(this);
|
821 |
|
}
|
822 |
|
}
|
823 |
|
|
824 |
|
/**
|
825 |
|
* Gets selection decorator.
|
826 |
|
*
|
827 |
|
* @return the label decorator for selected items in the list
|
828 |
|
*/
|
829 |
|
public ILabelDecorator getSelectionDecorator() {
|
830 |
|
return selectionDecorator;
|
|
574 |
this.provider.addListener(this);
|
831 |
575 |
}
|
832 |
576 |
|
833 |
577 |
/**
|
... | ... | |
841 |
585 |
Assert.isNotNull(newProvider);
|
842 |
586 |
provider.removeListener(this);
|
843 |
587 |
provider.dispose();
|
844 |
|
|
845 |
588 |
provider = newProvider;
|
846 |
589 |
|
847 |
590 |
if (provider != null) {
|
848 |
591 |
provider.addListener(this);
|
849 |
592 |
}
|
850 |
|
|
851 |
|
// setOwnerDrawEnabled(showColoredLabels() && provider instanceof IStyledLabelProvider);
|
852 |
593 |
}
|
853 |
594 |
|
854 |
595 |
|
... | ... | |
872 |
613 |
return getSeparatorLabel(((ItemsListSeparator) element)
|
873 |
614 |
.getName());
|
874 |
615 |
}
|
875 |
|
|
876 |
616 |
String str = provider.getText(element);
|
877 |
|
if (selectionDecorator != null && isSelected(element)) {
|
878 |
|
return selectionDecorator.decorateText(str.toString(), element);
|
879 |
|
}
|
880 |
|
|
881 |
617 |
return str;
|
882 |
618 |
}
|
883 |
619 |
|
... | ... | |
885 |
621 |
IStyledLabelProvider provider) {
|
886 |
622 |
StyledString string = provider.getStyledText(element);
|
887 |
623 |
|
888 |
|
if (selectionDecorator != null && isSelected(element)) {
|
889 |
|
String decorated = selectionDecorator.decorateText(string
|
890 |
|
.getString(), element);
|
891 |
|
return StyledCellLabelProvider.styleDecoratedString(decorated, null, string);
|
892 |
|
// no need to add colors when element is selected
|
893 |
|
}
|
894 |
624 |
return string;
|
895 |
625 |
}
|
896 |
626 |
|
... | ... | |
968 |
698 |
public void dispose() {
|
969 |
699 |
provider.removeListener(this);
|
970 |
700 |
provider.dispose();
|
971 |
|
|
972 |
|
if (selectionDecorator != null) {
|
973 |
|
selectionDecorator.removeListener(this);
|
974 |
|
selectionDecorator.dispose();
|
975 |
|
}
|
976 |
|
|
977 |
701 |
super.dispose();
|
978 |
702 |
}
|
979 |
703 |
|
... | ... | |
988 |
712 |
if (provider.isLabelProperty(element, property)) {
|
989 |
713 |
return true;
|
990 |
714 |
}
|
991 |
|
if (selectionDecorator != null
|
992 |
|
&& selectionDecorator.isLabelProperty(element, property)) {
|
993 |
|
return true;
|
994 |
|
}
|
995 |
715 |
return false;
|
996 |
716 |
}
|
997 |
717 |
|
... | ... | |
1054 |
774 |
protected Point getInitialSize() {
|
1055 |
775 |
return new Point(593, 399);
|
1056 |
776 |
}
|
1057 |
|
}
|
|
777 |
}
|
1058 |
778 |
|
1059 |
779 |
|
code cleaning