Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

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

Prototype

PropertyChangeListener

Source Link

Usage

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorComponent.java

public void handleFileAnnotationRemoveCheck(final FileAnnotationCheckResult result) {
    if (!result.getSingleParentAnnotations().isEmpty()) {

        JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();

        FileAttachmentWarningDialog dlg = new FileAttachmentWarningDialog(f, result);
        dlg.addPropertyChangeListener(new PropertyChangeListener() {

            @Override/*ww w.  ja v  a 2s. co  m*/
            public void propertyChange(PropertyChangeEvent arg0) {
                if (arg0.getPropertyName().equals(FileAttachmentWarningDialog.DELETE_PROPERTY)) {
                    for (FileAnnotationData fd : result.getSingleParentAnnotations()) {
                        view.deleteAnnotation(fd);
                    }
                    for (FileAnnotationData fd : result.getAllAnnotations()) {
                        view.unlinkAttachedFile(fd);
                    }
                }

            }
        });
        UIUtilities.centerAndShow(dlg);
    }

    else {
        for (FileAnnotationData fd : result.getAllAnnotations()) {
            view.unlinkAttachedFile(fd);
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Creates the menu displaying the groups and users.
 * /*from www . j  a  v a  2  s .co m*/
 * @param source The invoker.
 * @param p The location of the mouse clicked.
 */
private void createGroupsAndUsersMenu(Component source, Point p) {
    if (!source.isEnabled())
        return;
    Collection groups = model.getGroups();
    if (CollectionUtils.isEmpty(groups))
        return;
    popupMenu.removeAll();
    GroupData group;
    List sortedGroups = sorter.sort(groups);

    //Determine the group already displayed.
    Browser browser = model.getBrowser(Browser.PROJECTS_EXPLORER);
    List<TreeImageDisplay> nodes;
    ExperimenterVisitor visitor;
    //Find the user already added to the selected group.
    visitor = new ExperimenterVisitor(browser, -1);
    browser.accept(visitor);
    nodes = visitor.getNodes();
    Iterator<TreeImageDisplay> k = nodes.iterator();
    List<Long> groupIds = new ArrayList<Long>();
    long id;
    while (k.hasNext()) {
        id = k.next().getUserObjectId();
        if (id >= 0)
            groupIds.add(id);
    }

    //Create the group menu.
    Iterator i = sortedGroups.iterator();
    int size = sortedGroups.size();
    long userID = model.getExperimenter().getId();

    //First add item to toggle between users and group display
    DataMenuItem data = new DataMenuItem(DataMenuItem.USERS_TEXT, null);
    data.setSelected(model.getDisplayMode() == LookupNames.EXPERIMENTER_DISPLAY);
    data.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (DataMenuItem.ITEM_SELECTED_PROPERTY.equals(name)) {
                DataMenuItem data = (DataMenuItem) evt.getNewValue();
                handleSelectionDisplay(data.isSelected());
            }
        }
    });
    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    panel.setBorder(null);
    IconManager icons = IconManager.getInstance();
    panel.add(new JLabel(icons.getIcon(IconManager.TRANSPARENT)));
    panel.add(data);
    popupMenu.add(panel);
    popupMenu.add(new JSeparator());
    GroupItem item;
    GroupItem allGroup = null;
    //First add option to add all the groups.
    if (size > 1) {
        item = new GroupItem(false);
        item.setUserID(userID);
        createGroupMenu(item, 0);
        popupMenu.add(item);
        popupMenu.add(new JSeparator());
        allGroup = item;
    }

    boolean selected;
    int count = 0;
    while (i.hasNext()) {
        group = (GroupData) i.next();
        boolean b = groupIds.contains(group.getId());
        item = new GroupItem(group, b, size > 1);
        item.setUserID(userID);
        selected = createGroupMenu(item, size);
        popupMenu.add(item);
        if (selected)
            count++;
    }
    if (allGroup != null) {
        allGroup.setMenuSelected(count == sortedGroups.size(), false);
    }
    popupMenu.show(source, p.x, p.y);
}

From source file:edu.ku.brc.specify.config.init.MasterUserPanel.java

/**
 * /*  w w w  .  j  a v a 2 s . c  o m*/
 */
protected void createMasterUser() {
    String saUsrNm = ((JTextField) comps.get("saUserName")).getText();
    if (StringUtils.isNotEmpty(saUsrNm) && saUsrNm.equalsIgnoreCase("root")) {
        UIRegistry.showLocalizedError("MASTER_NO_ROOT");
        ((JTextField) comps.get("saUserName")).setText("");
        return;
    }

    if (!checkPermsForMasterUserCreation()) {
        return;
    }

    if (isOK == null || !isOK) {
        progressBar.setIndeterminate(true);
        progressBar.setVisible(true);

        setUIEnabled(false);

        label.setText(UIRegistry.getResourceString("CONN_DB"));

        createMUBtn.setVisible(false);

        SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
            @Override
            protected Object doInBackground() throws Exception {
                MasterUserPanel.this.label.setForeground(Color.BLACK);

                isOK = false;
                if (!isEmbedded) {
                    DBMSUserMgr mgr = DBMSUserMgr.getInstance();

                    String dbUserName = properties.getProperty("dbUserName");
                    String dbPassword = properties.getProperty("dbPassword");
                    String dbName = properties.getProperty("dbName");
                    String hostName = properties.getProperty("hostName");

                    String saUserName = ((JTextField) comps.get("saUserName")).getText();
                    String saPassword = ((JTextField) comps.get("saPassword")).getText();

                    if (mgr.connectToDBMS(dbUserName, dbPassword, hostName)) {

                        if (mgr.doesUserExists(saUserName)) {
                            if (!mgr.setPermissions(saUserName, dbName, DBMSUserMgr.PERM_ALL_BASIC)) {
                                errorKey = "ERR_SET_PERM";
                            } else {
                                isOK = true;
                            }
                        }

                        if (!mgr.doesUserExists(saUserName)) {
                            firePropertyChange(propName, 0, 1);

                            isOK = mgr.createUser(saUserName, saPassword, dbName, DBMSUserMgr.PERM_ALL_BASIC);
                            if (!isOK) {
                                errorKey = "ERR_CRE_MASTER";
                            } else {
                                isOK = true;
                            }
                        }
                    } else {
                        errorKey = "NO_CONN_ROOT";
                        isOK = false;
                    }

                    if (mgr != null) {
                        mgr.close();
                    }
                } else {
                    isOK = true;
                }

                return null;
            }

            /* (non-Javadoc)
             * @see javax.swing.SwingWorker#done()
             */
            @Override
            protected void done() {
                super.done();

                progressBar.setIndeterminate(false);
                progressBar.setVisible(false);

                setUIEnabled(true);

                updateBtnUI();

                createMUBtn.setVisible(!isOK);

                if (isOK) {
                    setUIEnabled(false);
                    label.setText(UIRegistry.getResourceString("MASTER_CREATED"));

                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            nextBtn.doClick();
                        }
                    });

                } else {
                    label.setText(UIRegistry.getResourceString(errorKey));
                    UIRegistry.showLocalizedError(errorKey);
                }
            }
        };

        worker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (propName.equals(evt.getPropertyName())) {
                    MasterUserPanel.this.label.setText(UIRegistry.getLocalizedMessage("CREATE_MASTER"));
                }
            }
        });
        worker.execute();
    }
}

