org.openide.NotificationLineSupport - java examples

Here are the examples of the java api org.openide.NotificationLineSupport taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

49 Examples 7

19 View Complete Implementation : MessageDestinationPanel.java
Copyright Apache License 2.0
Author : apache
public void setNotificationLine(NotificationLineSupport statusLine) {
    this.statusLine = statusLine;
}

19 View Complete Implementation : DataSourceReferencePanel.java
Copyright Apache License 2.0
Author : apache
public void setNotificationLine(NotificationLineSupport statusLine) {
    this.statusLine = statusLine;
    verify();
}

19 View Complete Implementation : SelectAppServerPanel.java
Copyright Apache License 2.0
Author : apache
private void setNLS(NotificationLineSupport notif) {
    nls = notif;
}

19 View Complete Implementation : SelectAppServerPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author mkleint
 */
public clreplaced SelectAppServerPanel extends javax.swing.JPanel {

    private NotificationLineSupport nls;

    private Project project;

    private SelectAppServerPanel(boolean showIgnore, Project project) {
        this.project = project;
        initComponents();
        loadComboModel();
        if (showIgnore) {
            checkIgnoreEnablement();
            comServer.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    checkIgnoreEnablement();
                }
            });
            rbIgnore.addItemListener(new ItemListener() {

                @Override
                public void itemStateChanged(ItemEvent e) {
                    printIgnoreWarning();
                }
            });
        } else {
            rbIgnore.setVisible(false);
        }
        updateProjectLbl();
        rbPermanentStateChanged(null);
    }

    public static boolean showServerSelectionDialog(Project project, J2eeModuleProvider provider, RunConfig config) {
        if (ExecutionChecker.DEV_NULL.equals(provider.getServerInstanceID())) {
            SelectAppServerPanel panel = new SelectAppServerPanel(isGoalOverridden(config), project);
            DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(SelectAppServerPanel.clreplaced, "replaced_Select"));
            panel.setNLS(dd.createNotificationLineSupport());
            Object obj = DialogDisplayer.getDefault().notify(dd);
            if (obj == NotifyDescriptor.OK_OPTION) {
                String instanceId = panel.getSelectedServerInstance();
                String serverId = panel.getSelectedServerType();
                if (!ExecutionChecker.DEV_NULL.equals(instanceId)) {
                    boolean permanent = panel.isPermanent();
                    boolean doNotRemember = panel.isDoNotRemember();
                    // The server should be used only for this deployment
                    if (doNotRemember) {
                        OneTimeDeployment oneTimeDeployment = project.getLookup().lookup(OneTimeDeployment.clreplaced);
                        if (oneTimeDeployment != null) {
                            oneTimeDeployment.setServerInstanceId(instanceId);
                        }
                        MavenProjectSupport.changeServer(project, true);
                    } else if (permanent) {
                        persistServer(project, instanceId, serverId, panel.getChosenProject());
                    } else {
                        SessionContent sc = project.getLookup().lookup(SessionContent.clreplaced);
                        if (sc != null) {
                            sc.setServerInstanceId(instanceId);
                        }
                        // We want to initiate context path to default value if there isn't related deployment descriptor yet
                        MavenProjectSupport.changeServer(project, true);
                    }
                    // NOI18N
                    LoggingUtils.logUsage(ExecutionChecker.clreplaced, "USG_PROJECT_CONFIG_MAVEN_SERVER", new Object[] { MavenProjectSupport.obtainServerName(project) }, "maven");
                    return true;
                } else {
                    // ignored used now..
                    if (panel.isIgnored() && config != null) {
                        removeNetbeansDeployFromActionMappings(project, config.getActionName());
                        return true;
                    }
                }
            }
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(SelectAppServerPanel.clreplaced, "ERR_Action_without_deployment_server"));
            return false;
        }
        return true;
    }

    private static void removeNetbeansDeployFromActionMappings(Project project, String actionName) {
        try {
            ProjectConfiguration cfg = project.getLookup().lookup(ProjectConfigurationProvider.clreplaced).getActiveConfiguration();
            NetbeansActionMapping mapp = ModelHandle2.getMapping(actionName, project, cfg);
            if (mapp != null) {
                mapp.getProperties().remove(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY);
                ModelHandle2.putMapping(mapp, project, cfg);
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    /**
     * Finds out if the run configuration uses different goal than the default one.
     *
     * <p>
     * The purpose of this method is to find out if there is some 'special' action
     * defined by the user instead of default run process. That might be for example
     * running jetty:run goal which starts temporary server which doesn't need to be
     * defined inside of NetBeans.
     * </p>
     *
     * @param config configuration of this project
     * @return {@code true} in case user overrides the goal, {@code false} otherwise
     */
    private static boolean isGoalOverridden(RunConfig config) {
        if (config == null) {
            return false;
        }
        return !config.getGoals().isEmpty();
    }

    private static void persistServer(Project project, final String iID, final String sID, final Project targetPrj) {
        JavaEEProjectSettings.setServerInstanceID(project, iID);
        MavenProjectSupport.setServerID(project, sID);
        // We want to initiate context path to default value if there isn't related deployment descriptor yet
        MavenProjectSupport.changeServer(project, true);
        // refresh all subprojects
        // TODO replace with DependencyProjectProvider or ProjectContainerProvider
        SubprojectProvider spp = targetPrj.getLookup().lookup(SubprojectProvider.clreplaced);
        // mkleint: we are replaceduming complete result (transitive projects included)
        // that's ok as far as the current maven impl goes afaik, but not according to the
        // doreplacedentation for SubProjectprovider
        Set<? extends Project> childrenProjs = spp.getSubprojects();
        if (!childrenProjs.contains(project)) {
            NbMavenProject.fireMavenProjectReload(project);
        }
        for (Project curPrj : childrenProjs) {
            NbMavenProject.fireMavenProjectReload(curPrj);
        }
    }

    private String getSelectedServerType() {
        return ((Server) comServer.getSelectedItem()).getServerID();
    }

    private String getSelectedServerInstance() {
        return ((Server) comServer.getSelectedItem()).getServerInstanceID();
    }

    private boolean isPermanent() {
        return rbPermanent.isSelected();
    }

    private boolean isIgnored() {
        return rbIgnore.isSelected();
    }

    private boolean isDoNotRemember() {
        return rbDontRemember.isSelected();
    }

    private Project getChosenProject() {
        return project;
    }

    private void loadComboModel() {
        Ear ear = Ear.getEar(project.getProjectDirectory());
        EjbJar ejb = EjbJar.getEjbJar(project.getProjectDirectory());
        WebModule war = WebModule.getWebModule(project.getProjectDirectory());
        J2eeModule.Type type = ear != null ? J2eeModule.Type.EAR : (war != null ? J2eeModule.Type.WAR : (ejb != null ? J2eeModule.Type.EJB : J2eeModule.Type.CAR));
        Profile profile = ear != null ? ear.getJ2eeProfile() : (war != null ? war.getJ2eeProfile() : (ejb != null ? ejb.getJ2eeProfile() : Profile.JAVA_EE_6_FULL));
        String[] ids = Deployment.getDefault().getServerInstanceIDs(Collections.singletonList(type), profile);
        Collection<Server> col = new ArrayList<>();
        col.add(new Server(ExecutionChecker.DEV_NULL));
        for (int i = 0; i < ids.length; i++) {
            Server wr = new Server(ids[i]);
            col.add(wr);
        }
        comServer.setModel(new DefaultComboBoxModel(col.toArray()));
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        lblServer = new javax.swing.JLabel();
        comServer = new javax.swing.JComboBox();
        rbSession = new javax.swing.JRadioButton();
        rbPermanent = new javax.swing.JRadioButton();
        rbIgnore = new javax.swing.JRadioButton();
        lblProject = new javax.swing.JLabel();
        btChange = new javax.swing.JButton();
        rbDontRemember = new javax.swing.JRadioButton();
        lblServer.setLabelFor(comServer);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(lblServer, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.lblServer.text"));
        buttonGroup1.add(rbSession);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(rbSession, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.rbSession.text"));
        buttonGroup1.add(rbPermanent);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(rbPermanent, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.rbPermanent.text"));
        rbPermanent.addChangeListener(new javax.swing.event.ChangeListener() {

            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                rbPermanentStateChanged(evt);
            }
        });
        buttonGroup1.add(rbIgnore);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(rbIgnore, org.openide.util.NbBundle.getBundle(SelectAppServerPanel.clreplaced).getString("SelectAppServerPanel.rbIgnore.text"));
        lblProject.setFont(lblProject.getFont().deriveFont(lblProject.getFont().getSize() - 1f));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(lblProject, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.lblProject.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(btChange, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.btChange.text"));
        // NOI18N
        btChange.setToolTipText(org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.btChange.toolTipText"));
        btChange.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btChangeActionPerformed(evt);
            }
        });
        buttonGroup1.add(rbDontRemember);
        rbDontRemember.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(rbDontRemember, org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.rbDontRemember.text"));
        // NOI18N
        rbDontRemember.setToolTipText(org.openide.util.NbBundle.getMessage(SelectAppServerPanel.clreplaced, "SelectAppServerPanel.rbDontRemember.toolTipText"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(lblServer).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(comServer, 0, 443, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(rbPermanent).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(btChange)).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(rbIgnore).addGroup(layout.createSequentialGroup().addGap(11, 11, 11).addComponent(lblProject)).addComponent(rbDontRemember).addComponent(rbSession)).addGap(0, 0, Short.MAX_VALUE))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(lblServer).addComponent(comServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(32, 32, 32).addComponent(rbDontRemember).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(rbSession).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(btChange, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(rbPermanent)).addGap(18, 18, 18).addComponent(lblProject).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(rbIgnore).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    private void rbPermanentStateChanged(javax.swing.event.ChangeEvent evt) {
        // GEN-FIRST:event_rbPermanentStateChanged
        boolean isSel = rbPermanent.isSelected();
        btChange.setEnabled(isSel);
        lblProject.setEnabled(isSel);
        if (nls != null) {
            if (isSel) {
                nls.setInformationMessage(NbBundle.getMessage(SelectAppServerPanel.clreplaced, "MSG_ParentHint"));
            } else {
                nls.clearMessages();
            }
        }
    }

    // GEN-LAST:event_rbPermanentStateChanged
    private void btChangeActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_btChangeActionPerformed
        SelectProjectPanel spp = new SelectProjectPanel(project);
        final DialogDescriptor dd = new DialogDescriptor(spp, NbBundle.getMessage(SelectAppServerPanel.clreplaced, "replaced_ChooseParent"));
        spp.attachDD(dd);
        Object obj = DialogDisplayer.getDefault().notify(dd);
        if (obj == NotifyDescriptor.OK_OPTION) {
            project = spp.getSelectedProject();
            updateProjectLbl();
        }
    }

    // GEN-LAST:event_btChangeActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btChange;

    private javax.swing.ButtonGroup buttonGroup1;

    private javax.swing.JComboBox comServer;

    private javax.swing.JLabel lblProject;

    private javax.swing.JLabel lblServer;

    private javax.swing.JRadioButton rbDontRemember;

    javax.swing.JRadioButton rbIgnore;

    javax.swing.JRadioButton rbPermanent;

    javax.swing.JRadioButton rbSession;

    // End of variables declaration//GEN-END:variables
    private void checkIgnoreEnablement() {
        String selectedServer = getSelectedServerType();
        if (selectedServer == null || ExecutionChecker.DEV_NULL.equals(selectedServer)) {
            rbIgnore.setEnabled(true);
        } else {
            if (rbIgnore.isSelected()) {
                rbSession.setSelected(true);
            }
            rbIgnore.setEnabled(false);
        }
    }

    private void setNLS(NotificationLineSupport notif) {
        nls = notif;
    }

    private void printIgnoreWarning() {
        if (rbIgnore.isSelected()) {
            nls.setWarningMessage(NbBundle.getMessage(SelectAppServerPanel.clreplaced, "WARN_Ignore_Server"));
        } else {
            nls.clearMessages();
        }
    }

    private void updateProjectLbl() {
        ProjectInformation pi = ProjectUtils.getInformation(project);
        if (pi != null) {
            lblProject.setText(NbBundle.getMessage(SelectAppServerPanel.clreplaced, "MSG_InProject", pi.getDisplayName()));
        }
    }
}

19 View Complete Implementation : RunAnalysisPanel.java
Copyright Apache License 2.0
Author : apache
// GEN-LAST:event_configurationComboActionPerformed
private AdjustConfigurationPanel showConfigurationPanel(replacedyzerFactory preselectedreplacedyzer, String preselected, Configuration configurationToSelect) {
    final NotificationLineSupport[] nls = new NotificationLineSupport[1];
    final DialogDescriptor[] dd = new DialogDescriptor[1];
    ErrorListener errorListener = new ErrorListener() {

        @Override
        public void setError(String error) {
            nls[0].setErrorMessage(error);
            dd[0].setValid(error == null);
        }
    };
    AdjustConfigurationPanel panel = new AdjustConfigurationPanel(replacedyzers, preselectedreplacedyzer, preselected, configurationToSelect, errorListener);
    DialogDescriptor nd = new DialogDescriptor(panel, Bundle.LBL_Configurations(), true, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION, null);
    nls[0] = nd.createNotificationLineSupport();
    dd[0] = nd;
    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
        return panel;
    }
    return null;
}

19 View Complete Implementation : CommitPanel.java
Copyright Apache License 2.0
Author : apache
public void setMessageLine(NotificationLineSupport messageLine) {
    this.messageLine = messageLine;
    validateInput();
}

19 View Complete Implementation : NewGroupPanel.java
Copyright Apache License 2.0
Author : apache
void setNotificationLineSupport(NotificationLineSupport notificationLineSupport) {
    this.notificationLineSupport = notificationLineSupport;
    updateNameField();
}

19 View Complete Implementation : NewGroupPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * Panel permitting user to create a new project group.
 * Applicable in advanced mode.
 * @author Jesse Glick
 */
public clreplaced NewGroupPanel extends JPanel {

    // NOI18N
    public static final String PROP_READY = "ready";

    static final int MAX_NAME = 50;

    public NewGroupPanel() {
        initComponents();
        DoreplacedentListener l = new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent e) {
                firePropertyChange(PROP_READY, null, null);
            }

            @Override
            public void removeUpdate(DoreplacedentEvent e) {
                firePropertyChange(PROP_READY, null, null);
            }

            @Override
            public void changedUpdate(DoreplacedentEvent e) {
            }
        };
        directoryField.getDoreplacedent().addDoreplacedentListener(l);
        nameField.setText("Group " + new SimpleDateFormat("yyyyMMdd-hh:mm:ss").format(new Date()));
        nameField.getDoreplacedent().addDoreplacedentListener(l);
        nameField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent e) {
                nameConstraintsWarnings();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent e) {
                nameConstraintsWarnings();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent e) {
                nameConstraintsWarnings();
            }
        });
    }

    private void nameConstraintsWarnings() {
        updateNotifications();
    }

    public boolean isReady() {
        // sort of suboptional to have the isReady method to duplicate the checks in updateNotifications();
        String name = nameField.getText();
        if (name != null) {
            if (name.trim().length() <= 0 || name.trim().length() >= MAX_NAME) {
                return false;
            }
            if (name.equalsIgnoreCase(NONE_GOUP)) {
                return false;
            }
            for (Group group : Group.allGroups()) {
                if (name.equalsIgnoreCase(group.getName())) {
                    return false;
                }
            }
        }
        if (subprojectsKindRadio.isSelected()) {
            String s = masterProjectField.getText();
            if (s != null && s.length() > 0) {
                File f = FileUtil.normalizeFile(new File(s));
                FileObject fo = FileUtil.toFileObject(f);
                if (fo != null && fo.isFolder()) {
                    try {
                        return ProjectManager.getDefault().findProject(fo) != null;
                    } catch (IOException x) {
                        Exceptions.printStackTrace(x);
                    }
                }
            }
            return false;
        } else if (directoryKindRadio.isSelected()) {
            String s = directoryField.getText();
            if (s != null) {
                return new File(s.trim()).isDirectory();
            } else {
                return false;
            }
        }
        return true;
    }

    private void updateNameField() {
        if (adHocKindRadio.isSelected() && useOpenCheckbox.isSelected()) {
            Project p = OpenProjects.getDefault().getMainProject();
            if (p != null && nameField.getText().length() == 0) {
                nameField.setText(ProjectUtils.getInformation(p).getDisplayName());
            }
        } else if (subprojectsKindRadio.isSelected()) {
            String s = masterProjectField.getText();
            if (s != null && s.length() > 0) {
                File f = new File(s);
                FileObject fo = FileUtil.toFileObject(f);
                if (fo != null && fo.isFolder()) {
                    try {
                        Project p = ProjectManager.getDefault().findProject(fo);
                        if (p != null) {
                            nameField.setText(ProjectUtils.getInformation(p).getDisplayName());
                        }
                    } catch (IOException x) {
                        Exceptions.printStackTrace(x);
                    }
                }
            }
        } else if (directoryKindRadio.isSelected()) {
            String s = directoryField.getText();
            if (s != null && s.length() > 0) {
                File f = new File(s);
                nameField.setText(f.getName());
            }
        }
    }

    public enum Type {

        ADHOC, SUB, DIR
    }

    public Type getSelectedType() {
        if (adHocKindRadio.isSelected()) {
            return Type.ADHOC;
        }
        if (subprojectsKindRadio.isSelected()) {
            return Type.SUB;
        }
        if (directoryKindRadio.isSelected()) {
            return Type.DIR;
        }
        throw new IllegalStateException();
    }

    public String getNameField() {
        return nameField.getText().trim();
    }

    public boolean isAutoSyncField() {
        return autoSynchCheckbox.isSelected();
    }

    public boolean isUseOpenedField() {
        return useOpenCheckbox.isSelected();
    }

    public String getMasterProjectField() {
        return masterProjectField.getText();
    }

    public String getDirectoryField() {
        return directoryField.getText() != null ? directoryField.getText().trim() : null;
    }

    public static Group create(Type type, String name, boolean autoSync, boolean useOpen, String masterProject, String directory) {
        if (Type.ADHOC.equals(type)) {
            AdHocGroup g = AdHocGroup.create(name, autoSync);
            if (useOpen) {
                g.setProjects(new HashSet<Project>(Arrays.asList(OpenProjects.getDefault().getOpenProjects())));
                g.setMainProject(OpenProjects.getDefault().getMainProject());
            }
            return g;
        } else if (Type.SUB.equals(type)) {
            FileObject fo = FileUtil.toFileObject(new File(masterProject));
            try {
                return SubprojectsGroup.create(name, ProjectManager.getDefault().findProject(fo));
            } catch (IOException x) {
                throw new replacedertionError(x);
            }
        } else {
            replacedert Type.DIR.equals(type);
            FileObject f = FileUtil.toFileObject(FileUtil.normalizeFile(new File(directory)));
            return DirectoryGroup.create(name, f);
        }
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        kindButtonGroup = new javax.swing.ButtonGroup();
        adHocKindRadio = new javax.swing.JRadioButton();
        adHocKindLabel = new javax.swing.JLabel();
        useOpenCheckbox = new javax.swing.JCheckBox();
        autoSynchCheckbox = new javax.swing.JCheckBox();
        subprojectsKindRadio = new javax.swing.JRadioButton();
        subprojectsKindLabel = new javax.swing.JLabel();
        masterProjectLabel = new javax.swing.JLabel();
        masterProjectField = new javax.swing.JTextField();
        masterProjectButton = new javax.swing.JButton();
        directoryKindRadio = new javax.swing.JRadioButton();
        directoryKindLabel = new javax.swing.JLabel();
        directoryLabel = new javax.swing.JLabel();
        directoryField = new javax.swing.JTextField();
        directoryButton = new javax.swing.JButton();
        nameLabel = new javax.swing.JLabel();
        nameField = new javax.swing.JTextField();
        kindButtonGroup.add(adHocKindRadio);
        adHocKindRadio.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(adHocKindRadio, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.adHocKindRadio.text"));
        adHocKindRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        adHocKindRadio.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adHocKindRadioActionPerformed(evt);
            }
        });
        adHocKindLabel.setLabelFor(adHocKindRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(adHocKindLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.adHocKindLabel.text"));
        useOpenCheckbox.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(useOpenCheckbox, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.useOpenCheckbox.text"));
        useOpenCheckbox.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                useOpenCheckboxActionPerformed(evt);
            }
        });
        autoSynchCheckbox.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(autoSynchCheckbox, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.autoSynchCheckbox.text"));
        kindButtonGroup.add(subprojectsKindRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(subprojectsKindRadio, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.subprojectsKindRadio.text"));
        subprojectsKindRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        subprojectsKindRadio.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subprojectsKindRadioActionPerformed(evt);
            }
        });
        subprojectsKindLabel.setLabelFor(subprojectsKindRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(subprojectsKindLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.subprojectsKindLabel.text"));
        subprojectsKindLabel.setEnabled(false);
        masterProjectLabel.setLabelFor(masterProjectField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(masterProjectLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectLabel.text"));
        masterProjectLabel.setEnabled(false);
        masterProjectField.setEditable(false);
        masterProjectField.setEnabled(false);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(masterProjectButton, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectButton.text"));
        masterProjectButton.setEnabled(false);
        masterProjectButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                masterProjectButtonActionPerformed(evt);
            }
        });
        kindButtonGroup.add(directoryKindRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(directoryKindRadio, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryKindRadio.text"));
        directoryKindRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        directoryKindRadio.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                directoryKindRadioActionPerformed(evt);
            }
        });
        directoryKindLabel.setLabelFor(directoryKindRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(directoryKindLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryKindLabel.text"));
        directoryKindLabel.setEnabled(false);
        directoryLabel.setLabelFor(directoryField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(directoryLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryLabel.text"));
        directoryLabel.setEnabled(false);
        directoryField.setEnabled(false);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(directoryButton, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryButton.text"));
        directoryButton.setEnabled(false);
        directoryButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                directoryButtonActionPerformed(evt);
            }
        });
        nameLabel.setLabelFor(nameField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.nameLabel.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(nameLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(nameField, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)).addComponent(directoryKindRadio).addComponent(adHocKindRadio).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(directoryLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(directoryField, javax.swing.GroupLayout.DEFAULT_SIZE, 554, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(directoryButton)).addComponent(directoryKindLabel))).addComponent(subprojectsKindRadio).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(masterProjectLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(masterProjectField, javax.swing.GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE)).addComponent(subprojectsKindLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(masterProjectButton)).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addComponent(adHocKindLabel)).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(autoSynchCheckbox).addComponent(useOpenCheckbox)))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(nameLabel).addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(18, 18, 18).addComponent(adHocKindRadio).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(adHocKindLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(useOpenCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(autoSynchCheckbox).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(subprojectsKindRadio).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(subprojectsKindLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(masterProjectLabel).addComponent(masterProjectButton).addComponent(masterProjectField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(directoryKindRadio).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(directoryKindLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(directoryLabel).addComponent(directoryField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(directoryButton)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        // NOI18N
        adHocKindRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.adHocKindRadio.AccessibleContext.accessibleDescription"));
        // NOI18N
        adHocKindLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.adHocKindLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        useOpenCheckbox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.useOpenCheckbox.AccessibleContext.accessibleDescription"));
        // NOI18N
        autoSynchCheckbox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.autoSynchCheckbox.AccessibleContext.accessibleDescription"));
        // NOI18N
        subprojectsKindRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.subprojectsKindRadio.AccessibleContext.accessibleDescription"));
        // NOI18N
        subprojectsKindLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.subprojectsKindLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        masterProjectLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        masterProjectField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectField.AccessibleContext.accessibleName"));
        // NOI18N
        masterProjectField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectField.AccessibleContext.accessibleDescription"));
        // NOI18N
        masterProjectButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.masterProjectButton.AccessibleContext.accessibleDescription"));
        // NOI18N
        directoryKindRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryKindRadio.AccessibleContext.accessibleDescription"));
        // NOI18N
        directoryKindLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryKindLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        directoryLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        directoryField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryField.AccessibleContext.accessibleName"));
        // NOI18N
        directoryField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryField.AccessibleContext.accessibleDescription"));
        // NOI18N
        directoryButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.directoryButton.AccessibleContext.accessibleDescription"));
        // NOI18N
        nameLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.nameLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        nameField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.nameField.AccessibleContext.accessibleName"));
        // NOI18N
        nameField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.nameField.AccessibleContext.accessibleDescription"));
        // NOI18N
        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.AccessibleContext.accessibleName"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(NewGroupPanel.clreplaced, "NewGroupPanel.AccessibleContext.accessibleDescription"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void directoryButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_directoryButtonActionPerformed
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        File start = ProjectChooser.getProjectsFolder();
        if (directoryField.getText() != null && directoryField.getText().trim().length() > 0) {
            start = new File(directoryField.getText().trim());
        }
        chooser.setCurrentDirectory(start);
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            File f = chooser.getSelectedFile();
            if (f != null) {
                directoryField.setText(f.getAbsolutePath());
                updateNameField();
            }
        }
    }

    // GEN-LAST:event_directoryButtonActionPerformed
    private void masterProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_masterProjectButtonActionPerformed
        JFileChooser chooser = ProjectChooser.projectChooser();
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            File f = chooser.getSelectedFile();
            if (f != null) {
                masterProjectField.setText(f.getAbsolutePath());
                updateNameField();
                firePropertyChange(PROP_READY, null, null);
            }
        }
    }

    // GEN-LAST:event_masterProjectButtonActionPerformed
    private void directoryKindRadioActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_directoryKindRadioActionPerformed
        adHocKindLabel.setEnabled(false);
        useOpenCheckbox.setEnabled(false);
        autoSynchCheckbox.setEnabled(false);
        subprojectsKindLabel.setEnabled(false);
        masterProjectLabel.setEnabled(false);
        masterProjectField.setEnabled(false);
        masterProjectButton.setEnabled(false);
        directoryKindLabel.setEnabled(true);
        directoryLabel.setEnabled(true);
        directoryField.setEnabled(true);
        directoryButton.setEnabled(true);
        updateNameField();
        firePropertyChange(PROP_READY, null, null);
        updateNotifications();
    }

    // GEN-LAST:event_directoryKindRadioActionPerformed
    private void subprojectsKindRadioActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_subprojectsKindRadioActionPerformed
        adHocKindLabel.setEnabled(false);
        useOpenCheckbox.setEnabled(false);
        autoSynchCheckbox.setEnabled(false);
        subprojectsKindLabel.setEnabled(true);
        masterProjectLabel.setEnabled(true);
        masterProjectField.setEnabled(true);
        masterProjectButton.setEnabled(true);
        directoryKindLabel.setEnabled(false);
        directoryLabel.setEnabled(false);
        directoryField.setEnabled(false);
        directoryButton.setEnabled(false);
        updateNameField();
        firePropertyChange(PROP_READY, null, null);
        updateNotifications();
    }

    // GEN-LAST:event_subprojectsKindRadioActionPerformed
    private void adHocKindRadioActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_adHocKindRadioActionPerformed
        adHocKindLabel.setEnabled(true);
        useOpenCheckbox.setEnabled(true);
        autoSynchCheckbox.setEnabled(true);
        subprojectsKindLabel.setEnabled(false);
        masterProjectLabel.setEnabled(false);
        masterProjectField.setEnabled(false);
        masterProjectButton.setEnabled(false);
        directoryKindLabel.setEnabled(false);
        directoryLabel.setEnabled(false);
        directoryField.setEnabled(false);
        directoryButton.setEnabled(false);
        updateNameField();
        firePropertyChange(PROP_READY, null, null);
        updateNotifications();
    }

    // GEN-LAST:event_adHocKindRadioActionPerformed
    private void useOpenCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_useOpenCheckboxActionPerformed
        updateNotifications();
    }

    // GEN-LAST:event_useOpenCheckboxActionPerformed
    private NotificationLineSupport notificationLineSupport;

    void setNotificationLineSupport(NotificationLineSupport notificationLineSupport) {
        this.notificationLineSupport = notificationLineSupport;
        updateNameField();
    }

    @Messages({ "NewGroupPanel.open_project_warning=The list of projects currently open will be lost, unless you make a free group for them first.", "NewGroupPanel.too_long_warning=Group name is too long.", "NewGroupPanel.exists_warning=Name equal to existing group." })
    private void updateNotifications() {
        // #192899
        replacedert notificationLineSupport != null;
        notificationLineSupport.clearMessages();
        if (adHocKindRadio.isSelected() && useOpenCheckbox.isSelected() || OpenProjects.getDefault().getOpenProjects().length == 0) {
        } else {
            notificationLineSupport.setWarningMessage(NewGroupPanel_open_project_warning());
        }
        String name = nameField.getText();
        if (name != null) {
            if (name.length() > MAX_NAME) {
                notificationLineSupport.setErrorMessage(NewGroupPanel_too_long_warning());
            }
            if (name.equalsIgnoreCase(NONE_GOUP)) {
                notificationLineSupport.setErrorMessage(NewGroupPanel_exists_warning());
            }
            for (Group group : Group.allGroups()) {
                if (name.equalsIgnoreCase(group.getName())) {
                    notificationLineSupport.setErrorMessage(NewGroupPanel_exists_warning());
                    break;
                }
            }
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel adHocKindLabel;

    private javax.swing.JRadioButton adHocKindRadio;

    private javax.swing.JCheckBox autoSynchCheckbox;

    private javax.swing.JButton directoryButton;

    private javax.swing.JTextField directoryField;

    private javax.swing.JLabel directoryKindLabel;

    private javax.swing.JRadioButton directoryKindRadio;

    private javax.swing.JLabel directoryLabel;

    private javax.swing.ButtonGroup kindButtonGroup;

    private javax.swing.JButton masterProjectButton;

    private javax.swing.JTextField masterProjectField;

    private javax.swing.JLabel masterProjectLabel;

    private javax.swing.JTextField nameField;

    private javax.swing.JLabel nameLabel;

    private javax.swing.JLabel subprojectsKindLabel;

    private javax.swing.JRadioButton subprojectsKindRadio;

    private javax.swing.JCheckBox useOpenCheckbox;
    // End of variables declaration//GEN-END:variables
}

19 View Complete Implementation : BrokenReferencesCustomizer.java
Copyright Apache License 2.0
Author : apache
synchronized void setNotificationLineSupport(@NullAllowed final NotificationLineSupport notificationLineSupport) {
    // NOI18N
    Parameters.notNull("notificationLineSupport", notificationLineSupport);
    nls = notificationLineSupport;
}

19 View Complete Implementation : DictionaryInstallerPanel.java
Copyright Apache License 2.0
Author : apache
void setNotifications(NotificationLineSupport notifications) {
    this.notifications = notifications;
    updateErrors();
}

19 View Complete Implementation : NotificationLineSupportAdapter.java
Copyright Apache License 2.0
Author : apache
/**
 * @author mkleint
 */
public final clreplaced NotificationLineSupportAdapter implements ValidationUI {

    private final NotificationLineSupport nls;

    public NotificationLineSupportAdapter(NotificationLineSupport nls) {
        this.nls = nls;
    }

    @Override
    public void clearProblem() {
        nls.clearMessages();
    }

    @Override
    public void showProblem(Problem p) {
        switch(p.severity()) {
            case INFO:
                nls.setInformationMessage(p.getMessage());
                break;
            case WARNING:
                nls.setWarningMessage(p.getMessage());
                break;
            case FATAL:
                nls.setErrorMessage(p.getMessage());
                break;
        }
    }
}

19 View Complete Implementation : EditDialog.java
Copyright Apache License 2.0
Author : apache
/**
 * EditDialog.java
 *
 * Created on November 28, 2004, 7:18 PM
 * @author mkuchtiak
 * @author Petr Slechta
 */
public abstract clreplaced EditDialog extends DialogDescriptor {

    private javax.swing.JPanel panel;

    private NotificationLineSupport statusLine;

    /**
     * Creates a new instance of EditDialog
     */
    public EditDialog(javax.swing.JPanel panel, String replacedle, boolean adding) {
        super(panel, getreplacedle(replacedle, adding), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.BOTTOM_ALIGN, null, null);
        this.panel = panel;
        statusLine = createNotificationLineSupport();
    }

    /**
     * Creates a new instance of EditDialog
     */
    public EditDialog(javax.swing.JPanel panel, String replacedle) {
        this(panel, replacedle, false);
    }

    private static String getreplacedle(String replacedle, boolean adding) {
        return (adding ? NbBundle.getMessage(EditDialog.clreplaced, "TTL_ADD", replacedle) : NbBundle.getMessage(EditDialog.clreplaced, "TTL_EDIT", replacedle));
    }

    /**
     * Returns the dialog panel
     * @return dialog panel
     */
    public final javax.swing.JPanel getDialogPanel() {
        return panel;
    }

    /**
     * Calls validation of panel components, displays or removes the error message
     * Should be called from listeners listening to component changes.
     */
    public final void checkValues() {
        String errorMessage = validate();
        if (errorMessage == null) {
            statusLine.clearMessages();
            setValid(true);
        } else {
            statusLine.setErrorMessage(errorMessage);
            setValid(false);
        }
    }

    /**
     * Provides validation for panel components
     */
    protected abstract String validate();

    /**
     * Useful DoreplacedentListener clreplaced that can be added to the panel's text compoents
     */
    public static clreplaced DocListener implements javax.swing.event.DoreplacedentListener {

        EditDialog dialog;

        public DocListener(EditDialog dialog) {
            this.dialog = dialog;
        }

        /**
         * Method from DoreplacedentListener
         */
        public void changedUpdate(javax.swing.event.DoreplacedentEvent evt) {
            dialog.checkValues();
        }

        /**
         * Method from DoreplacedentListener
         */
        public void insertUpdate(javax.swing.event.DoreplacedentEvent evt) {
            dialog.checkValues();
        }

        /**
         * Method from DoreplacedentListener
         */
        public void removeUpdate(javax.swing.event.DoreplacedentEvent evt) {
            dialog.checkValues();
        }
    }
}

18 View Complete Implementation : MessageDestinationPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * Panel for adding message destination.
 * @author Tomas Mysik
 */
public clreplaced MessageDestinationPanel extends javax.swing.JPanel {

    public static final String IS_VALID = MessageDestinationPanel.clreplaced.getName() + ".IS_VALID";

    // map because of faster searching
    private final Map<String, MessageDestination.Type> destinationMap;

    private final boolean generated;

    private final String prefix;

    private NotificationLineSupport statusLine;

    // private because correct initialization is needed
    private MessageDestinationPanel(Map<String, MessageDestination.Type> destinationMap, boolean generated, String prefix) {
        initComponents();
        this.destinationMap = destinationMap;
        this.generated = generated;
        this.prefix = prefix;
    }

    /**
     * Factory method for creating new instance.
     * @param destinationMap the names and the types of project message destinations.
     * @return MessageDestinationPanel instance.
     */
    public static MessageDestinationPanel newInstance(final Map<String, MessageDestination.Type> destinationMap, boolean generated, String prefix) {
        MessageDestinationPanel mdp = new MessageDestinationPanel(destinationMap, generated, prefix);
        mdp.initialize();
        return mdp;
    }

    public void setNotificationLine(NotificationLineSupport statusLine) {
        this.statusLine = statusLine;
    }

    /**
     * Get the name of the message destination.
     * @return message destination name.
     */
    public String getDestinationName() {
        String name = destinationNameText.getText().trim();
        if (generated) {
            return JndiNamespacesDefinition.normalize(name, prefix);
        }
        return name;
    }

    /**
     * Get the type of the message destination.
     * @return message destination type.
     * @see MessageDestination.Type
     */
    public MessageDestination.Type getDestinationType() {
        if (queueTypeRadio.isSelected()) {
            return MessageDestination.Type.QUEUE;
        }
        return MessageDestination.Type.TOPIC;
    }

    private void initialize() {
        registerListeners();
        verifyAndFire();
    }

    private void registerListeners() {
        // text field
        destinationNameText.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent event) {
                verifyAndFire();
            }

            public void removeUpdate(DoreplacedentEvent event) {
                verifyAndFire();
            }

            public void changedUpdate(DoreplacedentEvent event) {
                verifyAndFire();
            }
        });
        // radio buttons
        queueTypeRadio.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent event) {
                verifyAndFire();
            }
        });
        topicTypeRadio.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent event) {
                verifyAndFire();
            }
        });
        addAncestorListener(new AncestorListener() {

            public void ancestorAdded(AncestorEvent event) {
                verifyAndFire();
            }

            public void ancestorRemoved(AncestorEvent event) {
                verifyAndFire();
            }

            public void ancestorMoved(AncestorEvent event) {
                verifyAndFire();
            }
        });
    }

    private void setError(String key) {
        if (statusLine != null) {
            statusLine.setErrorMessage(NbBundle.getMessage(MessageDestinationPanel.clreplaced, key));
        }
    }

    private void setInfo(String key) {
        if (statusLine != null) {
            statusLine.setInformationMessage(NbBundle.getMessage(MessageDestinationPanel.clreplaced, key));
        }
    }

    private void verifyAndFire() {
        boolean isValid = verifyComponents();
        firePropertyChange(IS_VALID, !isValid, isValid);
    }

    private boolean verifyComponents() {
        // destination name - form & duplicity
        String destinationName = destinationNameText.getText();
        if (destinationName == null || destinationName.trim().length() == 0) {
            // NOI18N
            setInfo("ERR_NoDestinationName");
            return false;
        } else {
            destinationName = destinationName.trim();
            if (generated) {
                destinationName = JndiNamespacesDefinition.normalize(destinationName, prefix);
            }
            MessageDestination.Type type = destinationMap.get(destinationName);
            if (type != null && type.equals(getDestinationType())) {
                // NOI18N
                setError("ERR_DuplicateDestination");
                return false;
            }
        }
        // destination type (radio)
        if (destinationTypeGroup.getSelection() == null) {
            // NOI18N
            setInfo("ERR_NoDestinationType");
            return false;
        }
        // no errors
        statusLine.clearMessages();
        return true;
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        destinationTypeGroup = new javax.swing.ButtonGroup();
        destinationNameLabel = new javax.swing.JLabel();
        destinationNameText = new javax.swing.JTextField();
        destinationTypeLabel = new javax.swing.JLabel();
        queueTypeRadio = new javax.swing.JRadioButton();
        topicTypeRadio = new javax.swing.JRadioButton();
        destinationNameLabel.setLabelFor(destinationNameText);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(destinationNameLabel, org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "LBL_DestinationName"));
        destinationTypeLabel.setLabelFor(queueTypeRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(destinationTypeLabel, org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "LBL_DestinationType"));
        destinationTypeGroup.add(queueTypeRadio);
        queueTypeRadio.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(queueTypeRadio, org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "LBL_Queue"));
        queueTypeRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        queueTypeRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
        destinationTypeGroup.add(topicTypeRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(topicTypeRadio, org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "LBL_Topic"));
        topicTypeRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        topicTypeRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(destinationTypeLabel).addComponent(destinationNameLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(topicTypeRadio).addComponent(queueTypeRadio).addComponent(destinationNameText, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(destinationNameLabel).addComponent(destinationNameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(destinationTypeLabel).addComponent(queueTypeRadio)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(topicTypeRadio).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        // NOI18N
        destinationNameLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "MessageDestinationPanel.destinationNameLabel.AccessibleContext.accessibleDescription"));
        // NOI18N
        queueTypeRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "MessageDestinationPanel.queueTypeRadio.AccessibleContext.accessibleDescription"));
        // NOI18N
        topicTypeRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "MessageDestinationPanel.topicTypeRadio.AccessibleContext.accessibleDescription"));
        // NOI18N
        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "ACSD_AddMessageDestination"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MessageDestinationPanel.clreplaced, "ACSD_AddMessageDestination"));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel destinationNameLabel;

    private javax.swing.JTextField destinationNameText;

    private javax.swing.ButtonGroup destinationTypeGroup;

    private javax.swing.JLabel destinationTypeLabel;

    private javax.swing.JRadioButton queueTypeRadio;

    private javax.swing.JRadioButton topicTypeRadio;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : DatasourceComboBoxCustomizer.java
