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:ome.formats.importer.gui.FileQueueHandler.java

public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if (prop.equals(ADD)) {
        doSelection(false);/*w w  w.  j  a  va 2  s. c o m*/
    }

    else if (prop.equals(REMOVE)) {
        int[] rows = qTable.getQueue().getSelectedRows();

        if (rows.length == 0) {
            JOptionPane.showMessageDialog(viewer, "You must select at least one file in the queue to\n"
                    + "remove. Choose an image in the right-hand panel \n" + "first before removing.");
            return;
        }

        while (rows.length > 0) {
            if (qTable.getQueue().getValueAt(rows[0], 2) == "added"
                    || qTable.getQueue().getValueAt(rows[0], 2) == "pending") {
                removeFileFromQueue(rows[0]);
                rows = qTable.getQueue().getSelectedRows();
            }
        }
    }

    else if (prop.equals(CLEARDONE)) {
        int numRows = qTable.getQueue().getRowCount();

        for (int i = (numRows - 1); i >= 0; i--) {
            if (qTable.getQueue().getValueAt(i, 2) == "done") {
                removeFileFromQueue(i);
            }
        }
        qTable.clearDoneBtn.setEnabled(false);
    }

    else if (prop.equals(CLEARFAILED)) {
        int numRows = qTable.getQueue().getRowCount();

        for (int i = (numRows - 1); i >= 0; i--) {
            if (qTable.getQueue().getValueAt(i, 2) == "failed"
                    || qTable.getQueue().getValueAt(i, 2) == "unreadable") {
                removeFileFromQueue(i);
            }
        }
        qTable.clearFailedBtn.setEnabled(false);
    }

    else if (prop.equals(IMPORT)) {
        if (viewer.getLoggedIn() == false) {
            JOptionPane.showMessageDialog(viewer, "You must be logged in before you can import.");
            return;
        }

        qTable.clearDoneBtn.setEnabled(false);
        qTable.clearFailedBtn.setEnabled(false);
        try {
            if (qTable.importing == false) {
                ImportContainer[] candidates = qTable.getImportContainersFromTable();

                if (candidates != null) {
                    ImportLibrary library = new ImportLibrary(getOMEROMetadataStoreClient(), importReader);
                    library.addObserver(new LoggingImportMonitor());

                    if (getOMEROMetadataStoreClient() != null) {
                        ImportHandler importHandler = new ImportHandler(importEx, viewer, qTable, config,
                                library, candidates);
                        importHandler.addObserver(viewer);
                        importHandler.addObserver(qTable);
                    }
                }
                qTable.importing = true;
                qTable.getQueue().setRowSelectionAllowed(false);
                qTable.removeBtn.setEnabled(false);
            } else {
                qTable.importBtn.setText("Wait...");
                qTable.importBtn.setEnabled(false);
                viewer.getStatusBar().setStatusIcon("gfx/import_cancelling_16.png",
                        "Cancelling import... please wait.");
                //JOptionPane.showMessageDialog(viewer, 
                //        "You import will be cancelled after the " +
                //        "current file has finished importing.");
                if (cancelImportDialog(viewer) == true) {
                    qTable.cancel = true;
                    qTable.abort = true;
                    qTable.importing = false;
                    System.exit(0);
                } else {
                    qTable.cancel = true;
                    qTable.importing = false;
                }
            }
        } catch (Exception ex) {
            log.error("Generic error while updating GUI for import.", ex);
            return;
        }
    }

    else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
        config.savedDirectory.set(new File(fileChooser.getCurrentDirectory().getAbsolutePath()));
    }

    else if (prop.equals(REFRESH)) {
        fileChooser.setVisible(false);
        fileChooser.rescanCurrentDirectory();
        fileChooser.setVisible(true);
    }
}

From source file:com.github.fritaly.dualcommander.DualCommander.java

@Override
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == preferences) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("User preference '%s' changed: '%s' -> '%s'", e.getPropertyName(),
                    e.getOldValue(), e.getNewValue()));
        }/*from w ww.jav a 2s  . com*/

        // The 'show hidden' property changed, need to refresh the active
        // directory browsers
        // TODO Set a flag for the inactive directory browsers to refresh
        // when they get the focus
        this.leftPane.getActiveBrowser().refresh();
        this.rightPane.getActiveBrowser().refresh();
    }
}

From source file:org.rdv.viz.image.HighResImageViz.java