From source file:DialogDemo.java

/** Creates the panel shown by the second tab. */
private JPanel createFeatureDialogBox() {
    final int numButtons = 5;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    JButton showItButton = null;/*from  ww  w  .j a  v  a2s  . com*/

    final String pickOneCommand = "pickone";
    final String textEnteredCommand = "textfield";
    final String nonAutoCommand = "nonautooption";
    final String customOptionCommand = "customoption";
    final String nonModalCommand = "nonmodal";

    radioButtons[0] = new JRadioButton("Pick one of several choices");
    radioButtons[0].setActionCommand(pickOneCommand);

    radioButtons[1] = new JRadioButton("Enter some text");
    radioButtons[1].setActionCommand(textEnteredCommand);

    radioButtons[2] = new JRadioButton("Non-auto-closing dialog");
    radioButtons[2].setActionCommand(nonAutoCommand);

    radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)");
    radioButtons[3].setActionCommand(customOptionCommand);

    radioButtons[4] = new JRadioButton("Non-modal dialog");
    radioButtons[4].setActionCommand(nonModalCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // pick one of many
            if (command == pickOneCommand) {
                Object[] possibilities = { "ham", "spam", "yam" };
                String s = (String) JOptionPane.showInputDialog(frame,
                        "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog",
                        JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham");

                // If a string was returned, say so.
                if ((s != null) && (s.length() > 0)) {
                    setLabel("Green eggs and... " + s + "!");
                    return;
                }

                // If you're here, the return value was null/empty.
                setLabel("Come on, finish the sentence!");

                // text input
            } else if (command == textEnteredCommand) {
                String s = (String) JOptionPane.showInputDialog(frame,
                        "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog",
                        JOptionPane.PLAIN_MESSAGE, icon, null, "ham");

                // If a string was returned, say so.
                if ((s != null) && (s.length() > 0)) {
                    setLabel("Green eggs and... " + s + "!");
                    return;
                }

                // If you're here, the return value was null/empty.
                setLabel("Come on, finish the sentence!");

                // non-auto-closing dialog
            } else if (command == nonAutoCommand) {
                final JOptionPane optionPane = new JOptionPane(
                        "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n"
                                + "Do you understand?",
                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

                // You can't use pane.createDialog() because that
                // method sets up the JDialog with a property change
                // listener that automatically closes the window
                // when a button is clicked.
                final JDialog dialog = new JDialog(frame, "Click a button", true);
                dialog.setContentPane(optionPane);
                dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                dialog.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent we) {
                        setLabel("Thwarted user attempt to close window.");
                    }
                });
                optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent e) {
                        String prop = e.getPropertyName();

                        if (dialog.isVisible() && (e.getSource() == optionPane)
                                && (JOptionPane.VALUE_PROPERTY.equals(prop))) {
                            // If you were going to check something
                            // before closing the window, you'd do
                            // it here.
                            dialog.setVisible(false);
                        }
                    }
                });
                dialog.pack();
                dialog.setLocationRelativeTo(frame);
                dialog.setVisible(true);

                int value = ((Integer) optionPane.getValue()).intValue();
                if (value == JOptionPane.YES_OPTION) {
                    setLabel("Good.");
                } else if (value == JOptionPane.NO_OPTION) {
                    setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. "
                            + "You can't!");
                } else {
                    setLabel("Window unavoidably closed (ESC?).");
                }

                // non-auto-closing dialog with custom message area
                // NOTE: if you don't intend to check the input,
                // then just use showInputDialog instead.
            } else if (command == customOptionCommand) {
                customDialog.setLocationRelativeTo(frame);
                customDialog.setVisible(true);

                String s = customDialog.getValidatedText();
                if (s != null) {
                    // The text is valid.
                    setLabel("Congratulations!  " + "You entered \"" + s + "\".");
                }

                // non-modal dialog
            } else if (command == nonModalCommand) {
                // Create the dialog.
                final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog");

                // Add contents to it. It must have a close button,
                // since some L&Fs (notably Java/Metal) don't provide one
                // in the window decorations for dialogs.
                JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>"
                        + "You can have one or more of these up<br>" + "and still use the main window.");
                label.setHorizontalAlignment(JLabel.CENTER);
                Font font = label.getFont();
                label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f));

                JButton closeButton = new JButton("Close");
                closeButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        dialog.setVisible(false);
                        dialog.dispose();
                    }
                });
                JPanel closePanel = new JPanel();
                closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS));
                closePanel.add(Box.createHorizontalGlue());
                closePanel.add(closeButton);
                closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));

                JPanel contentPane = new JPanel(new BorderLayout());
                contentPane.add(label, BorderLayout.CENTER);
                contentPane.add(closePanel, BorderLayout.PAGE_END);
                contentPane.setOpaque(true);
                dialog.setContentPane(contentPane);

                // Show it.
                dialog.setSize(new Dimension(300, 150));
                dialog.setLocationRelativeTo(frame);
                dialog.setVisible(true);
            }
        }
    });

    return createPane(moreDialogDesc + ":", radioButtons, showItButton);
}