Copyright Apache License 2.0
Author : apache
/**
 * @author  Libor Kotouc
 * @author  Petr Slechta
 */
final clreplaced DatasourceComboBoxCustomizer extends javax.swing.JPanel {

    private Dialog dialog = null;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private boolean dialogOK = false;

    private final HashMap<String, Datasource> datasources;

    private String jndiName;

    private String url;

    private String username;

    private String preplacedword;

    private String driverClreplacedName;

    public DatasourceComboBoxCustomizer(Set<Datasource> datasources) {
        this.datasources = new HashMap<String, Datasource>();
        if (datasources != null) {
            // transform Set to Map for faster searching
            for (Iterator it = datasources.iterator(); it.hasNext(); ) {
                Datasource datasource = (Datasource) it.next();
                if (datasource.getJndiName() != null)
                    this.datasources.put(datasource.getJndiName(), datasource);
            }
        }
        initComponents();
        DatabaseExplorerUIs.connect(connCombo, ConnectionManager.getDefault());
        connCombo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                verify();
            }
        });
        jndiNameField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void changedUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }

            public void insertUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }

            public void removeUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }
        });
        addAncestorListener(new AncestorListener() {

            public void ancestorAdded(AncestorEvent event) {
                verify();
            }

            public void ancestorRemoved(AncestorEvent event) {
                verify();
            }

            public void ancestorMoved(AncestorEvent event) {
                verify();
            }
        });
    }

    public boolean showDialog() {
        descriptor = new DialogDescriptor(// NOI18N
        this, // NOI18N
        NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "LBL_DatasourceCustomizer"), // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, // NOI18N
        new HelpCtx("DatasourceUIHelper_DatasourceCustomizer"), new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                boolean close = true;
                if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
                    boolean valid = handleConfirmation();
                    close = valid;
                    dialogOK = valid;
                }
                if (close) {
                    dialog.dispose();
                }
            }
        });
        statusLine = descriptor.createNotificationLineSupport();
        descriptor.setClosingOptions(new Object[] { DialogDescriptor.CANCEL_OPTION });
        verify();
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        repaint();
        return dialogOK;
    }

    private boolean handleConfirmation() {
        jndiName = jndiNameField.getText().trim();
        DatabaseConnection conn = (DatabaseConnection) connCombo.getSelectedItem();
        if (conn.getPreplacedword() == null) {
            ConnectionManager.getDefault().showConnectionDialog(conn);
        }
        if (conn.getPreplacedword() == null) {
            // user did not provide the preplacedword
            // NOI18N
            statusLine.setErrorMessage(NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "ERR_NoPreplacedword"));
            return false;
        }
        url = conn.getDatabaseURL();
        username = conn.getUser();
        preplacedword = conn.getPreplacedword();
        driverClreplacedName = conn.getDriverClreplaced();
        return true;
    }

    private boolean verify() {
        boolean isValid = verifyJndiName();
        if (isValid)
            isValid = verifyConnection();
        return isValid;
    }

    private boolean verifyJndiName() {
        boolean valid = true;
        String jndiName = jndiNameField.getText().trim();
        if (jndiName.length() == 0) {
            // NOI18N
            statusLine.setInformationMessage(NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "ERR_JNDI_NAME_EMPTY"));
            valid = false;
        } else if (datasourceAlreadyExists(jndiName)) {
            // NOI18N
            statusLine.setErrorMessage(NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "ERR_DS_EXISTS"));
            valid = false;
        } else {
            statusLine.clearMessages();
        }
        descriptor.setValid(valid);
        return valid;
    }

    private boolean verifyConnection() {
        boolean valid = true;
        if (!(connCombo.getSelectedItem() instanceof DatabaseConnection)) {
            // NOI18N
            statusLine.setInformationMessage(NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "ERR_NO_CONN_SELECTED"));
            valid = false;
        } else {
            statusLine.clearMessages();
        }
        descriptor.setValid(valid);
        return valid;
    }

    // TODO this is incorrect - it is needed to normalize jndiName (e.g. "DefaultDs" vs. "java:DefaultDs" vs. "java:/DefaultDs")
    private boolean datasourceAlreadyExists(String jndiName) {
        return datasources.containsKey(jndiName);
    }

    String getJndiName() {
        return jndiName;
    }

    String getUrl() {
        return url;
    }

    String getUsername() {
        return username;
    }

    String getPreplacedword() {
        return preplacedword;
    }

    String getDriverClreplacedName() {
        return driverClreplacedName;
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jndiNameField = new javax.swing.JTextField();
        connCombo = new javax.swing.JComboBox();
        setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setLabelFor(jndiNameField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "LBL_DSC_JndiName"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(DatasourceComboBoxCustomizer.clreplaced, "LBL_DSC_DbConn"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel1)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jndiNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE).addComponent(connCombo, 0, 337, Short.MAX_VALUE)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(jndiNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(connCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(27, 27, 27)));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox connCombo;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JTextField jndiNameField;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : AddBeanPanelVisual.java
Copyright Apache License 2.0
Author : apache
/**
 * @author alexeybutenko
 */
public clreplaced AddBeanPanelVisual extends javax.swing.JPanel {

    private Dialog dialog = null;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private boolean dialogOK = false;

    private AddBeanPanel panel;

    private FileObject fileObject;

    private final AtomicBoolean clreplacedFound = new AtomicBoolean(false);

    private static final RequestProcessor RP = new RequestProcessor();

    /**
     * Creates new form AddBeanPanelVisual
     */
    public AddBeanPanelVisual(AddBeanPanel panel) {
        this.panel = panel;
        fileObject = NbEditorUtilities.getFileObject(panel.getDoreplacedent());
        initComponents();
        scanningLabel.setVisible(false);
        idTextField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }
        });
        clreplacedNameTextField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }
        });
    }

    public boolean showDialog() {
        String id = panel.getId();
        String clreplacedName = panel.getClreplacedName();
        if (clreplacedName != null) {
            clreplacedNameTextField.setEditable(false);
        } else {
            // NOI18N
            clreplacedName = "";
        }
        idTextField.setText(id);
        clreplacedNameTextField.setText(clreplacedName);
        // NOI18N
        String displayName = "";
        try {
            displayName = NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "TTL_Add_Bean_Panel");
        } catch (Exception e) {
        }
        descriptor = new DialogDescriptor(// NOI18N
        this, // NOI18N
        displayName, // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
                    collectInput();
                    dialogOK = true;
                }
                dialog.dispose();
            }
        });
        statusLine = descriptor.createNotificationLineSupport();
        validateInput();
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        repaint();
        return dialogOK;
    }

    private void collectInput() {
        panel.setClreplacedName(clreplacedNameTextField.getText());
        panel.setId(idTextField.getText());
    }

    private void validateInput() {
        validateInput(true);
    }

    private void validateInput(boolean validateClreplaced) {
        if (descriptor == null)
            return;
        if (idTextField.getText().length() < 1) {
            // NOI18N
            statusLine.setInformationMessage(NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "Error_Empty_ID"));
            descriptor.setValid(false);
            return;
        }
        if (idExist()) {
            // NOI18N
            statusLine.setErrorMessage(NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "Error_not_uniq_ID"));
            descriptor.setValid(false);
            return;
        }
        if (clreplacedNameTextField.getText().length() < 1) {
            // NOI18N
            statusLine.setInformationMessage(NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "Error_Empty_Clreplaced"));
            descriptor.setValid(false);
            return;
        }
        if (beanExist()) {
            // NOI18N
            statusLine.setErrorMessage(NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "Error_Bean_Already_exist"));
            descriptor.setValid(false);
            return;
        }
        if (validateClreplaced) {
            scanningLabel.setVisible(SourceUtils.isScanInProgress());
            RP.submit(new Runnable() {

                @Override
                public void run() {
                    validClreplaced();
                }
            });
        }
        if (!clreplacedFound.get()) {
            // NOI18N
            statusLine.setErrorMessage(NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "Error_No_Such_clreplaced"));
            descriptor.setValid(false);
            return;
        }
        statusLine.clearMessages();
        descriptor.setValid(true);
    }

    private boolean idExist() {
        SpringScope scope = SpringScope.getSpringScope(fileObject);
        final String id = idTextField.getText();
        final boolean[] found = { false };
        for (SpringConfigModel model : scope.getAllConfigModels()) {
            try {
                model.runReadAction(new Action<SpringBeans>() {

                    public void run(SpringBeans beans) {
                        SpringBean bean = beans.findBean(id);
                        if (bean != null)
                            found[0] = true;
                    }
                });
                if (found[0]) {
                    return true;
                }
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        return found[0];
    }

    private boolean beanExist() {
        final boolean[] found = { false };
        SpringScope scope = SpringScope.getSpringScope(fileObject);
        final String clreplacedName = clreplacedNameTextField.getText();
        if (clreplacedName == null || "".equals(clreplacedName)) {
            return false;
        }
        for (SpringConfigModel model : scope.getAllConfigModels()) {
            try {
                model.runReadAction(new Action<SpringBeans>() {

                    public void run(SpringBeans beans) {
                        for (SpringBean bean : beans.getBeans()) {
                            if (clreplacedName.equals(bean.getClreplacedName())) {
                                found[0] = true;
                                break;
                            }
                        }
                    }
                });
                if (found[0]) {
                    return true;
                }
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        return found[0];
    }

    private void validClreplaced() {
        JavaSource js = JavaSource.create(ClreplacedpathInfo.create(fileObject));
        if (js == null) {
            return;
        }
        try {
            ClreplacedSeeker laterSeeker = new ClreplacedSeeker();
            Future<Void> seekingTask = js.runWhenScanFinished(laterSeeker, true);
            if (seekingTask.isDone()) {
                clreplacedFound.set(laterSeeker.isClreplacedFound());
                return;
            }
            ClreplacedSeeker promptSeeker = new ClreplacedSeeker();
            js.runUserActionTask(promptSeeker, true);
            clreplacedFound.set(promptSeeker.isClreplacedFound());
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    private clreplaced ClreplacedSeeker implements Task<CompilationController> {

        private final AtomicBoolean found = new AtomicBoolean(false);

        public boolean isClreplacedFound() {
            return found.get();
        }

        @Override
        public void run(CompilationController parameter) throws Exception {
            found.set(parameter.getElements().getTypeElement(clreplacedNameTextField.getText()) != null);
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    scanningLabel.setVisible(SourceUtils.isScanInProgress());
                    validateInput(false);
                }
            });
        }
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        idTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        clreplacedNameTextField = new javax.swing.JTextField();
        scanningLabel = new javax.swing.JLabel();
        setPreferredSize(new java.awt.Dimension(420, 120));
        setRequestFocusEnabled(false);
        jLabel1.setLabelFor(idTextField);
        // NOI18N
        jLabel1.setText(org.openide.util.NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "AddBeanPanelVisual.jLabel1.text"));
        // NOI18N
        idTextField.setText(org.openide.util.NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "AddBeanPanelVisual.idTextField.text"));
        idTextField.setMinimumSize(new java.awt.Dimension(200, 27));
        idTextField.setPreferredSize(new java.awt.Dimension(450, 27));
        idTextField.setRequestFocusEnabled(false);
        jLabel2.setLabelFor(clreplacedNameTextField);
        // NOI18N
        jLabel2.setText(org.openide.util.NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "AddBeanPanelVisual.jLabel2.text"));
        // NOI18N
        clreplacedNameTextField.setText(org.openide.util.NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "AddBeanPanelVisual.clreplacedNameTextField.text"));
        clreplacedNameTextField.setPreferredSize(new java.awt.Dimension(450, 27));
        // NOI18N
        scanningLabel.setFont(new java.awt.Font("Dialog", 2, 12));
        // NOI18N
        scanningLabel.setText(org.openide.util.NbBundle.getMessage(AddBeanPanelVisual.clreplaced, "AddBeanPanelVisual.scanningLabel.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(scanningLabel).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel1)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(idTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE).addComponent(clreplacedNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 18, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(clreplacedNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(scanningLabel).addContainerGap()));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField clreplacedNameTextField;

    private javax.swing.JTextField idTextField;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel scanningLabel;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : AddViewDialog.java
Copyright Apache License 2.0
Author : apache
public clreplaced AddViewDialog {

    private static final Logger LOGGER = Logger.getLogger(AddIndexDialog.clreplaced.getName());

    Dialog dialog = null;

    JTextField namefld;

    JTextArea tarea;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    public AddViewDialog(final Specification spec, final String schemaName) {
        try {
            JPanel pane = new JPanel();
            pane.setBorder(new EmptyBorder(new Insets(5, 5, 5, 5)));
            GridBagLayout layout = new GridBagLayout();
            GridBagConstraints con = new GridBagConstraints();
            pane.setLayout(layout);
            // Index name
            JLabel label = new JLabel();
            Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddViewDialog.clreplaced, "AddViewName"));
            label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewNameA11yDesc"));
            con.anchor = GridBagConstraints.WEST;
            con.insets = new java.awt.Insets(2, 2, 2, 2);
            con.gridx = 0;
            con.gridy = 0;
            layout.setConstraints(label, con);
            pane.add(label);
            // Index name field
            con.fill = GridBagConstraints.HORIZONTAL;
            con.weightx = 1.0;
            con.gridx = 1;
            con.gridy = 0;
            con.insets = new java.awt.Insets(2, 2, 2, 2);
            namefld = new JTextField(35);
            namefld.setToolTipText(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewNameTextFieldA11yDesc"));
            namefld.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewNameTextFieldA11yName"));
            label.setLabelFor(namefld);
            layout.setConstraints(namefld, con);
            pane.add(namefld);
            DoreplacedentListener docListener = new DoreplacedentListener() {

                @Override
                public void insertUpdate(DoreplacedentEvent e) {
                    validate();
                }

                @Override
                public void removeUpdate(DoreplacedentEvent e) {
                    validate();
                }

                @Override
                public void changedUpdate(DoreplacedentEvent e) {
                    validate();
                }
            };
            namefld.getDoreplacedent().addDoreplacedentListener(docListener);
            // Items list replacedle
            label = new JLabel();
            Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddViewDialog.clreplaced, "AddViewLabel"));
            label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewLabelA11yDesc"));
            con.weightx = 0.0;
            con.anchor = GridBagConstraints.WEST;
            con.insets = new java.awt.Insets(2, 2, 2, 2);
            con.gridx = 0;
            con.gridy = 1;
            con.gridwidth = 2;
            layout.setConstraints(label, con);
            pane.add(label);
            // Editor list
            tarea = new JTextArea(5, 50);
            tarea.setToolTipText(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewTextAreaA11yDesc"));
            tarea.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewTextAreaA11yName"));
            label.setLabelFor(tarea);
            tarea.getDoreplacedent().addDoreplacedentListener(docListener);
            con.weightx = 1.0;
            con.weighty = 1.0;
            con.gridwidth = 2;
            con.fill = GridBagConstraints.BOTH;
            con.insets = new java.awt.Insets(0, 0, 0, 0);
            con.gridx = 0;
            con.gridy = 2;
            JScrollPane spane = new JScrollPane(tarea);
            layout.setConstraints(spane, con);
            pane.add(spane);
            ActionListener listener = new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    if (event.getSource() == DialogDescriptor.OK_OPTION) {
                        try {
                            boolean wasException = DbUtilities.doWithProgress(null, new Callable<Boolean>() {

                                @Override
                                public Boolean call() throws Exception {
                                    return AddViewDDL.addView(spec, schemaName, getViewName(), getViewCode());
                                }
                            });
                            if (!wasException) {
                                dialog.setVisible(false);
                                dialog.dispose();
                            }
                        } catch (InvocationTargetException e) {
                            Throwable cause = e.getCause();
                            if (cause instanceof DDLException) {
                                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
                            } else {
                                LOGGER.log(Level.INFO, cause.getLocalizedMessage(), cause);
                                DbUtilities.reportError(NbBundle.getMessage(AddViewDialog.clreplaced, "ERR_UnableToCreateView"), e.getMessage());
                            }
                        }
                    }
                }
            };
            // NOI18N
            pane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddViewDialog.clreplaced, "ACS_AddViewDialogA11yDesc"));
            // NOI18N
            descriptor = new DialogDescriptor(pane, NbBundle.getMessage(AddViewDialog.clreplaced, "AddViewreplacedle"), true, listener);
            // NOI18N
            descriptor.setHelpCtx(new HelpCtx("createviews"));
            statusLine = descriptor.createNotificationLineSupport();
            // inbuilt close of the dialog is only after CANCEL button click
            // after OK button is dialog closed by hand
            Object[] closingOptions = { DialogDescriptor.CANCEL_OPTION };
            descriptor.setClosingOptions(closingOptions);
            dialog = DialogDisplayer.getDefault().createDialog(descriptor);
            dialog.setResizable(true);
            validate();
        } catch (MissingResourceException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }

    public String getViewName() {
        return namefld.getText();
    }

    public String getViewCode() {
        return tarea.getText();
    }

    /**
     * Validate and update state of UI.
     */
    private void validate() {
        // NOI18N
        replacedert statusLine != null : "Notification status line not available";
        String message = null;
        String viewName = getViewName();
        if (viewName == null || viewName.length() == 0) {
            message = NbBundle.getMessage(AddViewDialog.clreplaced, "AddViewMissingViewName");
        } else if (getViewCode() == null || getViewCode().length() == 0) {
            message = NbBundle.getMessage(CreateTableDialog.clreplaced, "AddViewMissingViewCode");
        }
        if (message == null) {
            statusLine.clearMessages();
            descriptor.setValid(true);
        } else {
            statusLine.setInformationMessage(message);
            descriptor.setValid(false);
        }
    }

    /**
     *  Shows Create View dialog and creates a new view in specified schema.
     * @param spec DB specification
     * @param schema DB schema to create table in
     * @return true if new view successfully created, false if cancelled
     */
    public static boolean showDialogAndCreate(final Specification spec, final String schema) {
        final AddViewDialog panel = new AddViewDialog(spec, schema);
        panel.dialog.setVisible(true);
        if (panel.descriptor.getValue() == DialogDescriptor.OK_OPTION) {
            return true;
        }
        return false;
    }
}

18 View Complete Implementation : CommitPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author Petr Hejl
 */
