Example usage for java.beans PropertyChangeEvent PropertyChangeEvent

List of usage examples for java.beans PropertyChangeEvent PropertyChangeEvent

Introduction

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

Prototype

public PropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue) 

Source Link

Document

Constructs a new PropertyChangeEvent .

Usage

From source file:org.talend.repository.RepositoryService.java

@Override
public void openLoginDialog() {
    if (isloginDialogDisabled()) {
        return;//w w w.ja  v  a2s  .  com
    }

    if (CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY) != null) {
        return;
    }

    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    boolean logged = false;
    LoginDialogV2 loginDialog = new LoginDialogV2(shell);
    // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(true);
    logged = loginDialog.open() == LoginDialogV2.OK;
    if (logged) {

        // addCommand();
        new DisableLanguageActions().earlyStartup();

        new BindingActions().bind();

        IMigrationToolService toolService = CorePlugin.getDefault().getMigrationToolService();
        toolService.executeMigration(SwitchProjectAction.PLUGIN_MODEL);

        IRunProcessService runService = CorePlugin.getDefault().getRunProcessService();
        runService.deleteAllJobs(SwitchProjectAction.PLUGIN_MODEL);

        CorePlugin.getDefault().getCodeGeneratorService().initializeTemplates();
        CorePlugin.getDefault().getDesignerCoreService()
                .synchronizeDesignerUI(new PropertyChangeEvent(this, IComponentConstants.NORMAL, null, null));
    }

}

From source file:org.ngrinder.recorder.Recorder.java

/**
 * Initialize global message handlers./* w w w.j ava2  s  .c o m*/
 * 
 * @param tabbedPane
 *            tabbedPane
 */
protected void initMessageHandler(final TabbedPane tabbedPane) {
    final File home = recorderConfig.getHome().getDirectory();
    final MessageBus messageBusInstance = MessageBus.getInstance();
    MessageBusConnection connect = messageBusInstance.connect();
    connect.subscribe(Topics.HOME, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            Browser browser = cast(evt.getSource());
            browser.navigate(toURL(tempFile).toString());
        }
    });
    connect.subscribe(Topics.APPLICATION_CLOSE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            proxy.stopProxy();
            frame.setExtendedState(Frame.NORMAL);
            File frameInfoFile = recorderConfig.getHome().getFile("last_frame");
            try {
                Pair<Dimension, Point> pair = Pair.of(frame.getSize(), frame.getLocation());
                String frameInfo = gson.toJson(pair);
                FileUtils.writeStringToFile(frameInfoFile, frameInfo);
            } catch (Exception e) {
                LOGGER.error("Failed to save the frame info", e);
            }

            messageBusInstance.getPublisher(Topics.PREPARE_TO_CLOSE)
                    .propertyChange(new PropertyChangeEvent(this, "PREPARE_TO_CLOSE", null, home));

            tabbedPane.disposeAllTabs();
            frame.setVisible(false);
            frame.dispose();

            System.exit(0);
        }
    });
    connect.subscribe(Topics.WINDOW_MAXIMIZE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
                frame.setExtendedState(Frame.NORMAL);
            } else {
                frame.setExtendedState(Frame.MAXIMIZED_BOTH);
            }
        }
    });

    connect.subscribe(Topics.WINDOW_MINIMIZE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (frame.getExtendedState() == Frame.ICONIFIED) {
                frame.setExtendedState(Frame.NORMAL);
            } else {
                frame.setExtendedState(Frame.ICONIFIED);
            }
        }
    });

    connect.subscribe(Topics.SHOW_ABOUT_DIALOG, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            AboutDialog dialog = AboutDialog.getInstance(frame, recorderConfig);
            dialog.setVisible(true);
        }
    });
}

From source file:net.sf.jabref.model.entry.BibtexEntry.java

private void firePropertyChangedEvent(String fieldName, Object oldValue, Object newValue)
        throws PropertyVetoException {
    changeSupport.fireVetoableChange(new PropertyChangeEvent(this, fieldName, oldValue, newValue));
}

From source file:org.polymap.rhei.table.FormFeatureTableColumn.java

void updateFieldValue(IFeatureTableElement elm, Object newFieldValue) {
    modifiedFieldValues.put(elm, newFieldValue);
    getViewer().update(elm, null);//w  w w  .j a v  a2  s .  com
    EventManager.instance().publish(new PropertyChangeEvent(this, getName(), null, null));
}

