Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:ru.org.sevn.audiobookplayer.AppService.java

@Override
public void propertyChange(PropertyChangeEvent event) {
    saveSettings(event.getPropertyName());
}

From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java

@Override
protected PropertyChangeListener getPCLForWorker() {
    return new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if ("progress".equals(evt.getPropertyName())) {
                if (progress != null)
                    progress.setValue((Integer) evt.getNewValue());
            }/*from  w  ww . j  a va2 s  .c o m*/
        }
    };
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java

/**
 * // w w w . j ava  2s  .  co  m
 */
private void importSchema(final boolean doLocalization) {
    FileDialog fileDlg = new FileDialog((Dialog) null);
    fileDlg.setTitle(getResourceString(doLocalization ? SL_CHS_LOC : SL_CHS_IMP));
    UIHelper.centerAndShow(fileDlg);

    String fileName = fileDlg.getFile();
    if (StringUtils.isNotEmpty(fileName)) {
        String title = getResourceString(doLocalization ? "SL_L10N_SCHEMA" : "SL_IMPORT_SCHEMA");

        final File file = new File(fileDlg.getDirectory() + File.separator + fileName);
        final SimpleGlassPane glassPane = new SimpleGlassPane(title, 18);
        glassPane.setBarHeight(12);
        glassPane.setFillColor(new Color(0, 0, 0, 85));

        setGlassPane(glassPane);
        glassPane.setVisible(true);

        SwingWorker<Integer, Integer> importWorker = new SwingWorker<Integer, Integer>() {
            private boolean isOK = false;

            @Override
            protected Integer doInBackground() throws Exception {
                DataProviderSessionIFace localSession = null;
                try {
                    localSession = DataProviderFactory.getInstance().createSession();

                    localSession.beginTransaction();

                    BuildSampleDatabase bsd = new BuildSampleDatabase();

                    Discipline discipline = localSession.get(Discipline.class,
                            AppContextMgr.getInstance().getClassObject(Discipline.class).getId());

                    isOK = bsd.loadSchemaLocalization(discipline, schemaType, DBTableIdMgr.getInstance(), null, //catFmtName,
                            null, //accFmtName,
                            doLocalization ? UpdateType.eLocalize : UpdateType.eImport, // isDoingUpdate
                            file, // external file
                            glassPane, localSession);
                    if (isOK) {
                        localSession.commit();
                    } else {
                        localSession.rollback();
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildSampleDatabase.class, ex);

                } finally {
                    if (localSession != null) {
                        localSession.close();
                    }
                }

                return null;
            }

            @Override
            protected void done() {
                super.done();

                glassPane.setVisible(false);

                if (isOK) {
                    UIRegistry.showLocalizedMsg("Specify.ABT_EXIT");
                    CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit"));
                }
            }
        };
        importWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                }
            }
        });
        importWorker.execute();
    }
}

From source file:FormattedTextFieldExample.java

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(FormattedTextField.FORMAT_PROPERTY)) {
        // Install the new format specification
        formatSpec = editor.getFormatSpec();

        // Recreate the View hierarchy
        modelChanged();// www.  ja  va 2s.  c  o  m
    }
}

From source file:org.polymap.core.data.ui.featureselection.FeatureSelectionView.java