public clreplaced CommitPanel extends javax.swing.JPanel {

    private final JButton actionButton;

    private NotificationLineSupport messageLine;

    /**
     * Creates new form CommitPanel
     */
    public CommitPanel(DockerInstance instance, JButton actionButton) {
        initComponents();
        this.actionButton = actionButton;
        DefaultDoreplacedentListener listener = new DefaultDoreplacedentListener();
        ((JTextComponent) repositoryComboBox.getEditor().getEditorComponent()).getDoreplacedent().addDoreplacedentListener(listener);
        tagTextField.getDoreplacedent().addDoreplacedentListener(listener);
        authorTextField.setText(System.getProperty("user.name"));
        UiUtils.loadRepositories(instance, repositoryComboBox);
    }

    public void setMessageLine(NotificationLineSupport messageLine) {
        this.messageLine = messageLine;
        validateInput();
    }

    @NbBundle.Messages({ "MSG_EmptyRepository=The repository must not be empty when using tag." })
    private void validateInput() {
        if (messageLine == null) {
            return;
        }
        messageLine.clearMessages();
        actionButton.setEnabled(true);
        if (getRepository() == null && getTag() != null) {
            messageLine.setErrorMessage(Bundle.MSG_EmptyRepository());
            actionButton.setEnabled(false);
            return;
        }
        String repository = getRepository();
        if (repository != null) {
            String message = Validations.validateRepository(repository);
            if (message != null) {
                messageLine.setErrorMessage(message);
                actionButton.setEnabled(false);
                return;
            }
        }
        String tag = getTag();
        if (tag != null) {
            String message = Validations.validateTag(tag);
            if (message != null) {
                messageLine.setErrorMessage(message);
                actionButton.setEnabled(false);
                return;
            }
        }
    }

    private clreplaced DefaultDoreplacedentListener implements DoreplacedentListener {

        @Override
        public void insertUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void removeUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void changedUpdate(DoreplacedentEvent e) {
            validateInput();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        messageLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        messageTextArea = new javax.swing.JTextArea();
        pauseCheckBox = new javax.swing.JCheckBox();
        repositoryLabel = new javax.swing.JLabel();
        repositoryComboBox = new javax.swing.JComboBox<>();
        tagLabel = new javax.swing.JLabel();
        tagTextField = new javax.swing.JTextField();
        authorLabel = new javax.swing.JLabel();
        authorTextField = new javax.swing.JTextField();
        messageLabel.setLabelFor(messageTextArea);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(messageLabel, org.openide.util.NbBundle.getMessage(CommitPanel.clreplaced, "CommitPanel.messageLabel.text"));
        messageTextArea.setColumns(20);
        messageTextArea.setRows(5);
        jScrollPane1.setViewportView(messageTextArea);
        pauseCheckBox.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(pauseCheckBox, org.openide.util.NbBundle.getMessage(CommitPanel.clreplaced, "CommitPanel.pauseCheckBox.text"));
        repositoryLabel.setLabelFor(repositoryComboBox);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(repositoryLabel, org.openide.util.NbBundle.getMessage(CommitPanel.clreplaced, "CommitPanel.repositoryLabel.text"));
        repositoryComboBox.setEditable(true);
        tagLabel.setLabelFor(tagTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(tagLabel, org.openide.util.NbBundle.getMessage(CommitPanel.clreplaced, "CommitPanel.tagLabel.text"));
        authorLabel.setLabelFor(authorTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(authorLabel, org.openide.util.NbBundle.getMessage(CommitPanel.clreplaced, "CommitPanel.authorLabel.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(repositoryLabel).addComponent(tagLabel).addComponent(authorLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(repositoryComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(tagTextField).addComponent(authorTextField))).addGroup(layout.createSequentialGroup().addComponent(messageLabel).addGap(0, 0, Short.MAX_VALUE)).addComponent(pauseCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(repositoryLabel).addComponent(repositoryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(tagLabel).addComponent(tagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(authorLabel).addComponent(authorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(messageLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(pauseCheckBox).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    public String getRepository() {
        return UiUtils.getValue(repositoryComboBox);
    }

    public String getTag() {
        return UiUtils.getValue(tagTextField);
    }

    public String getAuthor() {
        return UiUtils.getValue(authorTextField);
    }

    public String getMessage() {
        return UiUtils.getValue(messageTextArea);
    }

    public boolean isPause() {
        return pauseCheckBox.isSelected();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel authorLabel;

    private javax.swing.JTextField authorTextField;

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JLabel messageLabel;

    private javax.swing.JTextArea messageTextArea;

    private javax.swing.JCheckBox pauseCheckBox;

    private javax.swing.JComboBox<String> repositoryComboBox;

    private javax.swing.JLabel repositoryLabel;

    private javax.swing.JLabel tagLabel;

    private javax.swing.JTextField tagTextField;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : RenamePanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author Petr Hejl
 */
public clreplaced RenamePanel extends javax.swing.JPanel {

    private final JButton actionButton;

    private NotificationLineSupport messageLine;

    /**
     * Creates new form RenamePanel
     */
    public RenamePanel(JButton actionButton) {
        initComponents();
        this.actionButton = actionButton;
        nameTextField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent e) {
                validateInput();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent e) {
                validateInput();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent e) {
                validateInput();
            }
        });
    }

    public void setMessageLine(NotificationLineSupport messageLine) {
        this.messageLine = messageLine;
        validateInput();
    }

    @NbBundle.Messages({ "MSG_EmptyName=The name must not be empty." })
    private void validateInput() {
        if (messageLine == null) {
            return;
        }
        messageLine.clearMessages();
        actionButton.setEnabled(true);
        if (getContainerName() == null) {
            messageLine.setErrorMessage(Bundle.MSG_EmptyName());
            actionButton.setEnabled(false);
            return;
        }
        String name = getContainerName();
        if (name != null) {
            String message = Validations.validateContainer(name);
            if (message != null) {
                messageLine.setErrorMessage(message);
                actionButton.setEnabled(false);
                return;
            }
        }
    }

    public String getContainerName() {
        return UiUtils.getValue(nameTextField);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        nameLabel = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        nameLabel.setLabelFor(nameTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(RenamePanel.clreplaced, "RenamePanel.nameLabel.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(nameLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(nameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 419, Short.MAX_VALUE).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(nameLabel).addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel nameLabel;

    private javax.swing.JTextField nameTextField;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : TagPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author Petr Hejl
 */
public clreplaced TagPanel extends javax.swing.JPanel {

    private final JButton actionButton;

    private NotificationLineSupport messageLine;

    /**
     * Creates new form TagPanel
     */
    public TagPanel(DockerInstance instance, JButton actionButton) {
        initComponents();
        this.actionButton = actionButton;
        DefaultDoreplacedentListener listener = new DefaultDoreplacedentListener();
        ((JTextComponent) repositoryComboBox.getEditor().getEditorComponent()).getDoreplacedent().addDoreplacedentListener(listener);
        tagTextField.getDoreplacedent().addDoreplacedentListener(listener);
        UiUtils.loadRepositories(instance, repositoryComboBox);
    }

    public void setMessageLine(NotificationLineSupport messageLine) {
        this.messageLine = messageLine;
        validateInput();
    }

    @NbBundle.Messages({ "MSG_EmptyRepository=The repository must not be empty." })
    private void validateInput() {
        if (messageLine == null) {
            return;
        }
        messageLine.clearMessages();
        actionButton.setEnabled(true);
        if (getRepository() == null) {
            messageLine.setErrorMessage(Bundle.MSG_EmptyRepository());
            actionButton.setEnabled(false);
            return;
        }
        String repository = getRepository();
        if (repository != null) {
            String message = Validations.validateRepository(repository);
            if (message != null) {
                messageLine.setErrorMessage(message);
                actionButton.setEnabled(false);
                return;
            }
        }
        String tag = getTag();
        if (tag != null) {
            String message = Validations.validateTag(tag);
            if (message != null) {
                messageLine.setErrorMessage(message);
                actionButton.setEnabled(false);
                return;
            }
        }
    }

    private clreplaced DefaultDoreplacedentListener implements DoreplacedentListener {

        @Override
        public void insertUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void removeUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void changedUpdate(DoreplacedentEvent e) {
            validateInput();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        repositoryLabel = new javax.swing.JLabel();
        repositoryComboBox = new javax.swing.JComboBox<>();
        tagLabel = new javax.swing.JLabel();
        tagTextField = new javax.swing.JTextField();
        forceCheckBox = new javax.swing.JCheckBox();
        repositoryLabel.setLabelFor(repositoryComboBox);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(repositoryLabel, org.openide.util.NbBundle.getMessage(TagPanel.clreplaced, "TagPanel.repositoryLabel.text"));
        repositoryComboBox.setEditable(true);
        tagLabel.setLabelFor(tagTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(tagLabel, org.openide.util.NbBundle.getMessage(TagPanel.clreplaced, "TagPanel.tagLabel.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(forceCheckBox, org.openide.util.NbBundle.getMessage(TagPanel.clreplaced, "TagPanel.forceCheckBox.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(forceCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(repositoryLabel).addComponent(tagLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(repositoryComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(tagTextField)))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(repositoryLabel).addComponent(repositoryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(tagLabel).addComponent(tagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(forceCheckBox).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    public String getRepository() {
        return UiUtils.getValue(repositoryComboBox);
    }

    public String getTag() {
        return UiUtils.getValue(tagTextField);
    }

    public boolean isForce() {
        return forceCheckBox.isSelected();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox forceCheckBox;

    private javax.swing.JComboBox<String> repositoryComboBox;

    private javax.swing.JLabel repositoryLabel;

    private javax.swing.JLabel tagLabel;

    private javax.swing.JTextField tagTextField;
    // End of variables declaration//GEN-END:variables
}

18 View Complete Implementation : InstancePropertiesVisual.java
Copyright Apache License 2.0
Author : apache
void init(NotificationLineSupport msgs, JButton addButton) {
    replacedert msgs != null;
    this.msgs = msgs;
    this.addButton = addButton;
    check();
}

18 View Complete Implementation : InstancePropertiesVisual.java
Copyright Apache License 2.0
Author : apache
clreplaced InstancePropertiesVisual extends JPanel {

    public InstancePropertiesVisual() {
        initComponents();
        DoreplacedentListener l = new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent e) {
                check();
            }

            public void removeUpdate(DoreplacedentEvent e) {
                check();
            }

            public void changedUpdate(DoreplacedentEvent e) {
            }
        };
        nameTxt.getDoreplacedent().addDoreplacedentListener(l);
        urlTxt.getDoreplacedent().addDoreplacedentListener(l);
        checkProgress.setVisible(false);
    }

    private NotificationLineSupport msgs;

    private JButton addButton;

    void init(NotificationLineSupport msgs, JButton addButton) {
        replacedert msgs != null;
        this.msgs = msgs;
        this.addButton = addButton;
        check();
    }

    void showChecking() {
        checkProgress.setVisible(true);
        nameTxt.setEnabled(false);
        urlTxt.setEnabled(false);
        autoSyncCheckBox.setEnabled(false);
        autoSyncSpinner.setEnabled(false);
        proxyButton.setEnabled(false);
    }

    void checkFailed(String explanation) {
        msgs.setErrorMessage(explanation);
        checkProgress.setVisible(false);
        nameTxt.setEnabled(true);
        urlTxt.setEnabled(true);
        autoSyncCheckBox.setEnabled(true);
        autoSyncSpinner.setEnabled(autoSyncCheckBox.isSelected());
        proxyButton.setEnabled(true);
        urlTxt.requestFocusInWindow();
    }

    String getDisplayName() {
        return nameTxt.getText().trim();
    }

    String getUrl() {
        return urlTxt.getText().trim();
    }

    int getSyncTime() {
        return autoSyncCheckBox.isSelected() ? (Integer) autoSyncSpinner.getValue() : 0;
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        nameLabel = new javax.swing.JLabel();
        nameTxt = new javax.swing.JTextField();
        urlLabel = new javax.swing.JLabel();
        urlTxt = new javax.swing.JTextField();
        autoSyncCheckBox = new javax.swing.JCheckBox();
        autoSyncSpinner = new javax.swing.JSpinner();
        autoSyncLabel = new javax.swing.JLabel();
        proxyButton = new javax.swing.JButton();
        checkProgress = new javax.swing.JProgressBar();
        nameLabel.setLabelFor(nameTxt);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "LBL_Name"));
        urlLabel.setLabelFor(urlTxt);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(urlLabel, org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "LBL_Url"));
        // NOI18N
        urlTxt.setText(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.urlTxt.text"));
        autoSyncCheckBox.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(autoSyncCheckBox, org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "LBL_AutoSync"));
        autoSyncCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        autoSyncCheckBox.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                autoSyncCheckBoxActionPerformed(evt);
            }
        });
        autoSyncSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(5), Integer.valueOf(1), null, Integer.valueOf(1)));
        autoSyncSpinner.addChangeListener(new javax.swing.event.ChangeListener() {

            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                autoSyncSpinnerStateChanged(evt);
            }
        });
        autoSyncLabel.setLabelFor(autoSyncSpinner);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(autoSyncLabel, org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "LBL_AutoSyncMinutes"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(proxyButton, org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "LBL_Proxy"));
        proxyButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                proxyButtonActionPerformed(evt);
            }
        });
        checkProgress.setIndeterminate(true);
        // NOI18N
        checkProgress.setString(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.checkProgress.string"));
        checkProgress.setStringPainted(true);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(checkProgress, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(autoSyncCheckBox).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(autoSyncSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(autoSyncLabel)).addComponent(proxyButton).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(nameLabel).addComponent(urlLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(urlTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE).addComponent(nameTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(nameLabel).addComponent(nameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(urlLabel).addComponent(urlTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(autoSyncCheckBox).addComponent(autoSyncSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(autoSyncLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(proxyButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(checkProgress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        // NOI18N
        nameTxt.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.nameTxt.AccessibleContext.accessibleDescription"));
        // NOI18N
        urlTxt.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.urlTxt.AccessibleContext.accessibleDescription"));
        // NOI18N
        autoSyncCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.autoSyncCheckBox.AccessibleContext.accessibleDescription"));
        // NOI18N
        autoSyncSpinner.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.autoSyncSpinner.AccessibleContext.accessibleDescription"));
        // NOI18N
        proxyButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.proxyButton.AccessibleContext.accessibleDescription"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstancePropertiesVisual.AccessibleContext.accessibleDescription"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void proxyButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_proxyButtonActionPerformed
        // NOI18N
        OptionsDisplayer.getDefault().open("General");
    }

    // GEN-LAST:event_proxyButtonActionPerformed
    private void autoSyncSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {
        // GEN-FIRST:event_autoSyncSpinnerStateChanged
        check();
    }

    // GEN-LAST:event_autoSyncSpinnerStateChanged
    private void autoSyncCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_autoSyncCheckBoxActionPerformed
        autoSyncSpinner.setEnabled(autoSyncCheckBox.isSelected());
        check();
    }

    // GEN-LAST:event_autoSyncCheckBoxActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox autoSyncCheckBox;

    private javax.swing.JLabel autoSyncLabel;

    private javax.swing.JSpinner autoSyncSpinner;

    private javax.swing.JProgressBar checkProgress;

    private javax.swing.JLabel nameLabel;

    private javax.swing.JTextField nameTxt;

    private javax.swing.JButton proxyButton;

    private javax.swing.JLabel urlLabel;

    private javax.swing.JTextField urlTxt;

    // End of variables declaration//GEN-END:variables
    private void check() {
        addButton.setEnabled(false);
        String name = getDisplayName();
        String url = getUrl();
        if (name.length() == 0) {
            msgs.setInformationMessage(NbBundle.getMessage(InstanceDialog.clreplaced, "MSG_EmptyName"));
            return;
        }
        if (HudsonManager.getInstanceByName(name) != null) {
            msgs.setErrorMessage(NbBundle.getMessage(InstanceDialog.clreplaced, "MSG_ExistName"));
            return;
        }
        if (url.length() == 0 || url.endsWith("//")) {
            msgs.setInformationMessage(NbBundle.getMessage(InstanceDialog.clreplaced, "MSG_EmptyUrl"));
            return;
        }
        if (!url.endsWith("/")) {
            // NOI18N
            msgs.setInformationMessage(NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstanceDialog.end_with_slash"));
            return;
        }
        try {
            URL u = new URL(url);
            if (!u.getProtocol().matches("https?")) {
                // NOI18N
                msgs.setErrorMessage(NbBundle.getMessage(InstancePropertiesVisual.clreplaced, "InstanceDialog.http_protocol"));
                return;
            }
        } catch (MalformedURLException x) {
            msgs.setErrorMessage(x.getLocalizedMessage());
            return;
        }
        if (HudsonManager.getInstance(url) != null) {
            msgs.setErrorMessage(NbBundle.getMessage(InstanceDialog.clreplaced, "MSG_ExistUrl"));
            return;
        }
        msgs.clearMessages();
        addButton.setEnabled(true);
    }
}

18 View Complete Implementation : ExportZIP.java
Copyright Apache License 2.0
Author : apache
@Messages({ "ERR_no_proj=No project selected.", "ERR_no_root=Must select a root directory to package.", "# {0} - directory", "ERR_no_dir={0} does not exist.", "ERR_no_zip=Must select a ZIP to export to.", "# {0} - file", "WRN_exists={0} already exists.", "ERR_hg=If using Mercurial, consider instead: hg bundle --all ..." })
private boolean check(NotificationLineSupport notifications) {
    notifications.clearMessages();
    if (projectRadio.isSelected() && projectCombo.getSelectedIndex() == -1) {
        notifications.setInformationMessage(ERR_no_proj());
        return false;
    } else if (otherRadio.isSelected()) {
        String t = otherField.getText();
        if (t.isEmpty()) {
            notifications.setInformationMessage(ERR_no_root());
            return false;
        } else if (!new File(t).isDirectory()) {
            notifications.setErrorMessage(ERR_no_dir(t));
            return false;
        }
    }
    String t = zipField.getText();
    if (t.isEmpty()) {
        notifications.setInformationMessage(ERR_no_zip());
        return false;
    } else if (new File(t).exists()) {
        notifications.setWarningMessage(WRN_exists(t));
    } else if (new File(t).getParentFile() == null) {
        notifications.setErrorMessage(ERR_no_dir(new File(t)));
        return false;
    } else if (!new File(t).getParentFile().isDirectory()) {
        notifications.setErrorMessage(ERR_no_dir(new File(t).getParent()));
        return false;
    }
    if (new File(root(), ".hg/store").isDirectory()) {
        notifications.setInformationMessage(ERR_hg());
    }
    return true;
}

18 View Complete Implementation : CIEntryEditPanel.java
Copyright GNU General Public License v2.0
Author : nbphpcouncil
void setValidityObjects(DialogDescriptor validityDescriptor, NotificationLineSupport validityNotificationSupport) {
    this.validityDescriptor = validityDescriptor;
    this.validityNotificationSupport = validityNotificationSupport;
    attachValidityChecks();
}

17 View Complete Implementation : DatasourceCustomizer.java
Copyright Apache License 2.0
Author : apache
/**
 * @author  Libor Kotouc
 * @author  Petr Slechta
 */
clreplaced DatasourceCustomizer extends javax.swing.JPanel {

    private static final ResourceBundle bundle = NbBundle.getBundle(DatasourceCustomizer.clreplaced);

    private Dialog dialog = null;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private boolean dialogOK = false;

    private HashMap<String, Datasource> datasources;

    private String jndiName;

    private String url;

    private String username;

    private String preplacedword;

    private String driverClreplacedName;

    public DatasourceCustomizer(List<Datasource> datasources) {
        if (datasources != null) {
            // transform Set to Map for faster searching
            this.datasources = new HashMap<String, Datasource>();
            for (Iterator it = datasources.iterator(); it.hasNext(); ) {
                Datasource ds = (Datasource) it.next();
                if (ds.getJndiName() != null)
                    this.datasources.put(ds.getJndiName(), ds);
            }
        }
        initComponents();
        DatabaseExplorerUIs.connect(connCombo, ConnectionManager.getDefault());
        connCombo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                verify();
            }
        });
        jndiNameField.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void changedUpdate(DoreplacedentEvent e) {
                verify();
            }

            public void insertUpdate(DoreplacedentEvent e) {
                verify();
            }

            public void removeUpdate(DoreplacedentEvent e) {
                verify();
            }
        });
    }

    public boolean showDialog() {
        descriptor = new DialogDescriptor(// NOI18N
        this, // NOI18N
        NbBundle.getMessage(DatasourceCustomizer.clreplaced, "LBL_DatasourceCustomizer"), // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(DatasourceCustomizer.clreplaced), new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                boolean close = true;
                if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
                    boolean valid = handleConfirmation();
                    close = valid;
                    dialogOK = valid;
                }
                if (close) {
                    dialog.dispose();
                }
            }
        });
        descriptor.setClosingOptions(new Object[] { DialogDescriptor.CANCEL_OPTION });
        statusLine = descriptor.createNotificationLineSupport();
        verify();
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        repaint();
        return dialogOK;
    }

    private boolean handleConfirmation() {
        jndiName = jndiNameField.getText().trim();
        DatabaseConnection conn = (DatabaseConnection) connCombo.getSelectedItem();
        if (conn.getPreplacedword() == null) {
            ConnectionManager.getDefault().showConnectionDialog(conn);
        }
        if (conn.getPreplacedword() == null) {
            // user did not provide the preplacedword
            // NOI18N
            statusLine.setErrorMessage(bundle.getString("ERR_NoPreplacedword"));
            return false;
        }
        url = conn.getDatabaseURL();
        username = conn.getUser();
        preplacedword = conn.getPreplacedword();
        driverClreplacedName = conn.getDriverClreplaced();
        return true;
    }

    private boolean verify() {
        boolean isValid = verifyJndiName();
        if (isValid)
            isValid = verifyConnection();
        return isValid;
    }

    private boolean verifyJndiName() {
        boolean valid = true;
        String jndiNameFromField = jndiNameField.getText().trim();
        if (jndiNameFromField.length() == 0) {
            // NOI18N
            statusLine.setInformationMessage(bundle.getString("ERR_JNDI_NAME_EMPTY"));
            valid = false;
        } else if (datasourceAlreadyExists(jndiNameFromField)) {
            // NOI18N
            statusLine.setErrorMessage(bundle.getString("ERR_DS_EXISTS"));
            valid = false;
        } else {
            statusLine.clearMessages();
        }
        descriptor.setValid(valid);
        return valid;
    }

    private boolean verifyConnection() {
        boolean valid = true;
        if (!(connCombo.getSelectedItem() instanceof DatabaseConnection)) {
            // NOI18N
            statusLine.setInformationMessage(bundle.getString("ERR_NO_CONN_SELECTED"));
            valid = false;
        } else {
            statusLine.clearMessages();
        }
        descriptor.setValid(valid);
        return valid;
    }

    private boolean datasourceAlreadyExists(String jndiName) {
        return datasources.containsKey(jndiName);
    }

    String getJndiName() {
        return jndiName;
    }

    String getUrl() {
        return url;
    }

    String getUsername() {
        return username;
    }

    String getPreplacedword() {
        return preplacedword;
    }

    String getDriverClreplacedName() {
        return driverClreplacedName;
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jndiNameField = new javax.swing.JTextField();
        connCombo = new javax.swing.JComboBox();
        setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setLabelFor(jndiNameField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DatasourceCustomizer.clreplaced, "LBL_DSC_JndiName"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(DatasourceCustomizer.clreplaced, "LBL_DSC_DbConn"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1).addComponent(jLabel2)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jndiNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE).addComponent(connCombo, 0, 327, Short.MAX_VALUE)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(jndiNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(connCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap()));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox connCombo;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JTextField jndiNameField;
    // End of variables declaration//GEN-END:variables
}

17 View Complete Implementation : MessageDestinationUiSupport.java
Copyright Apache License 2.0
Author : apache
/**
 * Open the dialog for adding message destination. If the javaEE platform is EJB3.2+ it will return instance
 * of the (@link JmsDestinationDefinition} with flag for generation. Such destination has to be created as an
 * annotation inside the source file. Otherwise (for EJB3.1-) it will create static resource using the
 * {@link J2eeModuleProvider.ConfigSupport#createMessageDestination}.
 * @param project project where we are generating
 * @param j2eeModuleProvider Java EE module provider.
 * @param moduleDestinations module message destinations.
 * @param serverDestinations server message destinations.
 * @return created message destination or <code>null</code> if no message destination is created.
 */
public static MessageDestination prepareMessageDestination(final Project project, final J2eeModuleProvider j2eeModuleProvider, final Set<MessageDestination> moduleDestinations, final Set<MessageDestination> serverDestinations) {
    replacedert j2eeModuleProvider != null;
    replacedert moduleDestinations != null;
    replacedert serverDestinations != null;
    // message destination names - create map for faster searching
    Map<String, MessageDestination.Type> destinations = new HashMap<String, MessageDestination.Type>();
    for (MessageDestination md : moduleDestinations) {
        destinations.put(md.getName(), md.getType());
    }
    for (MessageDestination md : serverDestinations) {
        destinations.put(md.getName(), md.getType());
    }
    J2eeProjectCapabilities capabilities = J2eeProjectCapabilities.forProject(project);
    MessageDestinationPanel messageDestination = MessageDestinationPanel.newInstance(destinations, capabilities.isEjb32Supported(), JndiNamespacesDefinition.APPLICATION_NAMESPACE);
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(messageDestination, NbBundle.getMessage(MessageDestinationPanel.clreplaced, "LBL_AddMessageDestination"), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(MessageDestinationPanel.clreplaced), null);
    NotificationLineSupport statusLine = dialogDescriptor.createNotificationLineSupport();
    messageDestination.setNotificationLine(statusLine);
    // initial invalidation
    dialogDescriptor.setValid(false);
    messageDestination.addPropertyChangeListener(MessageDestinationPanel.IS_VALID, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            Object newvalue = evt.getNewValue();
            if ((newvalue != null) && (newvalue instanceof Boolean)) {
                dialogDescriptor.setValid(((Boolean) newvalue).booleanValue());
            }
        }
    });
    Object option = DialogDisplayer.getDefault().notify(dialogDescriptor);
    MessageDestination md = null;
    if (option == DialogDescriptor.OK_OPTION) {
        if (capabilities.isEjb32Supported()) {
            md = new JmsDestinationDefinition(messageDestination.getDestinationName(), messageDestination.getDestinationType(), true);
        } else {
            md = createMessageDestination(j2eeModuleProvider, messageDestination.getDestinationName(), messageDestination.getDestinationType());
        }
    }
    return md;
}

17 View Complete Implementation : CallEjbPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author Chris Webster
 * @author Martin Adamek
 * @Petr Slechta
 */
public clreplaced CallEjbPanel extends javax.swing.JPanel {

    private static final Logger LOGGER = Logger.getLogger(CallEjbPanel.clreplaced.getName());

    // NOI18N
    public static final String IS_VALID = "CallEjbPanel_isValid";

    private Set<String> refNameSet;

    private final NodeDisplayPanel nodeDisplayPanel;

    private final ServiceLocatorStrategyPanel slPanel;

    private final NodeAcceptor nodeAcceptor;

    private final Project project;

    private final String clreplacedName;

    private final FileObject srcFile;

    private final FutureTask<Boolean> taskIsTargetJavaSE;

    private Boolean targetIsJavaSE = null;

    private NotificationLineSupport statusLine;

    /**
     * Creates new form CallEjbPanel
     */
    public CallEjbPanel(FileObject fileObject, Node rootNode, String lastLocator, final String clreplacedName) throws IOException {
        initComponents();
        this.srcFile = fileObject;
        this.project = FileOwnerQuery.getOwner(srcFile);
        this.clreplacedName = clreplacedName;
        this.nodeAcceptor = new NodeAcceptorImpl();
        // initialization of targetIsJavaSE outside EDT
        taskIsTargetJavaSE = new FutureTask<Boolean>(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return Utils.isTargetJavaSE(srcFile, clreplacedName);
            }
        });
        RequestProcessor.getDefault().post(taskIsTargetJavaSE);
        nodeDisplayPanel = new NodeDisplayPanel(rootNode);
        nodeDisplayPanel.setBorder(new EtchedBorder());
        displayPanel.add(nodeDisplayPanel);
        nodeDisplayPanel.addPropertyChangeListener(new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent pce) {
                if (ExplorerManager.PROP_NODE_CHANGE.equals(pce.getPropertyName())) {
                    Node[] nodes = nodeDisplayPanel.getSelectedNodes();
                    if (nodes.length == 0) {
                        return;
                    }
                    EjbReference ejbReference = nodes[0].getLookup().lookup(EjbReference.clreplaced);
                    if (ejbReference != null) {
                        try {
                            setGeneratedName(ejbReference, remoteRadioButton.isSelected(), nodes[0]);
                        } catch (IOException ioe) {
                            Exceptions.printStackTrace(ioe);
                        }
                    }
                    validateReferences();
                }
            }
        });
        referenceNameTextField.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent keyEvent) {
                validateReferences();
            }
        });
        slPanel = new ServiceLocatorStrategyPanel(lastLocator, ClreplacedpathInfo.create(fileObject));
        slPanel.getUnreferencedServiceLocator().addItemListener(new java.awt.event.ItemListener() {

            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                validateReferences();
            }
        });
        slPanel.getClreplacedName().getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent doreplacedentEvent) {
                validateReferences();
            }

            public void removeUpdate(DoreplacedentEvent doreplacedentEvent) {
                validateReferences();
            }

            public void changedUpdate(DoreplacedentEvent doreplacedentEvent) {
                validateReferences();
            }
        });
        serviceLocatorPanel.add(slPanel, BorderLayout.CENTER);
    }

    public void setNotificationLine(NotificationLineSupport statusLine) {
        this.statusLine = statusLine;
    }

    public void disableServiceLocator() {
        serviceLocatorPanel.setVisible(false);
    }

    private boolean isTargetJavaSE() {
        if (targetIsJavaSE == null) {
            try {
                targetIsJavaSE = taskIsTargetJavaSE.get();
            } catch (InterruptedException ex) {
                LOGGER.log(Level.WARNING, null, ex);
            } catch (ExecutionException ex) {
                LOGGER.log(Level.WARNING, null, ex);
            }
        }
        return targetIsJavaSE;
    }

    // lazy initialization
    private Set<String> getRefNameSet() throws IOException {
        if (refNameSet == null) {
            refNameSet = new HashSet<String>();
            // This is working only for EJB project. Will need some enhancement in EnterpriseReferenceContainer API?
            org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(srcFile);
            if (ejbModule != null) {
                MetadataModel<EjbJarMetadata> model = ejbModule.getMetadataModel();
                model.runReadAction(new MetadataModelAction<EjbJarMetadata, Void>() {

                    public Void run(EjbJarMetadata metadata) throws IOException {
                        EjbJar ejbJar = metadata.getRoot();
                        if (ejbJar != null) {
                            final EnterpriseBeans enterpriseBeans = ejbJar.getEnterpriseBeans();
                            if (enterpriseBeans != null) {
                                ClreplacedpathInfo cpi = ClreplacedpathInfo.create(srcFile);
                                // NOI18N
                                int beginIndex = clreplacedName.lastIndexOf('.') + 1;
                                String simpleName = clreplacedName.substring(beginIndex);
                                Set<ElementHandle<TypeElement>> handles = cpi.getClreplacedIndex().getDeclaredTypes(simpleName, NameKind.SIMPLE_NAME, Collections.singleton(SearchScope.SOURCE));
                                for (ElementHandle<TypeElement> elementHandle : handles) {
                                    for (Ejb ejb : enterpriseBeans.getEjbs()) {
                                        if (elementHandle.getQualifiedName().contentEquals(ejb.getEjbClreplaced())) {
                                            EjbRef[] ejbRefs = ejb.getEjbRef();
                                            EjbLocalRef[] ejbLocalRefs = ejb.getEjbLocalRef();
                                            for (int j = 0; j < ejbRefs.length; j++) {
                                                refNameSet.add(ejbRefs[j].getEjbRefName());
                                            }
                                            for (int j = 0; j < ejbLocalRefs.length; j++) {
                                                refNameSet.add(ejbLocalRefs[j].getEjbRefName());
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        return null;
                    }
                });
            }
        }
        return refNameSet;
    }

    public void validateReferences() {
        boolean nodeAccepted = nodeAcceptor.acceptNodes(nodeDisplayPanel.getSelectedNodes());
        if ((slPanel.getUnreferencedServiceLocator().isSelected() && slPanel.getClreplacedName().getText().trim().equals("")) || !nodeAccepted) {
            firePropertyChange(IS_VALID, true, false);
        } else {
            firePropertyChange(IS_VALID, false, true);
        }
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        intefaceButtonGroup = new javax.swing.ButtonGroup();
        serviceLocatorPanel = new javax.swing.JPanel();
        convertToRuntime = new javax.swing.JCheckBox();
        displayPanel = new javax.swing.JPanel();
        javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        referenceNameTextField = new javax.swing.JTextField();
        noInterfaceRadioButton = new javax.swing.JRadioButton();
        localRadioButton = new javax.swing.JRadioButton();
        remoteRadioButton = new javax.swing.JRadioButton();
        setLayout(new java.awt.GridBagLayout());
        serviceLocatorPanel.setLayout(new java.awt.BorderLayout());
        convertToRuntime.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle").getString("LBL_ConvertToRuntimeMneumonic").charAt(0));
        convertToRuntime.setSelected(true);
        // NOI18N
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle");
        // NOI18N
        convertToRuntime.setText(bundle.getString("LBL_ConvertToRuntime"));
        serviceLocatorPanel.add(convertToRuntime, java.awt.BorderLayout.SOUTH);
        // NOI18N
        convertToRuntime.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "ACSD_ConvertToRuntime"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(serviceLocatorPanel, gridBagConstraints);
        displayPanel.setLayout(new java.awt.BorderLayout());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(displayPanel, gridBagConstraints);
        // NOI18N
        displayPanel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_DisplayPanel"));
        // NOI18N
        displayPanel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_DisplayPanel"));
        jLabel1.setLabelFor(displayPanel);
        // NOI18N
        jLabel1.setText(bundle.getString("LBL_ModuleMustBeInSameApplication"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        add(jLabel1, gridBagConstraints);
        jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle").getString("MN_ReferenceName").charAt(0));
        jLabel2.setLabelFor(referenceNameTextField);
        // NOI18N
        jLabel2.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_ReferenceName"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(jLabel2, gridBagConstraints);
        // NOI18N
        jLabel3.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_ReferencedInterface"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(jLabel3, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(referenceNameTextField, gridBagConstraints);
        // NOI18N
        referenceNameTextField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_ReferenceName"));
        // NOI18N
        referenceNameTextField.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_ReferenceName"));
        intefaceButtonGroup.add(noInterfaceRadioButton);
        noInterfaceRadioButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle").getString("MN_NoInterface").charAt(0));
        noInterfaceRadioButton.setSelected(true);
        // NOI18N
        noInterfaceRadioButton.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_NoInterface"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
        add(noInterfaceRadioButton, gridBagConstraints);
        noInterfaceRadioButton.getAccessibleContext().setAccessibleDescription("No interface");
        intefaceButtonGroup.add(localRadioButton);
        localRadioButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle").getString("MN_Local").charAt(0));
        // NOI18N
        localRadioButton.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_Local"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(localRadioButton, gridBagConstraints);
        // NOI18N
        localRadioButton.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Local"));
        // NOI18N
        localRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_Local"));
        intefaceButtonGroup.add(remoteRadioButton);
        remoteRadioButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/Bundle").getString("MN_Remote").charAt(0));
        // NOI18N
        remoteRadioButton.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_Remote"));
        remoteRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        remoteRadioButton.addItemListener(new java.awt.event.ItemListener() {

            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                remoteRadioButtonItemStateChanged(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 5);
        add(remoteRadioButton, gridBagConstraints);
        // NOI18N
        remoteRadioButton.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Remote"));
        // NOI18N
        remoteRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_Remote"));
        // NOI18N
        getAccessibleContext().setAccessibleName(bundle.getString("ACS_CallEJBPanel"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CallEJBPanel"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void remoteRadioButtonItemStateChanged(java.awt.event.ItemEvent evt) {
        // GEN-FIRST:event_remoteRadioButtonItemStateChanged
        validateReferences();
    }

    // GEN-LAST:event_remoteRadioButtonItemStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox convertToRuntime;

    private javax.swing.JPanel displayPanel;

    private javax.swing.ButtonGroup intefaceButtonGroup;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JRadioButton localRadioButton;

    private javax.swing.JRadioButton noInterfaceRadioButton;

    private javax.swing.JTextField referenceNameTextField;

    private javax.swing.JRadioButton remoteRadioButton;

    private javax.swing.JPanel serviceLocatorPanel;

    // End of variables declaration//GEN-END:variables
    public boolean convertToRuntime() {
        return convertToRuntime.isSelected();
    }

    public Node getEjb() {
        Node[] selectedNodes = nodeDisplayPanel.getSelectedNodes();
        return selectedNodes.length > 0 ? selectedNodes[0] : null;
    }

    public String getServiceLocator() {
        return slPanel.clreplacedSelected();
    }

    public String getReferenceName() {
        return referenceNameTextField.getText();
    }

    public boolean isDefaultRefName() {
        Node[] nodes = nodeDisplayPanel.getSelectedNodes();
        if (nodes.length > 0) {
            EjbReference ejbReference = nodes[0].getLookup().lookup(EjbReference.clreplaced);
            if (ejbReference != null) {
                try {
                    return getReferenceName().equals(generateName(ejbReference, remoteRadioButton.isSelected(), nodes[0]));
                } catch (IOException ioe) {
                    Exceptions.printStackTrace(ioe);
                }
            }
        }
        return false;
    }

    public EjbReference.EjbRefIType getSelectedInterface() {
        if (noInterfaceRadioButton.isSelected()) {
            return EjbReference.EjbRefIType.NO_INTERFACE;
        } else if (localRadioButton.isSelected()) {
            return EjbReference.EjbRefIType.LOCAL;
        } else if (remoteRadioButton.isSelected()) {
            return EjbReference.EjbRefIType.REMOTE;
        } else {
            return null;
        }
    }

    private String generateName(EjbReference ejbReference, boolean remote, Node selectedNode) throws IOException {
        // maven projects never have ant artifacts, if you want to uncomment this, talk to me please, mkleint.
        // if (Utils.getAntArtifact(ejbReference) == null) {
        // return "";
        // }
        String name = "";
        final ElementHandle<TypeElement> elementHandle = _RetoucheUtil.getJavaClreplacedFromNode(selectedNode);
        replacedert elementHandle != null : "ElementHandle not found for the node: " + selectedNode;
        org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = ejbReference.getEjbModule();
        if (ejbModule != null) {
            Map<String, String> names = ejbModule.getMetadataModel().runReadAction(new MetadataModelAction<EjbJarMetadata, Map<String, String>>() {

                public Map<String, String> run(EjbJarMetadata metadata) throws Exception {
                    Map<String, String> result = new HashMap<String, String>();
                    EnreplacedyAndSession ejb = (EnreplacedyAndSession) metadata.findByEjbClreplaced(elementHandle.getQualifiedName());
                    if (ejb != null) {
                        result.put(EnreplacedyAndSession.HOME, ejb.getHome());
                        result.put(EnreplacedyAndSession.EJB_NAME, ejb.getEjbName());
                    }
                    return result;
                }
            });
            if (remote) {
                if (isTargetJavaSE() && ProjectUtil.isJavaEE5orHigher(project)) {
                    name = elementHandle.getQualifiedName();
                } else if (isTargetJavaSE()) {
                    name = names.get(EnreplacedyAndSession.HOME);
                } else {
                    name = names.get(EnreplacedyAndSession.EJB_NAME);
                }
            } else {
                name = names.get(EnreplacedyAndSession.EJB_NAME);
            }
        }
        int uniquifier = 1;
        String newName = name;
        while (getRefNameSet().contains(newName)) {
            newName = name + String.valueOf(uniquifier++);
        }
        return name;
    }

    private void setGeneratedName(EjbReference ejbReference, boolean remote, Node selectedNode) throws IOException {
        referenceNameTextField.setText(generateName(ejbReference, remote, selectedNode));
    }

    private clreplaced NodeAcceptorImpl implements NodeAcceptor {

        public NodeAcceptorImpl() {
        }

        public boolean acceptNodes(Node[] nodes) {
            statusLine.clearMessages();
            // no node selected
            if (nodes.length == 0) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_SelectOneEJB"));
                return false;
            }
            // more than one node selected
            if (nodes.length > 1) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_MoreEJBsSelected"));
                return false;
            }
            ElementHandle<TypeElement> elementHandle = null;
            try {
                elementHandle = _RetoucheUtil.getJavaClreplacedFromNode(nodes[0]);
            } catch (IOException ioe) {
                Exceptions.printStackTrace(ioe);
            }
            // non-EJB node is selected
            if (elementHandle == null) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_NodeIsNotEJB"));
                return false;
            }
            if (elementHandle.getQualifiedName().equals(clreplacedName)) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_CannotCallItself", clreplacedName));
                return false;
            }
            // maven projects never have ant artifacts, if you want to uncomment this, talk to me please, mkleint.
            // 
            // // builded archive with beans is not available
            // if (!hasJarArtifact()) {
            // statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_EJBNotInDistributionArchive")); //NOI18N
            // return false;
            // }
            // node cannot act as EJB reference
            EjbReference ejbRef = nodes[0].getLookup().lookup(EjbReference.clreplaced);
            if (ejbRef == null) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_ReferencesNotSupported"));
                return false;
            }
            // check interfaces radiobuttons in context of selected node
            if (!acceptInterfaces(nodes)) {
                return false;
            }
            // validate reference name
            if (!validateRefName()) {
                return false;
            }
            // if local ref is used, modules must be in same module or J2EE application
            FileObject fileObject = nodes[0].getLookup().lookup(FileObject.clreplaced);
            if (fileObject == null) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_NoSourcesForBean"));
                return false;
            }
            boolean isRemoteInterfaceSelected = getSelectedInterface() == EjbReference.EjbRefIType.REMOTE;
            Project nodeProject = FileOwnerQuery.getOwner(fileObject);
            if (isRemoteInterfaceSelected) {
                try {
                    if (nodeProject.equals(Utils.getProject(ejbRef, EjbReference.EjbRefIType.REMOTE))) {
                        // NOI18N
                        statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_RemoteNotInSeparateJar"));
                        return false;
                    }
                } catch (IOException ex) {
                }
            } else {
                if (!nodeProject.equals(project) && !Utils.areInSameJ2EEApp(project, nodeProject)) {
                    // NOI18N
                    statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_NotInSameEarOrProject"));
                    return false;
                }
                // AC cannot contain references to local beans
                if (Utils.isAppClient(project)) {
                    // NOI18N
                    statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_CannotCallLocalInAC"));
                    return false;
                }
                // Unit tests or clreplacedes in a JSE project cannot contain references to local beans
                if (isTargetJavaSE()) {
                    // NOI18N
                    statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_CannotCallLocalInJSE"));
                    return false;
                }
            }
            // see #75876
            if (!ProjectUtil.isJavaEE5orHigher(project) && ProjectUtil.isJavaEE5orHigher(nodeProject)) {
                // NOI18N
                statusLine.setWarningMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_JEESpecificationLevelsDiffer"));
            }
            return true;
        }

        private boolean acceptInterfaces(Node[] nodes) {
            EjbReference ejbReference = nodes[0].getLookup().lookup(EjbReference.clreplaced);
            if (ejbReference == null) {
                return false;
            }
            boolean shouldEnableNoInterface = J2eeProjectCapabilities.forProject(project).isEjb31LiteSupported() && isNoInterfaceViewExposed(ejbReference);
            boolean shouldEnableLocal = (ejbReference.getLocal() != null);
            boolean shouldEnableRemote = (ejbReference.getRemote() != null);
            noInterfaceRadioButton.setEnabled(shouldEnableNoInterface);
            localRadioButton.setEnabled(shouldEnableLocal);
            remoteRadioButton.setEnabled(shouldEnableRemote);
            if (!shouldEnableLocal && !shouldEnableRemote && !shouldEnableNoInterface) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "LBL_ReferencesNotSupported"));
                return false;
            }
            if (!intefaceButtonGroup.getSelection().isEnabled()) {
                if (shouldEnableNoInterface) {
                    noInterfaceRadioButton.setSelected(true);
                } else if (shouldEnableLocal) {
                    localRadioButton.setSelected(true);
                } else if (shouldEnableRemote) {
                    remoteRadioButton.setSelected(true);
                }
            }
            statusLine.clearMessages();
            return true;
        }

        private boolean isNoInterfaceViewExposed(final EjbReference ejbRef) {
            if (ejbRef.getLocal() == null && ejbRef.getRemote() == null) {
                return true;
            }
            Boolean result = Boolean.FALSE;
            try {
                result = ejbRef.getEjbModule().getMetadataModel().runReadAction(new MetadataModelAction<EjbJarMetadata, Boolean>() {

                    @Override
                    public Boolean run(EjbJarMetadata metadata) throws Exception {
                        Ejb ejb = metadata.findByEjbClreplaced(ejbRef.getEjbClreplaced());
                        if (ejb instanceof Session) {
                            return ((Session) ejb).isLocalBean();
                        }
                        return Boolean.FALSE;
                    }
                });
            } catch (MetadataModelException ex) {
                Exceptions.printStackTrace(ex);
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
            return result.booleanValue();
        }

        private boolean hasJarArtifact() {
            Project nodeProject = FileOwnerQuery.getOwner(srcFile);
            if (nodeProject.equals(project)) {
                // we're in same project, no need for output jar
                return true;
            }
            return AntArtifactQuery.findArtifactsByType(nodeProject, JavaProjectConstants.ARTIFACT_TYPE_JAR).length > 0;
        }

        private boolean validateRefName() {
            String refName = referenceNameTextField.getText();
            if (refName.trim().length() < 1) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "ERR_ReferenceNameEmpty", refName));
                return false;
            } else if (refNameSet.contains(refName)) {
                // NOI18N
                statusLine.setErrorMessage(NbBundle.getMessage(CallEjbPanel.clreplaced, "ERR_ReferenceNameExists", refName));
                return false;
            }
            return true;
        }
    }
}