From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java

public SQLComponent createComponent() {

    return new BaseSQLComponent(this) {

        private ValidState validVarName;
        private JRadioButton radioVal = new JRadioButton("Valeur");
        private JRadioButton radioFormule = new JRadioButton("Formule");

        private final JTextField textValeur = new JTextField();
        // private final ITextArea textFormule = new ITextArea();
        private final VariableTree treeVariable = new VariableTree();
        private final JTextField textNom = new JTextField();
        private final JLabel labelWarningBadVar = new JLabelWarning();
        private ElementComboBox comboSelSal;
        private EditFrame edit = null;
        private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree());

        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();

            this.validVarName = null;
            this.textFormule.setEditable(false);

            // Arbre des variables
            JScrollPane sc = new JScrollPane(this.treeVariable);
            sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height));

            this.treeVariable.addMouseListener(new MouseAdapter() {
                public void mousePressed(final MouseEvent mE) {
                    if (mE.getButton() == MouseEvent.BUTTON3) {
                        JPopupMenu menuDroit = new JPopupMenu();

                        TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                mE.getPoint().y);

                        final Object obj = path.getLastPathComponent();

                        if ((obj == null) || !(obj instanceof VariableRowTreeNode)) {
                            return;
                        }/*w  w  w.  j a v a  2  s.c  o  m*/

                        menuDroit.add(new AbstractAction("Editer") {
                            public void actionPerformed(ActionEvent e) {
                                if (edit == null) {
                                    edit = new EditFrame(getElement(), EditFrame.MODIFICATION);
                                }

                                System.err.println("Action performed");

                                if (obj != null) {
                                    System.err.println("Object not null --> " + obj.toString());
                                    if (obj instanceof VariableRowTreeNode) {
                                        System.err.println("Object VariableRowTreeNode");
                                        VariableRowTreeNode varNode = (VariableRowTreeNode) obj;

                                        edit.selectionId(varNode.getID(), 1);
                                        edit.setVisible(true);
                                    }
                                }
                            }
                        });
                        menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y);
                    } else {
                        if (mE.getClickCount() == 2) {
                            TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                    mE.getPoint().y);
                            Object obj = path.getLastPathComponent();

                            if (obj != null) {
                                if (obj instanceof FormuleTreeNode) {
                                    final FormuleTreeNode n = (FormuleTreeNode) obj;

                                    int start = textFormule.getSelectionStart();
                                    String tmp = textFormule.getText();
                                    textFormule.setText(tmp.substring(0, start) + n.getTextValue()
                                            + tmp.substring(start, tmp.length()));
                                }
                            }
                        }
                    }
                }
            });

            JPanel panelDroite = new JPanel();
            panelDroite.setLayout(new GridBagLayout());

            // Categorie
            JTextField textCategorie = new JTextField();
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy = 0;
            JLabel labelCategorie = new JLabel("Catgorie");
            panelDroite.add(labelCategorie, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(textCategorie, c);
            c.gridwidth = 1;

            // Nom
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy++;
            JLabel labelNom = new JLabel("Nom");
            panelDroite.add(labelNom, c);

            c.gridx++;
            c.weightx = 1;
            panelDroite.add(this.textNom, c);

            this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() {
                @Override
                public void update(DocumentEvent e) {
                    updateValidVarName();
                }
            });

            c.gridx++;
            c.weightx = 0;
            panelDroite.add(this.labelWarningBadVar, c);

            // Description
            JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
            ITextArea textInfos = new ITextArea();
            c.gridy++;
            c.gridx = 1;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(labelInfos, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            c.weighty = 0;
            panelDroite.add(textInfos, c);

            // Valeur
            c.gridx = 1;
            c.gridy++;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(this.radioVal, c);

            c.gridx++;
            c.weightx = 1;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textValeur, c);

            c.gridwidth = 1;
            c.gridx = 1;
            c.gridy++;
            panelDroite.add(this.radioFormule, c);

            c.gridx++;
            c.weightx = 1;
            c.weighty = 1;
            c.fill = GridBagConstraints.BOTH;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textFormule, c);
            c.gridwidth = 1;

            ButtonGroup group = new ButtonGroup();
            group.add(this.radioVal);
            group.add(this.radioFormule);

            this.radioVal.setSelected(true);
            setFormuleEnabled(false);

            this.radioVal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(false);
                }
            });
            this.radioFormule.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(true);
                }
            });

            c.gridy++;
            c.gridx = 1;
            c.weighty = 0;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;

            this.comboSelSal = new ElementComboBox(false);
            this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class));

            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 0;
            panelDroite.add(this.comboSelSal, c);
            c.gridwidth = 1;

            JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite);

            c.fill = GridBagConstraints.BOTH;
            c.gridx = 0;
            c.gridy = 0;
            c.weightx = 1;
            c.weighty = 1;
            this.add(split, c);

            this.addRequiredSQLObject(this.textNom, "NOM");
            this.addSQLObject(this.textValeur, "VALEUR");
            this.addSQLObject(this.textFormule, "FORMULE");
            this.addSQLObject(textCategorie, "CATEGORIE");
            this.addSQLObject(textInfos, "INFOS");

            this.comboSelSal.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    // TODO Auto-generated method stub
                    textFormule.setSalarieID(comboSelSal.getSelectedId());
                }
            });
        }

        @Override
        public synchronized ValidState getValidState() {
            return super.getValidState().and(this.validVarName);
        }

        private void setFormuleEnabled(boolean b) {

            if (b) {
                this.textValeur.setText("");
            } else {
                this.textFormule.setText("");
            }

            this.textValeur.setEditable(!b);
            this.textValeur.setEnabled(!b);
            this.textFormule.setEditable(b);
            this.textFormule.setEnabled(b);
            this.treeVariable.setEnabled(b);
            this.treeVariable.setEditable(b);
        }

        private void setValidVarName(ValidState s) {
            if (!s.equals(this.validVarName)) {
                this.validVarName = s;
                final boolean warningVisible = !s.isValid();
                if (warningVisible)
                    this.labelWarningBadVar.setText(s.getValidationText());
                this.labelWarningBadVar.setVisible(warningVisible);
                this.fireValidChange();
            }
        }

        private void updateValidVarName() {
            this.setValidVarName(this.computeValidVarName());
        }

        private ValidState computeValidVarName() {
            // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _)
            final String varName = this.textNom.getText().trim();

            System.err.println("Verification de la validit du nom de la variable.");

            if (varName.length() == 0) {
                return VAR_NO_NAME;
            }

            // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre
            if (!isJavaVar(varName)) {
                return VAR_NAME_NOT_CORRECT;
            }

            // on vrifie que la variable n'existe pas dja
            SQLSelect selAllVarName = new SQLSelect(getTable().getBase());

            selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID"));
            Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName);
            w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID()));
            selAllVarName.setWhere(w);

            String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "'
            // REGEXP VARIABLE_PAYE.NOM";
            Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName,
                    new ArrayListHandler())).toArray();

            if (objKeysRowName.length > 0) {
                return VAR_ALREADY_EXIST;
            } else {

                // Impossible de crer une variable du meme nom qu'un champ du salarie
                if (isForbidden(varName))
                    return VAR_ALREADY_EXIST;

                this.textFormule.setVarAssign(varName);
                return ValidState.getTrueInstance();
            }
        }

        private boolean isJavaVar(String s) {
            if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) {
                System.err.println("Erreur la variable commence par un chiffre!!");
                return false;
            } else {
                for (int i = 0; i < s.length(); i++) {

                    if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9'))
                            || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z')
                            || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) {
                        System.err.println("Erreur la variable contient un caractere incorrect!!");
                        return false;
                    }
                }

                return (!CTokenMarker.getKeywords().isExisting(s));
            }
        }

        @Override
        public void select(SQLRowAccessor r) {

            super.select(r);
            // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " +
            // this.hashCode());
            if (r != null) {
                if (r.getString("FORMULE").trim().length() == 0) {
                    this.radioVal.setSelected(true);
                    setFormuleEnabled(false);
                } else {
                    this.radioFormule.setSelected(true);
                    setFormuleEnabled(true);
                }

                this.textFormule.setVarAssign(r.getString("NOM"));
            }

            this.updateValidVarName();
        }
    };
}

