Revision 288183cd
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java | ||
---|---|---|
21 | 21 |
import org.eclipse.core.runtime.OperationCanceledException; |
22 | 22 |
import org.eclipse.jface.action.MenuManager; |
23 | 23 |
import org.eclipse.jface.viewers.ISelection; |
24 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
|
24 | 25 |
import org.eclipse.jface.viewers.ISelectionProvider; |
25 | 26 |
import org.eclipse.jface.viewers.StructuredSelection; |
27 |
import org.eclipse.swt.SWT; |
|
26 | 28 |
import org.eclipse.swt.dnd.DND; |
27 | 29 |
import org.eclipse.swt.dnd.DropTarget; |
28 | 30 |
import org.eclipse.swt.dnd.Transfer; |
31 |
import org.eclipse.swt.graphics.Color; |
|
29 | 32 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Display; |
|
30 | 34 |
import org.eclipse.swt.widgets.Menu; |
31 | 35 |
import org.eclipse.ui.IEditorInput; |
32 | 36 |
import org.eclipse.ui.IEditorSite; |
... | ... | |
94 | 98 |
private ManagedForm managedForm; |
95 | 99 |
private ScrolledForm scrolledForm; |
96 | 100 |
private Composite parent; |
97 |
private ISelectionProvider provider;
|
|
101 |
private ISelectionProvider selectionProvider;
|
|
98 | 102 |
|
99 | 103 |
private final MultiPageTaxonEditor editor; |
100 | 104 |
|
... | ... | |
186 | 190 |
public boolean setInput(Object input) { |
187 | 191 |
if (input instanceof AbstractGroupedContainer) { |
188 | 192 |
selection = ((AbstractGroupedContainer) input).getData(); |
189 |
provider.setSelection(new StructuredSelection(selection));
|
|
193 |
getSite().getSelectionProvider().setSelection(new StructuredSelection(selection));
|
|
190 | 194 |
} |
191 | 195 |
return super.setInput(input); |
192 | 196 |
} |
... | ... | |
489 | 493 |
setSite(site); |
490 | 494 |
setInput(input); |
491 | 495 |
|
492 |
provider = new SimpleSelectionProvider();
|
|
493 |
getSite().setSelectionProvider(provider);
|
|
496 |
selectionProvider = new SimpleSelectionProvider();
|
|
497 |
getSite().setSelectionProvider(selectionProvider);
|
|
494 | 498 |
} |
495 | 499 |
|
496 | 500 |
/** |
... | ... | |
891 | 895 |
} |
892 | 896 |
return getAcceptedNameContainer(); |
893 | 897 |
} |
898 |
|
|
899 |
@Override |
|
900 |
public void setDisabled(){ |
|
901 |
setEnabled(false); |
|
902 |
|
|
903 |
// coloring the widgets |
|
904 |
|
|
905 |
// TODO move this to resources and make configurable via Preferences |
|
906 |
Color disabledColor = Display.getDefault().getSystemColor(SWT.COLOR_RED); |
|
907 |
|
|
908 |
for(AbstractGroupedContainer groupedContainer : getGroupedContainers()){ |
|
909 |
groupedContainer.setBackground(disabledColor); |
|
910 |
} |
|
911 |
getControl().setBackground(disabledColor); |
|
912 |
} |
|
913 |
|
|
914 |
@Override |
|
915 |
public void setEnabled(boolean enabled) { |
|
916 |
for(AbstractGroupedContainer groupedContainer : getGroupedContainers()){ |
|
917 |
groupedContainer.setEnabled(getManagedForm().setInput(selection)); |
|
918 |
} |
|
919 |
|
|
920 |
// send an empty selection to the current provider |
|
921 |
selectionProvider.setSelection(new StructuredSelection()); |
|
922 |
|
|
923 |
// decide on the new selection provider |
|
924 |
|
|
925 |
ISelectionProvider newSelectionProvider = enabled ? selectionProvider : new ISelectionProvider() { |
|
926 |
|
|
927 |
@Override |
|
928 |
public void setSelection(ISelection selection) { |
|
929 |
|
|
930 |
} |
|
931 |
|
|
932 |
@Override |
|
933 |
public void removeSelectionChangedListener( |
|
934 |
ISelectionChangedListener listener) { |
|
935 |
|
|
936 |
} |
|
937 |
|
|
938 |
@Override |
|
939 |
public ISelection getSelection() { |
|
940 |
return null; |
|
941 |
} |
|
942 |
|
|
943 |
@Override |
|
944 |
public void addSelectionChangedListener(ISelectionChangedListener listener) { |
|
945 |
|
|
946 |
} |
|
947 |
}; |
|
948 |
|
|
949 |
getSite().setSelectionProvider(newSelectionProvider); |
|
950 |
|
|
951 |
System.out.println("SELECTION PROVIDER" + getSite().getSelectionProvider()); |
|
952 |
} |
|
894 | 953 |
} |
Also available in: Unified diff
Upgraded to cdmlib-3.0.9, working on error warning for unsavable editor