17 View Complete Implementation : DataSourceReferencePanel.java
Copyright Apache License 2.0
Author : apache
/**
 * Panel for adding data source reference.
 * @author Tomas Mysik
 * @author Petr Slechta
 */
public clreplaced DataSourceReferencePanel extends JPanel {

    // NOI18N
    public static final String IS_VALID = DataSourceReferencePanel.clreplaced.getName() + ".IS_VALID";

    private final J2eeModuleProvider provider;

    private final Set<String> refNames;

    private final Set<Datasource> moduleDatasources;

    private final Set<Datasource> serverDatasources;

    private final boolean isDsApiSupportedByServerPlugin;

    private NotificationLineSupport statusLine;

    /**
     * Creates new form DataSourceReferencePanel
     */
    public DataSourceReferencePanel(J2eeModuleProvider provider, Set<String> refNames, Set<Datasource> moduleDatasources, Set<Datasource> serverDatasources) {
        initComponents();
        this.provider = provider;
        this.refNames = refNames;
        this.moduleDatasources = moduleDatasources;
        this.serverDatasources = serverDatasources;
        isDsApiSupportedByServerPlugin = isDsApiSupportedByServerPlugin();
        registerListeners();
        setupAddButton();
        setupComboBoxes();
        handleComboBoxes();
        populate();
    }

    public void setNotificationLine(NotificationLineSupport statusLine) {
        this.statusLine = statusLine;
        verify();
    }

    /**
     * Get the name of the data source reference.
     * @return the reference name.
     */
    public String getReferenceName() {
        return dsReferenceText.getText().trim();
    }

    /**
     * Get the data source.
     * @return selected data source.
     */
    public Datasource getDataSource() {
        if (projectDsRadio.isSelected()) {
            return (Datasource) projectDsCombo.getSelectedItem();
        }
        return (Datasource) serverDsCombo.getSelectedItem();
    }

    public boolean copyDataSourceToProject() {
        if (projectDsRadio.isSelected()) {
            return false;
        }
        return dsCopyToProjectCheck.isSelected();
    }

    // TODO this method should be reviewed (handle 'Missing server' error)
    private boolean isDsApiSupportedByServerPlugin() {
        return (provider != null && provider.isDatasourceCreationSupported() && ServerUtil.isValidServerInstance(provider));
    }

    private void registerListeners() {
        // text field
        dsReferenceText.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void changedUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }

            public void insertUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }

            public void removeUpdate(DoreplacedentEvent doreplacedentEvent) {
                verify();
            }
        });
        // radio buttons
        projectDsRadio.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                verify();
                handleComboBoxes();
            }
        });
        serverDsRadio.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                verify();
                handleComboBoxes();
            }
        });
        // combo boxes
        projectDsCombo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                verify();
            }
        });
        serverDsCombo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                verify();
            }
        });
        addAncestorListener(new AncestorListener() {

            public void ancestorAdded(AncestorEvent event) {
                verify();
            }

            public void ancestorRemoved(AncestorEvent event) {
                verify();
            }

            public void ancestorMoved(AncestorEvent event) {
                verify();
            }
        });
    }

    private void setupComboBoxes() {
        projectDsCombo.setPrototypeDisplayValue(SelectDatabasePanel.PROTOTYPE_VALUE);
        projectDsCombo.setRenderer(DatasourceUIHelper.createDatasourceListCellRenderer());
        serverDsCombo.setRenderer(DatasourceUIHelper.createDatasourceListCellRenderer());
    }

    private void handleComboBoxes() {
        projectDsCombo.setEnabled(projectDsRadio.isSelected());
        serverDsCombo.setEnabled(serverDsRadio.isSelected());
        dsCopyToProjectCheck.setEnabled(serverDsRadio.isSelected());
    }

    private void populate() {
        populateDataSources(moduleDatasources, projectDsCombo);
        populateDataSources(serverDatasources, serverDsCombo);
    }

    private static void populateDataSources(final Set<Datasource> datasources, final JComboBox comboBox) {
        replacedert datasources != null && comboBox != null;
        List<Datasource> sortedDatasources = new ArrayList<Datasource>(datasources);
        Collections.sort(sortedDatasources, DatasourceUIHelper.createDatasourceComparator());
        comboBox.removeAllItems();
        for (Datasource ds : sortedDatasources) {
            comboBox.addItem(ds);
        }
    }

    private void setupAddButton() {
        addButton.setEnabled(isDsApiSupportedByServerPlugin);
        warningLabel.setVisible(!isDsApiSupportedByServerPlugin);
        projectDsRadio.setEnabled(isDsApiSupportedByServerPlugin);
        projectDsRadio.setSelected(isDsApiSupportedByServerPlugin);
        serverDsRadio.setSelected(!isDsApiSupportedByServerPlugin);
    }

    public void verify() {
        boolean isValid = verifyComponents();
        firePropertyChange(IS_VALID, !isValid, isValid);
    }

    private boolean verifyComponents() {
        // reference name
        String refName = dsReferenceText.getText();
        if (refName == null || refName.trim().length() == 0) {
            // NOI18N
            setInfo("ERR_NO_REFNAME");
            return false;
        } else {
            refName = refName.trim();
            if (!Utilities.isJavaIdentifier(refName)) {
                // NOI18N
                setError("ERR_INVALID_REFNAME");
                return false;
            }
            if (refNames.contains(refName)) {
                // NOI18N
                setError("ERR_DUPLICATE_REFNAME");
                return false;
            }
        }
        // data sources (radio + combo)
        if (dsGroup.getSelection() == null) {
            // NOI18N
            setInfo("ERR_NO_DATASOURCE_SELECTED");
            return false;
        } else if (projectDsRadio.isSelected()) {
            if (projectDsCombo.gereplacedemCount() == 0 || projectDsCombo.getSelectedIndex() == -1) {
                // NOI18N
                setInfo("ERR_NO_DATASOURCE_SELECTED");
                return false;
            }
        } else if (serverDsRadio.isSelected()) {
            if (serverDsCombo.gereplacedemCount() == 0 || serverDsCombo.getSelectedIndex() == -1) {
                // NOI18N
                setInfo("ERR_NO_DATASOURCE_SELECTED");
                return false;
            }
        }
        if (!isDsApiSupportedByServerPlugin) {
            // DS API is not supported by the server plugin
            statusLine.setWarningMessage(NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_DSC_Warning"));
            return true;
        }
        // no errors
        statusLine.clearMessages();
        return true;
    }

    private void setError(String key) {
        if (statusLine != null) {
            statusLine.setErrorMessage(NbBundle.getMessage(DataSourceReferencePanel.clreplaced, key));
        }
    }

    private void setInfo(String key) {
        if (statusLine != null) {
            statusLine.setInformationMessage(NbBundle.getMessage(DataSourceReferencePanel.clreplaced, key));
        }
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        dsGroup = new javax.swing.ButtonGroup();
        dsReferenceLabel = new javax.swing.JLabel();
        dsReferenceText = new javax.swing.JTextField();
        projectDsRadio = new javax.swing.JRadioButton();
        serverDsRadio = new javax.swing.JRadioButton();
        projectDsCombo = new javax.swing.JComboBox();
        serverDsCombo = new javax.swing.JComboBox();
        dsCopyToProjectCheck = new javax.swing.JCheckBox();
        addButton = new javax.swing.JButton();
        warningLabel = new javax.swing.JLabel();
        dsReferenceLabel.setLabelFor(dsReferenceText);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(dsReferenceLabel, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_DsReferenceName"));
        dsGroup.add(projectDsRadio);
        projectDsRadio.setSelected(true);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(projectDsRadio, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_ProjectDs"));
        projectDsRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        projectDsRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
        dsGroup.add(serverDsRadio);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(serverDsRadio, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_ServerDs"));
        serverDsRadio.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        serverDsRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(dsCopyToProjectCheck, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_DsCopyToProject"));
        dsCopyToProjectCheck.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        dsCopyToProjectCheck.setMargin(new java.awt.Insets(0, 0, 0, 0));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(addButton, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_Add"));
        addButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "LBL_DSC_Warning"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addComponent(dsCopyToProjectCheck, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)).addComponent(serverDsRadio))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addGap(29, 29, 29).addComponent(warningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 516, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(projectDsRadio).addComponent(dsReferenceLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(serverDsCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 351, Short.MAX_VALUE).addComponent(dsReferenceText, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE).addComponent(projectDsCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 351, Short.MAX_VALUE)))).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(addButton))).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(dsReferenceLabel).addComponent(dsReferenceText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(projectDsRadio).addComponent(projectDsCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(addButton)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(warningLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(serverDsRadio).addComponent(serverDsCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(dsCopyToProjectCheck).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        // NOI18N
        dsReferenceLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_ReferenceName"));
        // NOI18N
        projectDsRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_ProjectDataSource"));
        // NOI18N
        serverDsRadio.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_ServerDataSource"));
        // NOI18N
        addButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_AddDataSource"));
        // NOI18N
        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_AddDataSourceRef"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DataSourceReferencePanel.clreplaced, "ACSD_AddDataSourceRef"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_addButtonActionPerformed
        Datasource datasource = handleDataSourceCustomizer();
        if (datasource != null) {
            moduleDatasources.add(datasource);
            populateDataSources(moduleDatasources, projectDsCombo);
            projectDsCombo.setSelectedItem(datasource);
        }
    }

    // GEN-LAST:event_addButtonActionPerformed
    private Datasource handleDataSourceCustomizer() {
        Datasource datasource = null;
        Set<Datasource> datasources = new HashSet<Datasource>(moduleDatasources);
        datasources.addAll(serverDatasources);
        DatasourceComboBoxCustomizer dsc = new DatasourceComboBoxCustomizer(datasources);
        if (dsc.showDialog()) {
            datasource = createDataSource(dsc);
        }
        return datasource;
    }

    private Datasource createDataSource(DatasourceComboBoxCustomizer dsc) {
        // if provider is able to create it, we will use it
        if (isDsApiSupportedByServerPlugin) {
            return createServerDataSource(dsc);
        }
        return createProjectDataSource(dsc);
    }

    private Datasource createServerDataSource(DatasourceComboBoxCustomizer dsc) {
        final Datasource[] ds = new Datasource[1];
        // creating datasources asynchronously
        final String preplacedword = dsc.getPreplacedword();
        final String jndiName = dsc.getJndiName();
        final String url = dsc.getUrl();
        final String username = dsc.getUsername();
        final String driverClreplacedName = dsc.getDriverClreplacedName();
        Action action = new ProgressSupport.BackgroundAction() {

            public void run(Context actionContext) {
                String msg = NbBundle.getMessage(DatasourceUIHelper.clreplaced, "MSG_creatingDS");
                actionContext.progress(msg);
                try {
                    ds[0] = provider.createDatasource(jndiName, url, username, preplacedword, driverClreplacedName);
                } catch (DatasourceAlreadyExistsException daee) {
                    // it should not occur bcs it should be already handled in DatasourceCustomizer
                    StringBuilder sb = new StringBuilder();
                    for (Object conflict : daee.getDatasources()) {
                        // NOI18N
                        sb.append(conflict.toString() + "\n");
                    }
                    String message = NbBundle.getMessage(DatasourceUIHelper.clreplaced, "ERR_DsConflict", sb.toString());
                    Exceptions.printStackTrace(Exceptions.attachLocalizedMessage(daee, message));
                } catch (ConfigurationException ce) {
                    Exceptions.printStackTrace(ce);
                }
            }

            @Override
            public boolean isEnabled() {
                return preplacedword != null;
            }
        };
        // invoke action
        Collection<Action> actions = Collections.singleton(action);
        ProgressSupport.invoke(actions);
        return ds[0];
    }

    private Datasource createProjectDataSource(DatasourceComboBoxCustomizer dsc) {
        return new DatasourceImpl(dsc.getJndiName(), dsc.getUrl(), dsc.getUsername(), dsc.getPreplacedword(), dsc.getDriverClreplacedName());
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButton;

    private javax.swing.JCheckBox dsCopyToProjectCheck;

    private javax.swing.ButtonGroup dsGroup;

    private javax.swing.JLabel dsReferenceLabel;

    private javax.swing.JTextField dsReferenceText;

    private javax.swing.JComboBox projectDsCombo;

    private javax.swing.JRadioButton projectDsRadio;

    private javax.swing.JComboBox serverDsCombo;

    private javax.swing.JRadioButton serverDsRadio;

    private javax.swing.JLabel warningLabel;

    // End of variables declaration//GEN-END:variables
    private static clreplaced DatasourceImpl implements Datasource {

        private final String jndiName;

        private final String url;

        private final String username;

        private final String preplacedword;

        private final String driverClreplacedName;

        private String displayName;

        public DatasourceImpl(String jndiName, String url, String username, String preplacedword, String driverClreplacedName) {
            this.jndiName = jndiName;
            this.url = url;
            this.username = username;
            this.preplacedword = preplacedword;
            this.driverClreplacedName = driverClreplacedName;
        }

        public String getJndiName() {
            return jndiName;
        }

        public String getUrl() {
            return url;
        }

        public String getUsername() {
            return username;
        }

        public String getPreplacedword() {
            return preplacedword;
        }

        public String getDriverClreplacedName() {
            return driverClreplacedName;
        }

        public String getDisplayName() {
            if (displayName == null) {
                // NOI18N
                displayName = getJndiName() + " [" + getUrl() + "]";
            }
            return displayName;
        }

        @Override
        public String toString() {
            return getDisplayName();
        }
    }
}

17 View Complete Implementation : SendEmailCodeGenerator.java
Copyright Apache License 2.0
Author : apache
public void invoke() {
    Project enterpriseProject = FileOwnerQuery.getOwner(srcFile);
    // make sure configuration is ready
    J2eeModuleProvider pwm = enterpriseProject.getLookup().lookup(J2eeModuleProvider.clreplaced);
    pwm.getConfigSupport().ensureConfigurationReady();
    EnterpriseReferenceContainer erc = enterpriseProject.getLookup().lookup(EnterpriseReferenceContainer.clreplaced);
    // NOI18N
    final SendEmailPanel sendEmailPanel = new SendEmailPanel(erc.getServiceLocatorName(), ClreplacedpathInfo.create(srcFile));
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(sendEmailPanel, NbBundle.getMessage(SendEmailCodeGenerator.clreplaced, "LBL_SpecifyMailResource"), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(SendEmailPanel.clreplaced), null);
    final NotificationLineSupport notificationSupport = dialogDescriptor.createNotificationLineSupport();
    sendEmailPanel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(SendEmailPanel.IS_VALID)) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    boolean isValid = ((Boolean) newvalue).booleanValue();
                    dialogDescriptor.setValid(isValid);
                    if (isValid) {
                        notificationSupport.clearMessages();
                    } else {
                        notificationSupport.setErrorMessage(sendEmailPanel.getErrorMessage());
                    }
                }
            }
        }
    });
    Object option = DialogDisplayer.getDefault().notify(dialogDescriptor);
    if (option == NotifyDescriptor.OK_OPTION) {
        try {
            String serviceLocator = sendEmailPanel.getServiceLocator();
            ServiceLocatorStrategy serviceLocatorStrategy = null;
            if (serviceLocator != null) {
                serviceLocatorStrategy = ServiceLocatorStrategy.create(enterpriseProject, srcFile, serviceLocator);
            }
            String jndiName = null;
            if (!ProjectUtil.isJavaEE5orHigher(enterpriseProject) || !InjectionTargetQuery.isInjectionTarget(srcFile, beanClreplaced.getQualifiedName().toString())) {
                jndiName = generateJNDILookup(sendEmailPanel.getJndiName(), erc, srcFile, beanClreplaced.getQualifiedName().toString());
            }
            generateMethods(enterpriseProject, srcFile, beanClreplaced.getQualifiedName().toString(), jndiName, sendEmailPanel.getJndiName(), serviceLocatorStrategy);
            if (serviceLocator != null) {
                erc.setServiceLocatorName(serviceLocator);
            }
        } catch (IOException ioe) {
            NotifyDescriptor ndd = new NotifyDescriptor.Message(ioe.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notify(ndd);
        }
    }
}

17 View Complete Implementation : SQLStmtCustomizer.java
Copyright Apache License 2.0
Author : apache
/**
 * @author  Libor Kotouc, Petr Slechta
 */
public clreplaced SQLStmtCustomizer extends javax.swing.JPanel {

    private static final ResourceBundle bundle = NbBundle.getBundle(SQLStmtCustomizer.clreplaced);

    private Dialog dialog = null;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private boolean dialogOK = false;

    SQLStmt stmt;

    JTextComponent target;

    private String displayName;

    private String stmtLabel;

    private String stmtACSN;

    private String stmtACSD;

    private String helpID;

    private boolean mayVariableNameBeEmpty;

    /**
     * **********************************************************************
     */
    public SQLStmtCustomizer(SQLStmt stmt, JTextComponent target, String displayName, String stmtLabel, String stmtACSN, String stmtACSD, String helpID) {
        this(stmt, target, displayName, stmtLabel, stmtACSN, stmtACSD, helpID, true);
    }

    /**
     * **********************************************************************
     */
    public SQLStmtCustomizer(SQLStmt stmt, JTextComponent target, String displayName, String stmtLabel, String stmtACSN, String stmtACSD, String helpID, boolean mayVariableNameBeEmpty) {
        this.stmt = stmt;
        this.target = target;
        this.displayName = displayName;
        this.stmtLabel = stmtLabel;
        this.stmtACSN = stmtACSN;
        this.stmtACSD = stmtACSD;
        this.helpID = helpID;
        this.mayVariableNameBeEmpty = mayVariableNameBeEmpty;
        initComponents();
        jTextField1.setText(stmt.getVariable());
        if (!mayVariableNameBeEmpty) {
            jTextField1.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

                public void insertUpdate(DoreplacedentEvent evt) {
                    validateInput();
                }

                public void removeUpdate(DoreplacedentEvent evt) {
                    validateInput();
                }

                public void changedUpdate(DoreplacedentEvent evt) {
                    validateInput();
                }
            });
        }
        jComboBox2.setModel(new DefaultComboBoxModel(SQLStmt.scopes));
        jComboBox2.setSelectedIndex(stmt.getScopeIndex());
        jTextField2.setText(stmt.getDataSource());
        jTextArea1.setText(stmt.getStmt());
    }

    /**
     * **********************************************************************
     */
    private void validateInput() {
        if (jTextField1.getText().trim().length() < 1) {
            // NOI18N
            statusLine.setInformationMessage(bundle.getString("Error_Empty_VariableName"));
            descriptor.setValid(false);
            return;
        }
        statusLine.clearMessages();
        descriptor.setValid(true);
    }

    /**
     * **********************************************************************
     */
    public boolean showDialog() {
        dialogOK = false;
        descriptor = new DialogDescriptor(// NOI18N
        this, // NOI18N
        bundle.getString("LBL_Customizer_InsertPrefix") + " " + displayName, // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
                    evaluateInput();
                    dialogOK = true;
                }
                dialog.dispose();
            }
        });
        statusLine = descriptor.createNotificationLineSupport();
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        repaint();
        return dialogOK;
    }

    /**
     * **********************************************************************
     */
    private void evaluateInput() {
        String variable = jTextField1.getText();
        stmt.setVariable(variable);
        int scopeIndex = jComboBox2.getSelectedIndex();
        stmt.setScopeIndex(scopeIndex);
        String dataSource = jTextField2.getText();
        stmt.setDataSource(dataSource);
        String stmtString = jTextArea1.getText();
        stmt.setStmt(stmtString);
    }

    /**
     * ************************************************************************
     *  This method is called from within the constructor to
     *  initialize the form.
     *  WARNING: Do NOT modify this code. The content of this method is
     *  always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        jFileChooser1 = new javax.swing.JFileChooser();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jFileChooser1.setCurrentDirectory(null);
        setLayout(new java.awt.GridBagLayout());
        jLabel4.setLabelFor(jComboBox2);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "LBL_Stmt_Scope"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(jLabel4, gridBagConstraints);
        // NOI18N
        jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSN_Stmt_Scope"));
        // NOI18N
        jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSD_Stmt_Scope"));
        jLabel2.setLabelFor(jTextField1);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "LBL_Stmt_Variable"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(jLabel2, gridBagConstraints);
        // NOI18N
        jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSN_Stmt_Variable"));
        // NOI18N
        jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSD_Stmt_Variable"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
        add(jComboBox2, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
        add(jTextField1, gridBagConstraints);
        jLabel1.setLabelFor(jTextArea1);
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, stmtLabel);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(jLabel1, gridBagConstraints);
        jLabel1.getAccessibleContext().setAccessibleName(stmtACSN);
        jLabel1.getAccessibleContext().setAccessibleDescription(stmtACSD);
        jTextArea1.setColumns(35);
        jTextArea1.setRows(10);
        jScrollPane1.setViewportView(jTextArea1);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
        add(jScrollPane1, gridBagConstraints);
        jLabel3.setLabelFor(jTextField2);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "LBL_Stmt_DataSource"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(jLabel3, gridBagConstraints);
        // NOI18N
        jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSN_Stmt_DataSource"));
        // NOI18N
        jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSD_Stmt_DataSource"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
        add(jTextField2, gridBagConstraints);
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SQLStmtCustomizer.clreplaced, "ACSD_Stmt_Dialog", displayName));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox2;

    private javax.swing.JFileChooser jFileChooser1;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JTextArea jTextArea1;

    private javax.swing.JTextField jTextField1;

    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}

17 View Complete Implementation : UseBeanCustomizer.java
Copyright Apache License 2.0
Author : apache
/**
 * @author  Libor Kotouc
 */
