X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/3d6c9acc014b267446568f6c95cbae60dff59dd3..2d3da144847ad9fff96bc748db536b981ebf566e:/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java index 5048cf7fb..5b7b601e7 100644 --- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java +++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java @@ -10,6 +10,7 @@ package eu.etaxonomy.taxeditor.bulkeditor; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; @@ -41,20 +42,22 @@ import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation; import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel; import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; -import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider; +import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput; +import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart; +import eu.etaxonomy.taxeditor.model.IDirtyMarkable; import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; -import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; +import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; +import eu.etaxonomy.taxeditor.model.IPartContentHasMedia; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.store.CdmStore; /** - *

BulkEditor class.

- * * @author p.ciardelli * @created 07.07.2009 * @version 1.0 */ -public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDetails, IDirtyMarkableSelectionProvider{ +public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDetails, + IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData, IPartContentHasMedia { /** Constant ID="bulkeditor.editor" */ public static final String ID = "bulkeditor.editor"; @@ -65,16 +68,12 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe private IPropertyChangeListener markerPreferenceListener; - /** - *

Constructor for BulkEditor.

- */ + private boolean isDirty; + public BulkEditor() { super(CdmStore.createConversation()); } - /* (non-Javadoc) - * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor() - */ /** {@inheritDoc} */ @Override protected void initializeEditor() { @@ -92,9 +91,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe setSourceViewerConfiguration(new BulkEditorViewerConfiguration(lineDisplayStrategy)); } - /* (non-Javadoc) - * @see eu.etaxonomy.taxeditor.bulkeditor.ListEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int) - */ /** {@inheritDoc} */ @Override protected ISourceViewer createSourceViewer(Composite parent, @@ -106,9 +102,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe return viewer; } - /* (non-Javadoc) - * @see eu.etaxonomy.taxeditor.bulkeditor.AnnotatedLineEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) - */ /** {@inheritDoc} */ @Override public void init(IEditorSite site, IEditorInput input) @@ -121,9 +114,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe super.init(site, input); } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite) - */ /** {@inheritDoc} */ @Override public void createPartControl(Composite parent) { @@ -153,9 +143,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe } } - /* (non-Javadoc) - * @see org.eclipse.ui.editors.text.TextEditor#dispose() - */ /** {@inheritDoc} */ @Override public void dispose() { @@ -165,21 +152,17 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe super.dispose(); } - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isEditable() - */ + /** {@inheritDoc} */ @Override public boolean isEditable() { return false; } - /* (non-Javadoc) - * @see eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor#setFocus() - */ /** {@inheritDoc} */ @Override public void setFocus() { + conversation.bind(); searchBar.setFocus(); // TODO find a better place to put this - this dialog should be shown after initial contents of @@ -188,29 +171,24 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe displayWarningDialog(); isInitialFocus = false; } + super.setFocus(); } - /** - * - */ private void displayWarningDialog() { IPreferenceStore prefs = PreferencesUtil.getPreferenceStore(); - if (!prefs.getBoolean(IPreferenceKeys.HIDE_BULKEDITOR_INFO)) { + if (!prefs.getBoolean(PreferencesUtil.HIDE_BULKEDITOR_INFO)) { String msg = "The Bulk Editor allows you to edit objects used to reference other objects, such as names, references, and authors.\n\n" + "Any changes you make to an object in the Bulk Editor will be displayed wherever the object is used.\n\n" + "For instance, a reference may be displayed with both a name and a descriptive element. If the reference name is changed here, the display of both the name and the descriptive element will be affected."; MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm (getSite().getShell(), "Bulk Editor", msg, "Do not show this message again", - false, null, IPreferenceKeys.HIDE_BULKEDITOR_INFO); + false, null, PreferencesUtil.HIDE_BULKEDITOR_INFO); if (dialog.getReturnCode() == Window.OK) { - prefs.setValue(IPreferenceKeys.HIDE_BULKEDITOR_INFO, dialog.getToggleState()); + prefs.setValue(PreferencesUtil.HIDE_BULKEDITOR_INFO, dialog.getToggleState()); } } } - /** - * @param control - */ private void addToggleMergeCandidateListener(Control control) { control.addMouseListener(new MouseAdapter() { @Override @@ -222,11 +200,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe }); } - /** - *

toggleMergeCandidateAnnotation

- * - * @param line a int. - */ public void toggleMergeCandidateAnnotation(int line) { IDocument document = getSourceViewer().getDocument(); @@ -248,6 +221,34 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe } } + @Override + public boolean isDirty() { + if(isDirty){ + return isDirty; + } + else{ + return super.isDirty(); + } + } + + @Override + public void forceDirty(){ + isDirty = true; + firePropertyChange(PROP_DIRTY); + } + + @Override + public void doSave(IProgressMonitor progressMonitor) { + isDirty = false; + + super.doSave(progressMonitor); + + selectFirstItem(); + + getSourceViewer().getTextWidget().setFocus(); + + } + /** {@inheritDoc} */ @Override public void changed(Object object) { @@ -257,9 +258,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe // firePropertyChange(PROP_DIRTY); } - /* (non-Javadoc) - * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) - */ /** {@inheritDoc} */ public void performSearch(BulkEditorQuery query) { if (query != null) { @@ -274,6 +272,8 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe return; } } + conversation.commit(); + conversation.clear(); getEditorInput().performSearch(query); @@ -290,9 +290,6 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe getSelectionProvider().setSelection(selection); } - /** - * - */ public void refresh() { if(getDocumentProvider().getAnnotationModel(getEditorInput()) != null){ ((AnnotationModel) getDocumentProvider().getAnnotationModel(getEditorInput())).removeAllAnnotations(); @@ -314,4 +311,9 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe menu.remove(ITextEditorActionConstants.SHIFT_LEFT); menu.remove(ITextEditorActionConstants.CONTEXT_PREFERENCES); } + + @Override + public boolean canAttachMedia() { + return getEditorInput() instanceof TaxonEditorInput?true:false; + } }