private void initImagePanel() {
    imagePanel = new ImagePanel();
    imagePanel.setBackground(Color.black);
    imagePanel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent pce) {
            String propertyName = pce.getPropertyName();
            if (propertyName.equals(ImagePanel.AUTO_SCALING_PROPERTY)) {
                boolean autoScaling = (Boolean) pce.getNewValue();
                //autoScaleMenuItem.setSelected(autoScaling);
                if (autoScaling) {
                    properties.setProperty(DATA_PANEL_PROPERTY_AUTOSCALE, "true");
                    properties.remove(DATA_PANEL_PROPERTY_SCALE);
                    properties.remove(DATA_PANEL_PROPERTY_ORIGIN);
                } else {
                    properties.setProperty(DATA_PANEL_PROPERTY_SCALE, Double.toString(imagePanel.getScale()));
                    properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, pointToString(imagePanel.getOrigin()));
                    properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE);
                }/*from  w w w.  j a va2 s  .co  m*/
            } else if (propertyName.equals(ImagePanel.SCALE_PROPERTY) && !imagePanel.isAutoScaling()) {
                properties.setProperty(DATA_PANEL_PROPERTY_SCALE, pce.getNewValue().toString());
                properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE);
            } else if (propertyName.equals(ImagePanel.ORIGIN_PROPERTY) && !imagePanel.isAutoScaling()) {
                Point origin = (Point) pce.getNewValue();
                String originString = pointToString(origin);
                properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, originString);
                properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE);
            } else if (propertyName.equals(ImagePanel.NAVIGATION_IMAGE_ENABLED_PROPERTY)) {
                boolean showNavigationImage = (Boolean) pce.getNewValue();
                //showNavigationImageMenuItem.setSelected(showNavigationImage);
                if (showNavigationImage) {
                    properties.setProperty(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE, "true");
                } else {
                    properties.remove(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE);
                }
            }
        }
    });

    panel.add(imagePanel, BorderLayout.CENTER);
}

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

/**
 * /*from w  ww. ja va 2s. c  o  m*/
 */