From source file:com.tulskiy.musique.system.configuration.Configuration.java

public void addPropertyChangeListener(String propertyName, boolean initialize,
        PropertyChangeListener listener) {
    addPropertyChangeListener(propertyName, listener);
    if (initialize)
        listener.propertyChange(new PropertyChangeEvent(this, propertyName, null, get(propertyName)));
}

From source file:org.polymap.wbv.ui.FlurstueckTableViewer.java

public FlurstueckTableViewer(PanelSite panelSite, Composite parent) {
    super(parent, /* SWT.VIRTUAL | SWT.V_SCROLL | SWT.FULL_SELECTION |*/ SWT.BORDER);
    this.panelSite = panelSite;
    IAppContext context = BatikApplication.instance().getContext();
    context.propagate(this);

    suppressSelection();/*from   w  w  w  .java  2 s  . c o m*/

    context.addListener(panelChangeListener, ev -> ev.getType().isOnOf(EventType.LIFECYCLE));

    // listen to column/field changes
    EventManager.instance().subscribe(this,
            ev -> ev instanceof PropertyChangeEvent && displayed.values().contains(ev.getSource()));

    try {
        // suppress deferred loading to fix "empty table" issue
        // setContent( fs.getFeatures( this.baseFilter ) );
        setContentProvider(new CompositesFeatureContentProvider());

        // Action: delete
        addColumn(new FormFeatureTableColumn(descriptorFor("", String.class)).setWeight(1, 25)
                .setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public Image getImage(Object elm) {
                        return WbvPlugin.images().svgImage("delete.svg", SvgImageRegistryHelper.NORMAL12);
                    }

                    @Override
                    public String getText(Object elm) {
                        return null;
                    }

                    @Override
                    public String getToolTipText(Object elm) {
                        return "Flurstck lschen";
                    }
                }).setEditing(new ActionCellEditor(elm -> {
                    assert wb.isPresent();
                    Flurstueck fst = FeatureTableElement.entity(elm);
                    fst.geloescht.set(true);
                    refresh();

                    flurstueckDeleted = true;
                    fieldChange(null);

                    // waldbesitzer lschen, wenn (wirklich) kein flurstck mehr da
                    if (wb.get().flurstuecke(null).isEmpty()) {
                        uow.get().removeEntity(wb.get());
                        panelSite.toolkit().createSnackbar(Appearance.FadeIn,
                                "Waldbesitzer wird beim Speichern <b>gelscht</b>!");
                    }
                })));

        // Action: transfer
        addColumn(new FormFeatureTableColumn(descriptorFor("", String.class)).setWeight(1, 30)
                .setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public Image getImage(Object elm) {
                        return WbvPlugin.images().svgImage("transfer.svg", SvgImageRegistryHelper.NORMAL12);
                    }

                    @Override
                    public String getText(Object elm) {
                        return null;
                    }

                    @Override
                    public String getToolTipText(Object elm) {
                        return "Eigentumsbergang: an einem anderen Waldbesitzer bertragen";
                    }
                }).setEditing(new ActionCellEditor(elm -> {
                    Flurstueck fst = FeatureTableElement.entity(elm);
                    selected.set(fst);

                    BatikApplication.instance().getContext().openPanel(panelSite.path(),
                            EigentumsuebergangPanel.ID);
                })));

        // Gemarkung
        String propName = Flurstueck.TYPE.gemarkung.info().getName();
        addColumn(new FormFeatureTableColumn(descriptorFor(propName, Gemarkung.class)).setWeight(6, 80)
                .setLabelsAndValidation(new DefaultTableValidator<Object, Gemarkung>() {
                    @Override
                    public Object transform2Field(Gemarkung gmk, ValidatorSite site) throws Exception {
                        if (site.isEditing()) {
                            return gmk;
                        } else {
                            //Flurstueck flst = FeatureTableElement.entity( site.element() );
                            String result = gmk != null ? gmk.label() : "-keine Gemarkung-"; //"WVK: " + flst.wvkGemarkung.get() + "/" + flst.wvkGemeinde.get();
                            return StringUtils.abbreviate(result, 30);
                        }
                    }

                    @Override
                    public Gemarkung transform2Model(Object fieldValue, ValidatorSite site) throws Exception {
                        return fieldValue != null ? uow.get().entity((Gemarkung) fieldValue) : null;
                    }
                }).setEditing(new PicklistFormField(Gemarkung.all.get()))
                .setSortable(new Comparator<IFeatureTableElement>() {
                    public int compare(IFeatureTableElement e1, IFeatureTableElement e2) {
                        return label(e1).compareTo(label(e2));
                    }

                    protected String label(IFeatureTableElement elm) {
                        Gemarkung gmk = (Gemarkung) elm.getValue(propName);
                        return gmk != null ? gmk.label() : "";
                    }
                })).sort(SWT.DOWN);

        // Flurstcksnummer
        addColumn(new FormFeatureTableColumn(descriptorFor(Flurstueck.TYPE.zaehlerNenner)).setWeight(3, 50)
                .setHeader("Nr.")
                .setLabelsAndValidation(AND(new NotEmptyValidator().forTable(), new AenderungValidator(),
                        new NummerValidator(), new FlurstueckExistsValidator()))
                .setEditing(new StringFormField()));

        // Flche
        NumberValidator flaecheValidator = new NumberValidator(Double.class, Locale.GERMANY, 10, 4, 1, 4);
        addColumn(new FormFeatureTableColumn(descriptorFor(Flurstueck.TYPE.flaeche)).setWeight(3, 50)
                .setHeader("Flche\n(in ha)")
                .setLabelsAndValidation(AND(flaecheValidator.forTable(), new AenderungValidator()))
                .setEditing(new StringFormField()).setSortable(true));

        // davon Wald
        addColumn(new FormFeatureTableColumn(descriptorFor(Flurstueck.TYPE.flaecheWald)).setWeight(3, 50)
                .setHeader("Wald\n(in ha)")
                .setLabelsAndValidation(
                        AND(new WaldflaecheValidator(flaecheValidator), new AenderungValidator()))
                .setEditing(new StringFormField()).setSortable(true));

        // nderungsdatum
        addColumn(new FormFeatureTableColumn(descriptorFor(Flurstueck.TYPE.aenderung)).setWeight(4, 80)
                .setHeader("nderung").setLabelsAndValidation(new DateValidator().forTable()));

        // Bemerkung
        FormFeatureTableColumn bcolumn = new FormFeatureTableColumn(descriptorFor(Flurstueck.TYPE.bemerkung));
        bcolumn.setWeight(11, 120);
        bcolumn.setLabelsAndValidation(new AenderungValidator());
        bcolumn.setEditing(new CellEditor() {
            private String value;
            private Text txt;

            @Override
            protected Control createControl(Composite _parent) {
                return null;
            }

            @Override
            protected void doSetFocus() {
            }

            @Override
            protected Object doGetValue() {
                return value;
            }

            @Override
            protected void doSetValue(Object newValue) {
                this.value = (String) newValue;
            }

            @Override
            public void activate() {
                Shell appShell = BatikApplication.shellToParentOn();
                new SimpleDialog().centerOn.put(appShell).title.put("Bemerkung").setContents(dialogParent -> {
                    dialogParent.setLayout(FormLayoutFactory.defaults().create());
                    txt = on(new Text(dialogParent, SWT.MULTI | SWT.WRAP | SWT.BORDER)).fill().width(350)
                            .height(150).control();
                    txt.setText(value != null ? value : "");
                    txt.setFocus();
                }).addOkAction("BERNEHMEN", () -> {
                    value = txt.getText();
                    fireApplyEditorValue();
                    EventManager.instance().publish(new PropertyChangeEvent(bcolumn, "bemerkung", value, null));
                    return null;
                }).addCancelAction("ABBRECHEN").open();
            }
        });
        addColumn(bcolumn);

        setInput(wb.get().flurstuecke(revier.get()));

        //            /* Register for property change events */
        //            EventManager.instance().subscribe( this, new EventFilter<PropertyChangeEvent>() {
        //                public boolean apply( PropertyChangeEvent input ) {
        //                    return input.getSource() instanceof Flurstueck;
        //                }
        //            });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:edu.ku.brc.specify.config.SpecifyGUIDGeneratorFactory.java

