List of usage examples for java.beans Customizer setObject
void setObject(Object bean);
From source file:org.apache.jmeter.testbeans.gui.TestBeanGUI.java
/** * Get values from element to fill propertyMap and setup customizer * @param element TestElement//w w w . j a v a2 s.c o m */ private void setValues(TestElement element) { // Copy all property values into the map: for (PropertyIterator jprops = element.propertyIterator(); jprops.hasNext();) { JMeterProperty jprop = jprops.next(); propertyMap.put(jprop.getName(), jprop.getObjectValue()); } if (customizer != null) { customizer.setObject(propertyMap); } else { if (initialized) { remove(customizerIndexInPanel); } Customizer c = customizers.get(element); if (c == null) { c = createCustomizer(); c.setObject(propertyMap); customizers.put(element, c); } add((Component) c, BorderLayout.CENTER); } }
From source file:org.eclipse.wb.internal.swing.customize.CustomizerAction.java
private void performCustomize0() throws Exception { Customizer customizer = m_customizerClass.newInstance(); // prepare properties information final JavaInfoState javaInfoState = JavaInfoState.getState(m_javaInfo); boolean explicit = isExplicitPropertyChange(m_javaInfo); PropertyChangeListener propertyChangeListener = null; if (explicit) { propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { javaInfoState.changedProperties.add(event.getPropertyName()); javaInfoState.changedPropertyValues.put(event.getPropertyName(), event.getNewValue()); }/* w ww . j a va 2 s . co m*/ }; customizer.addPropertyChangeListener(propertyChangeListener); } // try { // open customizer dialog customizer.setObject(javaInfoState.object); AwtComponentDialog dialog = new AwtComponentDialog(DesignerPlugin.getDefault(), (Component) customizer, ModelMessages.CustomizerAction_dialogTitle, MessageFormat .format(ModelMessages.CustomizerAction_dialogMessage, m_customizerClass.getName())); int dialogResult = dialog.open(); // handle update properties if (dialogResult == Window.OK) { RunnableEx runnable = null; if (explicit) { // update changed properties runnable = new RunnableEx() { public void run() throws Exception { int size = javaInfoState.properties.size(); for (int i = 0; i < size; i++) { Property property = javaInfoState.properties.get(i); if (javaInfoState.changedProperties.contains(property.getTitle())) { Object newValue = javaInfoState.changedPropertyValues.get(property.getTitle()); Object oldValue = javaInfoState.oldValues.get(i); if (!ObjectUtils.equals(newValue, oldValue)) { property.setValue(newValue); } } } } }; } else { // update all properties runnable = new RunnableEx() { public void run() throws Exception { int size = javaInfoState.properties.size(); for (int i = 0; i < size; i++) { Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object); Object oldValue = javaInfoState.oldValues.get(i); if (!ObjectUtils.equals(newValue, oldValue)) { javaInfoState.properties.get(i).setValue(newValue); } } } }; } // run update ExecutionUtils.run(m_javaInfo, runnable); } // rollback property changes if (dialogResult == Window.CANCEL) { ExecutionUtils.run(m_javaInfo, new RunnableEx() { public void run() throws Exception { int size = javaInfoState.properties.size(); for (int i = 0; i < size; i++) { Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object); Object oldValue = javaInfoState.oldValues.get(i); if (!ObjectUtils.equals(newValue, oldValue)) { javaInfoState.setters.get(i).invoke(javaInfoState.object, oldValue); } } } }); } } finally { if (propertyChangeListener != null) { customizer.removePropertyChangeListener(propertyChangeListener); } } }