IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
- private Taxon taxon;
+ private Taxon taxon;
- private ManagedForm managedForm;
- private ScrolledForm scrolledForm;
- private Composite parent;
- private ISelectionProvider simpleSelectionProvider;
+ private ManagedForm managedForm;
+ private ScrolledForm scrolledForm;
+ private Composite parent;
+ private ISelectionProvider simpleSelectionProvider;
- private TaxonBase selection;
+ private TaxonBase selection;
- private ConversationHolder conversation;
+ private ConversationHolder conversation;
- private AcceptedGroupE4 acceptedGroup;
- private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
- private MisappliedGroupE4 misappliedGroup;
+ private AcceptedGroupE4 acceptedGroup;
+ private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
+ private MisappliedGroupE4 misappliedGroup;
- private DropTarget target;
+ private DropTarget target;
- @Inject
- UISynchronize sync;
+ @Inject
+ UISynchronize sync;
- private TaxonBase objectAffectedByLastOperation;
+ private TaxonBase objectAffectedByLastOperation;
- @Inject
- private EMenuService menuService;
+ @Inject
+ private EMenuService menuService;
- @Inject
- private ESelectionService selService;
+ @Inject
+ private ESelectionService selService;
- @Inject
- private IEclipseContext context;
+ @Inject
+ private IEclipseContext context;
- @Inject
- private MDirtyable dirty;
+ @Inject
+ private MDirtyable dirty;
- private MPart thisPart;
+ private MPart thisPart;
private TaxonEditorInputE4 input;
@Inject
private IEventBroker eventBroker;
- @Inject
- public TaxonNameEditorE4() {
- undoContext = new UndoContext();
- }
-
+ @Inject
+ public TaxonNameEditorE4() {
+ undoContext = new UndoContext();
+ }
- @PostConstruct
+ @PostConstruct
public void createPartControl(Composite parent, MPart thisPart) {
- this.thisPart = thisPart;
+ this.thisPart = thisPart;
createManagedForm(parent);
- TaxeditorPartService.getInstance().addListener(
- TaxeditorPartService.PART_ACTIVATED, this);
+ TaxeditorPartService.getInstance().addListener(TaxeditorPartService.PART_ACTIVATED, this);
- }
+ }
- protected void createManagedForm(Composite composite) {
+ protected void createManagedForm(Composite composite) {
- managedForm = new ManagedForm(composite) {
+ managedForm = new ManagedForm(composite) {
- @Override
- public void dirtyStateChanged() {
- dirty.setDirty(true);
- }
+ @Override
+ public void dirtyStateChanged() {
+ dirty.setDirty(true);
+ }
- @Override
- public boolean setInput(Object input) {
- if (input instanceof AbstractGroupedContainerE4) {
- TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData();
- if(selection!=newSelection || TaxonNameEditorE4.this.isDirty()){
- selection = newSelection;
- selService.setSelection(new StructuredSelection(selection));
- }
- }else if(input == null){
- selection = null;
+ @Override
+ public boolean setInput(Object input) {
+ if (input instanceof AbstractGroupedContainerE4) {
+ TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData();
+ if (selection != newSelection || TaxonNameEditorE4.this.isDirty()) {
+ selection = newSelection;
+ selService.setSelection(new StructuredSelection(selection));
+
+ }
+ } else if (input == null) {
+ selection = null;
selService.setSelection(new StructuredSelection());
- }
+ }
+ return super.setInput(input);
+ }
+ };
- return super.setInput(input);
- }
- };
-
- scrolledForm = managedForm.getForm();
- parent = scrolledForm.getBody();
-
- parent.setData(taxon);
+ scrolledForm = managedForm.getForm();
+ parent = scrolledForm.getBody();
- TableWrapLayout layout = new TableWrapLayout();
- layout.leftMargin = 0;
- layout.rightMargin = 0;
- layout.topMargin = 0;
- layout.bottomMargin = 0;
+ parent.setData(taxon);
- layout.verticalSpacing = 0;
- layout.horizontalSpacing = 0;
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.leftMargin = 0;
+ layout.rightMargin = 0;
+ layout.topMargin = 0;
+ layout.bottomMargin = 0;
- parent.setLayout(layout);
- parent.setBackground(AbstractUtility
- .getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
- }
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
- public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) {
+ parent.setLayout(layout);
+ parent.setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ }
+ public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) {
- if (accepted){
+ if (accepted) {
ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this);
}
- if (heterotypicGroups){
+ if (heterotypicGroups) {
ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this);
}
- if (misappliedNames){
+ if (misappliedNames) {
ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this);
}
ContainerFactoryE4.setMenuToAllContainers(this);
+ // Redraw composite
+ parent.pack();
+ managedForm.refresh();
+ managedForm.reflow(true);
+ }
- // Redraw composite
- parent.pack();
- managedForm.refresh();
- managedForm.reflow(true);
-
-
- }
-
- @Override
+ @Override
public Taxon getTaxon() {
- return HibernateProxyHelper.deproxy(taxon);
- }
+ return HibernateProxyHelper.deproxy(taxon);
+ }
- public void setDirty() {
- managedForm.dirtyStateChanged();
- }
+ public void setDirty() {
+ managedForm.dirtyStateChanged();
+ }
- @Focus
- public void setFocus() {
- //make sure to bind again if maybe in another view the conversation was unbound
- if(conversation!=null && !conversation.isBound()){
+ @Focus
+ public void setFocus() {
+ // make sure to bind again if maybe in another view the conversation was
+ // unbound
+ if (conversation != null && !conversation.isBound()) {
conversation.bind();
}
- if(input!=null){
- if (getSelectedContainer() == null) {
- throw new IllegalStateException(
- Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE);
- }
- getSelectedContainer().setSelected();
- if (!input.getCdmEntitySession().isActive()){
- input.bind();
- }
-
- // check permissions
- boolean doEnable = permissionsSatisfied();
- managedForm.getForm().setEnabled(doEnable);
- }
+ if (input != null) {
+ if (getSelectedContainer() == null) {
+ throw new IllegalStateException(Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE);
+ }
+ getSelectedContainer().setSelected();
+ if (!input.getCdmEntitySession().isActive()) {
+ input.bind();
+ }
+
+ // check permissions
+ boolean doEnable = permissionsSatisfied();
+ managedForm.getForm().setEnabled(doEnable);
+ }
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, this);
- }
+ }
- @Override
- public boolean permissionsSatisfied() {
- TaxonNode taxonNode = input.getTaxonNode();
- boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), RequiredPermissions.TAXON_EDIT);
- return doEnable;
- }
+ @Override
+ public boolean permissionsSatisfied() {
+ TaxonNode taxonNode = input.getTaxonNode();
+ boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(),
+ RequiredPermissions.TAXON_EDIT);
+ return doEnable;
+ }
- @Override
+ @Override
public ConversationHolder getConversationHolder() {
- return conversation;
- }
+ return conversation;
+ }
- /** {@inheritDoc} */
- @Override
+ /** {@inheritDoc} */
+ @Override
public void update(CdmDataChangeMap events) {
- // redraw();
- }
-
- /**
- * Redraws this editor return true on success
- *
- * @return a boolean.
- */
+ // redraw();
+ }
+
+ /**
+ * Redraws this editor return true on success
+ *
+ * @return a boolean.
+ */
public boolean redraw() {
- return redraw(true, true, true, true);
- }
-
- /**
- * {@inheritDoc}
- *
- * Redraws the editor controls
- */
+ return redraw(true, true, true, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Redraws the editor controls
+ */
public boolean redraw(boolean focus, boolean accepted, boolean heterotypic, boolean misappliedNames) {
- createOrUpdateNameComposites(accepted, heterotypic, misappliedNames);
+ createOrUpdateNameComposites(accepted, heterotypic, misappliedNames);
- if (focus) {
- setFocus();
- }
+ if (focus) {
+ setFocus();
+ }
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean postOperation(Object objectAffectedByOperation) {
+ if (objectAffectedByOperation instanceof TaxonBase) {
+ objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation;
+ }
+ onComplete();
+ redraw(true, true, true, true);
+ changed(objectAffectedByOperation);
+
+
+ return true;
+ }
+
+ public ManagedForm getManagedForm() {
+ return managedForm;
+ }
+
+ /**
+ * <p>
+ * checkForEmptyNames
+ * </p>
+ *
+ * @return true if there are empty names
+ */
+ public boolean checkForEmptyNames() {
+ for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
+ if (container != null
+ && (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache()))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Set<AbstractGroupedContainerE4> getEmptyContainers() {
+ Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>();
+
+ for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
+ if (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())) {
+ containersWithEmptyNames.add(container);
+ }
+ }
+
+ return containersWithEmptyNames;
+ }
- changed(objectAffectedByOperation);
-
- redraw(true, true,true, true);
-
- if (objectAffectedByOperation instanceof TaxonBase) {
- objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation;
- }
-
- return true;
- }
-
- public ManagedForm getManagedForm() {
- return managedForm;
- }
-
-
- /**
- * <p>
- * checkForEmptyNames
- * </p>
- *
- * @return true if there are empty names
- */
- public boolean checkForEmptyNames() {
- for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
- if (container != null && (container.getName() == null
- || StringUtils.isEmpty(container.getName().getTitleCache()))) {
- return true;
- }
- }
- return false;
- }
-
- public Set<AbstractGroupedContainerE4> getEmptyContainers() {
- Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>();
-
- for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
- if (container.getName() == null
- || StringUtils.isEmpty(container.getName().getTitleCache())) {
- containersWithEmptyNames.add(container);
- }
- }
-
- return containersWithEmptyNames;
- }
-
- /** {@inheritDoc} */
- @Override
+ /** {@inheritDoc} */
+ @Override
@Persist
- public void save(IProgressMonitor monitor) {
-
- monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size());
- if (!conversation.isBound()) {
- conversation.bind();
-
- }
- conversation.commit(true);
- monitor.worked(1);
-
- // check for empty names
- if (checkForEmptyNames()) {
- MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED,
- Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE);
- return;
- }
- for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
-
- monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES
- + container.getTaxonBase().getTitleCache());
- container.persistName();
- //because of missing cascading the concepts need to be saved separately
- if (container instanceof ConceptContainerE4){
- input.addToSaveNewConcept((Taxon)container.getData());
- }
- // In case the progress monitor was canceled throw an exception.
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- // Otherwise declare this step as done.
- monitor.worked(1);
-
- }
- input.setSync(sync);
- input.merge();
- // commit the conversation and start a new transaction immediately
+ public void save(IProgressMonitor monitor) {
+
+ monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size());
+ if (!conversation.isBound()) {
+ conversation.bind();
+
+ }
conversation.commit(true);
+ monitor.worked(1);
+
+ // check for empty names
+ if (checkForEmptyNames()) {
+ MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED,
+ Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE);
+ return;
+ }
+ for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
+
+ monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES + container.getTaxonBase().getTitleCache());
+ container.persistName();
+ // because of missing cascading the concepts need to be saved
+ // separately
+ if (container instanceof ConceptContainerE4) {
+ input.addToSaveNewConcept((Taxon) container.getData());
+ }
+ // In case the progress monitor was canceled throw an exception.
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ // Otherwise declare this step as done.
+ monitor.worked(1);
+
+ }
+ input.setSync(sync);
+ input.merge();
+ // commit the conversation and start a new transaction immediately
+ conversation.commit(true);
dirty.setDirty(false);
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true);
- // Stop the progress monitor.
- monitor.done();
- }
-
- public void init(TaxonEditorInputE4 input) {
- if (this.input != null){
- this.input.dispose();
-// this.acceptedGroup = null;
-// this.heterotypicSynonymGroups.clear();
-// this.misappliedGroup = null;
- }
- if (!(input != null)) {
+ // Stop the progress monitor.
+ monitor.done();
+ }
+
+ public void init(TaxonEditorInputE4 input) {
+ if (this.input != null) {
+ this.input.dispose();
+ // this.acceptedGroup = null;
+ // this.heterotypicSynonymGroups.clear();
+ // this.misappliedGroup = null;
+ }
+ if (!(input != null)) {
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT));
return;
}
- if (input.getAdapter(Taxon.class) != null) {
- taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
- } else {
- MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
- return;
- }
+ if (input.getAdapter(Taxon.class) != null) {
+ taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
+ } else {
+ MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
+ return;
+ }
- this.input = input;
- conversation = input.getConversationHolder();
+ this.input = input;
+ conversation = input.getConversationHolder();
createOrUpdateNameComposites(true, true, true);
setPartName();
- //set initial selection
+ // set initial selection
TaxonBase initiallySelectedTaxonBase = input.getInitiallySelectedTaxonBase();
- if(initiallySelectedTaxonBase!=null){
+ if (initiallySelectedTaxonBase != null) {
selService.setSelection(new StructuredSelection(initiallySelectedTaxonBase));
getContainer(initiallySelectedTaxonBase).setSelected();
}
- }
-
- private void createDragSupport() {
- // Listen for names being dragged outside of existing homotypic groups -
- // user wants to create a new group
- Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() };
- int operations = DND.DROP_MOVE;
- if (target == null) {
- target = new DropTarget(parent, operations);
- target.setTransfer(types);
- target.addDropListener(new NameEditorDropTargetListenerE4(this));
- }
- }
-
- public AcceptedNameContainerE4 getAcceptedNameContainer() {
- return getAcceptedGroup().getAcceptedNameContainer();
- }
-
- public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer(
- HomotypicalGroup homotypicalGroup) {
- for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) {
- if (group.getGroup().equals(homotypicalGroup)) {
- return group;
- }
- }
-
- return null;
- }
-
- /**
- * <p>
- * getDirtyNames
- * </p>
- *
- * @return a Set containing all composites that have been edited
- */
- public Set<AbstractGroupedContainerE4> getDirtyNames() {
- Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>();
-
- for (AbstractGroupedContainerE4 composite : getGroupedContainers()) {
- if (composite.isDirty()) {
- dirtyNames.add(composite);
- }
- }
-
- return dirtyNames;
- }
-
- public List<AbstractGroupedContainerE4> getGroupedContainers() {
- List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>();
-
- for (AbstractGroupE4 group : getAllGroups()) {
- if (group!= null){
- groupedComposites.addAll(group.getGroupedContainers());
- }
- }
-
- return groupedComposites;
- }
-
- public List<AbstractGroupE4> getAllGroups() {
- List<AbstractGroupE4> allGroups = new ArrayList<>();
-
- allGroups.add(getAcceptedGroup());
-
- heterotypicSynonymGroups = getHeterotypicSynonymGroups();
-
- if (heterotypicSynonymGroups != null) {
- allGroups.addAll(heterotypicSynonymGroups);
- }
-
- if (misappliedGroup != null) {
- allGroups.add(misappliedGroup);
- }
-
- return allGroups;
- }
-
- @Override
- public IEclipseContext getContext() {
- return context;
- }
-
- @Override
+ }
+
+ private void createDragSupport() {
+ // Listen for names being dragged outside of existing homotypic groups -
+ // user wants to create a new group
+ Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() };
+ int operations = DND.DROP_MOVE;
+ if (target == null) {
+ target = new DropTarget(parent, operations);
+ target.setTransfer(types);
+ target.addDropListener(new NameEditorDropTargetListenerE4(this));
+ }
+ }
+
+ public AcceptedNameContainerE4 getAcceptedNameContainer() {
+ return getAcceptedGroup().getAcceptedNameContainer();
+ }
+
+ public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer(HomotypicalGroup homotypicalGroup) {
+ for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) {
+ if (group.getGroup().equals(homotypicalGroup)) {
+ return group;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * <p>
+ * getDirtyNames
+ * </p>
+ *
+ * @return a Set containing all composites that have been edited
+ */
+ public Set<AbstractGroupedContainerE4> getDirtyNames() {
+ Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>();
+
+ for (AbstractGroupedContainerE4 composite : getGroupedContainers()) {
+ if (composite.isDirty()) {
+ dirtyNames.add(composite);
+ }
+ }
+
+ return dirtyNames;
+ }
+
+ public List<AbstractGroupedContainerE4> getGroupedContainers() {
+ List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>();
+
+ for (AbstractGroupE4 group : getAllGroups()) {
+ if (group != null) {
+ groupedComposites.addAll(group.getGroupedContainers());
+ }
+ }
+
+ return groupedComposites;
+ }
+
+ public List<AbstractGroupE4> getAllGroups() {
+ List<AbstractGroupE4> allGroups = new ArrayList<>();
+
+ allGroups.add(getAcceptedGroup());
+
+ heterotypicSynonymGroups = getHeterotypicSynonymGroups();
+
+ if (heterotypicSynonymGroups != null) {
+ allGroups.addAll(heterotypicSynonymGroups);
+ }
+
+ if (misappliedGroup != null) {
+ allGroups.add(misappliedGroup);
+ }
+
+ return allGroups;
+ }
+
+ @Override
+ public IEclipseContext getContext() {
+ return context;
+ }
+
+ @Override
public boolean isDirty() {
- return dirty.isDirty();
- }
+ return dirty.isDirty();
+ }
- @PreDestroy
- public void dispose() {
- if(conversation!=null){
+ @PreDestroy
+ public void dispose() {
+ if (conversation != null) {
conversation.unregisterForDataStoreChanges(this);
conversation.close();
}
- if(input!=null){
+ if (input != null) {
input.dispose();
}
dirty.setDirty(false);
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, null);
- }
+ }
- /** {@inheritDoc} */
- @Override
+ /** {@inheritDoc} */
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- System.err.println("Bla");
- }
+ System.err.println("Bla");
+ }
- public AbstractGroupedContainerE4 getSelectedContainer() {
- return (selection != null) ? getContainer(selection)
- : getAcceptedNameContainer();
- }
+ public AbstractGroupedContainerE4 getSelectedContainer() {
+ return (selection != null) ? getContainer(selection) : getAcceptedNameContainer();
+ }
@Override
public void dragEntered() {
// TODO change this
- getControl().setBackground(
- AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER));
+ getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER));
}
@Override
public void dragLeft() {
- getControl().setBackground(
- AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
}
+ public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) {
+ this.misappliedGroup = misappliedGroup;
+ }
- public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) {
- this.misappliedGroup = misappliedGroup;
- }
-
- public FormToolkit getToolkit() {
- return managedForm.getToolkit();
- }
+ public FormToolkit getToolkit() {
+ return managedForm.getToolkit();
+ }
- public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
- return heterotypicSynonymGroups;
- }
+ public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
+ return heterotypicSynonymGroups;
+ }
- public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
- heterotypicSynonymGroups.add(group);
- }
+ public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
+ heterotypicSynonymGroups.add(group);
+ }
- public AcceptedGroupE4 getAcceptedGroup() {
- return acceptedGroup;
- }
+ public AcceptedGroupE4 getAcceptedGroup() {
+ return acceptedGroup;
+ }
- public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
- this.acceptedGroup = acceptedGroup;
- }
+ public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
+ this.acceptedGroup = acceptedGroup;
+ }
- public MisappliedGroupE4 getMisappliedGroup() {
- return misappliedGroup;
- }
+ public MisappliedGroupE4 getMisappliedGroup() {
+ return misappliedGroup;
+ }
- public boolean isActive() {
- return this.equals(AbstractUtility.getActivePart());
- }
+ public boolean isActive() {
+ return this.equals(AbstractUtility.getActivePart());
+ }
@Override
public boolean onComplete() {
- getContainer(objectAffectedByLastOperation).setSelected();
- return true;
- }
+ getContainer(objectAffectedByLastOperation).setSelected();
+ return true;
+ }
- /** {@inheritDoc} */
- @Override
+ /** {@inheritDoc} */
+ @Override
public void partChanged(Integer eventType, IWorkbenchPartReference partRef) {
- if (!partRef.getPart(false).equals(this)) {
- // getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
- }
- }
-
- public void removeGroup(AbstractGroupE4 group) {
- if (group != null) {
- group.dispose();
-
- //if (heterotypicSynonymGroups != null) {
- heterotypicSynonymGroups.remove(group);
- //}
- }
- }
-
- public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
- @SuppressWarnings("rawtypes")
+ if (!partRef.getPart(false).equals(this)) {
+ // getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
+ }
+ }
+
+ public void removeGroup(AbstractGroupE4 group) {
+ if (group != null) {
+ group.dispose();
+
+ // if (heterotypicSynonymGroups != null) {
+ heterotypicSynonymGroups.remove(group);
+ // }
+ }
+ }
+
+ public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
+ @SuppressWarnings("rawtypes")
List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers();
- for (AbstractGroupedContainerE4 container : groupedContainers) {
- if (container.getData().equals(taxonBase)
- && container.getNameViewer().getTextWidget() != null) {
- return container;
- }
- }
- return getAcceptedNameContainer();
- }
+ for (AbstractGroupedContainerE4 container : groupedContainers) {
+ if (container.getData().equals(taxonBase) && container.getNameViewer().getTextWidget() != null) {
+ return container;
+ }
+ }
+ return getAcceptedNameContainer();
+ }
public void setOnError() {
- Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
- setEnabled(false, disabledColor);
- }
+ Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
+ setEnabled(false, disabledColor);
+ }
- public void setDisabled(){
- Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
- setEnabled(false, disabledColor);
- }
+ public void setDisabled() {
+ Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
+ setEnabled(false, disabledColor);
+ }
- protected void setEnabled(boolean enabled, Color background) {
+ protected void setEnabled(boolean enabled, Color background) {
- for(AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()){
- groupedContainer.setEnabled(enabled);
- }
+ for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
+ groupedContainer.setEnabled(enabled);
+ }
- // send an empty selection to the current provider - TODO only on error ???
- if (!enabled) {
- getManagedForm().setInput(null);
+ // send an empty selection to the current provider - TODO only on error
+ // ???
+ if (!enabled) {
+ getManagedForm().setInput(null);
- for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
- groupedContainer.setBackground(background);
- }
- }
- getControl().setBackground(background);
- }
+ for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
+ groupedContainer.setBackground(background);
+ }
+ }
+ getControl().setBackground(background);
+ }
@Override
public void changed(Object element) {
// setDirty(true);
- // if the attribute is null then do not set the dirty flag -> hotfix for the problem that for tasks done in service methods the changes are saved automatically
- if (element != null){
+ // if the attribute is null then do not set the dirty flag -> hotfix for
+ // the problem that for tasks done in service methods the changes are
+ // saved automatically
+ if (element != null) {
dirty.setDirty(true);
- //refresh part title
- //TODO: refresh taxon node in taxon navigator
+ // refresh part title
+ // TODO: refresh taxon node in taxon navigator
setPartName();
}
}
}
- public void setPartName(){
- //FIXME: temporary fix for #6437 to avoid outdated title caches
+ public void setPartName() {
+ // FIXME: temporary fix for #6437 to avoid outdated title caches
thisPart.setLabel(this.taxon.getName().generateFullTitle());
-// thisPart.setLabel(this.taxon.getName().getFullTitleCache());
+ // thisPart.setLabel(this.taxon.getName().getFullTitleCache());
}
@Override
setDirty();
}
-
public IUndoContext getUndoContext() {
return undoContext;
}
@Override
- public Composite getControl(){
+ public Composite getControl() {
return managedForm.getForm().getBody();
}
return selService;
}
-
/**
* {@inheritDoc}
*/
@Inject
@Optional
- private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)CdmBase cdmbase){
+ private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) CdmBase cdmbase) {
- if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this)) || (this.taxon != null && (this.taxon.equals(cdmbase) || (this.taxon.getName() != null && this.taxon.getName().equals(cdmbase))))){
+ if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this))
+ || (this.taxon != null && (this.taxon.equals(cdmbase)
+ || (this.taxon.getName() != null && this.taxon.getName().equals(cdmbase))))) {
this.redraw(false, true, true, true);
this.setDirty();
- if (cdmbase instanceof TaxonBase){
+ if (cdmbase instanceof TaxonBase) {
this.selection = (TaxonBase) cdmbase;
}
-
}
}
@Inject
@Optional
- private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)UUID cdmbaseUuid){
+ private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) UUID cdmbaseUuid) {
- if (this.taxon.getUuid().equals(cdmbaseUuid)){
+ if (this.taxon.getUuid().equals(cdmbaseUuid)) {
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(cdmbaseUuid);
init(input);
}
@Inject
@Optional
- private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.DELETE_DERIVATIVE)DeleteResult result){
- if(taxon.getName()==null){
+ private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.DELETE_DERIVATIVE) DeleteResult result) {
+ if (taxon.getName() == null) {
return;
}
Set<DerivedUnit> typeDesignationSpecimens = new HashSet<>();
- this.taxon.getName().getSpecimenTypeDesignations().forEach(designation->typeDesignationSpecimens.add(designation.getTypeSpecimen()));
- //check if any deleted object was a type specimen
- if(result.getUpdatedObjects().stream()
- //filter only DerivedUnits
- .filter(cdmBase->cdmBase.isInstanceOf(DerivedUnit.class))
- //deproxy from CdmBase to DerivedUnit
- .map(unit->HibernateProxyHelper.deproxy(unit, DerivedUnit.class))
- //check for match in type designations
- .anyMatch(unit->typeDesignationSpecimens.contains(unit))){
- EditorUtil.updateEditor(this.input.getTaxonNode(), this);
+ this.taxon.getName().getSpecimenTypeDesignations()
+ .forEach(designation -> typeDesignationSpecimens.add(designation.getTypeSpecimen()));
+ // check if any deleted object was a type specimen
+ if (result.getUpdatedObjects().stream()
+ // filter only DerivedUnits
+ .filter(cdmBase -> cdmBase.isInstanceOf(DerivedUnit.class))
+ // deproxy from CdmBase to DerivedUnit
+ .map(unit -> HibernateProxyHelper.deproxy(unit, DerivedUnit.class))
+ // check for match in type designations
+ .anyMatch(unit -> typeDesignationSpecimens.contains(unit))) {
+ EditorUtil.updateEditor(this.input.getTaxonNode(), this);
}
-
-
-
}
}