/**
 * @param pcl//ww  w.j a v a  2 s.c  o m
 * @param classes
 */
public static void buildAllGUIDsAynch(final PropertyChangeListener pcl, final ArrayList<Class<?>> classes) {
    final String COUNT = "COUNT";

    final GhostGlassPane glassPane = UIRegistry.writeGlassPaneMsg(getResourceString("SETTING_GUIDS"),
            UIRegistry.STD_FONT_SIZE);
    glassPane.setProgress(0);

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (SubPaneMgr.getInstance().aboutToShutdown()) {
                Taskable task = TaskMgr.getTask("Startup");
                if (task != null) {
                    SubPaneIFace splash = edu.ku.brc.specify.tasks.StartUpTask
                            .createFullImageSplashPanel(task.getTitle(), task);
                    SubPaneMgr.getInstance().addPane(splash);
                    SubPaneMgr.getInstance().showPane(splash);
                }

                final GUIDWorker worker = new GUIDWorker() {
                    protected Integer doInBackground() throws Exception {
                        if (getInstance() instanceof SpecifyGUIDGeneratorFactory) {
                            SpecifyGUIDGeneratorFactory guidGen = (SpecifyGUIDGeneratorFactory) getInstance();
                            guidGen.buildGUIDs(this);
                        }
                        return null;
                    }

                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getPropertyName().equals("COUNT")) {
                            firePropertyChange("COUNT", 0, evt.getNewValue());
                        }
                    }

                    @Override
                    protected void done() {
                        glassPane.setProgress(100);
                        UIRegistry.clearGlassPaneMsg();
                        if (pcl != null) {
                            pcl.propertyChange(new PropertyChangeEvent(this, "complete", "true", "true"));
                        }
                    }
                };

                worker.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(final PropertyChangeEvent evt) {
                        if (COUNT.equals(evt.getPropertyName())) {
                            glassPane.setProgress((int) (((Integer) evt.getNewValue() * 100.0)
                                    / (double) CATEGORY_TYPE.values().length));
                        }
                    }
                });
                worker.execute();
            }
        }
    });

}