public clreplaced UseBeanCustomizer extends javax.swing.JPanel {

    private static final ResourceBundle bundle = NbBundle.getBundle(UseBeanCustomizer.clreplaced);

    private Dialog dialog = null;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private boolean dialogOK = false;

    PageInfo.BeanData[] beanData = null;

    UseBean useBean;

    JTextComponent target;

    /**
     * Creates new form TABLECustomizerPanel
     */
    public UseBeanCustomizer(UseBean useBean, JTextComponent target) {
        this.useBean = useBean;
        this.target = target;
        initComponents();
        jComboBox2.setModel(new DefaultComboBoxModel(UseBean.scopes));
        jComboBox2.setSelectedIndex(useBean.getScopeIndex());
        jTextField2.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            public void removeUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            public void changedUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }
        });
        jTextField1.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            public void removeUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }

            public void changedUpdate(DoreplacedentEvent arg0) {
                validateInput();
            }
        });
    }

    public boolean showDialog(PageInfo.BeanData[] beanData) {
        this.beanData = beanData;
        dialogOK = false;
        // NOI18N
        String displayName = "";
        try {
            // NOI18N
            displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-UseBean");
        } catch (Exception e) {
        }
        descriptor = new DialogDescriptor(// NOI18N
        this, // NOI18N
        bundle.getString("LBL_Customizer_InsertPrefix") + " " + displayName, // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
                    collectInput();
                    dialogOK = true;
                }
                dialog.dispose();
            }
        });
        statusLine = descriptor.createNotificationLineSupport();
        validateInput();
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        repaint();
        return dialogOK;
    }

    private void collectInput() {
        useBean.setBean(jTextField2.getText());
        String clazz = jTextField1.getText();
        useBean.setClazz(clazz);
        int scopeIndex = jComboBox2.getSelectedIndex();
        useBean.setScopeIndex(scopeIndex);
    }

    private void validateInput() {
        if (jTextField2.getText().length() < 1) {
            // NOI18N
            statusLine.setInformationMessage(bundle.getString("Error_Empty_ID"));
            descriptor.setValid(false);
            return;
        }
        if (JspPaletteUtilities.idExists(jTextField2.getText(), beanData)) {
            // NOI18N
            statusLine.setErrorMessage(bundle.getString("Error_not_uniq_ID"));
            descriptor.setValid(false);
            return;
        }
        if (jTextField1.getText().length() < 1) {
            // NOI18N
            statusLine.setInformationMessage(bundle.getString("Error_Empty_clreplaced"));
            descriptor.setValid(false);
            return;
        }
        if (!JspPaletteUtilities.typeExists(target, jTextField1.getText())) {
            // NOI18N
            statusLine.setErrorMessage(bundle.getString("Error_No_Such_clreplaced"));
            descriptor.setValid(false);
            return;
        }
        statusLine.clearMessages();
        descriptor.setValid(true);
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        jFileChooser1 = new javax.swing.JFileChooser();
        jLabel4 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jTextField2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jFileChooser1.setCurrentDirectory(null);
        setLayout(new java.awt.GridBagLayout());
        jLabel4.setLabelFor(jComboBox2);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "LBL_UseBean_Scope"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(jLabel4, gridBagConstraints);
        // NOI18N
        jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSN_UseBean_Scope"));
        // NOI18N
        jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSD_UseBean_Scope"));
        jTextField1.setColumns(35);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12);
        add(jTextField1, gridBagConstraints);
        jLabel1.setLabelFor(jTextField2);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "LBL_UseBean_ID"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(jLabel1, gridBagConstraints);
        // NOI18N
        jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSN_UseBean_ID"));
        // NOI18N
        jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSD_UseBean_ID"));
        jLabel2.setLabelFor(jTextField1);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "LBL_UseBean_Clreplaced"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(jLabel2, gridBagConstraints);
        // NOI18N
        jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSN_UseBean_Clreplaced"));
        // NOI18N
        jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSD_UseBean_Clreplaced"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12);
        add(jComboBox2, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
        add(jTextField2, gridBagConstraints);
        jLabel3.setForeground(new java.awt.Color(255, 0, 0));
        add(jLabel3, new java.awt.GridBagConstraints());
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.clreplaced, "ACSD_UseBean_Dialog"));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox2;

    private javax.swing.JFileChooser jFileChooser1;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JTextField jTextField1;

    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}

17 View Complete Implementation : AddTableColumnDialog.java
Copyright Apache License 2.0
Author : apache
public clreplaced AddTableColumnDialog extends JPanel {

    static final Logger LOGGER = Logger.getLogger(AddTableColumnDialog.clreplaced.getName());

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    Dialog dialog = null;

    JTextField colnamefield, colsizefield, colscalefield, defvalfield;

    JTextArea checkfield;

    JComboBox coltypecombo;

    JCheckBox pkcheckbox, ixcheckbox, checkcheckbox, nullcheckbox, uniquecheckbox;

    DataModel dmodel = new DataModel();

    private final Collection<String> sizelesstypes;

    private final Collection<String> charactertypes;

    @SuppressWarnings("unchecked")
    public AddTableColumnDialog(final Specification spe) {
        setBorder(new EmptyBorder(new Insets(12, 12, 5, 11)));
        GridBagLayout layout = new GridBagLayout();
        GridBagConstraints con;
        setLayout(layout);
        // Column name
        JLabel label = new JLabel();
        // NOI18N
        Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnName"));
        label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnNameA11yDesc"));
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 0;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(0, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        add(label, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 0;
        con.gridwidth = 3;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(0, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        colnamefield = new JTextField(35);
        colnamefield.setName(ColumnItem.NAME);
        colnamefield.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnNameTextFieldA11yDesc"));
        colnamefield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnNameTextFieldA11yName"));
        label.setLabelFor(colnamefield);
        add(colnamefield, con);
        DoreplacedentListener docListener = new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent e) {
                updateState();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent e) {
                updateState();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent e) {
                updateState();
            }
        };
        colnamefield.getDoreplacedent().addDoreplacedentListener(docListener);
        // Column type
        // NOI18N
        Collection<String> sizelesstypesSpec = (Collection<String>) spe.getProperties().get("SizelessTypes");
        // NOI18N
        Collection<String> charactertypesSpec = (Collection<String>) spe.getProperties().get("CharacterTypes");
        sizelesstypes = sizelesstypesSpec != null ? sizelesstypesSpec : Collections.<String>emptyList();
        charactertypes = charactertypesSpec != null ? charactertypesSpec : Collections.<String>emptyList();
        Map<String, String> tmap = spe.getTypeMap();
        List<TypeElement> ttab = new ArrayList<TypeElement>(tmap.size());
        for (String key : tmap.keySet()) {
            ttab.add(new TypeElement(key, tmap.get(key)));
        }
        ColumnItem item = new ColumnItem();
        item.setProperty(ColumnItem.TYPE, ttab.get(0));
        dmodel.addRow(item);
        label = new JLabel();
        // NOI18N
        Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnType"));
        label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnTypeA11yDesc"));
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 1;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(12, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        add(label, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 1;
        con.gridwidth = 3;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        coltypecombo = new JComboBox(ttab.toArray());
        coltypecombo.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updateState();
            }
        });
        coltypecombo.setName(ColumnItem.TYPE);
        coltypecombo.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnTypeComboBoxA11yDesc"));
        coltypecombo.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnTypeComboBoxA11yName"));
        label.setLabelFor(coltypecombo);
        add(coltypecombo, con);
        // Column size
        label = new JLabel();
        // NOI18N
        Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnSize"));
        label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnSizeA11yDesc"));
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 2;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(12, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        add(label, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 2;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        colsizefield = new JTextField();
        colsizefield.setName(ColumnItem.SIZE);
        colsizefield.getDoreplacedent().addDoreplacedentListener(docListener);
        colsizefield.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnSizeTextFieldA11yDesc"));
        colsizefield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnSizeTextFieldA11yName"));
        label.setLabelFor(colsizefield);
        add(colsizefield, con);
        // Column scale
        label = new JLabel();
        // NOI18N
        Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnScale"));
        label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnScaleA11yDesc"));
        con = new GridBagConstraints();
        con.gridx = 2;
        con.gridy = 2;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        add(label, con);
        con = new GridBagConstraints();
        con.gridx = 3;
        con.gridy = 2;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        colscalefield = new JTextField();
        colscalefield.setName(ColumnItem.SCALE);
        colscalefield.getDoreplacedent().addDoreplacedentListener(docListener);
        colscalefield.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnScaleTextFieldA11yDesc"));
        colscalefield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnScaleTextFieldA11yName"));
        label.setLabelFor(colscalefield);
        add(colscalefield, con);
        // Column default value
        label = new JLabel();
        // NOI18N
        Mnemonics.setLocalizedText(label, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnDefault"));
        label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnDefaultA11yDesc"));
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 3;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(12, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        add(label, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 3;
        con.gridwidth = 3;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        defvalfield = new JTextField(35);
        defvalfield.setName(ColumnItem.DEFVAL);
        defvalfield.getDoreplacedent().addDoreplacedentListener(docListener);
        defvalfield.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnDefaultTextFieldA11yDesc"));
        defvalfield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnDefaultTextFieldA11yName"));
        label.setLabelFor(defvalfield);
        layout.setConstraints(defvalfield, con);
        add(defvalfield);
        // Check subpane
        JPanel subpane = new JPanel();
        // NOI18N
        subpane.setBorder(new replacedledBorder(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnConstraintsreplacedle")));
        GridBagLayout sublayout = new GridBagLayout();
        subpane.setLayout(sublayout);
        ItemListener checkBoxListener = new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                JCheckBox cbx = (JCheckBox) e.getSource();
                // just set value. Validation is handled in model
                dmodel.setValue(Boolean.valueOf(cbx.isSelected()), cbx.getName(), 0);
            }
        };
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 0;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(0, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        pkcheckbox = new JCheckBox();
        // NOI18N
        Mnemonics.setLocalizedText(pkcheckbox, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnConstraintPKreplacedle"));
        pkcheckbox.setName(ColumnItem.PRIMARY_KEY);
        pkcheckbox.addItemListener(checkBoxListener);
        pkcheckbox.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnConstraintPKreplacedleA11yDesc"));
        subpane.add(pkcheckbox, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 0;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(0, 12, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        uniquecheckbox = new JCheckBox();
        // NOI18N
        Mnemonics.setLocalizedText(uniquecheckbox, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnConstraintUniquereplacedle"));
        uniquecheckbox.setName(ColumnItem.UNIQUE);
        uniquecheckbox.addItemListener(checkBoxListener);
        uniquecheckbox.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnConstraintUniquereplacedleA11yDesc"));
        subpane.add(uniquecheckbox, con);
        con = new GridBagConstraints();
        con.gridx = 2;
        con.gridy = 0;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(0, 12, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        nullcheckbox = new JCheckBox();
        // NOI18N
        Mnemonics.setLocalizedText(nullcheckbox, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnConstraintNullreplacedle"));
        nullcheckbox.setName(ColumnItem.NULLABLE);
        nullcheckbox.addItemListener(checkBoxListener);
        nullcheckbox.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnConstraintNullreplacedleA11yDesc"));
        subpane.add(nullcheckbox, con);
        con = new GridBagConstraints();
        con.gridx = 3;
        con.gridy = 0;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.WEST;
        con.insets = new java.awt.Insets(0, 12, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        ixcheckbox = new JCheckBox();
        // NOI18N
        Mnemonics.setLocalizedText(ixcheckbox, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnIndexName"));
        ixcheckbox.setName(ColumnItem.INDEX);
        ixcheckbox.addItemListener(checkBoxListener);
        ixcheckbox.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnIndexNameA11yDesc"));
        subpane.add(ixcheckbox, con);
        // Insert subpane
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 4;
        con.gridwidth = 4;
        con.gridheight = 1;
        con.fill = GridBagConstraints.HORIZONTAL;
        con.insets = new java.awt.Insets(12, 0, 0, 0);
        con.weightx = 1.0;
        con.weighty = 0.0;
        add(subpane, con);
        // Check replacedle and textarea
        con = new GridBagConstraints();
        con.gridx = 0;
        con.gridy = 5;
        con.gridwidth = 1;
        con.gridheight = 1;
        con.anchor = GridBagConstraints.NORTHWEST;
        con.insets = new java.awt.Insets(12, 0, 0, 0);
        con.weightx = 0.0;
        con.weighty = 0.0;
        checkcheckbox = new JCheckBox();
        // NOI18N
        Mnemonics.setLocalizedText(checkcheckbox, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumnConstraintCheckreplacedle"));
        checkcheckbox.setName(ColumnItem.CHECK);
        checkcheckbox.addItemListener(checkBoxListener);
        checkcheckbox.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnCheckreplacedleA11yDesc"));
        add(checkcheckbox, con);
        con = new GridBagConstraints();
        con.gridx = 1;
        con.gridy = 5;
        con.gridwidth = 3;
        con.gridheight = 1;
        con.fill = GridBagConstraints.BOTH;
        con.insets = new java.awt.Insets(12, 12, 0, 0);
        con.weightx = 1.0;
        con.weighty = 1.0;
        checkfield = new JTextArea(3, 35);
        checkfield.setName(ColumnItem.CHECK_CODE);
        checkfield.getDoreplacedent().addDoreplacedentListener(docListener);
        checkfield.setToolTipText(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnCheckTextAreaA11yDesc"));
        checkfield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnCheckTextAreaA11yName"));
        checkfield.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnCheckTextAreaA11yDesc"));
        JScrollPane spane = new JScrollPane(checkfield);
        add(spane, con);
        checkcheckbox.setSelected(false);
        checkcheckbox.setSelected(false);
        nullcheckbox.setSelected(true);
        uniquecheckbox.setSelected(false);
        // update changes of model to check boxes
        item.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                String pname = evt.getPropertyName();
                Object nval = evt.getNewValue();
                if (nval instanceof Boolean) {
                    boolean set = ((Boolean) nval).booleanValue();
                    if (pname.equals(ColumnItem.PRIMARY_KEY)) {
                        pkcheckbox.setSelected(set);
                    } else if (pname.equals(ColumnItem.INDEX)) {
                        ixcheckbox.setSelected(set);
                    } else if (pname.equals(ColumnItem.UNIQUE)) {
                        uniquecheckbox.setSelected(set);
                        ixcheckbox.setEnabled(!set);
                    } else if (pname.equals(ColumnItem.NULLABLE)) {
                        nullcheckbox.setSelected(set);
                    }
                }
            }
        });
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ACS_AddTableColumnDialogA11yDesc"));
        doLayout();
        Dimension referenceCurDimension = colsizefield.getSize();
        Dimension referencePrefDimension = colsizefield.getPreferredSize();
        Dimension referenceMinDimension = colsizefield.getMinimumSize();
        Dimension referenceMaxDimension = colsizefield.getMaximumSize();
        colsizefield.setSize(referenceCurDimension);
        colsizefield.setPreferredSize(referencePrefDimension);
        colsizefield.setMinimumSize(referenceMinDimension);
        colsizefield.setMaximumSize(referenceMaxDimension);
        colscalefield.setSize(referenceCurDimension);
        colscalefield.setPreferredSize(referencePrefDimension);
        colscalefield.setMinimumSize(referenceMinDimension);
        colscalefield.setMaximumSize(referenceMaxDimension);
    }

    /**
     * Returns Integer instance from given text field or null if cannot be parsed.
     * If field is empty it returns zero.
     */
    private Integer getIntValue(JTextField textField) {
        String text = textField.getText();
        try {
            if (text == null || text.length() == 0) {
                text = "0";
            }
            return new Integer(text);
        } catch (NumberFormatException nfe) {
            return null;
        }
    }

    /**
     * Validate and update state of model and UI.
     */
    private void updateState() {
        // NOI18N
        replacedert statusLine != null : "Notification status line not available";
        // enable/disable size/scale text field
        Object selectedItem = coltypecombo.getSelectedItem();
        String columnType = selectedItem == null ? null : selectedItem.toString();
        if (sizelesstypes.contains(columnType)) {
            if (colsizefield.isEditable()) {
                colsizefield.setText(null);
                colscalefield.setText(null);
            }
            colsizefield.setEditable(false);
            colscalefield.setEditable(false);
            colsizefield.setEnabled(false);
            colscalefield.setEnabled(false);
        } else {
            boolean disableScale = charactertypes.contains(columnType);
            colsizefield.setEditable(true);
            colscalefield.setEditable(!disableScale);
            colsizefield.setEnabled(true);
            colscalefield.setEnabled(!disableScale);
            if (disableScale) {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        colscalefield.setText(null);
                    }
                });
            }
        }
        String columnName = colnamefield.getText();
        if (columnName == null || columnName.length() < 1) {
            statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_EmptyColName"));
            updateOK(false);
            return;
        }
        Integer size = getIntValue(colsizefield);
        if (size == null) {
            statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_SizeNotNumber"));
            updateOK(false);
            return;
        }
        Integer scale = getIntValue(colscalefield);
        if (scale == null) {
            statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_ScaleNotNumber"));
            updateOK(false);
            return;
        }
        if (columnType.equals("VARCHAR")) {
            // NOI18N
            if (size == 0) {
                statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_NotVarcharSize"));
                updateOK(false);
                return;
            }
            // #155142 - check size of default value for VARCHAR
            if (defvalfield.getText().length() > size) {
                statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_DefaultOverSize"));
                updateOK(false);
                return;
            }
        }
        if (size < scale) {
            statusLine.setInformationMessage(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddTableColumn_ScaleOverSize"));
            updateOK(false);
            return;
        }
        // update model
        dmodel.setValue(columnName, colnamefield.getName(), 0);
        dmodel.setValue(scale, colscalefield.getName(), 0);
        dmodel.setValue(size, colsizefield.getName(), 0);
        dmodel.setValue(defvalfield.getText(), defvalfield.getName(), 0);
        dmodel.setValue(checkfield.getText(), checkfield.getName(), 0);
        dmodel.setValue(coltypecombo.getSelectedItem(), coltypecombo.getName(), 0);
        statusLine.clearMessages();
        updateOK(true);
    }

    /**
     * Updates OK button.
     */
    private void updateOK(boolean valid) {
        if (descriptor != null) {
            descriptor.setValid(valid);
        }
    }

    private void setDescriptor(DialogDescriptor descriptor) {
        this.descriptor = descriptor;
        this.statusLine = descriptor.getNotificationLineSupport();
        updateState();
    }

    private ColumnItem getColumnItem() {
        return (ColumnItem) dmodel.getData().get(0);
    }

    /**
     * Sets UI controls according to given ColumnItem.
     */
    private void setValues(ColumnItem columnItem) {
        colnamefield.setText(columnItem.getName());
        coltypecombo.setSelectedItem(columnItem.getType());
        if (!sizelesstypes.contains(columnItem.getType().toString())) {
            colsizefield.setText(String.valueOf(columnItem.getSize()));
            colscalefield.setText(String.valueOf(columnItem.getScale()));
        }
        defvalfield.setText(columnItem.getDefaultValue());
        pkcheckbox.setSelected(columnItem.isPrimaryKey());
        uniquecheckbox.setSelected(columnItem.isUnique());
        nullcheckbox.setSelected(columnItem.allowsNull());
        ixcheckbox.setSelected(columnItem.isIndexed());
        checkcheckbox.setSelected(columnItem.hasCheckConstraint());
        checkfield.setText(columnItem.getCheckConstraint());
    }

    /**
     * Shows Add Column dialog and returns ColumnItem instance or null if
     * cancelled.
     * @param spec DB specification
     * @param columnItem column item to be edited or null
     * @return ColumnItem instance or null if cancelled
     */
    public static ColumnItem showDialog(Specification spec, ColumnItem columnItem) {
        AddTableColumnDialog panel = new AddTableColumnDialog(spec);
        // NOI18N
        DialogDescriptor descriptor = new DialogDescriptor(panel, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddColumnDialogreplacedle"));
        descriptor.createNotificationLineSupport();
        panel.setDescriptor(descriptor);
        if (columnItem != null) {
            panel.setValues(columnItem);
        }
        Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setVisible(true);
        if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
            return panel.getColumnItem();
        }
        return null;
    }

    /**
     *  Shows Add Column dialog and creates a new column in specified table.
     * @param spec DB specification
     * @param node table node
     * @return true if new column successfully added, false if cancelled
     */
    public static boolean showDialogAndCreate(Specification spec, TableNode node) {
        final AddTableColumnDialog panel = new AddTableColumnDialog(spec);
        // NOI18N
        DialogDescriptor descriptor = new DialogDescriptor(panel, NbBundle.getMessage(AddTableColumnDialog.clreplaced, "AddColumnDialogreplacedle"));
        descriptor.createNotificationLineSupport();
        // inbuilt close of the dialog is only after CANCEL button click
        // after OK button is dialog closed by hand
        descriptor.setClosingOptions(new Object[] { DialogDescriptor.CANCEL_OPTION });
        panel.setDescriptor(descriptor);
        final Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        String tableName = node.getName();
        String schemaName = node.getSchemaName();
        String catName = node.getCatalogName();
        if (schemaName == null) {
            schemaName = catName;
        }
        final AddTableColumnDDL ddl = new AddTableColumnDDL(spec, schemaName, tableName);
        ActionListener listener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent event) {
                if (event.getSource() != DialogDescriptor.OK_OPTION) {
                    return;
                }
                final ColumnItem columnItem = (ColumnItem) panel.dmodel.getData().get(0);
                boolean wasException;
                try {
                    wasException = DbUtilities.doWithProgress(null, new Callable<Boolean>() {

                        @Override
                        public Boolean call() throws Exception {
                            return ddl.execute(panel.colnamefield.getText(), columnItem);
                        }
                    });
                } catch (InvocationTargetException e) {
                    Throwable cause = e.getCause();
                    if (cause instanceof DDLException) {
                        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
                    } else {
                        LOGGER.log(Level.INFO, cause.getLocalizedMessage(), cause);
                        DbUtilities.reportError(NbBundle.getMessage(AddTableColumnDialog.clreplaced, "ERR_UnableToAddColumn"), e.getMessage());
                    }
                    return;
                }
                // was execution of commands with or without exception?
                if (wasException) {
                    return;
                }
                // dialog is closed after successfully add column
                dialog.setVisible(false);
                dialog.dispose();
            }
        };
        descriptor.setButtonListener(listener);
        dialog.setVisible(true);
        if (descriptor.getValue() == DialogDescriptor.CANCEL_OPTION) {
            return false;
        }
        return true;
    }
}

17 View Complete Implementation : CredentialsPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * @author Petr Hejl
 */
public clreplaced CredentialsPanel extends javax.swing.JPanel {

    private static final Pattern EMAIL_PATTERN = Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");

    private final JPreplacedwordField reference = new JPreplacedwordField();

    private final JButton actionButton;

    private final Set<String> registries;

    private NotificationLineSupport messageLine;

    /**
     * Creates new form CredentialsDetailPanel
     */
    public CredentialsPanel(JButton actionButton, Set<String> registries) {
        initComponents();
        this.actionButton = actionButton;
        this.registries = registries;
        DefaultDoreplacedentListener listener = new DefaultDoreplacedentListener();
        registryTextField.getDoreplacedent().addDoreplacedentListener(listener);
        usernameTextField.getDoreplacedent().addDoreplacedentListener(listener);
        emailTextField.getDoreplacedent().addDoreplacedentListener(listener);
    }

    public void setMessageLine(NotificationLineSupport messageLine) {
        this.messageLine = messageLine;
        validateInput();
    }

    @NbBundle.Messages({ "MSG_EmptyRegistry=Registry must not be empty.", "MSG_ExistingRegistry=This registry is already defined.", "MSG_EmptyUsername=Username must not be empty.", "MSG_InvalidEmail=Email address does not seem to be valid" })
    private void validateInput() {
        if (messageLine == null) {
            return;
        }
        messageLine.clearMessages();
        actionButton.setEnabled(true);
        String registry = UiUtils.getValue(registryTextField);
        if (registry == null) {
            messageLine.setErrorMessage(Bundle.MSG_EmptyRegistry());
            actionButton.setEnabled(false);
            return;
        } else if (registries.contains(registry)) {
            messageLine.setErrorMessage(Bundle.MSG_ExistingRegistry());
            actionButton.setEnabled(false);
            return;
        }
        String username = UiUtils.getValue(usernameTextField);
        if (username == null) {
            messageLine.setErrorMessage(Bundle.MSG_EmptyUsername());
            actionButton.setEnabled(false);
            return;
        }
        String email = UiUtils.getValue(emailTextField);
        if (email != null && !EMAIL_PATTERN.matcher(email).matches()) {
            messageLine.setWarningMessage(Bundle.MSG_InvalidEmail());
        }
    }

    public Credentials getCredentials() {
        return new Credentials(UiUtils.getValue(registryTextField), UiUtils.getValue(usernameTextField), preplacedwordPreplacedwordField.getPreplacedword(), UiUtils.getValue(emailTextField));
    }

    public void setCredentials(Credentials credentials) {
        registryTextField.setEditable(false);
        registryTextField.setText(credentials.getRegistry());
        usernameTextField.setText(credentials.getUsername());
        if (credentials.getPreplacedword() != null) {
            preplacedwordPreplacedwordField.setText(new String(credentials.getPreplacedword()));
        }
        emailTextField.setText(credentials.getEmail());
    }

    private clreplaced DefaultDoreplacedentListener implements DoreplacedentListener {

        @Override
        public void insertUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void removeUpdate(DoreplacedentEvent e) {
            validateInput();
        }

        @Override
        public void changedUpdate(DoreplacedentEvent e) {
            validateInput();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        registryLabel = new javax.swing.JLabel();
        registryTextField = new javax.swing.JTextField();
        usernameLabel = new javax.swing.JLabel();
        usernameTextField = new javax.swing.JTextField();
        preplacedwordLabel = new javax.swing.JLabel();
        preplacedwordPreplacedwordField = new javax.swing.JPreplacedwordField();
        emailLabel = new javax.swing.JLabel();
        emailTextField = new javax.swing.JTextField();
        showPreplacedwordCheckBox = new javax.swing.JCheckBox();
        registryLabel.setLabelFor(registryTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(registryLabel, org.openide.util.NbBundle.getMessage(CredentialsPanel.clreplaced, "CredentialsPanel.registryLabel.text"));
        usernameLabel.setLabelFor(usernameTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(usernameLabel, org.openide.util.NbBundle.getMessage(CredentialsPanel.clreplaced, "CredentialsPanel.usernameLabel.text"));
        usernameTextField.setColumns(10);
        preplacedwordLabel.setLabelFor(preplacedwordPreplacedwordField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(preplacedwordLabel, org.openide.util.NbBundle.getMessage(CredentialsPanel.clreplaced, "CredentialsPanel.preplacedwordLabel.text"));
        emailLabel.setLabelFor(emailTextField);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(emailLabel, org.openide.util.NbBundle.getMessage(CredentialsPanel.clreplaced, "CredentialsPanel.emailLabel.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(showPreplacedwordCheckBox, org.openide.util.NbBundle.getMessage(CredentialsPanel.clreplaced, "CredentialsPanel.showPreplacedwordCheckBox.text"));
        showPreplacedwordCheckBox.addItemListener(new java.awt.event.ItemListener() {

            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                showPreplacedwordCheckBoxItemStateChanged(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(usernameLabel).addComponent(registryLabel).addComponent(preplacedwordLabel).addComponent(emailLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(registryTextField).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false).addComponent(preplacedwordPreplacedwordField, javax.swing.GroupLayout.Alignment.LEADING).addComponent(usernameTextField, javax.swing.GroupLayout.Alignment.LEADING)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(showPreplacedwordCheckBox).addGap(0, 101, Short.MAX_VALUE)).addComponent(emailTextField)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(registryLabel).addComponent(registryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(usernameLabel).addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(preplacedwordLabel).addComponent(preplacedwordPreplacedwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(showPreplacedwordCheckBox)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(emailLabel).addComponent(emailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    private void showPreplacedwordCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {
        // GEN-FIRST:event_showPreplacedwordCheckBoxItemStateChanged
        if (showPreplacedwordCheckBox.isSelected()) {
            preplacedwordPreplacedwordField.setEchoChar((char) 0);
        } else {
            preplacedwordPreplacedwordField.setEchoChar(reference.getEchoChar());
        }
    }

    // GEN-LAST:event_showPreplacedwordCheckBoxItemStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel emailLabel;

    private javax.swing.JTextField emailTextField;

    private javax.swing.JLabel preplacedwordLabel;

    private javax.swing.JPreplacedwordField preplacedwordPreplacedwordField;

    private javax.swing.JLabel registryLabel;

    private javax.swing.JTextField registryTextField;

    private javax.swing.JCheckBox showPreplacedwordCheckBox;

    private javax.swing.JLabel usernameLabel;

    private javax.swing.JTextField usernameTextField;
    // End of variables declaration//GEN-END:variables
}

17 View Complete Implementation : ClonePathsWizardPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * Invoked when the second page of wizard <em>Clone External Repository</em>
 * (aka <em>Clone Other...</em>) is displayed and one of the
 * <em>Change...</em> buttons is pressed. It displays a repository chooser
 * dialog.
 *
 * @param  replacedleMsgKey  resource bundle key for the replacedle of the repository
 *                      chooser dialog
 * @return  {@code HgURL} of the selected repository if one was selected,
 *          {@code HgURL.NO_URL} if the <em>Clear Path</em> button was
 *          selected, {@code null} otherwise (button <em>Cancel</em> pressed
 *          or the dialog closed without pressing any of the above buttons)
 */
private HgURL changeUrl(String replacedleMsgKey) {
    int repoModeMask = Repository.FLAG_URL_ENABLED | Repository.FLAG_SHOW_HINTS;
    String replacedle = getMessage(replacedleMsgKey);
    final JButton set = new JButton();
    final JButton clear = new JButton();
    // NOI18N
    Mnemonics.setLocalizedText(set, getMessage("changePullPushPath.Set"));
    // NOI18N
    Mnemonics.setLocalizedText(clear, getMessage("changePullPushPath.Clear"));
    final Repository repository = new Repository(repoModeMask, replacedle, true);
    set.setEnabled(repository.isValid());
    clear.setDefaultCapable(false);
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(HgUtils.addContainerBorder(repository.getPanel()), // replacedle
    replacedle, // modal
    true, new Object[] { set, clear, CANCEL_OPTION }, // default option
    set, // alignment
    DEFAULT_ALIGN, new HelpCtx(ClonePathsWizardPanel.clreplaced.getName() + // NOI18N
    ".change"), // action listener
    null);
    dialogDescriptor.setClosingOptions(new Object[] { clear, CANCEL_OPTION });
    final NotificationLineSupport notificationLineSupport = dialogDescriptor.createNotificationLineSupport();
    clreplaced RepositoryChangeListener implements ChangeListener, ActionListener {

        private Dialog dialog;

        public void setDialog(Dialog dialog) {
            this.dialog = dialog;
        }

        public void stateChanged(ChangeEvent e) {
            replacedert e.getSource() == repository;
            boolean isValid = repository.isValid();
            dialogDescriptor.setValid(isValid);
            set.setEnabled(isValid);
            if (isValid) {
                notificationLineSupport.clearMessages();
            } else {
                String errMsg = repository.getMessage();
                if ((errMsg != null) && (errMsg.length() != 0)) {
                    notificationLineSupport.setErrorMessage(errMsg);
                } else {
                    notificationLineSupport.clearMessages();
                }
            }
        }

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() != set) {
                return;
            }
            try {
                // remember the selected URL:
                dialogDescriptor.setValue(repository.getUrl());
                /*
                     * option "set" is not closing so we must handle closing
                     * of the dialog explictly here:
                     */
                dialog.setVisible(false);
                dialog.dispose();
            } catch (URISyntaxException ex) {
                repository.setInvalid();
                notificationLineSupport.setErrorMessage(ex.getMessage());
            }
        }
    }
    RepositoryChangeListener optionListener = new RepositoryChangeListener();
    repository.addChangeListener(optionListener);
    dialogDescriptor.setButtonListener(optionListener);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    optionListener.setDialog(dialog);
    dialog.pack();
    dialog.setVisible(true);
    Object selectedValue = dialogDescriptor.getValue();
    replacedert (selectedValue instanceof HgURL) || (selectedValue == clear) || (selectedValue == CANCEL_OPTION) || (selectedValue == CLOSED_OPTION);
    if (selectedValue instanceof HgURL) {
        return (HgURL) selectedValue;
    } else if (selectedValue == clear) {
        return HgURL.NO_URL;
    } else {
        // CANCEL_OPTION, CLOSED_OPTION
        return null;
    }
}

17 View Complete Implementation : BrokenReferencesCustomizer.java
Copyright Apache License 2.0
Author : apache
/**
 * @author David Konecny
 * @author Tomas Zezula
 */
public clreplaced BrokenReferencesCustomizer extends javax.swing.JPanel {

    private static final RequestProcessor RP = new RequestProcessor(BrokenReferencesCustomizer.clreplaced);

    private final BrokenReferencesModel model;

    // @GuardedBy("this")
    private NotificationLineSupport nls;

    /**
     * Creates new form BrokenReferencesCustomizer
     */
    public BrokenReferencesCustomizer(BrokenReferencesModel model) {
        initComponents();
        this.model = model;
        errorList.setModel(model);
        errorList.setSelectedIndex(0);
        errorList.setCellRenderer(new ListCellRendererImpl());
        errorList.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(@NonNull final MouseEvent evt) {
                if (evt.getClickCount() == 2) {
                    final int index = errorList.locationToIndex(evt.getPoint());
                    if (index != -1 && fix.isEnabled()) {
                        fixActionImpl(errorList.getModel().getElementAt(index));
                    }
                }
            }
        });
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        errorListLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        errorList = new javax.swing.JList();
        fix = new javax.swing.JButton();
        descriptionLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        description = new javax.swing.JTextArea();
        setPreferredSize(new java.awt.Dimension(550, 350));
        setLayout(new java.awt.GridBagLayout());
        errorListLabel.setLabelFor(errorList);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(errorListLabel, org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "LBL_BrokenLinksCustomizer_List"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(6, 12, 3, 0);
        add(errorListLabel, gridBagConstraints);
        // NOI18N
        errorListLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "ACSD_BrokenLinksCustomizer_List"));
        errorList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        errorList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {

            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                errorListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(errorList);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.5;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
        add(jScrollPane1, gridBagConstraints);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(fix, org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "LBL_BrokenLinksCustomizer_Fix"));
        fix.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fixActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 12);
        add(fix, gridBagConstraints);
        // NOI18N
        fix.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "ACSD_BrokenLinksCustomizer_Fix"));
        descriptionLabel.setLabelFor(description);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "LBL_BrokenLinksCustomizer_Description"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(6, 12, 3, 0);
        add(descriptionLabel, gridBagConstraints);
        // NOI18N
        descriptionLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "ACSD_BrokenLinksCustomizer_Description"));
        description.setEditable(false);
        description.setLineWrap(true);
        description.setWrapStyleWord(true);
        jScrollPane2.setViewportView(description);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipady = 60;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
        add(jScrollPane2, gridBagConstraints);
        // NOI18N
        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "ACSN_BrokenReferencesCustomizer"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.clreplaced, "ACSD_BrokenReferencesCustomizer"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void errorListValueChanged(javax.swing.event.ListSelectionEvent evt) {
        // GEN-FIRST:event_errorListValueChanged
        updateSelection();
    }

    // GEN-LAST:event_errorListValueChanged
    private void fixActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_fixActionPerformed
        fixActionImpl(errorList.getSelectedValue());
    }

    // GEN-LAST:event_fixActionPerformed
    private void fixActionImpl(@NonNull final Object value) {
        if (!(value instanceof BrokenReferencesModel.ProblemReference)) {
            return;
        }
        final BrokenReferencesModel.ProblemReference or = (BrokenReferencesModel.ProblemReference) value;
        errorList.setEnabled(false);
        fix.setEnabled(false);
        Future<ProjectProblemsProvider.Result> becomesResult = null;
        try {
            becomesResult = or.problem.resolve();
            replacedert becomesResult != null;
        } finally {
            if (becomesResult == null) {
                updateAfterResolve(null);
            } else if (becomesResult.isDone()) {
                ProjectProblemsProvider.Result result = null;
                try {
                    result = becomesResult.get();
                } catch (InterruptedException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (ExecutionException ex) {
                    Exceptions.printStackTrace(ex);
                } finally {
                    updateAfterResolve(result);
                }
            } else {
                final Future<ProjectProblemsProvider.Result> becomesResultFin = becomesResult;
                RP.post(new Runnable() {

                    @Override
                    public void run() {
                        final AtomicReference<ProjectProblemsProvider.Result> result = new AtomicReference<ProjectProblemsProvider.Result>();
                        try {
                            result.set(becomesResultFin.get());
                        } catch (InterruptedException ie) {
                            Exceptions.printStackTrace(ie);
                        } catch (ExecutionException ee) {
                            Exceptions.printStackTrace(ee);
                        } finally {
                            SwingUtilities.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    updateAfterResolve(result.get());
                                }
                            });
                        }
                    }
                });
            }
        }
    }

    private void updateAfterResolve(@NullAllowed final ProjectProblemsProvider.Result result) {
        if (!SwingUtilities.isEventDispatchThread()) {
            throw new IllegalStateException();
        }
        model.refresh();
        errorList.setEnabled(true);
        updateSelection();
        if (result != null) {
            notify(result.getStatus(), result.getMessage());
        }
    }

    @Messages("LBL_BrokenLinksCustomizer_Problem_Was_Resolved=This problem was resolved")
    private void updateSelection() {
        final Object value = errorList.getSelectedValue();
        if (value instanceof BrokenReferencesModel.ProblemReference) {
            final BrokenReferencesModel.ProblemReference reference = (BrokenReferencesModel.ProblemReference) value;
            if (!reference.resolved) {
                description.setText(reference.problem.getDescription());
                fix.setEnabled(reference.problem.isResolvable());
                javax.swing.SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        jScrollPane2.getVerticalScrollBar().setValue(0);
                    }
                });
            } else {
                description.setText(Bundle.LBL_BrokenLinksCustomizer_Problem_Was_Resolved());
                // Leave the button always enabled so that user can alter
                // resolved reference. Especially needed for automatically
                // resolved JAR references.
                fix.setEnabled(reference.problem.isResolvable());
            }
        } else {
            description.setText("");
            fix.setEnabled(false);
        }
        clearNotification();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea description;

    private javax.swing.JLabel descriptionLabel;

    private javax.swing.JList errorList;

    private javax.swing.JLabel errorListLabel;

    private javax.swing.JButton fix;

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JScrollPane jScrollPane2;

    // End of variables declaration//GEN-END:variables
    @StaticResource
    private static final String BROKEN_REF = "org/netbeans/modules/project/ui/resources/broken-reference.gif";

    @StaticResource
    private static final String RESOLVED_REF = "org/netbeans/modules/project/ui/resources/resolved-reference.gif";

    synchronized void setNotificationLineSupport(@NullAllowed final NotificationLineSupport notificationLineSupport) {
        // NOI18N
        Parameters.notNull("notificationLineSupport", notificationLineSupport);
        nls = notificationLineSupport;
    }

    private synchronized void notify(@NonNull final ProjectProblemsProvider.Status status, @NullAllowed final String message) {
        if (message != null) {
            switch(status) {
                case RESOLVED:
                    nls.setInformationMessage(message);
                    break;
                case RESOLVED_WITH_WARNING:
                    nls.setWarningMessage(message);
                    break;
                case UNRESOLVED:
                    nls.setErrorMessage(message);
                    break;
                default:
                    throw new IllegalStateException(status.name());
            }
        }
    }

    private synchronized void clearNotification() {
        // May be null when called from the constructor, before initialization
        if (nls != null) {
            nls.clearMessages();
        }
    }

    private static clreplaced ListCellRendererImpl extends DefaultListCellRenderer {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof BrokenReferencesModel.ProblemReference) {
                BrokenReferencesModel.ProblemReference problemRef = (BrokenReferencesModel.ProblemReference) value;
                super.getListCellRendererComponent(list, problemRef.getDisplayName(), index, isSelected, cellHasFocus);
                if (problemRef.resolved) {
                    setIcon(ImageUtilities.loadImageIcon(RESOLVED_REF, false));
                } else {
                    setIcon(ImageUtilities.loadImageIcon(BROKEN_REF, false));
                }
            }
            return this;
        }
    }
}

17 View Complete Implementation : ImportZIP.java
Copyright Apache License 2.0
Author : apache
@Messages({ "ERR_no_zip_open=Must select a ZIP to import from.", "# {0} - file", "ERR_zip_nonexistent={0} does not exist.", "# {0} - file", "ERR_not_zip={0} is not in ZIP format.", "ERR_no_folder=Must select a folder to unpack into.", "# {0} - folder", "ERR_folder_nonexistent={0} does not exist." })
private boolean check(NotificationLineSupport notifications) {
    notifications.clearMessages();
    if (zipField.getText().isEmpty()) {
        notifications.setInformationMessage(ERR_no_zip_open());
        return false;
    }
    File zip = new File(zipField.getText());
    if (!zip.isFile()) {
        notifications.setErrorMessage(ERR_zip_nonexistent(zip));
        return false;
    }
    try {
        if (!FileUtil.isArchiveFile(Utilities.toURI(zip).toURL())) {
            notifications.setErrorMessage(ERR_not_zip(zip));
            return false;
        }
    } catch (MalformedURLException x) {
        replacedert false : x;
    }
    if (folderField.getText().isEmpty()) {
        notifications.setInformationMessage(ERR_no_folder());
        return false;
    }
    if (!new File(folderField.getText()).isDirectory()) {
        notifications.setErrorMessage(ERR_folder_nonexistent(folderField.getText()));
        return false;
    }
    return true;
}

17 View Complete Implementation : DictionaryInstallerPanel.java
Copyright Apache License 2.0
Author : apache
@OptionsPanelController.Keywords(keywords = { "install", "dictionary", "#KW_DictionaryInstallerOptions" }, location = OptionsDisplayer.EDITOR, tabreplacedle = "#replacedLE_OptionsPanel")
public clreplaced DictionaryInstallerPanel extends javax.swing.JPanel {

    private final JButton okButton;

    private final Collection<? extends String> existingLocales;

    public DictionaryInstallerPanel(JButton okButton, Collection<? extends String> existingLocales) {
        this.okButton = okButton;
        this.existingLocales = existingLocales;
        initComponents();
        initValues();
        DoreplacedentListener l = new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent e) {
                updateErrors();
            }

            public void removeUpdate(DoreplacedentEvent e) {
                updateErrors();
            }

            public void changedUpdate(DoreplacedentEvent e) {
            }
        };
        tDictionary.getDoreplacedent().addDoreplacedentListener(l);
        tLocale.getDoreplacedent().addDoreplacedentListener(l);
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        file = new javax.swing.JLabel();
        tDictionary = new javax.swing.JTextField();
        bBrowse = new javax.swing.JButton();
        encoding = new javax.swing.JLabel();
        cEncoding = new javax.swing.JComboBox();
        locale = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        tLocale = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        setBorder(javax.swing.BorderFactory.createEmptyBorder(9, 9, 9, 9));
        setLayout(new java.awt.GridBagLayout());
        file.setLabelFor(tDictionary);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(file, org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "DictionaryInstallerPanel.file.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(file, gridBagConstraints);
        tDictionary.setColumns(30);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(tDictionary, gridBagConstraints);
        // NOI18N
        tDictionary.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "tDictionary_ACSN"));
        // NOI18N
        tDictionary.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "tDictionary_ACSD"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(bBrowse, org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "bBrowse"));
        bBrowse.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bBrowseActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(bBrowse, gridBagConstraints);
        // NOI18N
        bBrowse.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "bBrowse_ACSN"));
        // NOI18N
        bBrowse.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "bBrowse_ACSD"));
        encoding.setLabelFor(cEncoding);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(encoding, org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "DictionaryInstallerPanel.encoding.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(encoding, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(cEncoding, gridBagConstraints);
        // NOI18N
        cEncoding.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "cEncoding_ACSN"));
        // NOI18N
        cEncoding.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "cEncoding_ACSD"));
        locale.setLabelFor(tLocale);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(locale, org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "DictionaryInstallerPanel.locale.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(locale, gridBagConstraints);
        jPanel1.setLayout(new java.awt.GridBagLayout());
        tLocale.setColumns(8);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(tLocale, gridBagConstraints);
        // NOI18N
        tLocale.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "tLocale_ACSN"));
        // NOI18N
        tLocale.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, "tLocale_ACSD"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        jPanel1.add(jPanel2, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        add(jPanel1, gridBagConstraints);
    }

    // </editor-fold>//GEN-END:initComponents
    private void bBrowseActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_bBrowseActionPerformed
        JFileChooser filechooser = new JFileChooser(tDictionary.getText());
        int ret = filechooser.showOpenDialog(null);
        if (ret == JFileChooser.APPROVE_OPTION)
            tDictionary.setText(filechooser.getSelectedFile().getAbsolutePath());
    }

    // GEN-LAST:event_bBrowseActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton bBrowse;

    public javax.swing.JComboBox cEncoding;

    public javax.swing.JLabel encoding;

    public javax.swing.JLabel file;

    public javax.swing.JPanel jPanel1;

    public javax.swing.JPanel jPanel2;

    public javax.swing.JLabel locale;

    public javax.swing.JTextField tDictionary;

    public javax.swing.JTextField tLocale;

    // End of variables declaration//GEN-END:variables
    public static String getMessage(String key) {
        return NbBundle.getMessage(DictionaryInstallerPanel.clreplaced, key);
    }

    // NOI18N
    private static String homedir = System.getProperty("netbeans.home");

    // NOI18N
    private static String userdir = System.getProperty("netbeans.user");

    private static boolean availHomedir = new File(homedir).canWrite();

    private static boolean availUserdir = new File(userdir).canWrite();

    public final void initValues() {
        // NOI18N
        tDictionary.setText(System.getProperty("user.home"));
        Set<String> set = Charset.availableCharsets().keySet();
        cEncoding.setModel(new javax.swing.DefaultComboBoxModel(set.toArray(new String[set.size()])));
        // NOI18N
        cEncoding.setSelectedItem("ISO-8859-1");
        // NOI18N
        tLocale.setText("");
    // rAllUsers.setEnabled (availHomedir);
    // rCurrentUser.setEnabled (availUserdir);
    // if (availHomedir)
    // rAllUsers.setSelected (true);
    // else if (availUserdir)
    // rCurrentUser.setSelected (true);
    // else {
    // rAllUsers.setSelected (false);
    // rCurrentUser.setSelected (false);
    // }
    }

    private NotificationLineSupport notifications;

    void setNotifications(NotificationLineSupport notifications) {
        this.notifications = notifications;
        updateErrors();
    }

    private void updateErrors() {
        if (notifications == null)
            return;
        notifications.clearMessages();
        okButton.setEnabled(false);
        File dictFile = new File(tDictionary.getText());
        if (!dictFile.exists()) {
            notifications.setErrorMessage(getMessage("ERR_DictionaryFileDoesNotExist"));
            return;
        }
        if (!dictFile.isFile()) {
            notifications.setErrorMessage(getMessage("ERR_DictionaryFileNotFile"));
            return;
        }
        if (!dictFile.canRead()) {
            notifications.setErrorMessage(getMessage("ERR_DictionaryFileCannotBeRead"));
            return;
        }
        String error = SpellcheckerOptionsPanel.getErrorsForLocale(tLocale.getText());
        if (error != null) {
            notifications.setErrorMessage(getMessage(error));
            return;
        }
        if (existingLocales.contains(tLocale.getText())) {
            notifications.setErrorMessage(getMessage("ERR_DictionaryAlreadyExists"));
            return;
        }
        okButton.setEnabled(true);
    }

    private static final int BUFFER_LENGTH = 65536;

    private static File dictionaryFile(String loc, boolean shared) {
        String filename = shared ? homedir : userdir;
        // NOI18N
        filename += File.separator + "modules" + File.separator + "dict";
        filename += File.separator + "dictionary";
        if (loc != null && !"".equals(loc))
            filename += "_" + loc;
        // NOI18N
        return new File(filename + ".txt");
    }

    public static void doInstall(DictionaryDescription description) {
        InputStreamReader input = null;
        OutputStreamWriter output = null;
        try {
            boolean shared;
            if (description.rAllUsers)
                shared = true;
            else if (description.rCurrentUser)
                shared = false;
            else {
                // NOI18N
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(getMessage("MSG_NoInstallDirectoryAvailable"), NotifyDescriptor.ERROR_MESSAGE));
                return;
            }
            File file = dictionaryFile(description.targetLocale, shared);
            file.getParentFile().mkdirs();
            // TODO: if the dictionary already exists, provide user with a warning.
            input = new InputStreamReader(new FileInputStream(description.dictionaryFile), description.fileEncoding);
            // NOI18N
            output = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
            char[] buffer = new char[BUFFER_LENGTH];
            int len = BUFFER_LENGTH;
            do {
                len = input.read(buffer);
                output.write(buffer, 0, len);
            } while (len == BUFFER_LENGTH);
            // NOI18N
            StatusDisplayer.getDefault().setStatusText(getMessage("MSG_DictionaryWasInstalled"));
        } catch (FileNotFoundException e) {
            // NOI18N
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(getMessage("MSG_InputFileNotFound"), NotifyDescriptor.ERROR_MESSAGE));
        } catch (UnsupportedEncodingException e) {
            // NOI18N
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(getMessage("MSG_UnsupportedEncoding"), NotifyDescriptor.ERROR_MESSAGE));
        } catch (IOException e) {
            // NOI18N
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(getMessage("MSG_IOErrorDuringInstallation"), NotifyDescriptor.ERROR_MESSAGE));
        } finally {
            if (input != null)
                try {
                    input.close();
                } catch (IOException e) {
                }
            if (output != null)
                try {
                    output.close();
                } catch (IOException e) {
                }
        // TODO: Dictionary.clearDictionaries();
        }
    }

    public DictionaryDescription createDescription() {
        return new DictionaryDescription(false, true, /*rAllUsers.isSelected(), rCurrentUser.isSelected(), */
        tDictionary.getText(), (String) cEncoding.getSelectedItem(), tLocale.getText());
    }

    public static void removeDictionary(Locale remove) {
        File toRemove = dictionaryFile(remove.toString(), false);
        toRemove.delete();
        toRemove = dictionaryFile(remove.toString(), true);
        toRemove.delete();
        if (InstalledFileLocator.getDefault().locate("modules/dict/dictionary_" + remove.toString() + ".description", null, false) != null) {
            String filename = userdir;
            // NOI18N
            filename += File.separator + "modules" + File.separator + "dict";
            filename += File.separator + "dictionary";
            filename += "_" + remove.toString();
            File hiddenDictionaryFile = new File(filename + ".description_hidden");
            hiddenDictionaryFile.getParentFile().mkdirs();
            try {
                // NOI18N
                new FileOutputStream(hiddenDictionaryFile).close();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }

    public static clreplaced DictionaryDescription {

        private boolean rAllUsers;

        private boolean rCurrentUser;

        private String dictionaryFile;

        private String fileEncoding;

        private String targetLocale;

        public DictionaryDescription(boolean rAllUsers, boolean rCurrentUser, String dictionaryFile, String fileEncoding, String targetLocale) {
            this.rAllUsers = rAllUsers;
            this.rCurrentUser = rCurrentUser;
            this.dictionaryFile = dictionaryFile;
            this.fileEncoding = fileEncoding;
            this.targetLocale = targetLocale;
        }

        public Locale getLocale() {
            return Utilities.name2Locale(targetLocale);
        }
    }
}

17 View Complete Implementation : ConnectAction.java
Copyright Apache License 2.0
Author : apache
/**
 * Connects debugger to some currently running VM.
 * This clreplaced is final only for performance reasons,
 * can be happily unfinaled if desired.
 *
 * @author   Jan Jancura
 */
public final clreplaced ConnectAction extends AbstractAction {

    // NOI18N
    private static RequestProcessor computeEnabledRP = new RequestProcessor("ConnectAction is enabled", 1);

    private RequestProcessor.Task computeEnabledTask;

    private ConnectorPanel cp;

    private DialogDescriptor descr;

    private Dialog dialog;

    private JButton bOk;

    private JButton bCancel;

    private NotificationLineSupport notificationSupport;

    private volatile boolean lastEnabled = true;

    public ConnectAction() {
        putValue(Action.NAME, NbBundle.getMessage(ConnectAction.clreplaced, "CTL_Connect"));
        putValue(// NOI18N
        "iconBase", // NOI18N
        "org/netbeans/modules/debugger/resources/actions/Attach.gif");
    }

    @Override
    public boolean isEnabled() {
        if (computeEnabledTask == null) {
            computeEnabledTask = computeEnabledRP.create(new Runnable() {

                public void run() {
                    List attachTypes = DebuggerManager.getDebuggerManager().lookup(null, AttachType.clreplaced);
                    lastEnabled = attachTypes.size() > 0;
                }
            });
        }
        computeEnabledTask.schedule(0);
        try {
            // Wait 100ms at most in AWT.
            computeEnabledTask.waitFinished(100);
        } catch (InterruptedException ex) {
        }
        return lastEnabled;
    }

    public void actionPerformed(ActionEvent evt) {
        // NOI18N
        bOk = new JButton(NbBundle.getMessage(ConnectAction.clreplaced, "CTL_Ok"));
        // NOI18N
        bCancel = new JButton(NbBundle.getMessage(ConnectAction.clreplaced, "CTL_Cancel"));
        // NOI18N
        bOk.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ConnectAction.clreplaced, "ACSD_CTL_Ok"));
        // NOI18N
        bCancel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ConnectAction.clreplaced, "ACSD_CTL_Cancel"));
        bCancel.setDefaultCapable(false);
        cp = new ConnectorPanel();
        descr = new DialogDescriptor(cp, NbBundle.getMessage(ConnectAction.clreplaced, "CTL_Connect_to_running_process"), // modal
        true, new ConnectListener(cp));
        descr.setOptions(new JButton[] { bOk, bCancel });
        notificationSupport = descr.createNotificationLineSupport();
        descr.setClosingOptions(new Object[0]);
        // This is mandatory so that the descriptor tracks the changes in help correctly.
        descr.setHelpCtx(HelpCtx.findHelp(cp));
        dialog = DialogDisplayer.getDefault().createDialog(descr);
        dialog.setVisible(true);
    }

    // innerclreplacedes ............................................................
    private clreplaced ConnectListener implements ActionListener, PropertyChangeListener {

        ConnectorPanel connectorPanel;

        Controller controller;

        ConnectListener(ConnectorPanel connectorPanel) {
            this.connectorPanel = connectorPanel;
            startListening();
            setValid();
            connectorPanel.addPropertyChangeListener(this);
        }

        public void actionPerformed(ActionEvent e) {
            if (dialog == null) {
                // Already closed.
                return;
            }
            boolean okPressed = bOk.equals(e.getSource());
            boolean close = false;
            if (okPressed) {
                close = connectorPanel.ok();
            } else {
                close = connectorPanel.cancel();
            }
            if (!close)
                return;
            connectorPanel.removePropertyChangeListener(this);
            stopListening();
            dialog.setVisible(false);
            dialog.dispose();
            dialog = null;
        }

        void startListening() {
            controller = connectorPanel.getController();
            if (controller == null)
                return;
            controller.addPropertyChangeListener(this);
        }

        void stopListening() {
            if (controller == null)
                return;
            controller.removePropertyChangeListener(this);
            controller = null;
        }

        void setValid() {
            Controller controller = connectorPanel.getController();
            if (controller == null) {
                bOk.setEnabled(false);
                return;
            }
            bOk.setEnabled(controller.isValid());
        }

        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == ConnectorPanel.PROP_TYPE) {
                stopListening();
                notificationSupport.clearMessages();
                descr.setHelpCtx(HelpCtx.findHelp(cp));
                setValid();
                startListening();
            } else if (evt.getPropertyName() == Controller.PROP_VALID) {
                setValid();
            } else if (evt.getPropertyName() == NotifyDescriptor.PROP_ERROR_NOTIFICATION) {
                Object v = evt.getNewValue();
                String msg = (v == null) ? null : v.toString();
                notificationSupport.setErrorMessage(msg);
            } else if (evt.getPropertyName() == NotifyDescriptor.PROP_INFO_NOTIFICATION) {
                Object v = evt.getNewValue();
                String msg = (v == null) ? null : v.toString();
                notificationSupport.setInformationMessage(msg);
            } else if (evt.getPropertyName() == NotifyDescriptor.PROP_WARNING_NOTIFICATION) {
                Object v = evt.getNewValue();
                String msg = (v == null) ? null : v.toString();
                notificationSupport.setWarningMessage(msg);
            }
        }
    }
}

