protected void init() { prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus"); IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus"); default_visibility = prefs.get(BTSCorpusConstants.PREF_LEMMA_DEFAULT_VISIBILITY, null); default_reviewState = prefs.get(BTSCorpusConstants.PREF_LEMMA_DEFAULT_REVIEWSTATE, null); object = BtsCorpusModelFactory.eINSTANCE.createBTSTCObject(); object.setVisibility(default_visibility); object.setRevisionState(default_reviewState); DataBindingContext bindingContext = new DataBindingContext(); // visibility EMFUpdateValueStrategy targetToModel_vis = new EMFUpdateValueStrategy(); targetToModel_vis.setConverter(new BTSConfigItemToStringConverter()); EMFUpdateValueStrategy modelToTarget_vis = new EMFUpdateValueStrategy(); modelToTarget_vis.setConverter(new BTSStringToConfigItemConverter(visibility_viewer)); IObservableValue target_vis_viewer = ViewersObservables.observeSingleSelection(visibility_viewer); Binding binding_vis = bindingContext.bindValue( target_vis_viewer, EMFProperties.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__VISIBILITY) .observe(object), targetToModel_vis, modelToTarget_vis); // review status EMFUpdateValueStrategy targetToModel_rev = new EMFUpdateValueStrategy(); targetToModel_rev.setConverter(new BTSConfigItemToStringConverter()); EMFUpdateValueStrategy modelToTarget_rev = new EMFUpdateValueStrategy(); modelToTarget_rev.setConverter(new BTSStringToConfigItemConverter(reviewState_viewer)); IObservableValue target_rev_viewer = ViewersObservables.observeSingleSelection(reviewState_viewer); Binding binding_rev = bindingContext.bindValue( target_rev_viewer, EMFProperties.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__REVISION_STATE) .observe(object), targetToModel_rev, modelToTarget_rev); super.initialize(); }
@Override public boolean performOk() { boolean dirty = false; if (object != null && object.getVisibility() != null && !object.getVisibility().equals(default_visibility)) { ConfigurationScope.INSTANCE .getNode("org.bbaw.bts.ui.corpus") .put(BTSCorpusConstants.PREF_LEMMA_DEFAULT_VISIBILITY, object.getVisibility()); // update instance scope so that new value is injected InstanceScope.INSTANCE .getNode("org.bbaw.bts.ui.corpus") .put(BTSCorpusConstants.PREF_LEMMA_DEFAULT_VISIBILITY, object.getVisibility()); dirty = true; } if (object != null && object.getRevisionState() != null && !object.getRevisionState().equals(default_reviewState)) { ConfigurationScope.INSTANCE .getNode("org.bbaw.bts.ui.corpus") .put(BTSCorpusConstants.PREF_LEMMA_DEFAULT_REVIEWSTATE, object.getRevisionState()); // update instance scope so that new value is injected InstanceScope.INSTANCE .getNode("org.bbaw.bts.ui.corpus") .put(BTSCorpusConstants.PREF_LEMMA_DEFAULT_REVIEWSTATE, object.getRevisionState()); dirty = true; } if (dirty) { try { ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus").flush(); } catch (BackingStoreException e) { } try { InstanceScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus").flush(); } catch (BackingStoreException e) { } } return super.performOk(); }