From source file:org.kuali.kfs.module.tem.document.TravelEntertainmentDocument.java

@Transient
public void addAttendee(final Attendee line) {
    final String sequenceName = line.getSequenceName();
    final Long sequenceNumber = getSequenceAccessorService().getNextAvailableSequenceNumber(sequenceName,
            Attendee.class);
    line.setId(sequenceNumber.intValue());
    line.setDocumentNumber(this.documentNumber);
    notifyChangeListeners(new PropertyChangeEvent(this, "attendee", null, line));
    getAttendee().add(line);//from  www . jav  a  2  s .  c  om
}

From source file:org.kuali.kfs.module.tem.document.TravelEntertainmentDocument.java

@Transient
public void removeAttendee(final Integer index) {
    final Attendee line = getAttendee().remove((int) index);
    notifyChangeListeners(new PropertyChangeEvent(this, "attendee", line, null));
}

From source file:edu.ku.brc.specify.web.HttpLargeFileTransfer.java

/**
 * @param fileName/*from w ww. j a  v  a2 s.c o m*/
 * @param urlStr
 * @param isSiteFile
 * @param propChgListener
 */
public void transferFile(final String fileName, final String urlStr, final boolean isSiteFile,
        final PropertyChangeListener propChgListener) {

    final String prgName = HttpLargeFileTransfer.class.toString();

    final File file = new File(fileName);
    if (file.exists()) {
        final long fileSize = file.length();
        if (fileSize > 0) {
            SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
                protected String errorMsg = null;
                protected FileInputStream fis = null;
                protected OutputStream fos = null;
                protected int nChunks = 0;

                /* (non-Javadoc)
                 * @see javax.swing.SwingWorker#doInBackground()
                 */
                @Override
                protected Integer doInBackground() throws Exception {
                    try {
                        Thread.sleep(100);
                        fis = new FileInputStream(file);

                        nChunks = (int) (fileSize / MAX_CHUNK_SIZE);
                        if (fileSize % MAX_CHUNK_SIZE > 0) {
                            nChunks++;
                        }

                        byte[] buf = new byte[BUFFER_SIZE];
                        long bytesRemaining = fileSize;

                        String clientID = String.valueOf((long) (Long.MIN_VALUE * Math.random()));

                        URL url = new URL(urlStr);

                        UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);

                        for (int i = 0; i < nChunks; i++) {
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                            if (i == nChunks - 1) {
                                Thread.sleep(500);
                                int x = 0;
                                x++;
                            }

                            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                            conn.setRequestMethod("PUT");
                            conn.setDoOutput(true);
                            conn.setDoInput(true);
                            conn.setUseCaches(false);

                            int chunkSize = (int) ((bytesRemaining > MAX_CHUNK_SIZE) ? MAX_CHUNK_SIZE
                                    : bytesRemaining);
                            bytesRemaining -= chunkSize;

                            conn.setRequestProperty("Content-Type", "application/octet-stream");
                            conn.setRequestProperty("Content-Length", String.valueOf(chunkSize));

                            conn.setRequestProperty(CLIENT_ID_HEADER, clientID);
                            conn.setRequestProperty(FILE_NAME_HEADER, fileName);
                            conn.setRequestProperty(FILE_CHUNK_COUNT_HEADER, String.valueOf(nChunks));
                            conn.setRequestProperty(FILE_CHUNK_HEADER, String.valueOf(i));
                            conn.setRequestProperty(SERVICE_NUMBER, "10");
                            conn.setRequestProperty(IS_SITE_FILE, Boolean.toString(isSiteFile));

                            fos = conn.getOutputStream();

                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, (int)((double)chunkSize / BUFFER_SIZE));
                            int cnt = 0;
                            int bytesRead = 0;
                            while (bytesRead < chunkSize) {
                                int read = fis.read(buf);
                                if (read == -1) {
                                    break;

                                } else if (read > 0) {
                                    bytesRead += read;
                                    fos.write(buf, 0, read);
                                }
                                cnt++;
                                //firePropertyChange(prgName, cnt-1, cnt);
                            }
                            fos.close();

                            if (conn.getResponseCode() != HttpServletResponse.SC_OK) {
                                System.err.println(
                                        conn.getResponseMessage() + " " + conn.getResponseCode() + " ");
                                BufferedReader in = new BufferedReader(
                                        new InputStreamReader(conn.getErrorStream()));
                                String line = null;
                                StringBuilder sb = new StringBuilder();
                                while ((line = in.readLine()) != null) {
                                    sb.append(line);
                                    sb.append("\n");
                                }
                                System.out.println(sb.toString());
                                in.close();

                            } else {
                                System.err.println("OK");
                            }
                            //UIRegistry.getStatusBar().setProgressRange(prgName, 0, nChunks);
                            firePropertyChange(prgName, i - 1, i == nChunks - 1 ? Integer.MAX_VALUE : i);
                        }

                    } catch (IOException ex) {
                        errorMsg = ex.toString();
                    }

                    //firePropertyChange(prgName, 0, 100);
                    return null;
                }

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

                    UIRegistry.getStatusBar().setProgressDone(prgName);

                    UIRegistry.clearSimpleGlassPaneMsg();

                    if (StringUtils.isNotEmpty(errorMsg)) {
                        UIRegistry.showError(errorMsg);
                    }

                    if (propChgListener != null) {
                        propChgListener.propertyChange(
                                new PropertyChangeEvent(HttpLargeFileTransfer.this, "Done", 0, 1));
                    }
                }
            };

            final JStatusBar statusBar = UIRegistry.getStatusBar();
            statusBar.setIndeterminate(HttpLargeFileTransfer.class.toString(), true);

            UIRegistry.writeSimpleGlassPaneMsg(getLocalizedMessage("Transmitting..."), 24);

            backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(final PropertyChangeEvent evt) {
                    System.out.println(evt.getPropertyName() + "  " + evt.getNewValue());
                    if (prgName.equals(evt.getPropertyName())) {
                        Integer value = (Integer) evt.getNewValue();
                        if (value == Integer.MAX_VALUE) {
                            statusBar.setIndeterminate(prgName, true);
                            UIRegistry.writeSimpleGlassPaneMsg(
                                    getLocalizedMessage("Transfering data into the database."), 24);

                        } else {
                            statusBar.setValue(prgName, value);
                        }
                    }
                }
            });
            backupWorker.execute();

        } else {
            // file doesn't exist
        }
    } else {
        // file doesn't exist
    }
}