import java.util.Collection;
+import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.TableViewer;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.IContextListener;
-import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
+import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
* @date 20.09.2013
*
*/
-public abstract class DataImportEditor<T extends IIdentifiableEntity> extends EditorPart implements IPartContentHasFactualData, IDirtyMarkableSelectionProvider,
+public abstract class DataImportEditor<T> extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener{
+ protected Logger logger = Logger.getLogger(DataImportEditor.class);
+
private ConversationHolder conversation;
private TableViewer tableViewer;
/**
- * Constructs a new DataImportEditor with a new {@link ConversationHolder}
+ * Constructs a new DataImportEditor and registers it to listen to context changes
*/
public DataImportEditor() {
- CdmStore.getContextManager().addContextListener(this);
}
/* (non-Javadoc)
public void createPartControl(Composite parent) {
Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
- table.setHeaderVisible(true);//TODO: set header title as BioCase query
+ table.setHeaderVisible(true);//TODO: set header title as query
table.setLinesVisible(true);
tableViewer = new TableViewer(table);
*/
@Override
public void setFocus() {
+ tableViewer.getControl().setFocus();
//make sure to bind again if maybe in another view the conversation was unbound
if(!conversation.isBound()){
conversation.bind();
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ CdmStore.getContextManager().addContextListener(this);
setSite(site);
setInput(input);
setPartName(input.getName());
setTitleToolTip(input.getName());
- conversation = ((DataImportEditorInput)input).getConversationHolder();
+ conversation = ((DataImportEditorInput<T>)input).getConversationHolder();
}
/* (non-Javadoc)
IEditorInput editorInput = getEditorInput();
setInput(editorInput);
if(editorInput instanceof DataImportEditorInput){
- tableViewer.getTable().clearAll();
+ tableViewer.getTable().removeAll();
Collection<T> results = ((DataImportEditorInput<T>) editorInput).getResults();
if(results!=null){
- for(T specimen:results){
+ for(T item:results){
TableItem tableItem = new TableItem(tableViewer.getTable(), SWT.NONE);
- tableItem.setText(specimen.generateTitle());
- tableItem.setData(specimen);
+ tableItem.setText(getTextForTableItem(item));
+ tableItem.setData(item);
}
}
}
}
+ /**
+ * Returns the text label of the given item.
+ * @param item the item for which the label should be returnes
+ * @return the label of the item
+ */
+ protected abstract String getTextForTableItem(T item);
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.IContextListener#workbenchShutdown(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
- if(conversation!=null &&!conversation.isClosed()) {
+ if(conversation!=null && conversation.isBound() && !conversation.isClosed()) {
conversation.close();
}
}
// cannot be changed
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
+ */
+ @Override
+ public void forceDirty() {
+ // cannot be dirty
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
*/