16 View Complete Implementation : SelectDatabasePanel.java
Copyright Apache License 2.0
Author : apache
// </editor-fold>//GEN-END:initComponents
private void addReferenceButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_addReferenceButtonActionPerformed
    DataSourceReferencePanel referencePanel = new DataSourceReferencePanel(provider, references.keySet(), moduleDatasources, serverDatasources);
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(referencePanel, // NOI18N
    NbBundle.getMessage(SelectDatabasePanel.clreplaced, "LBL_AddDataSourceReference"), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, null);
    NotificationLineSupport statusLine = dialogDescriptor.createNotificationLineSupport();
    referencePanel.setNotificationLine(statusLine);
    // register listener
    referencePanel.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            if (DataSourceReferencePanel.IS_VALID.equals(evt.getPropertyName())) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    dialogDescriptor.setValid(((Boolean) newvalue).booleanValue());
                }
            }
        }
    });
    // initial invalidation
    dialogDescriptor.setValid(false);
    // show and eventually save
    Object option = DialogDisplayer.getDefault().notify(dialogDescriptor);
    if (option == NotifyDescriptor.OK_OPTION) {
        final String refName = referencePanel.getReferenceName();
        references.put(refName, referencePanel.getDataSource());
        if (referencePanel.copyDataSourceToProject()) {
        // TODO how to copy it?
        }
        copyDataSourceToProject = referencePanel.copyDataSourceToProject();
        // update gui (needed because of sorting)
        populateReferences();
        // Ensure that the correct item is selected before listeners like FocusListener are called.
        // ActionListener.actionPerformed() is not called if this method is already called from
        // actionPerformed(), in that case selecreplacedemLater should be set to true and setSelectedItem()
        // below is called asynchronously so that the actionPerformed() is called
        dsRefCombo.setSelectedItem(refName);
        boolean selecreplacedemLater = false;
        if (selecreplacedemLater) {
            SwingUtilities.invokeLater(new // postpone item selection to enable event firing from JCombobox.setSelectedItem()
            Runnable() {

                public void run() {
                    dsRefCombo.setSelectedItem(refName);
                }
            });
        }
    }
}

16 View Complete Implementation : SendJMSMessageCodeGenerator.java
Copyright Apache License 2.0
Author : apache
@Override
public void invoke() {
    try {
        final Project enterpriseProject = FileOwnerQuery.getOwner(srcFile);
        final EnterpriseReferenceContainer erc = enterpriseProject.getLookup().lookup(EnterpriseReferenceContainer.clreplaced);
        J2eeModuleProvider provider = enterpriseProject.getLookup().lookup(J2eeModuleProvider.clreplaced);
        MessageDestinationUiSupport.DestinationsHolder holder = SendJMSMessageUiSupport.getDestinations(enterpriseProject, provider);
        final SendJmsMessagePanel sendJmsMessagePanel = SendJmsMessagePanel.newInstance(enterpriseProject, provider, holder.getModuleDestinations(), holder.getServerDestinations(), erc.getServiceLocatorName(), ClreplacedpathInfo.create(srcFile));
        final DialogDescriptor dialogDescriptor = new DialogDescriptor(sendJmsMessagePanel, NbBundle.getMessage(SendJMSMessageCodeGenerator.clreplaced, "LBL_SendJmsMessage"), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(SendJMSMessageCodeGenerator.clreplaced), null);
        final NotificationLineSupport notificationSupport = dialogDescriptor.createNotificationLineSupport();
        sendJmsMessagePanel.addPropertyChangeListener(SendJmsMessagePanel.IS_VALID, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    boolean isValid = ((Boolean) newvalue).booleanValue();
                    dialogDescriptor.setValid(isValid);
                    if (isValid) {
                        if (sendJmsMessagePanel.getWarningMessage() == null) {
                            notificationSupport.clearMessages();
                        } else {
                            notificationSupport.setWarningMessage(sendJmsMessagePanel.getWarningMessage());
                        }
                    } else {
                        notificationSupport.setErrorMessage(sendJmsMessagePanel.getErrorMessage());
                    }
                }
            }
        });
        sendJmsMessagePanel.verifyAndFire();
        Object option = DialogDisplayer.getDefault().notify(dialogDescriptor);
        if (option != DialogDescriptor.OK_OPTION) {
            return;
        }
        String serviceLocator = sendJmsMessagePanel.getServiceLocator();
        final ServiceLocatorStrategy serviceLocatorStrategy = serviceLocator != null ? ServiceLocatorStrategy.create(enterpriseProject, srcFile, serviceLocator) : null;
        if (serviceLocator != null) {
            erc.setServiceLocatorName(serviceLocator);
        }
        MessageDestination messageDestination = sendJmsMessagePanel.getDestination();
        Project mdbHolderProject = sendJmsMessagePanel.getMdbHolderProject();
        final SendJMSGenerator generator = new SendJMSGenerator(messageDestination, mdbHolderProject != null ? mdbHolderProject : enterpriseProject);
        // do that not in AWT, may take some time
        // http://www.netbeans.org/issues/show_bug.cgi?id=164834
        // http://www.netbeans.org/nonav/issues/showattachment.cgi/82529/error.log
        RequestProcessor.getDefault().post(new Runnable() {

            @Override
            public void run() {
                try {
                    generator.genMethods(erc, beanClreplaced.getQualifiedName().toString(), sendJmsMessagePanel.getConnectionFactory(), srcFile, serviceLocatorStrategy, enterpriseProject.getLookup().lookup(J2eeModuleProvider.clreplaced));
                } catch (IOException ex) {
                    SendJMSMessageCodeGenerator.notifyExc(ex);
                }
            }
        });
    } catch (IOException ioe) {
        notifyExc(ioe);
    }
}

