List of usage examples for java.util Observable addObserver
public synchronized void addObserver(Observer o)
From source file:com.android.aft.AFApplicationHelper.activity.AFFragmentActivity.java
protected void addObservers() { for (final Observable obs : mLstObservables) { obs.addObserver(this); }/* w ww . ja v a 2s. c o m*/ }
From source file:org.apache.solr.kelvin.ScorerLoader.java
public void registerScorersAsObservers(Observable target) { for (IConfigurable s : resources) { Scorer scorer = (Scorer) s;// w ww . j a v a 2 s . co m target.addObserver(scorer); } }
From source file:ca.sfu.federation.model.Behavior.java
public void setHost(INamed Named) { this.host = Named; this.context = Named.getContext(); if (context instanceof Observable) { Observable observable = (Observable) context; observable.addObserver(this); }//from ww w . j ava 2 s.com }
From source file:ca.sfu.federation.viewer.propertysheet.BehaviorPropertySheet.java
private void setValues() { // target/*from w ww. j av a2 s . co m*/ this.target = (Assembly) Application.getContext().getViewState(ApplicationContext.VIEWER_SELECTION); // listen for changes on the target if (this.target instanceof Observable) { Observable o = (Observable) this.target; o.addObserver(this); } // set field values this.lblINamedObject.setText(this.target.getName()); this.jtfClass.setText(this.target.getClass().toString()); this.jtfName.setText(this.target.getName()); this.jtfCanonicalName.setText(this.target.getCanonicalName()); }
From source file:ca.sfu.federation.viewer.propertysheet.ScenarioPropertySheet.java
private void setValues() { // target/*from ww w. ja va 2 s . co m*/ this.target = (Scenario) Application.getContext().getViewState(ApplicationContext.VIEWER_SELECTION); // listen for changes on the target if (this.target instanceof Observable) { Observable o = (Observable) this.target; o.addObserver(this); } // set field values this.lblINamedObject.setText(this.target.getName()); this.jtfClass.setText(this.target.getClass().toString()); this.jtfName.setText(this.target.getName()); this.jtfCanonicalName.setText(this.target.getCanonicalName()); this.jtfParentContext.setText(this.target.getContext().getName()); }
From source file:ca.sfu.federation.viewer.propertysheet.AssemblyPropertySheet.java
private void setValues() { // target/*from w w w .j a v a 2 s .co m*/ this.target = (Assembly) Application.getContext().getViewState(ApplicationContext.VIEWER_SELECTION); // listen for changes on the target if (this.target instanceof Observable) { Observable o = (Observable) this.target; o.addObserver(this); } // set field values this.lblINamedObject.setText(this.target.getName()); this.jtfClass.setText(this.target.getClass().toString()); this.jtfName.setText(this.target.getName()); this.jtfCanonicalName.setText(this.target.getCanonicalName()); this.jtfParentContext.setText(this.target.getContext().getName()); }
From source file:ca.sfu.federation.model.ParametricModel.java
/** * Add a named object to the context.// w w w . j a v a 2 s . c om * @param Named Named object * @throws IllegalArgumentException An object identified by the same name already exists in the Context. */ public void add(INamed Named) throws IllegalArgumentException { Map elementsByName = getElementMap(); if (!elementsByName.containsKey(Named.getName())) { // add object elements.add(Named); // observe element for changes if (Named instanceof Observable) { Observable o = (Observable) Named; o.addObserver(this); } // notify observers of change this.setChanged(); this.notifyObservers(Integer.valueOf(ApplicationContext.EVENT_ELEMENT_ADD)); } else { throw new IllegalArgumentException( "An object identified by the same name already exists in the Context."); } }
From source file:ca.sfu.federation.viewer.propertysheet.CoordinateSystemPropertySheet.java
private void setValues() { // target/*from w w w. j a v a 2s .c o m*/ this.target = (Component) Application.getContext().getViewState(ApplicationContext.VIEWER_SELECTION); // listen for changes on the target if (this.target instanceof Observable) { Observable o = (Observable) this.target; o.addObserver(this); } // set field values this.lblINamedObject.setText(this.target.getName()); this.jtfClass.setText(this.target.getClass().toString()); this.jtfName.setText(this.target.getName()); // this.jtfDescription.setText(this.target.getDescription()); this.jtfCanonicalName.setText(this.target.getCanonicalName()); this.jtfParentContext.setText(this.target.getContext().getName()); List<Method> methods = this.target.getUpdateMethods(); Iterator<Method> it = methods.iterator(); while (it.hasNext()) { Method method = it.next(); jcbUpdateMethod.addItem(method.getName()); } }
From source file:ca.sfu.federation.model.Assembly.java
/** * Add a NamedObject./*w ww . j a v a2 s .co m*/ * @param Named NamedObject to be added. * @throws IllegalArgumentException An object identified by the same name already exists in the Context. */ @Override public void add(INamed Named) throws IllegalArgumentException { LinkedHashMap elementsByName = (LinkedHashMap) this.getElementMap(); if (!elementsByName.containsKey(Named.getName())) { // add object this.elements.add(Named); // observe element for changes if (Named instanceof Observable) { Observable o = (Observable) Named; o.addObserver(this); } // notify observers of change this.setChanged(); this.notifyObservers(Integer.valueOf(ApplicationContext.EVENT_ELEMENT_ADD)); } else { throw new IllegalArgumentException( "An object identified by the same name already exists in the Context."); } }
From source file:ca.sfu.federation.viewer.propertysheet.LinePropertySheet.java
private void setValues() { // target/*from ww w . j av a 2 s.c om*/ this.target = (Line) Application.getContext().getViewState(ApplicationContext.VIEWER_SELECTION); // set field values this.lblINamedObject.setText(this.target.getName()); this.jtfClass.setText(this.target.getClass().toString()); this.jtfName.setText(this.target.getName()); // this.jtfDescription.setText(this.target.getDescription()); this.jtfCanonicalName.setText(this.target.getCanonicalName()); this.jtfParentContext.setText(this.target.getContext().getName()); try { BeanProxy proxy = new BeanProxy(this.target); IPoint startPoint = (IPoint) proxy.get("startPoint"); IPoint midPoint = (IPoint) proxy.get("startPoint"); IPoint endPoint = (IPoint) proxy.get("startPoint"); Double length = (Double) proxy.get("length"); this.jtfStartPoint.setText(String.valueOf(startPoint)); this.jtfMidPoint.setText(String.valueOf(midPoint)); this.jtfEndPoint.setText(String.valueOf(endPoint)); this.jtfLength.setText(String.valueOf(length)); } catch (Exception ex) { String stack = ExceptionUtils.getFullStackTrace(ex); logger.log(Level.WARNING, "{0}", stack); } ArrayList<String> methodNameList = new ArrayList<String>(); List<Method> methods = this.target.getUpdateMethods(); Iterator<Method> it = methods.iterator(); while (it.hasNext()) { Method method = it.next(); String name = method.getName(); methodNameList.add(name); } DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(methodNameList.toArray()); jcbUpdateMethod.setModel(comboBoxModel); String selected = this.target.getUpdateMethodName(); jcbUpdateMethod.setSelectedItem(selected); // build the input panel this.buildUpdateMethodInputsPanel(); // listen for changes on the target if (this.target instanceof Observable) { Observable o = (Observable) this.target; o.addObserver(this); } }