From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java

private void createOntologySelectionPanel() {

    OntologyListRenderer listRenderer = new OntologyListRenderer();

    JPanel westPanel = new JPanel(new BorderLayout());

    JPanel selectedOntologiesContainer = new JPanel(new BorderLayout());
    selectedOntologiesContainer.setOpaque(false);

    // create List containing selected ontologies
    selectedOntologyListModel = new DefaultListModel();
    selectedOntologyList = new JList(selectedOntologyListModel);
    selectedOntologyList.setCellRenderer(new SelectedOntologyListRenderer());
    selectedOntologyList.setBackground(UIHelper.BG_COLOR);

    selectedOntologyList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            setOntologySelectionPanelPlaceholder(infoImage);

            setSelectedOntologyButtonVisibility(selectedOntologyList.isSelectionEmpty());
        }/*w  ww. java 2s .  com*/
    });

    JScrollPane selectedOntologiesScroller = new JScrollPane(selectedOntologyList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    selectedOntologiesScroller.setPreferredSize(new Dimension(200, 255));
    selectedOntologiesScroller.setBackground(UIHelper.BG_COLOR);
    selectedOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(selectedOntologiesScroller);

    selectedOntologiesContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7),
            "selected ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    selectedOntologiesContainer.add(selectedOntologiesScroller, BorderLayout.CENTER);

    // ADD BUTTONS
    removeOntologyButton = new JLabel(removeOntologyButtonIcon);
    removeOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {

            if (!selectedOntologyList.isSelectionEmpty()) {
                String ontologyToRemove = selectedOntologyList.getSelectedValue().toString();
                System.out.println("Removing  " + ontologyToRemove);
                selectedOntologies.remove(ontologyToRemove);
                setOntologySelectionPanelPlaceholder(infoImage);

                updateSelectedOntologies();
            }

            removeOntologyButton.setIcon(removeOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeOntologyButton.setIcon(removeOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeOntologyButton.setIcon(removeOntologyButtonIcon);
        }
    });

    removeOntologyButton.setVisible(false);

    viewOntologyButton = new JLabel(browseOntologyButtonIcon);
    viewOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            performTransition();
            viewOntologyButton.setIcon(browseOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            viewOntologyButton.setIcon(browseOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            viewOntologyButton.setIcon(browseOntologyButtonIcon);
        }
    });

    viewOntologyButton.setVisible(false);

    removeRestrictionButton = new JLabel(removeRestrictionButtonIcon);
    removeRestrictionButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (!selectedOntologyList.isSelectionEmpty()) {
                ((RecommendedOntology) selectedOntologyList.getSelectedValue()).setBranchToSearchUnder(null);
                removeRestrictionButton.setVisible(false);
                selectedOntologyList.repaint();
            }

            removeRestrictionButton.setIcon(removeRestrictionButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeRestrictionButton.setIcon(removeRestrictionButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeRestrictionButton.setIcon(removeRestrictionButtonIcon);
        }
    });

    removeRestrictionButton.setVisible(false);

    Box selectedOntologiesOptionContainer = Box.createHorizontalBox();
    selectedOntologiesOptionContainer.setOpaque(false);

    selectedOntologiesOptionContainer.add(removeOntologyButton);
    selectedOntologiesOptionContainer.add(viewOntologyButton);
    selectedOntologiesOptionContainer.add(removeRestrictionButton);

    selectedOntologiesContainer.add(selectedOntologiesOptionContainer, BorderLayout.SOUTH);

    // create panel populated with all available ontologies inside a filterable list!
    JPanel availableOntologiesListContainer = new JPanel(new BorderLayout());
    availableOntologiesListContainer
            .setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7),
                    "available ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                    UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    final ExtendedJList availableOntologies = new ExtendedJList(listRenderer);

    final JLabel addOntologyButton = new JLabel(addOntologyButtonIcon);
    addOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (!availableOntologies.isSelectionEmpty()) {
                Ontology ontology = (Ontology) availableOntologies.getSelectedValue();

                selectedOntologies.put(ontology.getOntologyDisplayLabel(), new RecommendedOntology(ontology));
                updateSelectedOntologies();

                setOntologySelectionPanelPlaceholder(infoImage);
            }

            addOntologyButton.setIcon(addOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addOntologyButton.setIcon(addOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addOntologyButton.setIcon(addOntologyButtonIcon);
        }
    });

    final JLabel info = UIHelper.createLabel("", UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR);

    availableOntologies.addPropertyChangeListener("update", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            info.setText("<html>viewing <b>" + availableOntologies.getFilteredItems().size()
                    + "</b> ontologies</html>");
        }
    });

    Box optionsBox = Box.createVerticalBox();

    optionsBox.add(UIHelper.wrapComponentInPanel(info));

    Box availableOntologiesOptionBox = Box.createHorizontalBox();
    availableOntologiesOptionBox.add(addOntologyButton);
    availableOntologiesOptionBox.add(Box.createHorizontalGlue());

    optionsBox.add(availableOntologiesOptionBox);

    availableOntologiesListContainer.add(optionsBox, BorderLayout.SOUTH);

    if (ontologiesToBrowseOn == null) {
        ontologiesToBrowseOn = new ArrayList<Ontology>();
        List<Ontology> bioportalQueryResult = bioportalClient.getAllOntologies();
        if (bioportalQueryResult != null) {
            ontologiesToBrowseOn.addAll(bioportalQueryResult);
        }
        ontologiesToBrowseOn.addAll(olsClient.getAllOntologies());
    }

    // precautionary check in case of having no ontologies available to search on.
    if (ontologiesToBrowseOn != null) {
        for (Ontology o : ontologiesToBrowseOn) {
            availableOntologies.addItem(o);
        }
    }

    info.setText(
            "<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>");

    // need to get ontologies available from bioportal and add them here.
    JScrollPane availableOntologiesScroller = new JScrollPane(availableOntologies,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    availableOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    availableOntologiesScroller.setPreferredSize(new Dimension(200, 125));
    availableOntologiesScroller.setBorder(new EmptyBorder(0, 0, 0, 0));

    IAppWidgetFactory.makeIAppScrollPane(availableOntologiesScroller);

    availableOntologiesListContainer.add(availableOntologiesScroller);
    availableOntologiesListContainer.add(availableOntologies.getFilterField(), BorderLayout.NORTH);

    westPanel.add(selectedOntologiesContainer, BorderLayout.CENTER);
    westPanel.add(availableOntologiesListContainer, BorderLayout.SOUTH);

    add(westPanel, BorderLayout.WEST);
}