public void checkForBadAttachments() {
    int count = getNumberofBadAttachments();
    if (count == 0) {
        AppPreferences.getGlobalPrefs().putBoolean("CHECK_ATTCH_ERR", false);
        return;
    }

    URL url = null;
    JEditorPane htmlPane;
    try {
        url = new URL("http://files.specifysoftware.org/attachment_recovery.html");
        htmlPane = new JEditorPane(url);
    } catch (Exception e) {
        e.printStackTrace();
        htmlPane = new JEditorPane("text/html", //$NON-NLS-1$
                "<html><body><h1>Network Error - You must have a network conneciton to get the instructions.</H1></body>");
    }
    JScrollPane scrollPane = UIHelper.createScrollPane(htmlPane);
    htmlPane.setEditable(false);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    CustomDialog infoDlg = new CustomDialog((Dialog) null, "Recovery Information", true, CustomDialog.OKCANCEL,
            panel);

    infoDlg.setCancelLabel("Close");
    infoDlg.setOkLabel("Print in Browser");
    infoDlg.createUI();
    infoDlg.setSize(1024, 600);
    try {
        hookupAction(infoDlg.getOkBtn(), url != null ? url.toURI() : null);
        infoDlg.setVisible(true);

    } catch (Exception ex) {

    }

    final String CNT = "CNT";
    final SwingWorker<Integer, Integer> worker = new SwingWorker<Integer, Integer>() {
        int totalFiles = 0;

        HashMap<Integer, Vector<Object[]>> resultsHashMap = new HashMap<Integer, Vector<Object[]>>();
        HashMap<Integer, String> tblTypeHash = new HashMap<Integer, String>();
        HashMap<Integer, String> agentHash = new HashMap<Integer, String>();
        HashMap<Integer, AttchTableModel> tableHash = new HashMap<Integer, AttchTableModel>();
        ArrayList<JTable> tableList = new ArrayList<JTable>();
        ArrayList<Integer> tableIdList = new ArrayList<Integer>();

        @Override
        protected Integer doInBackground() throws Exception {
            DataProviderSessionIFace session = null;

            try {
                // This doesn't need to include the new attachments
                int[] tableIds = { AccessionAttachment.getClassTableId(), AgentAttachment.getClassTableId(),
                        CollectingEventAttachment.getClassTableId(),
                        CollectionObjectAttachment.getClassTableId(),
                        ConservDescriptionAttachment.getClassTableId(),
                        ConservEventAttachment.getClassTableId(), DNASequencingRunAttachment.getClassTableId(),
                        FieldNotebookAttachment.getClassTableId(),
                        FieldNotebookPageAttachment.getClassTableId(),
                        FieldNotebookPageSetAttachment.getClassTableId(), LoanAttachment.getClassTableId(),
                        LocalityAttachment.getClassTableId(), PermitAttachment.getClassTableId(),
                        PreparationAttachment.getClassTableId(),
                        RepositoryAgreementAttachment.getClassTableId(), TaxonAttachment.getClassTableId() };

                Agent userAgent = AppContextMgr.getInstance().getClassObject(Agent.class);

                int totFiles = 0;
                firePropertyChange(CNT, 0, 0);
                int cnt = 0;
                for (int tableId : tableIds) {
                    Vector<Object[]> results = getImageData(userAgent.getId(), tableId, tblTypeHash);
                    if (results != null && results.size() > 0) {
                        resultsHashMap.put(tableId, results);
                        totFiles += results.size();
                        //System.out.println(tableId+"  ->  "+results.size());
                    }
                    firePropertyChange(CNT, 0, (int) ((double) cnt / (double) tableIds.length * 100.0));
                    cnt++;
                }

                if (resultsHashMap.size() == 0) // Shouldn't happen
                {
                    return null;
                }

                session = DataProviderFactory.getInstance().createSession();

                firePropertyChange(CNT, 0, 0);
                int i = 1;
                for (int tblId : resultsHashMap.keySet()) {
                    DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(tblId);

                    Vector<Object[]> dataRows = new Vector<Object[]>();
                    Vector<Object[]> results = resultsHashMap.get(tblId);
                    for (Object[] row : results) {
                        Integer agentId = (Integer) row[3];
                        String userName = agentHash.get(agentId);
                        if (userName == null) {
                            userName = BasicSQLUtils.querySingleObj(
                                    "SELECT su.Name FROM agent a INNER JOIN specifyuser su ON a.SpecifyUserID = su.SpecifyUserID WHERE a.AgentID = "
                                            + row[3]);
                            agentHash.put(agentId, userName);
                        }
                        //userName = i == 1 ? "bill.johnson" : "joe.smith";

                        int attachJoinID = (Integer) row[4];
                        String identTitle = getIdentityTitle(session, ti, attachJoinID);

                        String fullPath = (String) row[2];
                        //fullPath = StringUtils.replace(fullPath, "darwin\\", "darwin2\\");

                        //boolean doesExist = (new File(fullPath)).exists() && i != 1;
                        boolean doesExist = (new File(fullPath)).exists();
                        //String str        = i != 1 ? "/Users/joe/Desktop/xxx.png" : "/Users/bill/Desktop/xxx.png";
                        //String fullPath   = FilenameUtils.getFullPath(str) + String.format("DSC_%05d.png", i);

                        Object[] rowObjs = new Object[8];
                        rowObjs[0] = StringUtils.isEmpty(identTitle) ? ""
                                : (identTitle.length() > 30 ? identTitle.substring(0, 30) + "..." : identTitle);
                        rowObjs[1] = FilenameUtils.getName(fullPath);
                        rowObjs[2] = fullPath;
                        rowObjs[3] = userName;
                        rowObjs[4] = doesExist;
                        rowObjs[5] = Boolean.FALSE;
                        rowObjs[6] = row[0];
                        rowObjs[7] = attachJoinID;

                        dataRows.add(rowObjs);

                        if (doesExist) {
                            totalFiles++;
                        }
                        firePropertyChange(CNT, 0, (int) ((double) i / (double) totFiles * 100.0));
                        i++;
                    }
                    AttchTableModel model = new AttchTableModel(dataRows);
                    JTable table = new JTable(model);
                    tableHash.put(tblId, model);
                    tableList.add(table);
                    tableIdList.add(tblId);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                session.close();
            }

            return null;
        }

        @Override
        protected void done() {
            UIRegistry.clearSimpleGlassPaneMsg();

            if (tableList.size() > 0) {
                displayBadAttachments(tableList, tableIdList, resultsHashMap, tblTypeHash, tableHash,
                        totalFiles);
            }
            super.done();
        }
    };

    final SimpleGlassPane glassPane = UIRegistry
            .writeSimpleGlassPaneMsg("Verifying attachments in the repository...", 24);
    glassPane.setProgress(0);

    worker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (CNT.equals(evt.getPropertyName())) {
                glassPane.setProgress((Integer) evt.getNewValue());
            }
        }
    });

    worker.execute();
}