16 View Complete Implementation : UseDatabaseCodeGenerator.java
Copyright Apache License 2.0
Author : apache
public void invoke() {
    Project project = FileOwnerQuery.getOwner(fileObject);
    // make sure configuration is ready
    J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.clreplaced);
    j2eeModuleProvider.getConfigSupport().ensureConfigurationReady();
    EnterpriseReferenceContainer enterpriseReferenceContainer = project.getLookup().lookup(EnterpriseReferenceContainer.clreplaced);
    // get all the resources
    ResourcesHolder holder = getResources(j2eeModuleProvider, fileObject);
    final SelectDatabasePanel selectDatabasePanel = new SelectDatabasePanel(j2eeModuleProvider, enterpriseReferenceContainer.getServiceLocatorName(), holder.getReferences(), holder.getModuleDataSources(), holder.getServerDataSources(), ClreplacedpathInfo.create(fileObject));
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(selectDatabasePanel, // NOI18N
    NbBundle.getMessage(UseDatabaseCodeGenerator.clreplaced, "LBL_ChooseDatabase"), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(SelectDatabasePanel.clreplaced), null);
    final NotificationLineSupport notificationSupport = dialogDescriptor.createNotificationLineSupport();
    dialogDescriptor.setValid(checkConnections(selectDatabasePanel));
    selectDatabasePanel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(SelectDatabasePanel.IS_VALID)) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    Boolean booleanValue = (Boolean) newvalue;
                    if (booleanValue) {
                        dialogDescriptor.setValid(true);
                        notificationSupport.clearMessages();
                    } else {
                        dialogDescriptor.setValid(false);
                        notificationSupport.setErrorMessage(selectDatabasePanel.getErrorMessage());
                    }
                }
            }
        }
    });
    Object option = DialogDisplayer.getDefault().notify(dialogDescriptor);
    if (option == NotifyDescriptor.OK_OPTION) {
        String refName = selectDatabasePanel.getDatasourceReference();
        UseDatabaseGenerator generator = new UseDatabaseGenerator();
        try {
            generator.generate(fileObject, beanClreplaced.getQualifiedName().toString(), j2eeModuleProvider, refName, selectDatabasePanel.getDatasource(), selectDatabasePanel.createServerResources(), selectDatabasePanel.getServiceLocator());
        } catch (ConfigurationException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

16 View Complete Implementation : ChangeImportFolder.java
Copyright Apache License 2.0
Author : apache
@Messages({ "# {0} - folder", "ERR_project_folder_already_exists=Project folder \"{0}\" already exists." })
boolean checkImportFolder(NotificationLineSupport notifications, String entry) {
    notifications.clearMessages();
    String updatedPath = folderField.getText();
    File updatedFile = new File(updatedPath, entry);
    File folderToImport = new File(updatedPath);
    if (updatedFile.exists()) {
        notifications.setWarningMessage(Bundle.ERR_project_folder_already_exists(entry));
        return false;
    }
    if (updatedPath.isEmpty()) {
        notifications.setInformationMessage(Bundle.ERR_no_folder());
        return false;
    }
    if (!folderToImport.isDirectory()) {
        notifications.setErrorMessage(Bundle.ERR_folder_nonexistent(updatedPath));
        return false;
    }
    return true;
}

16 View Complete Implementation : CategoryArchiveFiles.java
Copyright GNU General Public License v2.0
Author : nbphpcouncil
// GEN-LAST:event_addZipButtonActionPerformed
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_editButtonActionPerformed
    int rowIndex = entryTable.getSelectedRow();
    if (rowIndex >= 0) {
        final CIEntry entry = model.getEntry(rowIndex);
        final CIEntryEditPanel panel = new CIEntryEditPanel();
        panel.load(entry);
        panel.setFileEntryMap(model.getEntryMap(entry));
        final DialogDescriptor descriptor = new DialogDescriptor(panel, // NOI18N
        getMessage("CTL_AddArchiveFile"), true, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION, null);
        descriptor.setClosingOptions(new Object[] {});
        NotificationLineSupport notificationLineSupport = descriptor.createNotificationLineSupport();
        panel.setValidityObjects(descriptor, notificationLineSupport);
        final Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        // NOI18N
        dialog.getAccessibleContext().setAccessibleName(getMessage("ACSN_Dialog"));
        // NOI18N
        dialog.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_Dialog"));
        dialog.setResizable(false);
        descriptor.setButtonListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (DialogDescriptor.OK_OPTION.equals(e.getSource())) {
                }
                dialog.setVisible(false);
            }
        });
        dialog.setVisible(true);
        if (NotifyDescriptor.OK_OPTION.equals(descriptor.getValue())) {
            panel.store(entry);
            model.setEntry(rowIndex, entry);
            entryTable.setRowSelectionInterval(rowIndex, rowIndex);
        }
        dialog.dispose();
    }
}

16 View Complete Implementation : CategoryArchiveFiles.java
Copyright GNU General Public License v2.0
Author : nbphpcouncil
// </editor-fold>//GEN-END:initComponents
private void addZipButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_addZipButtonActionPerformed
    final CIEntry entry = new CIEntry();
    final CIEntryEditPanel panel = new CIEntryEditPanel();
    panel.load(entry);
    panel.setFileEntryMap(model.getEntryMap());
    final DialogDescriptor descriptor = new DialogDescriptor(panel, // NOI18N
    getMessage("CTL_AddArchiveFile"), true, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION, null);
    descriptor.setClosingOptions(new Object[] {});
    NotificationLineSupport notificationLineSupport = descriptor.createNotificationLineSupport();
    panel.setValidityObjects(descriptor, notificationLineSupport);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    // NOI18N
    dialog.getAccessibleContext().setAccessibleName(getMessage("ACSN_Dialog"));
    // NOI18N
    dialog.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_Dialog"));
    dialog.setResizable(false);
    descriptor.setButtonListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (DialogDescriptor.OK_OPTION.equals(e.getSource())) {
            }
            dialog.setVisible(false);
        }
    });
    dialog.setVisible(true);
    if (NotifyDescriptor.OK_OPTION.equals(descriptor.getValue())) {
        panel.store(entry);
        model.addEntry(entry);
        int rowIndex = entryTable.getRowCount() - 1;
        entryTable.setRowSelectionInterval(rowIndex, rowIndex);
    }
    dialog.dispose();
}

16 View Complete Implementation : CIEntryEditPanel.java
Copyright GNU General Public License v2.0
Author : nbphpcouncil
/**
 * @author Junji Takakura
 */
public clreplaced CIEntryEditPanel extends javax.swing.JPanel {

    private static final long serialVersionUID = 1L;

    private static File lastZipFolder = null;

    private DialogDescriptor validityDescriptor;

    private NotificationLineSupport validityNotificationSupport;

    private CIVersion version;

    private Map<String, String> fileEntryMap;

    public CIEntryEditPanel() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        nameLabel = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        pathLabel = new javax.swing.JLabel();
        pathTextField = new javax.swing.JTextField();
        browseButton = new javax.swing.JButton();
        // NOI18N
        nameLabel.setText(org.openide.util.NbBundle.getMessage(CIEntryEditPanel.clreplaced, "CIEntryEditPanel.nameLabel.text"));
        // NOI18N
        nameTextField.setText(org.openide.util.NbBundle.getMessage(CIEntryEditPanel.clreplaced, "CIEntryEditPanel.nameTextField.text"));
        // NOI18N
        pathLabel.setText(org.openide.util.NbBundle.getMessage(CIEntryEditPanel.clreplaced, "CIEntryEditPanel.pathLabel.text"));
        // NOI18N
        pathTextField.setText(org.openide.util.NbBundle.getMessage(CIEntryEditPanel.clreplaced, "CIEntryEditPanel.pathTextField.text"));
        // NOI18N
        browseButton.setText(org.openide.util.NbBundle.getMessage(CIEntryEditPanel.clreplaced, "CIEntryEditPanel.browseButton.text"));
        browseButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                browseButtonActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(nameLabel).addComponent(pathLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(nameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE).addComponent(pathTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(browseButton).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(nameLabel).addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(pathLabel).addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(browseButton)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }

    // </editor-fold>//GEN-END:initComponents
    private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_browseButtonActionPerformed
        JFileChooser chooser = new JFileChooser();
        chooser.setFileHidingEnabled(false);
        setHelpToChooser(chooser);
        chooser.setFileFilter(new FileFilter() {

            @Override
            public boolean accept(File file) {
                // NOI18N
                return (file.isDirectory() || file.getName().endsWith(".zip"));
            }

            @Override
            public String getDescription() {
                // NOI18N
                return getMessage("CTL_ZipArchivesMask");
            }
        });
        if (lastZipFolder != null) {
            chooser.setCurrentDirectory(lastZipFolder);
        }
        chooser.setDialogreplacedle(getMessage("CTL_ZipDialogreplacedle"));
        chooser.setMultiSelectionEnabled(false);
        if (chooser.showDialog(this, getMessage("CTL_ApproveButtonreplacedle")) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            if (file != null && file.isFile()) {
                String path = file.getAbsolutePath();
                if (path != null) {
                    pathTextField.setText(path.trim());
                }
                detectVersion(file);
                String name = generateUniqueName();
                if (name != null) {
                    nameTextField.setText(name.trim());
                }
                lastZipFolder = chooser.getCurrentDirectory();
            }
        }
    }

    // GEN-LAST:event_browseButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton browseButton;

    private javax.swing.JLabel nameLabel;

    private javax.swing.JTextField nameTextField;

    private javax.swing.JLabel pathLabel;

    private javax.swing.JTextField pathTextField;

    // End of variables declaration//GEN-END:variables
    void load(CIEntry entry) {
        replacedert entry != null;
        nameTextField.setText(entry.getName());
        pathTextField.setText(entry.getPath());
        if (entry.getVersion() != null) {
            version = new CIVersion(entry.getBranch(), entry.getVersion());
        }
    }

    void store(CIEntry entry) {
        replacedert entry != null;
        entry.setName(nameTextField.getText().trim());
        entry.setPath(pathTextField.getText().trim());
        if (version != null) {
            entry.setBranch(version.getBranch());
            entry.setVersion(version.getVersion());
        }
    }

    void setFileEntryMap(Map<String, String> fileEntryMap) {
        this.fileEntryMap = fileEntryMap;
    }

    void setValidityObjects(DialogDescriptor validityDescriptor, NotificationLineSupport validityNotificationSupport) {
        this.validityDescriptor = validityDescriptor;
        this.validityNotificationSupport = validityNotificationSupport;
        attachValidityChecks();
    }

    private void attachValidityChecks() {
        DoreplacedentListener validityDoreplacedentListener = new DoreplacedentListener() {

            @Override
            public void insertUpdate(DoreplacedentEvent e) {
                checkValid();
            }

            @Override
            public void removeUpdate(DoreplacedentEvent e) {
                checkValid();
            }

            @Override
            public void changedUpdate(DoreplacedentEvent e) {
                checkValid();
            }
        };
        nameTextField.getDoreplacedent().addDoreplacedentListener(validityDoreplacedentListener);
        pathTextField.getDoreplacedent().addDoreplacedentListener(validityDoreplacedentListener);
        checkValid();
    }

    private boolean checkValidName() {
        boolean isValid = false;
        String name = nameTextField.getText().trim();
        // TODO add characters length check(80).
        if (name == null || name.trim().length() == 0) {
            validityDescriptor.setValid(false);
            validityNotificationSupport.setErrorMessage(getMessage("MSG_EmptyName"));
        } else if (fileEntryMap.containsKey(name)) {
            validityDescriptor.setValid(false);
            validityNotificationSupport.setErrorMessage(getMessage("MSG_ExistingName"));
        } else {
            isValid = true;
        }
        return isValid;
    }

    private boolean checkValidPath() {
        boolean isValid = false;
        String path = pathTextField.getText().trim();
        // TODO add characters length check(8192 - MAX_VALUE_LENGTH).
        if (path == null || path.trim().length() == 0) {
            validityDescriptor.setValid(false);
            validityNotificationSupport.setErrorMessage(getMessage("MSG_EmptyPath"));
        } else if (fileEntryMap.containsValue(path)) {
            validityDescriptor.setValid(false);
            validityNotificationSupport.setErrorMessage(getMessage("MSG_ExistingPath"));
        } else if (!new File(path).isFile()) {
            validityDescriptor.setValid(false);
            validityNotificationSupport.setErrorMessage(getMessage("MSG_InvalidPath"));
        } else {
            isValid = true;
        }
        return isValid;
    }

    private void checkValid() {
        if (validityNotificationSupport == null) {
            return;
        }
        if (checkValidName() && checkValidPath()) {
            validityDescriptor.setValid(true);
            validityNotificationSupport.clearMessages();
        }
    }

    private void detectVersion(File file) {
        if (file != null && file.isFile()) {
            Set<CIFile> files = CIRepositories.getInstance().getAllFiles();
            String md5sum = Utils.getMD5Sum(file);
            String sha1sum = Utils.getSHA1Sum(file);
            version = null;
            if (md5sum != null && sha1sum != null) {
                for (CIFile f : files) {
                    if (!md5sum.equals(f.getMd5Sum())) {
                    // TODO implements to add logger??
                    } else if (!sha1sum.equals(f.getSha1Sum())) {
                    // TODO implements to add logger??
                    } else {
                        version = new CIVersion(f.getBranch(), f.getVersion());
                        break;
                    }
                }
            }
        }
    }

    private String generateUniqueName() {
        String name = null;
        if (version != null) {
            name = version.toString();
        }
        if (name == null) {
            name = getMessage("LBL_CIUnsupportedVersion");
        }
        if (fileEntryMap.containsKey(name)) {
            int index = 1;
            StringBuilder sb = new StringBuilder();
            do {
                sb.delete(0, sb.length());
                sb.append(name).append("_(").append(index).append(")");
                index++;
            } while (fileEntryMap.containsKey(sb.toString()));
            name = sb.toString();
        }
        return name;
    }

    private String getMessage(String resourceName, Object... parameters) {
        return NbBundle.getMessage(CategoryArchiveFiles.clreplaced, resourceName, parameters);
    }

    private void setHelpToChooser(JFileChooser chooser) {
        HelpCtx help = HelpCtx.findHelp(this);
        if (help != null) {
            HelpCtx.setHelpIDString(chooser, help.getHelpID());
        }
    }
}

15 View Complete Implementation : OrderingItemPanel.java
Copyright Apache License 2.0
Author : apache
private void check() {
    if (desc == null)
        return;
    NotificationLineSupport supp = desc.getNotificationLineSupport();
    if (rbName.isSelected()) {
        String s = tfNameRef.getText();
        if (s == null || s.length() < 1) {
            supp.setInformationMessage(NbBundle.getMessage(OrderingItemPanel.clreplaced, "ERR_NO_NAME"));
            desc.setValid(false);
            return;
        }
        if (!Utilities.isJavaIdentifier(s)) {
            supp.setErrorMessage(NbBundle.getMessage(OrderingItemPanel.clreplaced, "ERR_WRONG_NAME"));
            desc.setValid(false);
            return;
        }
    }
    supp.clearMessages();
    desc.setValid(true);
}

15 View Complete Implementation : AddDependencyPanel.java
Copyright Apache License 2.0
Author : NBANDROIDTEAM
/**
 * @author mkleint
 * @author arsi NBANDROID MOD
 */
public clreplaced AddDependencyPanel extends javax.swing.JPanel {

    private static final Object LOCK = new Object();

    private static AbstractNode searchingNode;

    private static AbstractNode tooGeneralNode;

    private static AbstractNode noResultsNode;

    private NotificationLineSupport nls;

    @StaticResource
    private static final String EMPTY_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/empty.png";

    @StaticResource
    private static final String WAIT_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/wait.gif";

    @StaticResource
    private static final String MAVEN_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/maven.png";

    @StaticResource
    private static final String JFROG_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/jfrog.png";

    @StaticResource
    private static final String GOOGLE_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/google.png";

    @StaticResource
    private static final String PACKAGE_ICON = "sk/arsi/netbeans/gradle/android/maven/dialog/package.png";

    private static final RequestProcessor RPofQueryPanel = new RequestProcessor(AddDependencyPanel.QueryPanel.clreplaced.getName() + "-Search", 10);

    private static final RequestProcessor UPDATE_PROCESSOR = new RequestProcessor(AddDependencyPanel.QueryPanel.clreplaced.getName() + "-Node-Update", 1);

    private QueryPanel queryPanel;

    private static final AtomicLong searchId = new AtomicLong(0);

    private final List<Repository> repositories;

    private final List<String> currentPackages;

    private final List<MavenDependencyInfo> googleDependenciesInfos = new ArrayList<>();

    private final List<MavenDependencyInfo> jcenterDependenciesInfos = new ArrayList<>();

    private final List<MavenDependencyInfo> mavenDependenciesInfos = new ArrayList<>();

    private final List<MavenDependencyInfo> installedDependenciesInfos = new ArrayList<>();

    private boolean jcenterPartial = true;

    private boolean googlePartial = true;

    private boolean mavenPartial = true;

    private String selected = null;

    /**
     * Creates new form AddDependenCy
     */
    public AddDependencyPanel(List<Repository> repositories, List<String> currentPackages) {
        initComponents();
        this.repositories = repositories;
        this.currentPackages = currentPackages;
        for (String currentPackage : currentPackages) {
            StringTokenizer tok = new StringTokenizer(currentPackage, ":", false);
            if (tok.countTokens() > 1) {
                String grp = tok.nextToken();
                String packg = tok.nextToken();
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.MAVEN, grp, packg));
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.GOOGLE, grp, packg));
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.JCENTER, grp, packg));
            }
        }
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                queryPanel = new QueryPanel();
                resultsPanel.add(queryPanel, BorderLayout.CENTER);
                searchField.getDoreplacedent().addDoreplacedentListener(DelayedDoreplacedentChangeListener.create(searchField.getDoreplacedent(), queryPanel, 1500));
            }
        };
        SwingUtilities.invokeLater(runnable);
    }

    public AddDependencyPanel(List<Repository> repositories, List<String> currentPackages, List<MavenDependencyInfo> index) {
        initComponents();
        this.repositories = repositories;
        this.currentPackages = currentPackages;
        for (String currentPackage : currentPackages) {
            StringTokenizer tok = new StringTokenizer(currentPackage, ":", false);
            if (tok.countTokens() > 1) {
                String grp = tok.nextToken();
                String packg = tok.nextToken();
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.MAVEN, grp, packg));
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.GOOGLE, grp, packg));
                installedDependenciesInfos.add(new MavenDependencyInfo(MavenDependencyInfo.Type.JCENTER, grp, packg));
            }
        }
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                queryPanel = new QueryPanel();
                resultsPanel.add(queryPanel, BorderLayout.CENTER);
                labelQ.setVisible(false);
                searchField.setVisible(false);
                labelHelp.setVisible(false);
                googleDependenciesInfos.addAll(index);
                jcenterPartial = false;
                googlePartial = false;
                mavenPartial = false;
                queryPanel.updateResults();
            }
        };
        SwingUtilities.invokeLater(runnable);
    }

    public String getSelected() {
        return selected;
    }

    public void attachDialogDisplayer(DialogDescriptor dd) {
        nls = dd.getNotificationLineSupport();
        if (nls == null) {
            nls = dd.createNotificationLineSupport();
        }
    }

    public JButton getOkButton() {
        return ok;
    }

    public JButton getCancelButton() {
        return cancel;
    }

    private void changeSelection(Lookup lookup) {
        MavenDependencyInfo dependencyInfo = lookup.lookup(MavenDependencyInfo.clreplaced);
        MavenDependencyInfo.Version version = lookup.lookup(MavenDependencyInfo.Version.clreplaced);
        if (version != null) {
            labelGroup.setText(version.getGroupId());
            labelArtifact.setText(version.getArtifactId());
            labelVersion.setText(version.getVersion());
            selected = version.getGradleLine();
        } else if (dependencyInfo != null) {
            labelGroup.setText(dependencyInfo.getGroupId());
            labelArtifact.setText(dependencyInfo.getArtifactId());
            labelVersion.setText("+");
            selected = dependencyInfo.getGradleLine() + ":+";
        } else {
            labelGroup.setText("...");
            labelArtifact.setText("...");
            labelVersion.setText("...");
            selected = null;
        }
        ok.setEnabled(selected != null);
    }

    @Override
    public void addNotify() {
        super.addNotify();
        // NOI18N
        replacedert nls != null : " The notificationLineSupport was not attached to the panel.";
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        labelGroup = new javax.swing.JLabel();
        labelArtifact = new javax.swing.JLabel();
        labelVersion = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        labelQ = new javax.swing.JLabel();
        searchField = new javax.swing.JTextField();
        labelHelp = new javax.swing.JLabel();
        resultsLabel = new javax.swing.JLabel();
        resultsPanel = new javax.swing.JPanel();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.jLabel1.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.jLabel2.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.jLabel3.text"));
        // NOI18N
        labelGroup.setFont(new java.awt.Font("Arial", 1, 14));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(labelGroup, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.labelGroup.text"));
        // NOI18N
        labelArtifact.setFont(new java.awt.Font("Arial", 1, 14));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(labelArtifact, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.labelArtifact.text"));
        // NOI18N
        labelVersion.setFont(new java.awt.Font("Arial", 1, 14));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(labelVersion, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.labelVersion.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(labelQ, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.labelQ.text"));
        // NOI18N
        searchField.setText(org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.searchField.text"));
        labelHelp.setForeground(new java.awt.Color(153, 153, 153));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(labelHelp, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.labelHelp.text"));
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(resultsLabel, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.resultsLabel.text"));
        resultsPanel.setLayout(new java.awt.BorderLayout());
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(ok, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.ok.text"));
        ok.setEnabled(false);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(cancel, org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.cancel.text"));
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(resultsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(jPanel1Layout.createSequentialGroup().addComponent(labelQ).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addComponent(labelHelp).addGap(0, 477, Short.MAX_VALUE)).addComponent(searchField))).addGroup(jPanel1Layout.createSequentialGroup().addComponent(resultsLabel).addGap(0, 0, Short.MAX_VALUE)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(ok).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(cancel))).addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(labelQ).addComponent(searchField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(labelHelp).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(resultsLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(resultsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ok).addComponent(cancel)).addContainerGap()));
        // NOI18N
        jTabbedPane1.addTab(org.openide.util.NbBundle.getMessage(AddDependencyPanel.clreplaced, "AddDependencyPanel.jPanel1.TabConstraints.tabreplacedle"), jPanel1);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1).addComponent(jLabel2).addComponent(jLabel3)).addGap(18, 18, 18).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(labelVersion).addComponent(labelArtifact).addComponent(labelGroup)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addComponent(jTabbedPane1));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(labelGroup)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(labelArtifact)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel3).addComponent(labelVersion)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jTabbedPane1)));
    }

    // </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancel;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JPanel jPanel1;

    private javax.swing.JTabbedPane jTabbedPane1;

    private javax.swing.JLabel labelArtifact;

    private javax.swing.JLabel labelGroup;

    private javax.swing.JLabel labelHelp;

    private javax.swing.JLabel labelQ;

    private javax.swing.JLabel labelVersion;

    private javax.swing.JButton ok;

    private javax.swing.JLabel resultsLabel;

    private javax.swing.JPanel resultsPanel;

    private javax.swing.JTextField searchField;

    // End of variables declaration//GEN-END:variables
    private clreplaced QueryPanel extends JPanel implements ExplorerManager.Provider, Comparator<MavenDependencyInfo>, PropertyChangeListener, ChangeListener, RepoSearchListener {

        private final BeanTreeView btv;

        private final ExplorerManager manager;

        private final ResultsRootNode resultsRootNode;

        private String inProgressText, lastQueryText, curTypedText;

        private final Color defSearchC;

        private QueryPanel() {
            btv = new BeanTreeView();
            btv.setRootVisible(false);
            btv.setDefaultActionAllowed(true);
            btv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            manager = new ExplorerManager();
            setLayout(new BorderLayout());
            add(btv, BorderLayout.CENTER);
            defSearchC = AddDependencyPanel.this.searchField.getForeground();
            manager.addPropertyChangeListener(this);
            AddDependencyPanel.this.resultsLabel.setLabelFor(btv);
            btv.getAccessibleContext().setAccessibleDescription(AddDependencyPanel.this.resultsLabel.getAccessibleContext().getAccessibleDescription());
            resultsRootNode = new ResultsRootNode();
            manager.setRootContext(resultsRootNode);
        }

        /**
         * delayed change of query text
         */
        @Override
        public void stateChanged(ChangeEvent e) {
            Doreplacedent doc = (Doreplacedent) e.getSource();
            try {
                curTypedText = doc.getText(0, doc.getLength()).trim();
            } catch (BadLocationException ex) {
                // should never happen, nothing we can do probably
                return;
            }
            AddDependencyPanel.this.searchField.setForeground(defSearchC);
            if (curTypedText.length() > 0) {
                find(curTypedText);
            }
        }

        void find(String queryText) {
            synchronized (LOCK) {
                changeSelection(Lookup.EMPTY);
                if (queryText.equals(lastQueryText)) {
                    return;
                }
                lastQueryText = queryText;
            }
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    resultsRootNode.setOneChild(getSearchingNode());
                    AddDependencyPanel.this.searchField.setForeground(defSearchC);
                    AddDependencyPanel.this.nls.clearMessages();
                }
            });
            jcenterPartial = true;
            mavenPartial = true;
            googlePartial = true;
            long currentSearchId = searchId.incrementAndGet();
            Collection<? extends MavenSearchProvider> providers = Lookup.getDefault().lookupAll(MavenSearchProvider.clreplaced);
            for (MavenSearchProvider next : providers) {
                next.searchPackageName(queryText, "jcenter", WeakListeners.create(RepoSearchListener.clreplaced, (RepoSearchListener) this, null), currentSearchId, repositories);
            }
        }

        @Override
        public ExplorerManager getExplorerManager() {
            return manager;
        }

        void updateResults() {
            final List<MavenDependencyInfo> dependencyInfos = new ArrayList<>();
            dependencyInfos.addAll(googleDependenciesInfos);
            dependencyInfos.addAll(jcenterDependenciesInfos);
            dependencyInfos.addAll(mavenDependenciesInfos);
            dependencyInfos.removeAll(installedDependenciesInfos);
            Collections.sort(dependencyInfos, QueryPanel.this);
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    updateResultNodes(dependencyInfos);
                }
            });
        }

        private void updateResultNodes(List<MavenDependencyInfo> dependencyInfos) {
            if (dependencyInfos.size() > 0) {
                // some results available
                Map<MavenDependencyInfo, Node> currentNodes = new HashMap<>();
                for (Node nd : resultsRootNode.getChildren().getNodes()) {
                    currentNodes.put(nd.getLookup().lookup(MavenDependencyInfo.clreplaced), nd);
                }
                List<Node> newNodes = new ArrayList<Node>(dependencyInfos.size());
                // still searching?
                if (mavenPartial || jcenterPartial || googlePartial) {
                    newNodes.add(getSearchingNode());
                }
                for (MavenDependencyInfo key : dependencyInfos) {
                    Node nd;
                    nd = currentNodes.get(key);
                    if (null != nd) {
                        ((ArtifactNode) ((AddDependencyPanel.FilterNodeWithDefAction) nd).getOriginal()).setVersionInfos(key.getVersions());
                    } else {
                        nd = createFilterWithDefaultAction(new ArtifactNode(key), false);
                    }
                    newNodes.add(nd);
                }
                resultsRootNode.setNewChildren(newNodes);
            } else if (googlePartial || jcenterPartial || mavenPartial) {
                // still searching, no results yet
                resultsRootNode.setOneChild(getSearchingNode());
            } else {
                // finished searching with no results
                resultsRootNode.setOneChild(getNoResultsNode());
            }
        }

        /**
         * Impl of comparator, sorts artifacts asfabetically with exception of
         * items that contain current query string, which take precedence.
         */
        @Override
        public int compare(MavenDependencyInfo s1, MavenDependencyInfo s2) {
            return s1.getGradleLine().compareTo(s2.getGradleLine());
        }

        /**
         * PropertyChangeListener impl, stores maven coordinates of selected
         * artifact
         */
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
                Node[] selNodes = manager.getSelectedNodes();
                changeSelection(selNodes.length == 1 ? selNodes[0].getLookup() : Lookup.EMPTY);
            }
        }

        private String key(NBVersionInfo nbvi) {
            return nbvi.getGroupId() + ':' + nbvi.getArtifactId() + ':' + nbvi.getVersion();
        }

        @Override
        public void searchDone(Type type, long searchId, boolean isPartial, List<MavenDependencyInfo> dependencyInfos) {
            // handle only last search
            if (searchId == AddDependencyPanel.searchId.get()) {
                switch(type) {
                    case GOOGLE:
                        googleDependenciesInfos.clear();
                        googleDependenciesInfos.addAll(dependencyInfos);
                        googlePartial = isPartial;
                        break;
                    case JCENTER:
                        jcenterDependenciesInfos.clear();
                        jcenterDependenciesInfos.addAll(dependencyInfos);
                        jcenterPartial = isPartial;
                        break;
                    case MAVEN:
                        mavenDependenciesInfos.clear();
                        mavenDependenciesInfos.addAll(dependencyInfos);
                        mavenPartial = isPartial;
                        break;
                    default:
                        throw new replacedertionError(type.name());
                }
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        updateResults();
                    }
                };
                UPDATE_PROCESSOR.execute(runnable);
            }
        }
    }

    // QueryPanel
    public static clreplaced ArtifactNode extends AbstractNode {

        private final MavenDependencyInfo dependencyInfo;

        private List<MavenDependencyInfo.Version> versionInfos;

        private final ArtifactNodeChildren myChildren;

        public ArtifactNode(MavenDependencyInfo dependencyInfo) {
            super(new ArtifactNodeChildren(dependencyInfo.getVersions()), Lookups.fixed(dependencyInfo));
            myChildren = (ArtifactNodeChildren) getChildren();
            this.versionInfos = dependencyInfo.getVersions();
            this.dependencyInfo = dependencyInfo;
            setName(dependencyInfo.getGradleLine());
            setDisplayName(dependencyInfo.getGradleLine());
        }

        @Override
        public Image getIcon(int type) {
            switch(dependencyInfo.getType()) {
                case GOOGLE:
                    // NOI18N
                    return ImageUtilities.loadImage(GOOGLE_ICON);
                case JCENTER:
                    // NOI18N
                    return ImageUtilities.loadImage(JFROG_ICON);
                case MAVEN:
                    // NOI18N
                    return ImageUtilities.loadImage(MAVEN_ICON);
                default:
                    return super.getIcon(type);
            }
        }

        @Override
        public Image getOpenedIcon(int type) {
            return getIcon(type);
        }

        public List<MavenDependencyInfo.Version> getVersionInfos() {
            return new ArrayList<>(versionInfos);
        }

        public void setVersionInfos(List<MavenDependencyInfo.Version> versions) {
            versionInfos = versions;
            myChildren.setNewKeys(versions);
        }

        static clreplaced ArtifactNodeChildren extends Children.Keys<MavenDependencyInfo.Version> {

            private List<MavenDependencyInfo.Version> keys;

            public ArtifactNodeChildren(List<MavenDependencyInfo.Version> keys) {
                this.keys = keys;
            }

            @Override
            protected Node[] createNodes(MavenDependencyInfo.Version arg0) {
                return new Node[] { new VersionNode(arg0) };
            }

            @Override
            protected void addNotify() {
                setKeys(keys);
            }

            protected void setNewKeys(List<MavenDependencyInfo.Version> keys) {
                this.keys = keys;
                setKeys(keys);
            }
        }
    }

    public static clreplaced VersionNode extends AbstractNode {

        private final MavenDependencyInfo.Version nbvi;

        /**
         * Creates a new instance of VersionNode
         */
        public VersionNode(MavenDependencyInfo.Version version) {
            super(Children.LEAF, Lookups.fixed(version));
            this.nbvi = version;
            setName(version.getVersion());
            setDisplayName(version.getVersion());
        }

        @Override
        public Image getIcon(int type) {
            // NOI18N
            return ImageUtilities.loadImage(PACKAGE_ICON);
        }

        @Override
        public Image getOpenedIcon(int type) {
            return getIcon(type);
        }

        public MavenDependencyInfo.Version getVersionInfo() {
            return nbvi;
        }

        @Override
        public String getShortDescription() {
            return nbvi.toString();
        }
    }

    private clreplaced ResultsRootNode extends AbstractNode {

        private ResultsRootChildren resultsChildren;

        public ResultsRootNode() {
            this(new InstanceContent());
        }

        private ResultsRootNode(InstanceContent content) {
            super(new ResultsRootChildren(), new AbstractLookup(content));
            content.add(this);
            this.resultsChildren = (ResultsRootChildren) getChildren();
        }

        public void setOneChild(Node n) {
            List<Node> ch = new ArrayList<Node>(1);
            ch.add(n);
            setNewChildren(ch);
        }

        public void setNewChildren(List<Node> ch) {
            resultsChildren.setNewChildren(ch);
        }
    }

    private clreplaced ResultsRootChildren extends Children.Keys<Node> {

        List<Node> myNodes;

        public ResultsRootChildren() {
            myNodes = Collections.EMPTY_LIST;
        }

        private void setNewChildren(List<Node> ch) {
            myNodes = ch;
            refreshList();
        }

        @Override
        protected void addNotify() {
            refreshList();
        }

        private void refreshList() {
            List<Node> keys = new ArrayList();
            for (Node node : myNodes) {
                keys.add(node);
            }
            setKeys(keys);
        }

        @Override
        protected Node[] createNodes(Node key) {
            return new Node[] { key };
        }
    }

    private static Node getSearchingNode() {
        if (searchingNode == null) {
            AbstractNode nd = new AbstractNode(Children.LEAF) {

                @Override
                public Image getIcon(int arg0) {
                    // NOI18N
                    return ImageUtilities.loadImage(WAIT_ICON);
                }

                @Override
                public Image getOpenedIcon(int arg0) {
                    return getIcon(arg0);
                }
            };
            // NOI18N
            nd.setName("Searching");
            // NOI18N
            nd.setDisplayName("Searching..");
            searchingNode = nd;
        }
        return new FilterNode(searchingNode, Children.LEAF);
    }

    private static Node getTooGeneralNode() {
        if (tooGeneralNode == null) {
            AbstractNode nd = new AbstractNode(Children.LEAF) {

                @Override
                public Image getIcon(int arg0) {
                    // NOI18N
                    return ImageUtilities.loadImage(EMPTY_ICON);
                }

                @Override
                public Image getOpenedIcon(int arg0) {
                    return getIcon(arg0);
                }
            };
            // NOI18N
            nd.setName("Too General");
            // NOI18N
            nd.setDisplayName("Too General");
            tooGeneralNode = nd;
        }
        return new FilterNode(tooGeneralNode, Children.LEAF);
    }

    private static Node getNoResultsNode() {
        if (noResultsNode == null) {
            AbstractNode nd = new AbstractNode(Children.LEAF) {

                @Override
                public Image getIcon(int arg0) {
                    // NOI18N
                    return ImageUtilities.loadImage(EMPTY_ICON);
                }

                @Override
                public Image getOpenedIcon(int arg0) {
                    return getIcon(arg0);
                }
            };
            // NOI18N
            nd.setName("Empty");
            // NOI18N
            nd.setDisplayName("Empty");
            noResultsNode = nd;
        }
        return new FilterNode(noResultsNode, Children.LEAF);
    }

    private Node createFilterWithDefaultAction(final Node nd, boolean leaf) {
        return new FilterNodeWithDefAction(nd, leaf);
    }

    clreplaced FilterNodeWithDefAction extends FilterNode {

        public FilterNodeWithDefAction(Node nd, boolean leaf) {
            super(nd, leaf ? Children.LEAF : new FilterNode.Children(nd) {

                @Override
                protected Node[] createNodes(Node key) {
                    return new Node[] { createFilterWithDefaultAction(key, true) };
                }
            });
        }

        @Override
        public Action getPreferredAction() {
            return super.getPreferredAction();
        }

        @Override
        public Action[] getActions(boolean context) {
            return new Action[0];
        }

        @Override
        public Node getOriginal() {
            return super.getOriginal();
        }
    }
}