From source file:op.care.prescription.DlgOnDemand.java

/**
 * This method is called from within the constructor to
 * initialize the form./*  w  w  w  .  j av  a  2s  .  c  o  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    txtMed = new JXSearchField();
    cmbMed = new JComboBox<>();
    panel4 = new JPanel();
    btnMedWizard = new JButton();
    cmbIntervention = new JComboBox<>();
    txtSit = new JXSearchField();
    cmbSit = new JComboBox<>();
    panel3 = new JPanel();
    btnAddSit = new JButton();
    txtIntervention = new JXSearchField();
    jPanel2 = new JPanel();
    lblNumber = new JLabel();
    lblDose = new JLabel();
    lblMaxPerDay = new JLabel();
    txtMaxTimes = new JTextField();
    lblX = new JLabel();
    txtEDosis = new JTextField();
    lblCheckResultAfter = new JLabel();
    cmbCheckAfter = new JComboBox<>();
    jPanel3 = new JPanel();
    pnlOFF = new JPanel();
    rbActive = new JRadioButton();
    rbDate = new JRadioButton();
    txtOFF = new JTextField();
    jScrollPane3 = new JScrollPane();
    txtBemerkung = new JTextPane();
    lblText = new JLabel();
    pnlON = new JPanel();
    cmbDocON = new JComboBox<>();
    cmbHospitalON = new JComboBox<>();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnSave = new JButton();

    //======== this ========
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, default, 6dlu, 355dlu, $lcgap, 14dlu",
            "14dlu, $lgap, fill:default:grow, $lgap, fill:default, $lgap, 14dlu"));

    //======== jPanel1 ========
    {
        jPanel1.setBorder(null);
        jPanel1.setLayout(new FormLayout("68dlu, $lcgap, pref:grow, $lcgap, pref",
                "3*(16dlu, $lgap), default, $lgap, fill:113dlu:grow, $lgap, 60dlu"));

        //---- txtMed ----
        txtMed.setFont(new Font("Arial", Font.PLAIN, 14));
        txtMed.setPrompt("Medikamente");
        txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT);
        txtMed.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                txtMedActionPerformed(e);
            }
        });
        txtMed.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtMedFocusGained(e);
            }
        });
        jPanel1.add(txtMed, CC.xy(1, 1));

        //---- cmbMed ----
        cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbMed.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbMed.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                cmbMedItemStateChanged(e);
            }
        });
        jPanel1.add(cmbMed, CC.xy(3, 1));

        //======== panel4 ========
        {
            panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS));

            //---- btnMedWizard ----
            btnMedWizard.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnMedWizard.setBorderPainted(false);
            btnMedWizard.setBorder(null);
            btnMedWizard.setContentAreaFilled(false);
            btnMedWizard.setToolTipText("Neues Medikament eintragen");
            btnMedWizard.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnMedWizard.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnMedWizard.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnMedActionPerformed(e);
                }
            });
            panel4.add(btnMedWizard);
        }
        jPanel1.add(panel4, CC.xy(5, 1));

        //---- cmbIntervention ----
        cmbIntervention
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbIntervention, CC.xywh(3, 5, 3, 1));

        //---- txtSit ----
        txtSit.setPrompt("Situationen");
        txtSit.setFont(new Font("Arial", Font.PLAIN, 14));
        txtSit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                txtSitActionPerformed(e);
            }
        });
        jPanel1.add(txtSit, CC.xy(1, 3));

        //---- cmbSit ----
        cmbSit.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbSit.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbSit.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                cmbSitItemStateChanged(e);
            }
        });
        cmbSit.addPropertyChangeListener("model", new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent e) {
                cmbSitPropertyChange(e);
            }
        });
        jPanel1.add(cmbSit, CC.xy(3, 3));

        //======== panel3 ========
        {
            panel3.setLayout(new BoxLayout(panel3, BoxLayout.LINE_AXIS));

            //---- btnAddSit ----
            btnAddSit.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddSit.setBorderPainted(false);
            btnAddSit.setBorder(null);
            btnAddSit.setContentAreaFilled(false);
            btnAddSit.setToolTipText("Neue  Situation eintragen");
            btnAddSit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnAddSit.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddSit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnSituationActionPerformed(e);
                }
            });
            panel3.add(btnAddSit);
        }
        jPanel1.add(panel3, CC.xy(5, 3, CC.RIGHT, CC.DEFAULT));

        //---- txtIntervention ----
        txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        txtIntervention.setPrompt("Massnahmen");
        txtIntervention.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                txtMassActionPerformed(e);
            }
        });
        jPanel1.add(txtIntervention, CC.xy(1, 5));

        //======== jPanel2 ========
        {
            jPanel2.setLayout(new FormLayout("default, $lcgap, pref, $lcgap, default, $lcgap, 37dlu:grow",
                    "23dlu, fill:22dlu, $ugap, default"));

            //---- lblNumber ----
            lblNumber.setText("Anzahl");
            jPanel2.add(lblNumber, CC.xy(3, 1));

            //---- lblDose ----
            lblDose.setText("Dosis");
            jPanel2.add(lblDose, CC.xy(7, 1, CC.CENTER, CC.DEFAULT));

            //---- lblMaxPerDay ----
            lblMaxPerDay.setText("Max. Tagesdosis:");
            jPanel2.add(lblMaxPerDay, CC.xy(1, 2));

            //---- txtMaxTimes ----
            txtMaxTimes.setHorizontalAlignment(SwingConstants.CENTER);
            txtMaxTimes.setText("1");
            txtMaxTimes.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    txtMaxTimesActionPerformed(e);
                }
            });
            txtMaxTimes.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtMaxTimesFocusGained(e);
                }

                @Override
                public void focusLost(FocusEvent e) {
                    txtMaxTimesFocusLost(e);
                }
            });
            jPanel2.add(txtMaxTimes, CC.xy(3, 2));

            //---- lblX ----
            lblX.setText("x");
            jPanel2.add(lblX, CC.xy(5, 2));

            //---- txtEDosis ----
            txtEDosis.setHorizontalAlignment(SwingConstants.CENTER);
            txtEDosis.setText("1.0");
            txtEDosis.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtEDosisFocusGained(e);
                }

                @Override
                public void focusLost(FocusEvent e) {
                    txtEDosisFocusLost(e);
                }
            });
            txtEDosis.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    txtEDosisActionPerformed(e);
                }
            });
            jPanel2.add(txtEDosis, CC.xy(7, 2));

            //---- lblCheckResultAfter ----
            lblCheckResultAfter.setText("Nachkontrolle:");
            jPanel2.add(lblCheckResultAfter, CC.xy(1, 4));

            //---- cmbCheckAfter ----
            cmbCheckAfter.setModel(new DefaultComboBoxModel<>(new String[] { "keine Nachkontrolle",
                    "nach 1 Stunde", "nach 2 Stunden", "nach 3 Stunden" }));
            jPanel2.add(cmbCheckAfter, CC.xywh(3, 4, 5, 1));
        }
        jPanel1.add(jPanel2, CC.xywh(1, 9, 5, 1, CC.CENTER, CC.TOP));
    }
    contentPane.add(jPanel1, CC.xy(5, 3));

    //======== jPanel3 ========
    {
        jPanel3.setBorder(null);
        jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:100dlu:grow"));

        //======== pnlOFF ========
        {
            pnlOFF.setBorder(new TitledBorder("Absetzung"));
            pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "fill:17dlu, $lgap, fill:17dlu"));

            //---- rbActive ----
            rbActive.setText("text");
            rbActive.setSelected(true);
            rbActive.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    rbActiveItemStateChanged(e);
                }
            });
            pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1));

            //---- rbDate ----
            rbDate.setText(null);
            rbDate.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    rbDateItemStateChanged(e);
                }
            });
            pnlOFF.add(rbDate, CC.xy(1, 3));

            //---- txtOFF ----
            txtOFF.setEnabled(false);
            txtOFF.setFont(new Font("Arial", Font.PLAIN, 14));
            txtOFF.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    txtOFFFocusLost(e);
                }
            });
            pnlOFF.add(txtOFF, CC.xy(2, 3));
        }
        jPanel3.add(pnlOFF, CC.xy(1, 3));

        //======== jScrollPane3 ========
        {

            //---- txtBemerkung ----
            txtBemerkung.addCaretListener(new CaretListener() {
                @Override
                public void caretUpdate(CaretEvent e) {
                    txtBemerkungCaretUpdate(e);
                }
            });
            jScrollPane3.setViewportView(txtBemerkung);
        }
        jPanel3.add(jScrollPane3, CC.xy(1, 7));

        //---- lblText ----
        lblText.setText("Bemerkung:");
        jPanel3.add(lblText, CC.xy(1, 5));

        //======== pnlON ========
        {
            pnlON.setBorder(new TitledBorder("Ansetzung"));
            pnlON.setLayout(new FormLayout("119dlu:grow", "17dlu, $lgap, fill:17dlu"));

            //---- cmbDocON ----
            cmbDocON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            cmbDocON.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    cmbDocONKeyPressed(e);
                }
            });
            pnlON.add(cmbDocON, CC.xy(1, 1));

            //---- cmbHospitalON ----
            cmbHospitalON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            pnlON.add(cmbHospitalON, CC.xy(1, 3));
        }
        jPanel3.add(pnlON, CC.xy(1, 1));
    }
    contentPane.add(jPanel3, CC.xy(3, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));

        //---- btnClose ----
        btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnCloseActionPerformed(e);
            }
        });
        panel1.add(btnClose);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnSave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnSaveActionPerformed(e);
            }
        });
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));
    setSize(1035, 515);
    setLocationRelativeTo(getOwner());

    //---- bgMedikament ----
    ButtonGroup bgMedikament = new ButtonGroup();
    bgMedikament.add(rbActive);
    bgMedikament.add(rbDate);
}

From source file:op.care.med.structure.PnlMed.java

private java.util.List<Component> addCommands() {
    java.util.List<Component> list = new ArrayList<Component>();

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.INSERT, internalClassID)) {
        final JideButton addButton = GUITools.createHyperlinkButton(MedProductWizard.internalClassID,
                SYSConst.icon22wizard, null);

        addButton.addActionListener(new ActionListener() {
            @Override/*from   w w w .  j  a  va  2 s .  co m*/
            public void actionPerformed(ActionEvent actionEvent) {

                final JidePopup popup = new JidePopup();

                WizardDialog wizard = new MedProductWizard(new Closure() {
                    @Override
                    public void execute(Object o) {
                        popup.hidePopup();
                        // keine Manahme ntig
                    }
                }).getWizard();

                popup.setMovable(false);
                popup.setPreferredSize((new Dimension(800, 450)));
                popup.setResizable(false);
                popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
                popup.getContentPane().add(wizard.getContentPane());
                popup.setOwner(addButton);
                popup.removeExcludedComponent(addButton);
                popup.setTransient(false);
                popup.setDefaultFocusComponent(wizard.getContentPane());
                popup.addPropertyChangeListener("visible", new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                        popup.getContentPane().getComponentCount();
                    }
                });

                GUITools.showPopup(popup, SwingConstants.NORTH_EAST);
            }
        });

        list.add(addButton);
    }

    //       OPDE.debug("isCalcMediUPR1: " + OPDE.isCalcMediUPR1());
    //
    //        if (OPDE.isDebug()) {
    //            Iterator it = OPDE.getProps().entrySet().iterator();
    //            while (it.hasNext()) {
    //                OPDE.debug(it.next().toString());
    //            }
    //        }

    if (OPDE.isCalcMediUPR1() && OPDE.getAppInfo().isAllowedTo(InternalClassACL.INSERT, internalClassID)) {
        JideButton buchenButton = GUITools.createHyperlinkButton("nursingrecords.inventory.newstocks",
                SYSConst.icon22addrow, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                        new DlgNewStocks(null);
                    }
                });
        list.add(buchenButton);
    }

    return list;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java