From source file:com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java

public void propertyChange(PropertyChangeEvent evt) {
    if ("statusUpdate".equals(evt.getPropertyName())) {
        lblStatusSET.setText(taskUpdate.getStatus());
    }/*w  w w . j  a  v a 2  s .  c o m*/
}

From source file:org.sleuthkit.autopsy.imagegallery.ImageGalleryController.java

/**
 * invoked by {@link OnStart} to make sure that the ImageGallery listeners
 * get setup as early as possible, and do other setup stuff.
 *//* w ww .  j  ava 2  s. c  o  m*/
void onStart() {
    Platform.setImplicitExit(false);
    LOGGER.info("setting up ImageGallery listeners");
    //TODO can we do anything usefull in an InjestJobEventListener?
    //IngestManager.getInstance().addIngestJobEventListener((PropertyChangeEvent evt) -> {});
    IngestManager.getInstance().addIngestModuleEventListener((PropertyChangeEvent evt) -> {
        switch (IngestManager.IngestModuleEvent.valueOf(evt.getPropertyName())) {
        case CONTENT_CHANGED:
            //TODO: do we need to do anything here?  -jm
        case DATA_ADDED:
            /* we could listen to DATA events and progressivly
             * update files, and get data from DataSource ingest
             * modules, but given that most modules don't post new
             * artifacts in the events and we would have to query for
             * them, without knowing which are the new ones, we just
             * ignore these events for now. The relevant data should all
             * be captured by file done event, anyways -jm */
            break;
        case FILE_DONE:
            /**
             * getOldValue has fileID getNewValue has
             * {@link Abstractfile}
             */
            AbstractFile file = (AbstractFile) evt.getNewValue();
            if (isListeningEnabled()) {
                if (ImageGalleryModule.isSupportedAndNotKnown(file)) {
                    //this file should be included and we don't already know about it from hash sets (NSRL)
                    queueDBWorkerTask(new UpdateFileTask(file));
                } else if (ImageGalleryModule.getAllSupportedExtensions().contains(file.getNameExtension())) {
                    //doing this check results in fewer tasks queued up, and faster completion of db update
                    //this file would have gotten scooped up in initial grab, but actually we don't need it
                    queueDBWorkerTask(new RemoveFileTask(file));
                }
            } else { //TODO: keep track of what we missed for later
                setStale(true);
            }
            break;
        }
    });
    Case.addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (Case.Events.valueOf(evt.getPropertyName())) {
        case CURRENT_CASE:
            Case newCase = (Case) evt.getNewValue();
            if (newCase != null) { // case has been opened
                setCase(newCase); //connect db, groupmanager, start worker thread
            } else { // case is closing
                //close window, reset everything
                SwingUtilities.invokeLater(ImageGalleryTopComponent::closeTopComponent);
                reset();
            }
            break;
        case DATA_SOURCE_ADDED:
            //copy all file data to drawable databse
            Content newDataSource = (Content) evt.getNewValue();
            if (isListeningEnabled()) {
                queueDBWorkerTask(new PrePopulateDataSourceFiles(newDataSource));
            } else {//TODO: keep track of what we missed for later
                setStale(true);
            }
            break;
        }
    });
}

From source file:ome.formats.importer.gui.FileQueueHandler.java

/**
 * Retrieve the file chooser's selected reader then iterate over
 * each of our supplied containers filtering out those whose format
 * do not match those of the selected reader.
 * /*ww  w .j av  a 2s  .c om*/
 * @param allContainers List of ImporterContainers
 */