public void createPartControl(@SuppressWarnings("hiding") Composite parent) {
    if (initLayer.get() != null) {
        init(initLayer.get());/*from ww  w.  ja v a  2s  . c  o m*/
    } else {
        if (layer == null) {
            log.warn("No layer set. Closing view...");
            Label msg = new Label(parent, SWT.NONE);
            msg.setText("No layer.");
            close(null);
        } else {
            init(layer);
        }
    }

    this.parent = parent;
    this.parent.setLayout(new FormLayout());

    // check fs -> error message
    if (fs == null) {
        Label msg = new Label(parent, SWT.NONE);
        msg.setText("No feature pipeline for layer: " + (layer != null ? layer.getLabel() : "???"));
        return;
    }

    viewer = new FeatureTableViewer(parent, SWT.MULTI);
    viewer.getTable().setLayoutData(new SimpleFormData().fill().create());

    viewer.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent ev) {
            if (ev.getPropertyName().equals(FeatureTableViewer.PROP_CONTENT_SIZE)) {
                Integer count = (Integer) ev.getNewValue();
                setPartName(basePartName + " (" + count + ")");
            }
        }
    });
    viewer.addSelectionChangedListener(this);

    // double-click
    viewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent ev) {
            log.info("doubleClick(): " + ev);
            //IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler( "org.polymap.rhei.OpenFormAction" );
            if (openAction != null) {
                openAction.run(null);
            }
        }
    });

    // columns
    assert fs != null : "fs not set. Call init() first.";
    SimpleFeatureType schema = fs.getSchema();
    for (PropertyDescriptor prop : schema.getDescriptors()) {
        if (Geometry.class.isAssignableFrom(prop.getType().getBinding())) {
            // skip Geometry
        } else {
            viewer.addColumn(new DefaultFeatureTableColumn(prop));
        }
    }

    viewer.getTable().pack(true);

    getSite().setSelectionProvider(viewer);
    hookContextMenu();

    loadTable(filter);
}

From source file:org.openmicroscopy.shoola.agents.measurement.view.ObjectInspector.java

/** Initializes the component composing the display. */
private void initComponents() {
    infoLabel = new JLabel(MAGNIFICATION + " is " + model.getDrawingView().getScaleFactor());
    //create the table
    fieldTable = new FigureTable(new FigureTableModel(attributeFields, COLUMN_NAMES));
    fieldTable.getTableHeader().setReorderingAllowed(false);
    fieldTable.setRowHeight(26);// ww w .  ja  va  2 s. c o m
    fieldTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fieldTable.setCellSelectionEnabled(true);
    fieldTable.setColumnSelectionAllowed(true);
    fieldTable.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            int col = fieldTable.getSelectedColumn();
            int row = fieldTable.getSelectedRow();
            Object value = fieldTable.getValueAt(row, col);
            if (e.getClickCount() == 1) {
                if (value instanceof Boolean) {
                    toggleValue();
                }
            } else if (e.getClickCount() > 1) {
                e.consume();
                if (value instanceof Color) {
                    //Only if the figure is not read only.
                    FigureTableModel ftm = (FigureTableModel) fieldTable.getModel();
                    ROIFigure figure = ftm.getFigure();
                    if (figure != null && !figure.isReadOnly())
                        if (figure.canEdit())
                            controller.showColorPicker((Color) value);
                } else if (value instanceof Boolean) {
                    toggleValue();
                }
            }
        }
    });
    fieldTable.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FigureTable.VALUE_CHANGED_PROPERTY.equals(name)) {
                handleValueChanged((String) evt.getNewValue());
            }
        }
    });
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java

/**
 * Listens to property to create a new container.
 */// w  ww . j ava  2  s.com
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (CreateFolderDialog.CREATE_FOLDER_PROPERTY.equals(name)) {
        String folderName = (String) evt.getNewValue();
        if (folderName != null && folderName.trim().length() > 0)
            create(folderName);
    }
}

From source file:org.pentaho.aggdes.ui.form.controller.ConnectionController.java