/**
 * Downloads the possible script.//w  ww. j av  a2  s . com
 * 
 * @param param The parameter holding the script.
 */
private void downloadScript(ScriptActivityParam param) {
    FileChooser chooser = new FileChooser(view, FileChooser.SAVE, "Download",
            "Select where to download the file.", null, true);
    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
    chooser.setSelectedFileFull(param.getScript().getName());
    chooser.setApproveButtonText("Download");
    final long id = param.getScript().getScriptID();
    chooser.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
                File[] files = (File[]) evt.getNewValue();
                File folder = files[0];
                IconManager icons = IconManager.getInstance();
                DownloadActivityParam activity;
                activity = new DownloadActivityParam(id, DownloadActivityParam.ORIGINAL_FILE, folder,
                        icons.getIcon(IconManager.DOWNLOAD_22));
                UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
                SecurityContext ctx = new SecurityContext(
                        TreeViewerAgent.getUserDetails().getDefaultGroup().getId());
                un.notifyActivity(ctx, activity);
            }
        }
    });
    chooser.centerDialog();
}

From source file:org.signserver.admin.gui.MainView.java

public MainView(SingleFrameApplication app) {
    super(app);//  ww w  .  j a  v  a 2  s.  c o  m

    initComponents();

    final int rowHeights = new JComboBox/*<String>*/().getPreferredSize().height;

    // workaround a bug in the NetBeans form editor where the download
    // archive entries button sometimes looses its default disabled state
    downloadArchiveEntriesButton.setEnabled(false);

    statusSummaryTextPane.setContentType("text/html");

    auditlogConditionsModel.addCondition(AuditlogColumn.EVENTTYPE, RelationalOperator.NEQ, "ACCESS_CONTROL");
    auditLogTable.setModel(auditlogModel);
    archiveTable.setModel(archiveModel);
    conditionsTable.setModel(auditlogConditionsModel);
    conditionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                jButtonAuditConditionRemove.setEnabled(conditionsTable.getSelectedRowCount() > 0);
            }
        }
    });
    jTabbedPane1.setSelectedComponent(mainPanel);

    archiveConditionsTable.setModel(archiveConditionsModel);
    archiveConditionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                jButtonArchiveConditionRemove.setEnabled(archiveConditionsTable.getSelectedRowCount() > 0);
            }
        }
    });

    tokenEntriesTable.setModel(tokenEntriesModel);
    tokenEntriesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final boolean exactlyOneSelected = tokenEntriesTable.getSelectedRowCount() == 1;
                final boolean anySelected = tokenEntriesTable.getSelectedRowCount() > 0;
                tokenEntriesTestButton.setEnabled(exactlyOneSelected);
                tokenEntriesGenerateCSRButton.setEnabled(anySelected);
                tokenEntriesImportButton.setEnabled(anySelected);
                tokenEntriesRemoveButton.setEnabled(exactlyOneSelected);
                tokenEntriesDetailsButton.setEnabled(exactlyOneSelected);
            }
        }
    });

    final String action = "DetailsOnEnter";
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    tokenEntriesTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enter, action);
    tokenEntriesTable.getActionMap().put(action, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (tokenEntriesTable.getSelectedRows().length > 0) {
                tokenEntriesDetailsButton.doClick();
            }
        }
    });

    workersList.setCellRenderer(new MyListCellRenderer());

    workersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                selectedWorkers = new ArrayList<Worker>();

                for (Object o : workersList.getSelectedValues()) {
                    if (o instanceof Worker) {
                        selectedWorkers.add((Worker) o);
                    }
                }

                workerComboBox.setModel(new MyComboBoxModel(selectedWorkers));

                // removeKey should only be enabled iff one selected
                removeKeyMenu.setEnabled(selectedWorkers.size() == 1);

                if (selectedWorkers.size() > 0) {

                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Previously selected: " + selectedWorkerBeforeRefresh);
                    }

                    int comboBoxSelection = 0;

                    // Try to set the previously selected
                    if (selectedWorkerBeforeRefresh != null) {
                        comboBoxSelection = selectedWorkers.indexOf(selectedWorkerBeforeRefresh);
                        if (comboBoxSelection == -1) {
                            comboBoxSelection = 0;
                        }
                    }
                    workerComboBox.setSelectedIndex(comboBoxSelection);
                } else {
                    displayWorker(null);
                }
            }
        }
    });

    workerComboBox.setRenderer(new SmallWorkerListCellRenderer());

    workerComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (workerComboBox.getSelectedItem() instanceof Worker) {
                displayWorker((Worker) workerComboBox.getSelectedItem());
            }
        }
    });

    propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {

                final int row = propertiesTable.getSelectedRow();
                final boolean enable;

                if (row == -1) {
                    enable = false;
                } else {
                    final Object o = propertiesTable.getValueAt(row, 1);
                    enable = o instanceof X509Certificate || o instanceof Collection; // TODO: Too weak
                }
                statusPropertiesDetailsButton.setEnabled(enable);
            }
        }
    });
    propertiesTable.setRowHeight(rowHeights);

    configurationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final boolean enable = configurationTable.getSelectedRowCount() == 1;
                editButton.setEnabled(enable);
                removeButton.setEnabled(enable);
            }
        }
    });
    configurationTable.setRowHeight(rowHeights);

    authTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final boolean enable = authTable.getSelectedRowCount() == 1;
                authEditButton.setEnabled(enable);
                authRemoveButton.setEnabled(enable);
            }
        }
    });
    authTable.setRowHeight(rowHeights);

    archiveTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                downloadArchiveEntriesButton
                        .setEnabled(!fetchArchiveDataInProgress && archiveTable.getSelectedRowCount() > 0);
            }
        }
    });
    archiveTable.setRowHeight(rowHeights);

    auditLogTable.setRowHeight(rowHeights);
    conditionsTable.setRowHeight(rowHeights);
    archiveConditionsTable.setRowHeight(rowHeights);
    tokenEntriesTable.setRowHeight(rowHeights);

    displayWorker(null);

    // status bar initialization - message timeout, idle icon and busy
    // animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            statusMessageLabel.setText("");
        }
    });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
        busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
            statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
        }
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
                if (!busyIconTimer.isRunning()) {
                    statusAnimationLabel.setIcon(busyIcons[0]);
                    busyIconIndex = 0;
                    busyIconTimer.start();
                }
                progressBar.setVisible(true);
                progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName)) {
                busyIconTimer.stop();
                statusAnimationLabel.setIcon(idleIcon);
                progressBar.setVisible(false);
                progressBar.setValue(0);
            } else if ("message".equals(propertyName)) {
                String text = (String) evt.getNewValue();
                statusMessageLabel.setText((text == null) ? "" : text);
                messageTimer.restart();
            } else if ("progress".equals(propertyName)) {
                int value = (Integer) evt.getNewValue();
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            }
        }
    });
    getContext().getTaskService().execute(refreshWorkers());
}