14 View Complete Implementation : CallEjbDialog.java
Copyright Apache License 2.0
Author : apache
public boolean open(final FileObject referencingFO, final String referencingClreplacedName, String replacedle) throws IOException {
    Project enterpriseProject = FileOwnerQuery.getOwner(referencingFO);
    Project[] allProjects = Utils.getCallableEjbProjects(enterpriseProject);
    List<Node> ejbProjectNodes = new LinkedList<Node>();
    for (int i = 0; i < allProjects.length; i++) {
        Node projectView = new EjbsNode(allProjects[i]);
        ejbProjectNodes.add(new FilterNode(projectView, new EjbChildren(projectView)) {

            @Override
            public Action[] getActions(boolean context) {
                return new Action[0];
            }
        });
    }
    Children.Array children = new Children.Array();
    children.add(ejbProjectNodes.toArray(new Node[ejbProjectNodes.size()]));
    Node root = new AbstractNode(children);
    root.setDisplayName(NbBundle.getMessage(CallEjbDialog.clreplaced, "LBL_EJBModules"));
    EnterpriseReferenceContainer erc = enterpriseProject.getLookup().lookup(EnterpriseReferenceContainer.clreplaced);
    boolean isJavaEE5orHigher = ProjectUtil.isJavaEE5orHigher(enterpriseProject);
    final CallEjbPanel panel = new CallEjbPanel(referencingFO, root, isJavaEE5orHigher ? null : erc.getServiceLocatorName(), referencingClreplacedName);
    if (isJavaEE5orHigher) {
        panel.disableServiceLocator();
    }
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, replacedle, true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(CallEjbPanel.clreplaced), null);
    NotificationLineSupport statusLine = dialogDescriptor.createNotificationLineSupport();
    panel.setNotificationLine(statusLine);
    panel.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(CallEjbPanel.IS_VALID)) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    dialogDescriptor.setValid(((Boolean) newvalue).booleanValue());
                }
            }
        }
    });
    panel.validateReferences();
    Object button = DialogDisplayer.getDefault().notify(dialogDescriptor);
    if (button != NotifyDescriptor.OK_OPTION) {
        return false;
    }
    Node ejbNode = panel.getEjb();
    final boolean throwExceptions = !panel.convertToRuntime();
    EjbReference ref = ejbNode.getLookup().lookup(EjbReference.clreplaced);
    String referenceNameFromPanel = panel.getReferenceName();
    if (referenceNameFromPanel != null && referenceNameFromPanel.trim().equals("")) {
        referenceNameFromPanel = null;
    }
    final FileObject fileObject = ejbNode.getLookup().lookup(FileObject.clreplaced);
    final Project nodeProject = FileOwnerQuery.getOwner(fileObject);
    boolean isDefaultRefName = panel.isDefaultRefName();
    final String referencedClreplacedName = _RetoucheUtil.getJavaClreplacedFromNode(ejbNode).getQualifiedName();
    final CallEjbGenerator generator = CallEjbGenerator.create(ref, referenceNameFromPanel, isDefaultRefName);
    RequestProcessor.getDefault().post(new Runnable() {

        public void run() {
            try {
                final ElementHandle<? extends Element> elementHandle = generator.addReference(referencingFO, referencingClreplacedName, fileObject, referencedClreplacedName, panel.getServiceLocator(), panel.getSelectedInterface(), throwExceptions, nodeProject);
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        ElementOpen.open(referencingFO, elementHandle);
                    }
                });
            } catch (IOException ioe) {
                Exceptions.printStackTrace(ioe);
            }
        }
    });
    return true;
}

14 View Complete Implementation : CreateJobPanel.java
Copyright Apache License 2.0
Author : apache
/**
 * Visual configuration of {@link CreateJob}.
 */
public clreplaced CreateJobPanel extends JPanel implements ChangeListener {

    private Set<String> takenNames;

    private NotificationLineSupport notifications;

    private DialogDescriptor descriptor;

    private Set<Project> manuallyAddedProjects = new HashSet<Project>();

    ProjectHudsonJobCreator creator;

    HudsonInstance instance;

    CreateJobPanel() {
    }

    void init(DialogDescriptor descriptor, HudsonInstance instance) {
        this.descriptor = descriptor;
        this.notifications = descriptor.createNotificationLineSupport();
        initComponents();
        updateServerModel();
        this.instance = instance;
        server.setSelectedItem(instance);
        server.setRenderer(new ServerRenderer());
        updateProjectModel();
        project.setSelectedItem(project.gereplacedemCount() > 0 ? project.gereplacedemAt(0) : null);
        project.setRenderer(new ProjectRenderer());
        name.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

            public void insertUpdate(DoreplacedentEvent e) {
                check();
            }

            public void removeUpdate(DoreplacedentEvent e) {
                check();
            }

            public void changedUpdate(DoreplacedentEvent e) {
            }
        });
    }

    @Override
    public void addNotify() {
        super.addNotify();
        project.requestFocusInWindow();
        check();
    }

    @NbBundle.Messages({ "CreateJobPanel.emptyName=Please enter a Build Name" })
    private void check() {
        descriptor.setValid(false);
        notifications.clearMessages();
        if (name.getText() == null || name.getText().trim().isEmpty()) {
            notifications.setInformationMessage(Bundle.CreateJobPanel_emptyName());
            return;
        }
        if (instance == null) {
            notifications.setInformationMessage(NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.pick_server"));
            return;
        }
        Project p = selectedProject();
        if (p == null) {
            notifications.setInformationMessage(NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.pick_project"));
            return;
        }
        if (creator == null) {
            notifications.setErrorMessage(NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.unknown_project_type"));
            return;
        }
        if (takenNames.contains(name())) {
            notifications.setErrorMessage(NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.name_taken"));
            return;
        }
        if (ProjectHudsonProvider.getDefault().findreplacedociation(p) != null) {
            notifications.setWarningMessage(NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.already_replacedociated"));
        }
        ConfigurationStatus status = creator.status();
        if (status.getErrorMessage() != null) {
            notifications.setErrorMessage(status.getErrorMessage());
        } else {
            if (status.getWarningMessage() != null) {
                notifications.setWarningMessage(status.getWarningMessage());
            }
            descriptor.setValid(true);
        }
        JButton button = status.getExtraButton();
        if (button != null) {
            descriptor.setAdditionalOptions(new Object[] { button });
            descriptor.setClosingOptions(new Object[] { button, NotifyDescriptor.CANCEL_OPTION });
        } else {
            descriptor.setAdditionalOptions(new Object[0]);
            descriptor.setClosingOptions(new Object[] { NotifyDescriptor.CANCEL_OPTION });
        }
    }

    String name() {
        return name.getText();
    }

    Project selectedProject() {
        return (Project) project.getSelectedItem();
    }

    private void updateServerModel() {
        server.setModel(new DefaultComboBoxModel(HudsonManager.getAllInstances().toArray()));
    }

    private void computeTakenNames() {
        takenNames = new HashSet<String>();
        if (instance != null) {
            for (HudsonJob job : instance.getJobs()) {
                takenNames.add(job.getName());
            }
        }
    }

    private void updateProjectModel() {
        SortedSet<Project> projects = new TreeSet<Project>(ProjectRenderer.comparator());
        projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
        projects.addAll(manuallyAddedProjects);
        project.setModel(new DefaultComboBoxModel(projects.toArray(new Project[projects.size()])));
    }

    @SuppressWarnings("unchecked")
    private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    void initComponents() {
        serverLabel = new javax.swing.JLabel();
        server = new javax.swing.JComboBox();
        addServer = new javax.swing.JButton();
        nameLabel = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        projectLabel = new javax.swing.JLabel();
        project = new javax.swing.JComboBox();
        browse = new javax.swing.JButton();
        custom = new javax.swing.JPanel();
        explanationLabel = new javax.swing.JLabel();
        serverLabel.setLabelFor(server);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(serverLabel, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.serverLabel.text"));
        server.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverActionPerformed(evt);
            }
        });
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(addServer, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.addServer.text"));
        addServer.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addServerActionPerformed(evt);
            }
        });
        nameLabel.setLabelFor(name);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.nameLabel.text"));
        projectLabel.setLabelFor(project);
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(projectLabel, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.projectLabel.text"));
        project.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                projectActionPerformed(evt);
            }
        });
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(browse, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.browse.text"));
        browse.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                browseActionPerformed(evt);
            }
        });
        custom.setLayout(new java.awt.BorderLayout());
        // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(explanationLabel, org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.explanationLabel.text"));
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(explanationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(serverLabel).addComponent(nameLabel).addComponent(projectLabel)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(name, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE).addComponent(project, javax.swing.GroupLayout.Alignment.TRAILING, 0, 278, Short.MAX_VALUE).addComponent(server, 0, 278, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false).addComponent(addServer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(browse, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))).addComponent(custom, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(serverLabel).addComponent(server, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(addServer)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(nameLabel).addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(projectLabel).addComponent(project, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(browse)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(custom, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(explanationLabel).addContainerGap()));
        // NOI18N
        server.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.server.AccessibleContext.accessibleDescription"));
        // NOI18N
        addServer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.addServer.AccessibleContext.accessibleDescription"));
        // NOI18N
        name.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.name.AccessibleContext.accessibleDescription"));
        // NOI18N
        project.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.project.AccessibleContext.accessibleDescription"));
        // NOI18N
        browse.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.browse.AccessibleContext.accessibleDescription"));
        // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CreateJobPanel.clreplaced, "CreateJobPanel.AccessibleContext.accessibleDescription"));
    }

    // </editor-fold>//GEN-END:initComponents
    private void browseActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_browseActionPerformed
        JFileChooser chooser = ProjectChooser.projectChooser();
        chooser.showOpenDialog(this);
        File dir = chooser.getSelectedFile();
        if (dir != null) {
            FileObject d = FileUtil.toFileObject(dir);
            if (d != null) {
                try {
                    Project p = ProjectManager.getDefault().findProject(d);
                    if (p != null) {
                        manuallyAddedProjects.add(p);
                        updateProjectModel();
                        project.setSelectedItem(p);
                    }
                } catch (IOException x) {
                    Exceptions.printStackTrace(x);
                }
            }
        }
    }

    // GEN-LAST:event_browseActionPerformed
    private void projectActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_projectActionPerformed
        if (creator != null) {
            creator.removeChangeListener(this);
        }
        creator = null;
        Project p = selectedProject();
        if (p == null) {
            check();
            return;
        }
        if (p.getClreplaced().getName().equals("org.netbeans.modules.project.ui.LazyProject")) {
            // NOI18N
            // XXX ugly but not obvious how better to handle this...
            updateProjectModel();
            project.setSelectedItem(null);
            return;
        }
        for (ProjectHudsonJobCreatorFactory factory : Lookup.getDefault().lookupAll(ProjectHudsonJobCreatorFactory.clreplaced)) {
            creator = factory.forProject(p);
            if (creator != null) {
                break;
            }
        }
        if (creator == null) {
            check();
            return;
        }
        name.setText(creator.jobName());
        custom.removeAll();
        custom.add(creator.customizer());
        creator.addChangeListener(this);
        check();
    }

    // GEN-LAST:event_projectActionPerformed
    private void serverActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_serverActionPerformed
        instance = (HudsonInstance) server.getSelectedItem();
        computeTakenNames();
        check();
    }

    // GEN-LAST:event_serverActionPerformed
    private void addServerActionPerformed(java.awt.event.ActionEvent evt) {
        // GEN-FIRST:event_addServerActionPerformed
        HudsonInstance created = new InstanceDialog().show();
        if (created != null) {
            updateServerModel();
            instance = created;
            server.setSelectedItem(instance);
            check();
        }
    }

    // GEN-LAST:event_addServerActionPerformed
    public void stateChanged(ChangeEvent event) {
        check();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addServer;

    private javax.swing.JButton browse;

    private javax.swing.JPanel custom;

    private javax.swing.JLabel explanationLabel;

    private javax.swing.JTextField name;

    private javax.swing.JLabel nameLabel;

    private javax.swing.JComboBox project;

    private javax.swing.JLabel projectLabel;

    private javax.swing.JComboBox server;

    private javax.swing.JLabel serverLabel;

    // End of variables declaration//GEN-END:variables
    private static clreplaced ServerRenderer extends DefaultListCellRenderer {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value == null || /* #180088 */
            value instanceof String) {
                return super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus);
            }
            return super.getListCellRendererComponent(list, ((HudsonInstance) value).getName(), index, isSelected, cellHasFocus);
        }
    }
}

13 View Complete Implementation : CreateTableDialog.java
Copyright Apache License 2.0
Author : apache
public clreplaced CreateTableDialog {

    Dialog dialog = null;

    JTextField dbnamefield, dbownerfield;

    JTable table;

    JButton addbtn, delbtn, editBtn, upBtn, downBtn;

    Specification spec;

    private final BaseNode tablesNode;

    private DialogDescriptor descriptor = null;

    private NotificationLineSupport statusLine;

    private static Map dlgtab = null;

    // NOI18N
    private static final String filename = "org/netbeans/modules/db/resources/CreateTableDialog.plist";

    private static final Logger LOGGER = Logger.getLogger(CreateTableDialog.clreplaced.getName());

    public static Map getProperties() {
        if (dlgtab == null)
            try {
                ClreplacedLoader cl = CreateTableDialog.clreplaced.getClreplacedLoader();
                InputStream stream = cl.getResourcereplacedtream(filename);
                if (stream == null) {
                    // NOI18N
                    String message = NbBundle.getMessage(CreateTableDialog.clreplaced, "EXC_UnableToOpenStream", filename);
                    throw new Exception(message);
                }
                PListReader reader = new PListReader(stream);
                dlgtab = reader.getData();
                stream.close();
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
                dlgtab = null;
            }
        return dlgtab;
    }

    public CreateTableDialog(final BaseNode node, final String schema) {
        DatabaseConnection connection = node.getLookup().lookup(DatabaseConnection.clreplaced);
        spec = connection.getConnector().getDatabaseSpecification();
        tablesNode = node;
        try {
            JLabel label;
            JPanel pane = new JPanel();
            pane.setBorder(new EmptyBorder(new Insets(5, 5, 5, 5)));
            GridBagLayout layout = new GridBagLayout();
            GridBagConstraints constr = new GridBagConstraints();
            pane.setLayout(layout);
            pane.setMinimumSize(new Dimension(200, 100));
            // Table name field
            label = new JLabel();
            // NOI18N
            Mnemonics.setLocalizedText(label, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableName"));
            label.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableNameA11yDesc"));
            constr.anchor = GridBagConstraints.WEST;
            constr.weightx = 0.0;
            constr.weighty = 0.0;
            constr.fill = GridBagConstraints.NONE;
            constr.insets = new java.awt.Insets(2, 2, 2, 2);
            constr.gridx = 0;
            constr.gridy = 0;
            layout.setConstraints(label, constr);
            pane.add(label);
            constr.fill = GridBagConstraints.HORIZONTAL;
            constr.weightx = 1.0;
            constr.weighty = 0.0;
            constr.gridx = 1;
            constr.gridy = 0;
            constr.insets = new java.awt.Insets(2, 2, 2, 2);
            dbnamefield = new JTextField(getTableUnreplacedledName(), 10);
            dbnamefield.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableNameTextFieldA11yDesc"));
            dbnamefield.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableNameTextFieldA11yName"));
            label.setLabelFor(dbnamefield);
            layout.setConstraints(dbnamefield, constr);
            pane.add(dbnamefield);
            dbnamefield.getDoreplacedent().addDoreplacedentListener(new DoreplacedentListener() {

                @Override
                public void insertUpdate(DoreplacedentEvent e) {
                    validate();
                }

                @Override
                public void removeUpdate(DoreplacedentEvent e) {
                    validate();
                }

                @Override
                public void changedUpdate(DoreplacedentEvent e) {
                    validate();
                }
            });
            // Table columns in scrollpane
            constr.fill = GridBagConstraints.BOTH;
            constr.weightx = 1.0;
            constr.weighty = 1.0;
            constr.gridx = 0;
            constr.gridy = 1;
            constr.gridwidth = 4;
            constr.gridheight = 3;
            constr.insets = new java.awt.Insets(2, 2, 2, 2);
            table = new DataTable(new DataModel());
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            table.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableColumnTableA11yDesc"));
            table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableColumnTableA11yName"));
            table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableColumnTableA11yDesc"));
            JScrollPane scrollpane = new JScrollPane(table);
            scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED));
            layout.setConstraints(scrollpane, constr);
            pane.add(scrollpane);
            table.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent event) {
                    if (event.getClickCount() == 2) {
                        editBtn.doClick();
                    }
                }
            });
            table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                @Override
                public void valueChanged(ListSelectionEvent e) {
                    // update Edit and Remove buttons
                    validate();
                }
            });
            table.getModel().addTableModelListener(new TableModelListener() {

                @Override
                public void tableChanged(TableModelEvent e) {
                    validate();
                }
            });
            // Button pane
            constr.fill = GridBagConstraints.HORIZONTAL;
            constr.anchor = GridBagConstraints.NORTH;
            constr.weightx = 0.0;
            constr.weighty = 0.0;
            constr.gridx = 4;
            constr.gridy = 1;
            constr.insets = new java.awt.Insets(2, 8, 2, 2);
            JPanel btnpane = new JPanel();
            GridLayout btnlay = new GridLayout(5, 1, 0, 5);
            btnpane.setLayout(btnlay);
            layout.setConstraints(btnpane, constr);
            pane.add(btnpane);
            // Button add column
            addbtn = new JButton();
            // NOI18N
            Mnemonics.setLocalizedText(addbtn, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableAddButtonreplacedle"));
            addbtn.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableAddButtonreplacedleA11yDesc"));
            btnpane.add(addbtn);
            addbtn.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    ColumnItem columnItem = AddTableColumnDialog.showDialog(spec, null);
                    if (columnItem != null) {
                        DataModel model = (DataModel) table.getModel();
                        model.addRow(columnItem);
                    }
                }
            });
            // Button edit column
            editBtn = new JButton();
            // NOI18N
            Mnemonics.setLocalizedText(editBtn, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableEditButtonreplacedle"));
            // NOI18N
            editBtn.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableEditButtonreplacedleA11yDesc"));
            btnpane.add(editBtn);
            editBtn.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    int selectedIndex = table.getSelectedRow();
                    if (selectedIndex != -1) {
                        ColumnItem selectedColumnItem = ((DataModel) table.getModel()).getRow(selectedIndex);
                        ColumnItem columnItemModified = AddTableColumnDialog.showDialog(spec, selectedColumnItem);
                        if (columnItemModified != null) {
                            DataModel model = (DataModel) table.getModel();
                            model.removeRow(selectedIndex);
                            model.insertRow(selectedIndex, columnItemModified);
                        }
                    }
                }
            });
            // Button delete column
            delbtn = new JButton();
            // NOI18N
            Mnemonics.setLocalizedText(delbtn, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableRemoveButtonreplacedle"));
            // NOI18N
            delbtn.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableRemoveButtonreplacedleA11yDesc"));
            btnpane.add(delbtn);
            delbtn.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    int idx = table.getSelectedRow();
                    if (idx != -1) {
                        ((DataModel) table.getModel()).removeRow(idx);
                    }
                }
            });
            // Button to move row up
            upBtn = new JButton();
            // NOI18N
            Mnemonics.setLocalizedText(upBtn, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableUpButtonreplacedle"));
            // NOI18N
            upBtn.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableUpButtonreplacedleA11yDesc"));
            btnpane.add(upBtn);
            upBtn.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    int idx = table.getSelectedRow();
                    if (idx > 0) {
                        DataModel dm = (DataModel) table.getModel();
                        ColumnItem ci = dm.getRow(idx);
                        dm.removeRow(idx);
                        dm.insertRow(idx - 1, ci);
                        table.getSelectionModel().setSelectionInterval(idx - 1, idx - 1);
                    }
                }
            });
            // Button to move row down
            downBtn = new JButton();
            // NOI18N
            Mnemonics.setLocalizedText(downBtn, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableDownButtonreplacedle"));
            // NOI18N
            downBtn.setToolTipText(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableDownButtonreplacedleA11yDesc"));
            btnpane.add(downBtn);
            downBtn.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    int idx = table.getSelectedRow();
                    if (idx < table.getRowCount() - 1) {
                        DataModel dm = (DataModel) table.getModel();
                        ColumnItem ci = dm.getRow(idx);
                        dm.removeRow(idx);
                        dm.insertRow(idx + 1, ci);
                        table.getSelectionModel().setSelectionInterval(idx + 1, idx + 1);
                    }
                }
            });
            ActionListener listener = new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent event) {
                    final ActionEvent evt = event;
                    if (evt.getSource() == DialogDescriptor.OK_OPTION) {
                        try {
                            final String tablename = getTableName();
                            final DataModel dataModel = (DataModel) table.getModel();
                            final List<ColumnItem> data = dataModel.getData();
                            boolean wasException = DbUtilities.doWithProgress(null, new Callable<Boolean>() {

                                @Override
                                public Boolean call() throws Exception {
                                    CreateTableDDL ddl = new CreateTableDDL(spec, schema, tablename);
                                    return ddl.execute(data, dataModel.getTablePrimaryKeys());
                                }
                            });
                            // was execution of commands with or without exception?
                            if (!wasException) {
                                // dialog is closed after successfully create table
                                dialog.setVisible(false);
                                dialog.dispose();
                            }
                        // dialog is not closed after unsuccessfully create table
                        } catch (InvocationTargetException e) {
                            Throwable cause = e.getCause();
                            if (cause instanceof DDLException) {
                                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
                            } else {
                                LOGGER.log(Level.INFO, cause.getLocalizedMessage(), cause);
                                DbUtilities.reportError(NbBundle.getMessage(CreateTableDialog.clreplaced, "ERR_UnableToCreateTable"), e.getMessage());
                            }
                        }
                    }
                }
            };
            // NOI18N
            pane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CreateTableDialog.clreplaced, "ACS_CreateTableDialogA11yDesc"));
            // NOI18N
            descriptor = new DialogDescriptor(pane, NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableDialogreplacedle"), true, listener);
            // NOI18N
            descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.db.explorer.actions.CreateTableAction"));
            statusLine = descriptor.createNotificationLineSupport();
            // inbuilt close of the dialog is only after CANCEL button click
            // after OK button is dialog closed by hand
            Object[] closingOptions = { DialogDescriptor.CANCEL_OPTION };
            descriptor.setClosingOptions(closingOptions);
            dialog = DialogDisplayer.getDefault().createDialog(descriptor);
            dialog.setResizable(true);
            validate();
        } catch (MissingResourceException ex) {
            LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
        }
    }

    /**
     *  Shows Create Table dialog and creates a new table in specified schema.
     * @param spec DB specification
     * @param schema DB schema to create table in
     * @return true if new table successfully created, false if cancelled
     */
    public static boolean showDialogAndCreate(final BaseNode node, final String schema) {
        final CreateTableDialog dlg = new CreateTableDialog(node, schema);
        dlg.dialog.setVisible(true);
        if (dlg.descriptor.getValue() == DialogDescriptor.OK_OPTION) {
            return true;
        }
        return false;
    }

    private String getTableUnreplacedledName() {
        // NOI18N
        final String nameBase = NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableUnreplacedledName");
        String name = nameBase;
        int counter = 1;
        boolean existsSameTableName;
        do {
            existsSameTableName = false;
            for (Node node : tablesNode.getChildNodes()) {
                if (node instanceof TableNode && node.getName().equalsIgnoreCase(name)) {
                    counter++;
                    name = nameBase + counter;
                    existsSameTableName = true;
                }
            }
        } while (existsSameTableName);
        return name;
    }

    private String getTableName() {
        return dbnamefield.getText();
    }

    /**
     * Validate and update state of UI.
     */
    private void validate() {
        // NOI18N
        replacedert statusLine != null : "Notification status line not available";
        int selectedIndex = table.getSelectedRow();
        boolean oneRowSelected = table.getSelectedRowCount() == 1;
        editBtn.setEnabled(oneRowSelected);
        delbtn.setEnabled(oneRowSelected);
        upBtn.setEnabled(oneRowSelected && selectedIndex > 0);
        downBtn.setEnabled(oneRowSelected && selectedIndex < table.getRowCount() - 1);
        String tname = getTableName();
        if (tname == null || tname.length() < 1) {
            statusLine.setInformationMessage(NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableMissingTableName"));
            updateOK(false);
            return;
        }
        if (table.getModel().getRowCount() == 0) {
            statusLine.setInformationMessage(NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTableNoColumns"));
            updateOK(false);
            return;
        }
        statusLine.clearMessages();
        updateOK(true);
    }

    /**
     * Updates OK button.
     */
    private void updateOK(boolean valid) {
        if (descriptor != null) {
            descriptor.setValid(valid);
        }
    }

    clreplaced DataTable extends JTable {

        static final long serialVersionUID = 1222037401669064863L;

        public DataTable(TableModel model) {
            super(model);
            setSurrendersFocusOnKeystroke(true);
            TableColumnModel cmodel = getColumnModel();
            int i;
            int ccount = model.getColumnCount();
            int columnWidth;
            int preferredWidth;
            String columnName;
            int width = 0;
            for (i = 0; i < ccount; i++) {
                TableColumn col = cmodel.getColumn(i);
                Map cmap = ColumnItem.getColumnProperty(i);
                // NOI18N
                col.setIdentifier(cmap.get("name"));
                // NOI18N
                columnName = NbBundle.getMessage(CreateTableDialog.clreplaced, "CreateTable_" + i);
                columnWidth = (new Double(getFontMetrics(getFont()).getStringBounds(columnName, getGraphics()).getWidth())).intValue() + 20;
                if (cmap.containsKey("width")) {
                    // NOI18N
                    if (((Integer) cmap.get("width")).intValue() < columnWidth)
                        col.setPreferredWidth(columnWidth);
                    else
                        // NOI18N
                        col.setPreferredWidth(((Integer) cmap.get("width")).intValue());
                    preferredWidth = col.getPreferredWidth();
                }
                if (// NOI18N
                cmap.containsKey("minwidth"))
                    if (((Integer) cmap.get("minwidth")).intValue() < columnWidth)
                        col.setMinWidth(columnWidth);
                    else
                        // NOI18N
                        col.setMinWidth(((Integer) cmap.get("minwidth")).intValue());
                // if (cmap.containsKey("alignment")) {}
                // if (cmap.containsKey("tip")) ((JComponent)col.getCellRenderer()).setToolTipText((String)cmap.get("tip"));
                if (i < 7) {
                    // the first 7 columns should be visible
                    width += col.getPreferredWidth();
                }
            }
            width = Math.min(Math.max(width, 380), Toolkit.getDefaultToolkit().getScreenSize().width - 100);
            setPreferredScrollableViewportSize(new Dimension(width, 150));
        }
    }
}