private void handleFiles(List<ImportContainer> allContainers) {
    FileFilter selectedFilter = fileChooser.getFileFilter();
    IFormatReader selectedReader = null;

    if (selectedFilter instanceof FormatFileFilter) {
        log.debug("Selected file filter: " + selectedFilter);
        selectedReader = ((FormatFileFilter) selectedFilter).getReader();
    }

    List<ImportContainer> containers = new ArrayList<ImportContainer>();
    for (ImportContainer ic : allContainers) {
        if (selectedReader == null) {
            // The user selected "All supported file types"
            containers = allContainers;
            break;
        }
        String a = selectedReader.getFormat();
        String b = ic.getReader();
        if (a.equals(b) || b == null) {
            containers.add(ic);
        } else {
            log.debug(String.format("Skipping %s (%s != %s)", ic.getFile().getAbsoluteFile(), a, b));
        }
    }

    Boolean spw = spwOrNull(containers);

    if (containers.size() == 0 && !candidatesFormatException) {
        final JOptionPane optionPane = new JOptionPane("\nNo importable files found in this selection.",
                JOptionPane.WARNING_MESSAGE);
        final JDialog errorDialog = new JDialog(viewer, "No Importable Files Found", true);
        errorDialog.setContentPane(optionPane);

        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                String prop = e.getPropertyName();

                if (errorDialog.isVisible() && (e.getSource() == optionPane)
                        && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    errorDialog.dispose();
                }
            }
        });

        errorDialog.toFront();
        errorDialog.pack();
        errorDialog.setLocationRelativeTo(viewer);
        errorDialog.setVisible(true);
    }

    if (candidatesFormatException) {
        viewer.candidateErrorsCollected(viewer);
        candidatesFormatException = false;
    }

    if (spw == null) {
        addEnabled(true);
        containers.clear();
        return; // Invalid containers.
    }

    if (getOMEROMetadataStoreClient() != null && spw.booleanValue()) {
        addEnabled(true);
        SPWDialog dialog = new SPWDialog(config, viewer, "Screen Import", true, getOMEROMetadataStoreClient());
        if (dialog.cancelled == true || dialog.screen == null)
            return;
        for (ImportContainer ic : containers) {
            ic.setTarget(dialog.screen);
            String title = dialog.screen.getName().getValue();
            addFileToQueue(ic, title, false, 0);
        }

        qTable.centerOnRow(qTable.getQueue().getRowCount() - 1);
        qTable.importBtn.requestFocus();

    } else if (getOMEROMetadataStoreClient() != null) {
        addEnabled(true);
        ImportDialog dialog = new ImportDialog(config, viewer, "Image Import", true,
                getOMEROMetadataStoreClient());
        if (dialog.cancelled == true || dialog.dataset == null)
            return;

        Double[] pixelSizes = new Double[] { dialog.pixelSizeX, dialog.pixelSizeY, dialog.pixelSizeZ };
        Boolean useFullPath = config.useFullPath.get();
        if (dialog.useCustomNamingChkBox.isSelected() == false)
            useFullPath = null; //use the default bio-formats naming

        for (ImportContainer ic : containers) {
            ic.setTarget(dialog.dataset);
            ic.setUserPixels(pixelSizes);
            ic.setArchive(dialog.archiveImage.isSelected());
            String title = "";
            if (dialog.project.getId() != null) {
                ic.setProjectID(dialog.project.getId().getValue());
                title = dialog.project.getName().getValue() + " / " + dialog.dataset.getName().getValue();
            } else {
                title = "none / " + dialog.dataset.getName().getValue();
            }

            addFileToQueue(ic, title, useFullPath, config.numOfDirectories.get());
        }

        qTable.centerOnRow(qTable.getQueue().getRowCount() - 1);
        qTable.importBtn.requestFocus();
    } else {
        addEnabled(true);
        JOptionPane.showMessageDialog(viewer,
                "Due to an error the application is unable to \n"
                        + "retrieve an OMEROMetadataStore and cannot continue."
                        + "The most likely cause for this error is that you"
                        + "are not logged in. Please try to login again.");
    }
}

From source file:EditorPaneExample20.java

public HTMLInsertFrame(String title, JEditorPane editor) {
    super(title);
    this.pane = editor;

    // Build the layout
    textArea = new JTextArea(10, 32);
    textArea.setLineWrap(true);/*from   w w w . j  a va 2s  .co m*/
    textArea.setWrapStyleWord(true);
    insertButton = new JButton("Insert HTML");
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "HTML Source",
            TitledBorder.CENTER, TitledBorder.TOP));
    topPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    JPanel bottomPanel = new JPanel();
    bottomPanel.add(insertButton);

    getContentPane().add(topPanel, BorderLayout.CENTER);
    getContentPane().add(bottomPanel, BorderLayout.SOUTH);

    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                setGUIState();
            }
        }
    });

    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            if (kit instanceof HTMLEditorKit) {
                String htmlString = textArea.getText();
                if (htmlString.trim().equals("") == false) {
                    try {
                        ((HTMLEditorKit) kit).read(new StringReader(htmlString), pane.getDocument(),
                                pane.getCaretPosition());
                    } catch (Exception e) {
                    }
                }
            }
        }
    });

    setGUIState(); // Disable if not HTML content
    pack();
}

From source file:com.m4rc310.cb.builders.ComponentBuilder.java