@RequestHandler
public void onLoad() throws Exception {
    BindingFactory bf = bindingFactory;//from w  w w .  ja  v  a2  s.  c  o m
    bf.setDocument(document);

    for (final SchemaProviderUiExtension extension : schemaProviders) {
        try {
            document.addOverlay(extension.getOverlayPath());
            getXulDomContainer().addEventHandler(extension);

            ((XulEventSource) extension).addPropertyChangeListener(new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    boolean schemaAppliable = false;
                    if (evt.getPropertyName().equals("schemaDefined")
                            || evt.getPropertyName().equals("selected")) {
                        logger.debug("*** got schemaDefined=" + evt.getNewValue()
                                + ", checking if any providers are applyable");
                        for (SchemaProviderUiExtension ex : schemaProviders) {

                            //De-select other extensions
                            if (evt.getPropertyName().equals("selected") && extension != ex
                                    && evt.getNewValue() == Boolean.TRUE) {
                                ex.setSelected(false);
                            }

                            if (ex.isSchemaDefined() && ex.isSelected()) {
                                logger.debug("provider " + ex.getName() + " is applyable");
                                schemaAppliable = true;
                            } else {
                                logger.debug(ex.getName() + " NOT applyable: defined=[" + ex.isSchemaDefined()
                                        + "] selected=[" + ex.isSelected() + "]");
                            }
                        }
                        connectionModel.setApplySchemaSourceEnabled(schemaAppliable);
                    }
                }

            });

            bf.setBindingType(Binding.Type.ONE_WAY);
            bf.createBinding(connectionModel, "schemaLocked", extension, "!enabled");

            //        extension.onLoad();
        } catch (XulException e) {
            logger.error("Error loading Schema Provider Overlay", e);
        }
    }

    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);

    bf.createBinding(workspace, "applicationUnlocked", "open_advisor", "!disabled");
    bf.createBinding(workspace, "applicationUnlocked", "open_export", "!disabled");
    bf.createBinding(workspace, "applicationUnlocked", "agg_add_btn", "!disabled");
    bf.createBinding(connectionModel, "cubeNames", "cubeSelector", "elements");
    bf.createBinding(connectionModel, "cubeName", "cubeSelector", "selectedItem");

    bf.setBindingType(Binding.Type.ONE_WAY);

    bf.createBinding(connectionModel, "applySchemaSourceEnabled", "applySchemaSourceButton", "!disabled");
    bf.createBinding(connectionModel, "databaseName", "databaseName", "value");
    bf.createBinding(connectionModel, "cubeSelectionEnabled", "cubeSelector", "!disabled");

    bf.createBinding(connectionModel, "schemaLocked", "cubeSelector", "disabled");
    bf.createBinding(connectionModel, "schemaLocked", "applySchemaSourceButton", "disabled");

    bf.createBinding(connectionModel, "connectEnabled", "connection_dialog_accept", "!disabled")
            .fireSourceChanged();

    connectionModel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("selectedSchemaModel")) {
                SchemaModel model = (SchemaModel) evt.getNewValue();
                // select the correct schema value
                for (SchemaProviderUiExtension extension : schemaProviders) {
                    if (model != null && extension.supportsSchemaModel(model)) {
                        selectedSchemaProvider = extension;
                        extension.setSelected(true);
                        extension.setSchemaModel(model);
                    } else {
                        extension.setSelected(false);
                    }
                }
            }
        }
    });

    //call unload after the bindings since the extension's onload might trigger something
    for (SchemaProviderUiExtension extension : schemaProviders) {
        extension.onLoad();
    }

    // auto select provider if only one is present
    if (schemaProviders.size() == 1) {
        schemaProviders.get(0).setSelected(true);
    }

    document.invokeLater(new Runnable() {
        public void run() {
            showConnectionDialog();
        }
    });

}

From source file:org.goko.gcode.filesender.FileSenderPart.java

@Override
public void propertyChange(PropertyChangeEvent changeEvent) {
    if (StringUtils.equals(changeEvent.getPropertyName(), "gcodeProvider")) {
        getShell().getDisplay().asyncExec(new Runnable() {

            @Override//w  w  w  . java  2  s .  co  m
            public void run() {
                refreshCommandTable();
            }
        });
    }
}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.ExtendedTcStaticResourcesEditorSection.java

protected void addConfigurationChangeListener() {
    listener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (TcServer.PROPERTY_ENHANCED_REDEPLOY.equals(event.getPropertyName())) {
                updateEnablement();/* w  w  w. jav  a2  s.c  o m*/
            } else if (TcServer.PROPERTY_AGENT_REDEPLOY.equals(event.getPropertyName())) {
                updateEnablement();
            } else if (TcServer.PROPERTY_STATIC_FILENAMES.equals(event.getPropertyName())) {
                filenamesTableViewer.setInput(server);
            } else if (TcServer.PROPERTY_AGENT_OPTIONS.equals(event.getPropertyName())) {
                if (!updating) {
                    updating = true;
                    agentOptionsText.setText(serverWorkingCopy.getAgentOptions());
                    agentOptionsText.setSelection(agentOptionsText.getText().length());
                    updating = false;
                }
            }
        }

    };
    serverWorkingCopy.getServerWorkingCopy().addPropertyChangeListener(listener);
}