setActiveSession(null);
}
ownerSessionMap.remove(owner);
+ notifyObservers();
}
if(nullSession != null && nullSession.getOwner() == owner) {
nullSession = null;
}
- notifyObservers();
- }
- @Override
- public void disposeNullSession() {
- nullSession = null;
- notifyObservers();
}
+
@Override
public void disposeAll() {
Set<ICdmEntitySessionEnabled> owners =
session.dispose();
}
}
- notifyObservers();
+
}
void addToOwnerSessionMap(ICdmEntitySessionEnabled owner, ICdmEntitySession session) {
ownerSessionMap.put(owner, session);
+ notifyObservers();
}
/* (non-Javadoc)
*/
public ICdmEntitySession getNullSession();
- /**
- *
- */
- public void disposeNullSession();
}
\ No newline at end of file
return new MockCdmEntitySession();
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager#disposeNullSession()
- */
- @Override
- public void disposeNullSession() {
- // TODO Auto-generated method stub
-
- }
-
-
-
}
// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* <p>
* EditFeatureTreeWizardPage class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Aug 5, 2010
* @version 1.0
* <p>
* Constructor for EditFeatureTreeWizardPage.
* </p>
- *
+ *
* @param pageName
* a {@link java.lang.String} object.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
* .Composite)
* <p>
* setSelectedTree
* </p>
- *
+ *
* @param featureTree
* a {@link eu.etaxonomy.cdm.model.description.FeatureTree}
* object.
.getAdditionalFeatures();
for (Feature feature : additionalFeatures) {
FeatureNode child = FeatureNode.NewInstance(feature);
- CdmStore.getService(IFeatureNodeService.class)
- .saveOrUpdate(child);
+ if(CdmStore.getCurrentSessionManager().isRemoting()) {
+ CdmStore.getService(IFeatureNodeService.class).merge(child, true);
+ } else {
+ CdmStore.getService(IFeatureNodeService.class).saveOrUpdate(child);
+ }
parent.addChild(child);
}
viewer.refresh();
*/
@Override
public void dragFinished(DragSourceEvent event) {
- if (!event.doit)
- return;
+ if (!event.doit) {
+ return;
+ }
// if the featureNode was moved, remove it from the source viewer
if (event.detail == DND.DROP_MOVE) {
IStructuredSelection selection = (IStructuredSelection) viewer
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.featuretree;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.jface.wizard.Wizard;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @created Aug 5, 2010
* @version 1.0
*/
-public class FeatureTreeEditorWizard extends Wizard {
-
+public class FeatureTreeEditorWizard extends Wizard implements ICdmEntitySessionEnabled {
+
private SelectFeatureTreeWizardPage selectFeatureTreePage;
private EditFeatureTreeWizardPage editFeatureTreePage;
-
+
private FeatureTree selectedFeatureTree;
private ConversationHolder conversation;
-
+ private ICdmEntitySession cdmEntitySession;
+ private ICdmEntitySession previousCdmEntitySession;
+
/**
* <p>Constructor for FeatureTreeEditorWizard.</p>
*/
public FeatureTreeEditorWizard(){
conversation = CdmStore.createConversation();
+ previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
setWindowTitle("Feature Tree Editor");
}
-
+
/**
* <p>addPages</p>
*/
- public void addPages() {
+ @Override
+ public void addPages() {
selectFeatureTreePage = new SelectFeatureTreeWizardPage("SELECT");
addPage(selectFeatureTreePage);
-
+
editFeatureTreePage = new EditFeatureTreeWizardPage("EDIT");
addPage(editFeatureTreePage);
}
public boolean performFinish() {
try{
if (selectedFeatureTree != null){
- CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(selectedFeatureTree);
+ if(CdmStore.getCurrentSessionManager().isRemoting()) {
+ CdmStore.getService(IFeatureTreeService.class).merge(selectedFeatureTree, true);
+ } else {
+ CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(selectedFeatureTree);
+ }
}
conversation.commit();
}finally{
conversation.close();
+ cdmEntitySession.dispose();
+ if(previousCdmEntitySession != null) {
+ previousCdmEntitySession.bind();
+ }
}
-
+
return true;
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean performCancel() {
+ cdmEntitySession.dispose();
+ if(previousCdmEntitySession != null) {
+ previousCdmEntitySession.bind();
+ }
+ return true;
+ }
+
/**
* <p>Setter for the field <code>selectedFeatureTree</code>.</p>
*
public FeatureTree getSelectedFeatureTree() {
return selectedFeatureTree;
}
-
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+ */
+ @Override
+ public ICdmEntitySession getCdmEntitySession() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+ */
+ @Override
+ public List<FeatureTree> getRootEntities() {
+ return Arrays.asList(selectedFeatureTree);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+ */
+ @Override
+ public Map<Object, List<String>> getPropertyPathsMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
package eu.etaxonomy.taxeditor.preference;
-import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
* @created Aug 5, 2010
* @version 1.0
*/
-public class FeatureTreePreferences extends PreferencePage implements
+public class FeatureTreePreferences extends CdmPreferencePage implements
IWorkbenchPreferencePage {
/**
import java.util.Map;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
*/
public abstract class CdmPreferencePage extends PreferencePage implements ICdmEntitySessionEnabled {
+ private ICdmEntitySession previousCdmEntitySession;
+ private boolean isApply;
+
public CdmPreferencePage() {
- bindNullSession();
+ initSession();
}
public CdmPreferencePage(String title) {
super(title);
+ initSession();
+ }
+
+ public CdmPreferencePage(String title, ImageDescriptor image) {
+ super(title, image);
+ initSession();
+ }
+
+ private void initSession() {
+ previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
bindNullSession();
}
}
}
- protected void disposeNullSession() {
- if(CdmStore.isActive()) {
- CdmStore.getCurrentSessionManager().disposeNullSession();
- }
- }
-
@Override
public boolean performOk() {
- disposeNullSession();
+ if(previousCdmEntitySession != null && !isApply) {
+ previousCdmEntitySession.bind();
+ }
return super.performOk();
}
@Override
public boolean performCancel() {
- disposeNullSession();
+ if(previousCdmEntitySession != null) {
+ previousCdmEntitySession.bind();
+ }
return super.performCancel();
}
- /* (non-Javadoc)
+ @Override
+ public void performApply() {
+ isApply = true;
+ super.performApply();
+ isApply = false;
+ }
+
+ /* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
*/
@Override