public void _showDialog(Object objAnnotated, String ref, Object relative, Object... args) {

    if (objAnnotated != null) {
        objectAnnotated = objAnnotated;/* w w  w  . j  a va 2 s  .c  o m*/
        //            Class[] classArgs = new Class[args.length];
        //            MethodUtils.method(objectAnnotated, "setValuesToSearch", classArgs).invoke(args[0]);
    } else {
        objectAnnotated = getNewInstanceObjectAnnotated(ref, args);
    }

    Class<? extends Object> objectAnnotatedClass = objectAnnotated.getClass();

    dialog = new JDialogDefalt();

    if (objectAnnotatedClass.isAnnotationPresent(Amethod.class)) {
        Amethod am = objectAnnotatedClass.getDeclaredAnnotation(Amethod.class);
        final String methodOnError = am.methodOnError();
        LogServer.getInstance().debug(null, "Adicionando Listener de erro: {0}", methodOnError);
        if (!methodOnError.isEmpty()) {
            dialog.addPropertyChangeListener("onError", (PropertyChangeEvent evt) -> {
                getTargetsForMethodName(methodOnError).stream().forEach((tar) -> {
                    MethodUtils.declaredMethod(tar, methodOnError, String.class, String.class)
                            .invoke(evt.getPropertyName(), evt.getNewValue());
                });
            });
        }
    }

    Adialog ad = objectAnnotatedClass.getDeclaredAnnotation(Adialog.class);

    String title = getString(ad.title(), ref);
    if (ad.debug()) {
        title = getString("title.title.mode.debug", title);
    }
    dialog.setTitle(title);

    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            MethodUtils.method(objectAnnotated, "setComponentsBuilder", ComponentBuilder.class)
                    .invoke(ComponentBuilder.this);
            MethodUtils.method(objectAnnotated, "setDialog", Dialog.class).invoke(dialog);
            MethodUtils.method(objectAnnotated, "setGui", GuiUtils.class).invoke(gui);
        }
    });

    dialog.setLayout(new MigLayout(ad.layoutDialog()));
    dialog.abiliteCloseOnESC();

    putContainer(objectAnnotated.hashCode(), dialog);

    addTargets(objectAnnotated);
    loadAllFields(objectAnnotated, objectAnnotated.getClass());

    buildAllComponents();
    printDialog();

    dialog.setFontSize(ad.fontSize());
    dialog.setModal(ad.modal());
    dialog.setResizable(ad.resizable());
    dialog.pack();

    dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);

    dialog.setLocationRelativeTo((Component) relative);
    dialog.showWindow();
}

From source file:org.isatools.isacreator.gui.formelements.SubForm.java

private void removalConfirmation(final FieldTypes whatIsBeingRemoved) {
    // delete reference to protocol in subform

    // add one to take into account the model and the initial column which contains fields names.
    final int selectedItem = scrollTable.getSelectedColumn() + 1;

    // check to ensure the value isn't 0, if it is, nothing is selected in the table since -1 (value returned by model if
    // no column is selected + 1 = 0!)
    if ((selectedItem != 0) && (dataEntryForm != null)) {
        String displayText;// w w  w  .j  a va 2s . c  om
        if ((whatIsBeingRemoved == FieldTypes.FACTOR) || (whatIsBeingRemoved == FieldTypes.PROTOCOL)) {
            displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this "
                    + fieldType + " will result in all " + fieldType + "s of this type in subsequent assays</p>"
                    + "<p>being deleted too! Do you wish to continue?</p>" + "</html>";
        } else {
            displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this "
                    + fieldType + " will result in its complete removal from this experiment annotation!</p>"
                    + "<p>Do you wish to continue?</p>" + "</html>";
        }

        JOptionPane optionPane = new JOptionPane(displayText, JOptionPane.INFORMATION_MESSAGE,
                JOptionPane.YES_NO_OPTION);
        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                    int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());

                    if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                        removeItem(selectedItem);
                        ApplicationManager.getCurrentApplicationInstance().hideSheet();
                    } else {
                        // just hide the sheet and cancel further actions!
                        ApplicationManager.getCurrentApplicationInstance().hideSheet();
                    }
                }
            }
        });
        optionPane.setIcon(confirmRemoveColumn);
        UIHelper.applyOptionPaneBackground(optionPane, UIHelper.BG_COLOR);
        ApplicationManager.getCurrentApplicationInstance()
                .showJDialogAsSheet(optionPane.createDialog(this, "Confirm Delete"));
    } else {
        removeColumn(selectedItem);
    }
}