Example usage for javax.swing JLabel setEnabled

List of usage examples for javax.swing JLabel setEnabled

Introduction

In this page you can find the example usage for javax.swing JLabel setEnabled.

Prototype

@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether or not this component is enabled.

Usage

From source file:gui.GW2EventerGui.java

/**
 * Creates new form GW2EventerGui/*from   w w w  . j  a  v a  2 s.  c o m*/
 */
public GW2EventerGui() {

    this.guiIcon = new ImageIcon(ClassLoader.getSystemResource("media/icon.png")).getImage();

    if (System.getProperty("os.name").startsWith("Windows")) {
        this.OS = "Windows";
        this.isWindows = true;
    } else {
        this.OS = "Other";
        this.isWindows = false;
    }

    if (this.isWindows == true) {
        this.checkIniDir();
    }

    initComponents();

    this.speakQueue = new LinkedList();

    this.speakRunnable = new Runnable() {

        @Override
        public void run() {

            String path = System.getProperty("user.home") + "\\.gw2eventer";
            File f;
            String sentence;

            while (!speakQueue.isEmpty()) {

                f = new File(path + "\\tts.vbs");

                if (!f.exists() && !f.isDirectory()) {

                    sentence = (String) speakQueue.poll();

                    try {

                        Writer writer = new OutputStreamWriter(
                                new FileOutputStream(
                                        System.getProperty("user.home") + "\\.gw2eventer\\tts.vbs"),
                                "ISO-8859-15");
                        BufferedWriter fout = new BufferedWriter(writer);

                        fout.write("Dim Speak");
                        fout.newLine();
                        fout.write("Set Speak=CreateObject(\"sapi.spvoice\")");
                        fout.newLine();
                        fout.write("Speak.Speak \"" + sentence + "\"");

                        fout.close();

                        Runtime rt = Runtime.getRuntime();

                        try {
                            if (sentence.length() > 0) {
                                Process p = rt.exec(System.getProperty("user.home") + "\\.gw2eventer\\tts.bat");
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    };

    this.matchIds = new HashMap();
    this.matchId = "2-6";
    this.matchIdColor = "green";

    this.jLabelNewVersion.setVisible(false);
    this.updateInformed = false;

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(screenSize.width / 2 - this.getSize().width / 2,
            (screenSize.height / 2 - this.getSize().height / 2) - 20);

    double width = screenSize.getWidth();
    double height = screenSize.getHeight();

    if ((width == 1280) && (height == 720 || height == 768 || height == 800)) {
        this.setExtendedState(this.MAXIMIZED_BOTH);
        //this.setLocation(0, 0);
    }

    JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) this.jSpinnerRefreshTime.getEditor();
    DefaultFormatter formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);

    /*
     jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayX.getEditor();
     formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
     formatter.setAllowsInvalid(false);
            
     jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayY.getEditor();
     formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
     formatter.setAllowsInvalid(false);
     */
    this.workingButton = this.jButtonRefresh;
    this.refreshSelector = this.jCheckBoxAutoRefresh;

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {

            apiManager.saveSettingstoFile();
            System.exit(0);
        }
    });

    this.pushGui = new PushGui(this, true, "", "");
    this.pushGui.setIconImage(guiIcon);

    this.donateGui = new DonateGui(this, true);
    this.donateGui.setIconImage(guiIcon);

    this.infoGui = new InfoGui(this, true);
    this.infoGui.setIconImage(guiIcon);

    this.feedbackGui = new FeedbackGui(this, true);
    this.feedbackGui.setIconImage(guiIcon);

    this.overlayGui = new OverlayGui(this);
    this.initOverlayGui();

    this.settingsOverlayGui = new SettingsOverlayGui(this);
    this.initSettingsOverlayGui();

    this.wvwOverlayGui = new WvWOverlayGui(this);
    this.initWvwOverlayGui();

    this.language = "en";
    this.worldID = "2206"; //Millersund [DE]

    this.setTranslations();

    this.eventLabels = new ArrayList();
    this.eventLabelsTimer = new ArrayList();

    this.homeWorlds = new HashMap();

    this.preventSystemSleep = true;

    for (int i = 1; i <= EVENT_COUNT; i++) {

        try {

            Field f = getClass().getDeclaredField("labelEvent" + i);
            JLabel l = (JLabel) f.get(this);
            l.setPreferredSize(new Dimension(70, 28));
            //l.setToolTipText("");

            //int width2 = l.getX();
            //int height2 = l.getY();
            //System.out.println("$coords .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";");
            this.eventLabels.add(l);

            final int ii = i;

            l.addMouseListener(new java.awt.event.MouseAdapter() {
                @Override
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    showSoundSelector(ii);
                }
            });

            f = getClass().getDeclaredField("labelTimer" + i);
            l = (JLabel) f.get(this);
            l.setEnabled(true);
            l.setVisible(false);
            l.setForeground(Color.green);

            //int width2 = l.getX();
            //int height2 = l.getY();
            //System.out.println("$coords2 .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";");
            this.eventLabelsTimer.add(l);

        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
                | IllegalAccessException ex) {
            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    int[] disabledEvents = { 6, 8, 11, 12, 17, 18, 19, 20, 21, 22 };

    for (int i = 0; i < disabledEvents.length; i++) {

        Field f;
        JLabel l;

        try {
            f = getClass().getDeclaredField("labelEvent" + disabledEvents[i]);
            l = (JLabel) f.get(this);
            l.setEnabled(false);
            l.setVisible(false);

            f = getClass().getDeclaredField("labelTimer" + disabledEvents[i]);
            l = (JLabel) f.get(this);
            l.setEnabled(false);
            l.setVisible(false);
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
                | IllegalAccessException ex) {
            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    this.lastPush = new Date();

    if (this.apiManager == null) {

        this.apiManager = new ApiManager(this, this.jSpinnerRefreshTime, this.jCheckBoxAutoRefresh.isSelected(),
                this.eventLabels, this.language, this.worldID, this.homeWorlds, this.jComboBoxHomeWorld,
                this.jLabelServer, this.jLabelWorking, this.jCheckBoxPlaySounds.isSelected(),
                this.workingButton, this.refreshSelector, this.eventLabelsTimer, this.jComboBoxLanguage,
                this.overlayGui, this.jCheckBoxWvWOverlay);
    }

    //this.wvwMatchReader = new WvWMatchReader(this.matchIds, this.jCheckBoxWvW);
    //this.wvwMatchReader.start();
    this.preventSleepMode();
    this.runUpdateService();
    this.runPushService();
    this.runTips();
    //this.runTest();
}

From source file:Interfaz.rubiktimer.java

private void funcionalidad_botones(JLabel nuev_tiempo, JLabel scrambl, JButton elim, JButton penaliz,
        JButton dnf) {/*from   w  w  w .  j av  a2  s  .co m*/

    elim.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            System.out.println("///" + nuev_tiempo.getText() + "///");
            listaT.eliminar(tiempo, nuev_tiempo.getText());
            lista5mej.eliminar(tiempo, nuev_tiempo.getText());
            lista10mej.eliminar(tiempo, nuev_tiempo.getText());
            //lista5mej.actualizar5(lista5mej,listaT);
            //lista10mej.actualizar10(lista10mej,listaT);
            panel.remove(nuev_tiempo);
            panel.remove(scrambl);
            panel.remove(penaliz);
            panel.remove(elim);
            panel.remove(dnf);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();

        }

    });
    penaliz.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            lista5mej.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            listaT.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            lista10mej.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            penaliz.setEnabled(false);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();
        }

    });
    dnf.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            listaT.eliminar(tiempo, nuev_tiempo.getText());
            lista5mej.eliminar(tiempo, nuev_tiempo.getText());
            lista10mej.eliminar(tiempo, nuev_tiempo.getText());
            nuev_tiempo.setEnabled(false);
            scrambl.setEnabled(false);
            elim.setEnabled(false);
            penaliz.setEnabled(false);
            dnf.setEnabled(false);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();
        }

    });

}

From source file:edu.ku.brc.af.auth.UserAndMasterPasswordMgr.java

/**
 * Displays a dialog used for editing the Master Username and Password.
 * @param isLocal whether u/p is stored locally or not
 * @param usrName//from  w w  w  .j a  v  a 2 s.c  o  m
 * @param dbName
 * @param masterPath the path to the password
 * @return whether to ask for the information because it wasn't found
 */
protected boolean askForInfo(final Boolean isLocal, final String usrName, final String dbName,
        final String masterPath) {
    loadAndPushResourceBundle("masterusrpwd");

    FormLayout layout = new FormLayout("p, 2px, f:p:g, 4px, p, 4px, p, 4px, p", "p,2px,p,2px,p,2dlu,p,2dlu,p");

    PanelBuilder pb = new PanelBuilder(layout);
    pb.setDefaultDialogBorder();

    ButtonGroup group = new ButtonGroup();
    final JRadioButton isNetworkRB = new JRadioButton(getResourceString("IS_NET_BASED"));
    final JRadioButton isPrefBasedRB = new JRadioButton(getResourceString("IS_ENCRYPTED_KEY"));
    isPrefBasedRB.setSelected(true);
    group.add(isNetworkRB);
    group.add(isPrefBasedRB);

    final JTextField keyTxt = createTextField(35);
    final JTextField urlTxt = createTextField(35);
    final JLabel keyLbl = createI18NFormLabel("ENCRYPTED_USRPWD");
    final JLabel urlLbl = createI18NFormLabel("URL");
    final JButton createBtn = createI18NButton("CREATE_KEY");

    final JButton copyCBBtn = createIconBtn("ClipboardCopy", IconManager.IconSize.Std24, "CPY_TO_CB_TT", null);
    final JButton pasteCBBtn = createIconBtn("ClipboardPaste", IconManager.IconSize.Std24, "CPY_FROM_CB_TT",
            null);

    // retrieves the encrypted key for the current settings in the dialog
    String dbNameFromForm = AppPreferences.getLocalPrefs().get("login.databases_selected", null);
    if (isNotEmpty(dbNameFromForm) && isNotEmpty(usersUserName)) {
        String masterKey = getMasterPrefPath(usersUserName, dbNameFromForm, true);
        if (isNotEmpty(masterKey)) {
            String encryptedKey = AppPreferences.getLocalPrefs().get(masterKey, null);
            if (isNotEmpty(encryptedKey) && !encryptedKey.startsWith("http")) {
                keyTxt.setText(encryptedKey);
            }
        }
    }

    CellConstraints cc = new CellConstraints();

    int y = 1;
    pb.add(createI18NFormLabel("MASTER_LOC"), cc.xywh(1, y, 1, 3));
    pb.add(isPrefBasedRB, cc.xy(3, y));
    y += 2;
    pb.add(isNetworkRB, cc.xy(3, y));
    y += 2;

    pb.addSeparator("", cc.xyw(1, y, 9));
    y += 2;
    pb.add(keyLbl, cc.xy(1, y));
    pb.add(keyTxt, cc.xy(3, y));
    pb.add(createBtn, cc.xy(5, y));
    pb.add(copyCBBtn, cc.xy(7, y));
    pb.add(pasteCBBtn, cc.xy(9, y));
    y += 2;

    pb.add(urlLbl, cc.xy(1, y));
    pb.add(urlTxt, cc.xy(3, y));
    y += 2;

    boolean isEditMode = isLocal != null && isNotEmpty(masterPath);
    if (isEditMode) {
        isPrefBasedRB.setSelected(isLocal);
        if (isLocal) {
            keyTxt.setText(masterPath);
        } else {
            urlTxt.setText(masterPath);
        }
    }

    copyCBBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Copy to Clipboard
            UIHelper.setTextToClipboard(keyTxt.getText());
        }
    });

    pasteCBBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            keyTxt.setText(UIHelper.getTextFromClipboard());
        }
    });

    final CustomDialog dlg = new CustomDialog((Frame) null, getResourceString("MASTER_TITLE"), true,
            CustomDialog.OKCANCELHELP, pb.getPanel());
    if (!isEditMode) {
        dlg.setOkLabel(getResourceString("CONT"));
        dlg.setCancelLabel(getResourceString("BACK"));
    }
    dlg.setHelpContext("MASTERPWD_MAIN");
    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);
    urlLbl.setEnabled(false);
    urlTxt.setEnabled(false);
    copyCBBtn.setEnabled(true);
    pasteCBBtn.setEnabled(true);

    DocumentListener dl = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            dlg.getOkBtn().setEnabled((isPrefBasedRB.isSelected() && !keyTxt.getText().isEmpty())
                    || (isNetworkRB.isSelected() && !urlTxt.getText().isEmpty()));
        }
    };
    keyTxt.getDocument().addDocumentListener(dl);
    urlTxt.getDocument().addDocumentListener(dl);

    ChangeListener chgListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            boolean isNet = isNetworkRB.isSelected();
            keyLbl.setEnabled(!isNet);
            keyTxt.setEnabled(!isNet);
            createBtn.setEnabled(!isNet);
            copyCBBtn.setEnabled(!isNet);
            pasteCBBtn.setEnabled(!isNet);
            urlLbl.setEnabled(isNet);
            urlTxt.setEnabled(isNet);
            dlg.getOkBtn().setEnabled((isPrefBasedRB.isSelected() && !keyTxt.getText().isEmpty())
                    || (isNetworkRB.isSelected() && !urlTxt.getText().isEmpty()));
        }
    };

    isNetworkRB.addChangeListener(chgListener);
    isPrefBasedRB.addChangeListener(chgListener);

    boolean isPref = AppPreferences.getLocalPrefs().getBoolean(getIsLocalPrefPath(usrName, dbName, true), true);
    isNetworkRB.setSelected(!isPref);
    isPrefBasedRB.setSelected(isPref);

    createBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String[] keys = getUserNamePasswordKey();
            if (keys != null && keys.length == 4) {
                String encryptedStr = encrypt(keys[0], keys[1], keys[3]);
                if (encryptedStr != null) {
                    keyTxt.setText(encryptedStr);
                    dlg.getOkBtn().setEnabled(true);

                    usersUserName = keys[2];
                }
            }
        }
    });

    popResourceBundle();

    dlg.setVisible(true);

    if (!dlg.isCancelled()) {
        String value;
        if (isNetworkRB.isSelected()) {
            value = StringEscapeUtils.escapeHtml(urlTxt.getText());
        } else {
            value = keyTxt.getText();
        }

        AppPreferences.getLocalPrefs().putBoolean(getIsLocalPrefPath(usrName, dbName, true),
                !isNetworkRB.isSelected());
        AppPreferences.getLocalPrefs().put(getMasterPrefPath(usrName, dbName, true), value);
        return true;
    }
    return false;
}

From source file:com.pianobakery.complsa.MainGui.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*from w  w w .  j  a  v a  2 s  .  co m*/
 */
private void $$$setupUI$$$() {
    createUIComponents();
    mainPanel = new JPanel();
    mainPanel.setLayout(new FormLayout("fill:max(m;620px):grow", "center:max(m;600px):grow"));
    tabbedPane1 = new JTabbedPane();
    tabbedPane1.setEnabled(true);
    CellConstraints cc = new CellConstraints();
    mainPanel.add(tabbedPane1, cc.xy(1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
    setupPanel = new JPanel();
    setupPanel.setLayout(new FormLayout(
            "fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:126px:noGrow,fill:max(d;4px):noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:5dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:52px:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:d:grow,fill:d:grow,fill:d:grow,fill:66px:noGrow",
            "center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:d:noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow"));
    tabbedPane1.addTab("Project", setupPanel);
    newFolderButton = new JButton();
    newFolderButton.setText("New Folder");
    setupPanel.add(newFolderButton, cc.xy(1, 5));
    final JLabel label1 = new JLabel();
    label1.setText("Project Folder:");
    setupPanel.add(label1, cc.xy(1, 1, CellConstraints.LEFT, CellConstraints.DEFAULT));
    selectFolderButton = new JButton();
    selectFolderButton.setText("Select Folder");
    setupPanel.add(selectFolderButton, cc.xy(5, 5));
    wDirText = new JTextField();
    wDirText.setEditable(false);
    wDirText.setText("Create or select Project Folder");
    setupPanel.add(wDirText, cc.xyw(7, 5, 48, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JLabel label2 = new JLabel();
    label2.setText("The Project Folder contains all the Project Data.");
    setupPanel.add(label2, cc.xyw(1, 3, 54));
    final JLabel label3 = new JLabel();
    label3.setText("Arrange your Documents in a Folder. Then add it to the Software.");
    setupPanel.add(label3, cc.xyw(1, 15, 54));
    downloadModelButton = new JButton();
    downloadModelButton.setText("Download Models");
    setupPanel.add(downloadModelButton, cc.xy(1, 9));
    final JLabel label4 = new JLabel();
    label4.setText("Language Models:");
    setupPanel.add(label4, cc.xy(5, 9));
    langModelsText = new JLabel();
    langModelsText.setText("");
    setupPanel.add(langModelsText, cc.xyw(7, 9, 48));
    trainCorpButton = new JButton();
    trainCorpButton.setText("Train Semantics");
    setupPanel.add(trainCorpButton, cc.xy(1, 33, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JLabel label5 = new JLabel();
    label5.setText("Create Semantic Knowledge with selected Training Corpus:");
    setupPanel.add(label5, cc.xyw(1, 25, 7));
    addTopicCorpusButton = new JButton();
    addTopicCorpusButton.setEnabled(true);
    addTopicCorpusButton.setText(" Add Corpus Folder");
    setupPanel.add(addTopicCorpusButton, cc.xy(1, 19));
    addCorpRecursiveCheckBox = new JCheckBox();
    addCorpRecursiveCheckBox.setSelected(true);
    addCorpRecursiveCheckBox.setText("Recursive");
    setupPanel.add(addCorpRecursiveCheckBox, cc.xy(5, 19));
    createChunksCheckBox = new JCheckBox();
    createChunksCheckBox.setSelected(true);
    createChunksCheckBox.setText("Split in Paragraph of:");
    setupPanel.add(createChunksCheckBox, cc.xy(7, 19));
    final JLabel label6 = new JLabel();
    label6.setText("Add/Remove Training Corpus:");
    setupPanel.add(label6, cc.xyw(1, 17, 5));
    final JLabel label7 = new JLabel();
    label7.setText("Select Training Corpus:");
    setupPanel.add(label7, cc.xyw(1, 21, 54));
    selectTrainCorp = new JComboBox();
    selectTrainCorp.setEnabled(true);
    setupPanel.add(selectTrainCorp, cc.xyw(1, 23, 5));
    removeTopicCorpusButton = new JButton();
    removeTopicCorpusButton.setEnabled(true);
    removeTopicCorpusButton.setHorizontalAlignment(2);
    removeTopicCorpusButton.setText("Remove Training Corpus");
    setupPanel.add(removeTopicCorpusButton, cc.xy(7, 23));
    setupPanel.add(indexTypeComboBox, cc.xy(7, 33));
    amountOfSentencesPerTextField = new JTextField();
    amountOfSentencesPerTextField.setHorizontalAlignment(2);
    amountOfSentencesPerTextField.setText("20");
    setupPanel.add(amountOfSentencesPerTextField,
            cc.xyw(9, 19, 6, CellConstraints.FILL, CellConstraints.DEFAULT));
    posIndRadiusTextField = new JTextField();
    posIndRadiusTextField.setHorizontalAlignment(2);
    posIndRadiusTextField.setText("20");
    setupPanel.add(posIndRadiusTextField, cc.xyw(9, 33, 6, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JLabel label8 = new JLabel();
    label8.setText("Indextype:");
    setupPanel.add(label8, cc.xy(5, 33, CellConstraints.RIGHT, CellConstraints.DEFAULT));
    final JLabel label9 = new JLabel();
    label9.setHorizontalAlignment(2);
    label9.setText("Sentences");
    setupPanel.add(label9, cc.xy(15, 19));
    final JLabel label10 = new JLabel();
    label10.setHorizontalAlignment(2);
    label10.setText("Words");
    setupPanel.add(label10, cc.xy(15, 33));
    setupPanel.add(termComboBox, cc.xyw(31, 33, 19));
    final JLabel label11 = new JLabel();
    label11.setText("Termweight:");
    setupPanel.add(label11, cc.xyw(18, 33, 13));
    updateIndexButton = new JButton();
    updateIndexButton.setText("Update Index");
    setupPanel.add(updateIndexButton, cc.xy(1, 29));
    removeIndexButton = new JButton();
    removeIndexButton.setText("Remove Index");
    setupPanel.add(removeIndexButton, cc.xy(5, 29));
    final JLabel label12 = new JLabel();
    label12.setText("Add/Remove Search Corpus:");
    setupPanel.add(label12, cc.xyw(1, 41, 5));
    impSearchCorpButton = new JButton();
    impSearchCorpButton.setText("Add Search Corpus");
    setupPanel.add(impSearchCorpButton, cc.xy(1, 43));
    impSearchCorpRecursiveCheckBox = new JCheckBox();
    impSearchCorpRecursiveCheckBox.setSelected(true);
    impSearchCorpRecursiveCheckBox.setText("Recursive");
    setupPanel.add(impSearchCorpRecursiveCheckBox, cc.xy(5, 43));
    splitSearchCorpCheckBox = new JCheckBox();
    splitSearchCorpCheckBox.setSelected(true);
    splitSearchCorpCheckBox.setText("Split in Paragraph of:");
    setupPanel.add(splitSearchCorpCheckBox, cc.xy(7, 43));
    amountSearchCorpSent = new JTextField();
    amountSearchCorpSent.setHorizontalAlignment(2);
    amountSearchCorpSent.setText("20");
    setupPanel.add(amountSearchCorpSent, cc.xyw(9, 43, 6, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JLabel label13 = new JLabel();
    label13.setHorizontalAlignment(2);
    label13.setText("Sentences");
    setupPanel.add(label13, cc.xy(15, 43));
    searchCorpComboBox = new JComboBox();
    setupPanel.add(searchCorpComboBox, cc.xyw(1, 47, 5, CellConstraints.DEFAULT, CellConstraints.TOP));
    removeSearchCorpButton = new JButton();
    removeSearchCorpButton.setText("Remove Search Corpus");
    setupPanel.add(removeSearchCorpButton, cc.xy(7, 47));
    final JLabel label14 = new JLabel();
    label14.setText("Select Search Corpus:");
    setupPanel.add(label14, cc.xyw(1, 45, 5));
    final JLabel label15 = new JLabel();
    label15.setText("Arrange your Search Corpus in a Folder. Then add it to the Software. ");
    setupPanel.add(label15, cc.xyw(1, 39, 54));
    final JLabel label16 = new JLabel();
    label16.setText("First update the Index.");
    setupPanel.add(label16, cc.xyw(1, 27, 5));
    final JLabel label17 = new JLabel();
    label17.setText(
            "Then select an Algorithm and train the Software. On the Search Tab you can select the Algorithms to run your semantic searches.");
    setupPanel.add(label17, cc.xyw(1, 31, 54));
    final JLabel label18 = new JLabel();
    label18.setText("Download Language Models:");
    setupPanel.add(label18, cc.xyw(1, 7, 54));
    final JLabel label19 = new JLabel();
    label19.setText("Training Corpora:");
    setupPanel.add(label19, cc.xyw(1, 13, 54));
    final JLabel label20 = new JLabel();
    label20.setText("Search Corpora:");
    setupPanel.add(label20, cc.xyw(1, 37, 54));
    final JLabel label21 = new JLabel();
    label21.setEnabled(true);
    label21.setText(" ");
    setupPanel.add(label21, cc.xy(1, 11));
    final JLabel label22 = new JLabel();
    label22.setText(" ");
    setupPanel.add(label22, cc.xy(1, 35));
    searchDocs = new JPanel();
    searchDocs.setLayout(new FormLayout(
            "left:4dlu:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:277px:noGrow,left:4dlu:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(m;400px):grow,left:4dlu:noGrow,fill:max(m;200px):grow",
            "center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,top:3dlu:noGrow,center:d:noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:243px:grow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:38px:noGrow,top:3dlu:noGrow"));
    searchDocs.setEnabled(true);
    tabbedPane1.addTab("Search", searchDocs);
    final JLabel label23 = new JLabel();
    label23.setText("Choose Semantic Knowledge Algorithm:");
    searchDocs.add(label23, cc.xyw(3, 1, 5));
    final JLabel label24 = new JLabel();
    label24.setText("Enter Search Text or select Search Document:");
    searchDocs.add(label24, cc.xyw(3, 20, 5));
    final JLabel label25 = new JLabel();
    label25.setText("Document Search Results:");
    searchDocs.add(label25, cc.xyw(10, 1, 3));
    final JLabel label26 = new JLabel();
    label26.setText("Selection Metadata:");
    searchDocs.add(label26, cc.xyw(10, 27, 3));
    selectIndexTypeComboBox = new JComboBox();
    searchDocs.add(selectIndexTypeComboBox, cc.xyw(7, 10, 3));
    final JLabel label27 = new JLabel();
    label27.setText("Index Type:");
    searchDocs.add(label27, cc.xy(7, 8));
    final JLabel label28 = new JLabel();
    label28.setText("Termweight:");
    searchDocs.add(label28, cc.xy(7, 12));
    selectTermweightComboBox = new JComboBox();
    searchDocs.add(selectTermweightComboBox, cc.xy(7, 14));
    final JLabel label29 = new JLabel();
    label29.setText("Number of search results:");
    searchDocs.add(label29, cc.xy(7, 16));
    noOfSearchResultsText = new JTextField();
    noOfSearchResultsText.setText("20");
    searchDocs.add(noOfSearchResultsText, cc.xy(7, 18, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JScrollPane scrollPane1 = new JScrollPane();
    searchDocs.add(scrollPane1, cc.xywh(7, 22, 1, 2, CellConstraints.FILL, CellConstraints.FILL));
    searchTextArea = new JTextArea();
    searchTextArea.setLineWrap(true);
    searchTextArea.setText("");
    searchTextArea.setWrapStyleWord(true);
    scrollPane1.setViewportView(searchTextArea);
    selTextRadioButton = new JRadioButton();
    selTextRadioButton.setSelected(true);
    selTextRadioButton.setText("");
    searchDocs.add(selTextRadioButton, cc.xy(5, 22));
    algTextField = new JLabel();
    algTextField.setText("Knowledge Corpus: null");
    searchDocs.add(algTextField, cc.xy(7, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
    selectDocumentButton = new JButton();
    selectDocumentButton.setEnabled(false);
    selectDocumentButton.setText("Select Document");
    searchDocs.add(selectDocumentButton, cc.xy(7, 25));
    selDocRadioButton = new JRadioButton();
    selDocRadioButton.setText("");
    searchDocs.add(selDocRadioButton, cc.xy(5, 25));
    final JLabel label30 = new JLabel();
    label30.setText("Select Corpus to Search:");
    searchDocs.add(label30, cc.xyw(3, 30, 5));
    searchTopCorpRadioButton = new JRadioButton();
    searchTopCorpRadioButton.setSelected(true);
    searchTopCorpRadioButton.setText("Topic Corpus");
    searchDocs.add(searchTopCorpRadioButton, cc.xy(7, 32, CellConstraints.DEFAULT, CellConstraints.TOP));
    searchSearchCorpRadioButton = new JRadioButton();
    searchSearchCorpRadioButton.setSelected(false);
    searchSearchCorpRadioButton.setText("Search Corpus");
    searchDocs.add(searchSearchCorpRadioButton, cc.xy(7, 34, CellConstraints.DEFAULT, CellConstraints.TOP));
    searchButton = new JButton();
    searchButton.setText("Search");
    searchDocs.add(searchButton, cc.xy(7, 36));
    final JScrollPane scrollPane2 = new JScrollPane();
    searchDocs.add(scrollPane2, cc.xywh(10, 30, 3, 7, CellConstraints.FILL, CellConstraints.FILL));
    metadataTextField = new JTextArea();
    metadataTextField.setEditable(false);
    scrollPane2.setViewportView(metadataTextField);
    termTablePane = new JScrollPane();
    termTablePane.setEnabled(true);
    termTablePane.setVerticalScrollBarPolicy(22);
    searchDocs.add(termTablePane, cc.xywh(14, 3, 1, 21, CellConstraints.FILL, CellConstraints.FILL));
    termSearchResTable.setAutoCreateRowSorter(true);
    termSearchResTable.setAutoResizeMode(2);
    termSearchResTable.setFillsViewportHeight(false);
    termSearchResTable.setForeground(new Color(-16777216));
    termTablePane.setViewportView(termSearchResTable);
    docTablePane = new JScrollPane();
    docTablePane.setVerticalScrollBarPolicy(22);
    searchDocs.add(docTablePane, cc.xywh(10, 3, 3, 21, CellConstraints.FILL, CellConstraints.FILL));
    docSearchResTable.setAutoCreateRowSorter(true);
    docTablePane.setViewportView(docSearchResTable);
    final JLabel label31 = new JLabel();
    label31.setText("Term Search Result:");
    searchDocs.add(label31, cc.xy(14, 1));
    searchDocValue = new JLabel();
    searchDocValue.setText("nothing selected");
    searchDocs.add(searchDocValue, cc.xyw(12, 25, 3, CellConstraints.LEFT, CellConstraints.DEFAULT));
    openSearchDocumentButton = new JButton();
    openSearchDocumentButton.setEnabled(false);
    openSearchDocumentButton.setText("Open Search Document");
    searchDocs.add(openSearchDocumentButton, cc.xy(10, 25, CellConstraints.LEFT, CellConstraints.DEFAULT));
}

From source file:be.agiv.security.demo.Main.java

private void invokeClaimsAwareService() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    JPanel contentPanel = new JPanel(gridBagLayout);

    final JLabel ipStsLabel = new JLabel("IP-STS:");
    gridBagConstraints.gridx = 0;//from   www.  j  av  a  2 s  .c o  m
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.ipadx = 5;
    gridBagLayout.setConstraints(ipStsLabel, gridBagConstraints);
    contentPanel.add(ipStsLabel);

    final JTextField ipStsTextField = new JTextField(
            "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13",
            60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(ipStsTextField, gridBagConstraints);
    contentPanel.add(ipStsTextField);

    JLabel realmLabel = new JLabel("Realm:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(realmLabel, gridBagConstraints);
    contentPanel.add(realmLabel);

    JTextField realmTextField = new JTextField(AGIVSecurity.BETA_REALM, 30);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(realmTextField, gridBagConstraints);
    contentPanel.add(realmTextField);

    final CredentialPanel credentialPanel = new CredentialPanel();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(credentialPanel, gridBagConstraints);
    contentPanel.add(credentialPanel);

    final JLabel rStsLabel = new JLabel("R-STS:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = 1;
    gridBagLayout.setConstraints(rStsLabel, gridBagConstraints);
    contentPanel.add(rStsLabel);

    final JTextField rStsTextField = new JTextField(
            "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13",
            60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(rStsTextField, gridBagConstraints);
    contentPanel.add(rStsTextField);

    JLabel serviceRealmLabel = new JLabel("Service realm:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(serviceRealmLabel, gridBagConstraints);
    contentPanel.add(serviceRealmLabel);

    JTextField serviceRealmTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_REALM, 60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(serviceRealmTextField, gridBagConstraints);
    contentPanel.add(serviceRealmTextField);

    JLabel urlLabel = new JLabel("Service URL:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(urlLabel, gridBagConstraints);
    contentPanel.add(urlLabel);

    JTextField urlTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_LOCATION, 60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(urlTextField, gridBagConstraints);
    contentPanel.add(urlTextField);

    final JCheckBox noWsPolicyCheckBox = new JCheckBox("WSDL without WS-Policy");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(noWsPolicyCheckBox, gridBagConstraints);
    contentPanel.add(noWsPolicyCheckBox);

    final JCheckBox useWsSecureConversationCheckBox = new JCheckBox("Use WS-SecureConversation");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(useWsSecureConversationCheckBox, gridBagConstraints);
    contentPanel.add(useWsSecureConversationCheckBox);

    final JCheckBox usePreviousSecurityCheckBox = new JCheckBox("Use previous AGIV Security");
    final JCheckBox cancelPreviousSecureConversationToken = new JCheckBox("Cancel previous conversation token");
    usePreviousSecurityCheckBox.setEnabled(null != this.agivSecurity);
    cancelPreviousSecureConversationToken.setEnabled(false);
    usePreviousSecurityCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            LOG.debug("use previous security: " + usePreviousSecurityCheckBox.isSelected());
            boolean newSecurity = !usePreviousSecurityCheckBox.isSelected();
            ipStsLabel.setEnabled(newSecurity);
            ipStsTextField.setEditable(newSecurity);
            credentialPanel.setEnabled(newSecurity);
            rStsLabel.setEnabled(newSecurity);
            rStsTextField.setEnabled(newSecurity);
            cancelPreviousSecureConversationToken.setEnabled(!newSecurity);
        }
    });
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(usePreviousSecurityCheckBox, gridBagConstraints);
    contentPanel.add(usePreviousSecurityCheckBox);

    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(cancelPreviousSecureConversationToken, gridBagConstraints);
    contentPanel.add(cancelPreviousSecureConversationToken);

    JPanel expiresPanel = new JPanel();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = 2;
    gridBagLayout.setConstraints(expiresPanel, gridBagConstraints);
    contentPanel.add(expiresPanel);

    JLabel expiresLabelLabel = new JLabel("Secure conversation token expires:");
    expiresLabelLabel.setEnabled(null != this.agivSecurity);
    expiresPanel.add(expiresLabelLabel);

    JLabel expiresLabel = new JLabel();
    expiresLabel.setEnabled(null != this.agivSecurity);
    expiresPanel.add(expiresLabel);
    if (null != this.agivSecurity) {
        if (false == this.agivSecurity.getSecureConversationTokens().isEmpty()) {
            SecurityToken secureConversationToken = this.agivSecurity.getSecureConversationTokens().values()
                    .iterator().next();
            expiresLabel.setText(secureConversationToken.getExpires().toString());
        }
    }

    int dialogResult = JOptionPane.showConfirmDialog(this, contentPanel, "Claims Aware Service",
            JOptionPane.OK_CANCEL_OPTION);
    if (dialogResult == JOptionPane.CANCEL_OPTION) {
        return;
    }

    final String location = urlTextField.getText();
    final String serviceRealm = serviceRealmTextField.getText();
    final String ipStsLocation = ipStsTextField.getText();
    final String rStsLocation = rStsTextField.getText();
    final String username = credentialPanel.getUsername();
    final String password = credentialPanel.getPassword();
    final File pkcs12File = credentialPanel.getPKCS12File();
    final String realm = realmTextField.getText();

    ExecutorService executor = Executors.newFixedThreadPool(1);
    FutureTask<ArrayOfClaimInfo> futureTask = new FutureTask<ArrayOfClaimInfo>(
            new Callable<ArrayOfClaimInfo>() {

                public ArrayOfClaimInfo call() throws Exception {
                    Service service;
                    if (noWsPolicyCheckBox.isSelected()) {
                        service = ClaimsAwareServiceFactory.getInstanceNoWSPolicy();
                    } else {
                        service = ClaimsAwareServiceFactory.getInstance();
                    }
                    IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature());
                    BindingProvider bindingProvider = (BindingProvider) iservice;

                    if (false == usePreviousSecurityCheckBox.isSelected()) {
                        if (null != username) {
                            Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm,
                                    username, password);
                        } else {
                            Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm,
                                    pkcs12File, password);
                        }
                        Main.this.agivSecurity.addSTSListener(Main.this);
                        if (Main.this.proxyEnable) {
                            agivSecurity.setProxy(Main.this.proxyHost, Main.this.proxyPort,
                                    Main.this.proxyType);
                        }
                    }
                    if (cancelPreviousSecureConversationToken.isSelected()) {
                        Main.this.agivSecurity.cancelSecureConversationTokens();
                    }
                    Main.this.agivSecurity.enable(bindingProvider, location,
                            useWsSecureConversationCheckBox.isSelected(), serviceRealm);

                    ArrayOfClaimInfo result = iservice.getData(0);
                    return result;
                }
            }) {

        @Override
        protected void done() {
            try {
                ArrayOfClaimInfo result = get();
                List<ClaimInfo> claims = result.getClaimInfo();
                StringBuffer message = new StringBuffer();
                for (ClaimInfo claim : claims) {
                    message.append(claim.getName());
                    message.append(" = ");
                    message.append(claim.getValue());
                    message.append("\n");
                }

                JOptionPane.showMessageDialog(Main.this, message.toString(), "Claims Aware Service Result",
                        JOptionPane.INFORMATION_MESSAGE);
            } catch (final Exception e) {
                try {
                    SwingUtilities.invokeAndWait(new Runnable() {

                        public void run() {
                            Main.this.statusBar.setErrorStatus(e.getMessage());
                        }
                    });
                } catch (Exception e1) {
                }
                showException(e);
            }
        }
    };
    executor.execute(futureTask);
}

From source file:org.nuclos.client.ui.collect.Chart.java

private void init(int iScrollPane) {
    contentPane.add(toolbar,/*from  w  w  w. j av  a 2 s.c om*/
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    JFreeChart chart = new JFreeChart(new Plot() {

        @Override
        public String getPlotType() {
            return null;
        }

        @Override
        public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3,
                PlotRenderingInfo arg4) {
        }
    });

    panel = new ChartPanel(chart, false, false, true, false, false);
    if (bFromProperties) {
        panel.setPopupMenu(null);
    }

    if (iScrollPane == -1)
        scrollPane.add(panel, BorderLayout.CENTER);
    else {
        ((JScrollPane) scrollPane).getViewport().setBackground(panel.getBackground());

        JLabel labCorner = new JLabel();
        labCorner.setEnabled(false);
        labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
        labCorner.setBackground(Color.LIGHT_GRAY);
        ((JScrollPane) scrollPane).setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

        if (iScrollPane != 2) { //both
            if (iScrollPane == 0) { // horizontal
                JPanel pnl = new ScrollPaneHeightTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane)
                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            } else if (iScrollPane == 1) { // vertical
                JPanel pnl = new ScrollPaneWidthTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            } else if (iScrollPane == -1) { // none
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            }
        } else {
            ((JScrollPane) scrollPane).getViewport().setView(panel);
        }
    }
}

From source file:base.BasePlayer.Main.java

void setMenuBar() {
    //filemenu.addMouseListener(this);

    //toolmenu.addMouseListener(this);
    filemenu = new JMenu("File");
    toolmenu = new JMenu("Tools");
    help = new JMenu("Help");
    about = new JMenu("About");
    menubar = new JMenuBar();
    //help.addMouseListener(this);
    exit = new JMenuItem("Exit");
    manual = new JButton("Online manual");
    manual.addActionListener(new ActionListener() {

        @Override//  ww w  .j a va  2s  . c  o  m
        public void actionPerformed(ActionEvent arg0) {
            Main.gotoURL("https://baseplayer.fi/BPmanual");
        }

    });
    //   opensamples = new JMenuItem("Add samples");
    zoomout = new JButton("Zoom out");
    back = new JButton("<<");
    forward = new JButton(">>");
    manage = new JButton("Variant Manager");
    openvcfs = new JMenuItem("Add VCFs", open);
    openbams = new JMenuItem("Add BAMs", open);
    average = new JMenuItem("Coverage calculator");
    update = new JMenuItem("Update");
    update.setVisible(false);
    errorlog = new JMenuItem("View log");
    //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki");

    addURL = new JMenu("Add from URL");
    urlField = new JTextField("Enter URL");
    addtracks = new JMenuItem("Add tracks");
    fromURL = new JMenuItem("Add track from URL");
    addcontrols = new JMenuItem("Add controls");
    pleiadesButton = new JMenuItem("PLEIADES");
    saveProject = new JMenuItem("Save project");
    saveProjectAs = new JMenuItem("Save project as...");
    openProject = new JMenuItem("Open project");
    clear = new JMenuItem("Clear data");
    clearMemory = new JMenuItem("Clean memory");
    //   welcome = new JMenuItem("Welcome screen");
    filemenu.add(openvcfs);
    filemenu.add(openbams);
    variantCaller = new JMenuItem("Variant Caller");
    tbrowser = new JMenuItem("Table Browser");
    bconvert = new JMenuItem("BED converter");
    peakCaller = new JMenuItem("Peak Caller");
    addtracks = new JMenuItem("Add tracks", open);
    filemenu.add(addtracks);
    addcontrols = new JMenuItem("Add controls", open);
    filemenu.add(addcontrols);
    filemenu.add(fromURL);
    if (pleiades) {
        pleiadesButton.setPreferredSize(buttonDimension);
        pleiadesButton.addActionListener(this);

        filemenu.add(pleiadesButton);
    }

    filemenu.add(new JSeparator());
    openProject = new JMenuItem("Open project", open);
    filemenu.add(openProject);
    saveProject = new JMenuItem("Save project", save);
    filemenu.add(saveProject);
    saveProjectAs = new JMenuItem("Save project as...", save);
    filemenu.add(saveProjectAs);
    filemenu.add(new JSeparator());
    filemenu.add(genome);
    filemenu.add(update);
    filemenu.add(clear);
    filemenu.add(new JSeparator());
    filemenu.add(exit);
    exit.addActionListener(this);
    menubar.add(filemenu);
    manage.addActionListener(this);
    manage.addMouseListener(this);
    update.addActionListener(this);
    average.addActionListener(this);
    average.setEnabled(false);
    average.setToolTipText("No bam/cram files opened");
    tbrowser.addActionListener(this);
    bconvert.addActionListener(this);
    toolmenu.add(tbrowser);
    toolmenu.add(average);
    toolmenu.add(variantCaller);
    toolmenu.add(bconvert);
    fromURL.addMouseListener(this);
    fromURL.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            final JPopupMenu menu = new JPopupMenu();
            final JTextField area = new JTextField();
            JButton add = new JButton("Fetch");
            JLabel label = new JLabel("Paste track URL below");
            JScrollPane menuscroll = new JScrollPane();
            add.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        String urltext = area.getText().trim();
                        Boolean size = true;
                        if (urltext.contains("pleiades")) {
                            openPleiades(urltext);
                            return;
                        }
                        if (!FileRead.isTrackFile(urltext)) {
                            showError("The file format is not supported.\n"
                                    + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error");
                            return;

                        }
                        if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig")
                                && !urltext.toLowerCase().endsWith(".bb")
                                && !urltext.toLowerCase().endsWith(".bigbed")) {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                menu.setVisible(false);
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {

                                SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url);
                                TabixReader tabixReader = null;
                                String index = null;

                                try {
                                    if (stream.length() / (double) 1048576 >= Settings.settings
                                            .get("bigFile")) {
                                        size = false;
                                    }
                                    tabixReader = new TabixReader(urltext, urltext + ".tbi", stream);

                                    index = urltext + ".tbi";
                                    testurl = new URL(index);
                                    huc = (HttpURLConnection) testurl.openConnection();
                                    huc.setRequestMethod("HEAD");
                                    responseCode = huc.getResponseCode();

                                    if (responseCode == 404) {
                                        menu.setVisible(false);
                                        Main.showError("Index file (.tbi) not found in the URL.", "Error");

                                        return;
                                    }

                                } catch (Exception ex) {
                                    try {
                                        tabixReader = new TabixReader(urltext,
                                                urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream);
                                        index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi";
                                    } catch (Exception exc) {
                                        menu.setVisible(false);
                                        Main.showError("Could not read tabix file.", "Error");
                                    }
                                }
                                if (tabixReader != null && index != null) {
                                    stream.close();
                                    tabixReader.close();
                                    menu.setVisible(false);
                                    FileRead filereader = new FileRead();
                                    filereader.readBED(urltext, index, size);

                                }

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        } else {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            final URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {
                                menu.setVisible(false);
                                FileRead filereader = new FileRead();

                                filereader.readBED(urltext, "nan", true);

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                }

            });
            area.setFont(Main.menuFont);
            //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz");
            menu.add(label);
            menu.add(menuscroll);
            menu.add(add);
            area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8));

            area.setCaretPosition(0);
            area.revalidate();
            menuscroll.getViewport().add(area);
            area.requestFocus();
            menu.pack();

            menu.show(frame, mouseX + 20, fromURL.getY());
        }

    });
    //toolmenu.add(peakCaller);
    variantCaller.setToolTipText("No bam/cram files opened");
    variantCaller.addActionListener(this);
    variantCaller.setEnabled(false);
    peakCaller.setEnabled(true);
    peakCaller.addActionListener(this);
    settings.addActionListener(this);
    clearMemory.addActionListener(this);
    errorlog.addActionListener(this);
    toolmenu.add(clearMemory);
    toolmenu.add(errorlog);
    toolmenu.add(new JSeparator());
    toolmenu.add(settings);
    menubar.add(toolmenu);
    menubar.add(manage);
    area = new JEditorPane();

    String infotext = "<html><h2>BasePlayer</h2>This is a version " + version
            + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>"
            + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> "
            + "Contact: help@baseplayer.fi <br/> <br/>"

            + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> "
            + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> "
            + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> "

            + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> "
            + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>"
            + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>"
            + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>"
            + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>"
            + "on the same track.<br/><br/>"
            + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>";
    area = new JEditorPane();
    area.setEditable(false);
    area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
    area.setText(infotext);
    area.setFont(Main.menuFont);
    area.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
            final URL url = hyperlinkEvent.getURL();
            if (type == HyperlinkEvent.EventType.ACTIVATED) {
                Main.gotoURL(url.toString());
            }
        }
    });

    about.add(area);
    about.addMouseListener(this);
    help.add(about);
    help.add(manual);
    menubar.add(help);
    JLabel emptylab = new JLabel("  ");
    emptylab.setEnabled(false);
    emptylab.setOpaque(false);
    menubar.add(emptylab);

    chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray));
    chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    chromlabel.setToolTipText("Current chromosome");
    chromlabel.setFocusable(false);
    chromlabel.addMouseListener(this);
    chromlabel.setBackground(Color.white);
    chromlabel.setEditable(false);
    chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray));
    chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(chromlabel);
    chromosomeDropdown.setBackground(Color.white);
    chromosomeDropdown.setToolTipText("Current chromosome");
    menubar.add(chromosomeDropdown);
    JLabel empty3 = new JLabel("  ");
    empty3.setEnabled(false);
    empty3.setOpaque(false);
    menubar.add(empty3);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    searchField.addMouseListener(this);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);

    back.addMouseListener(this);
    back.setToolTipText("Back");
    forward.addMouseListener(this);
    forward.setToolTipText("Forward");
    back.setEnabled(false);
    forward.setEnabled(false);

    searchField.addMouseListener(this);

    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    back.addMouseListener(this);
    forward.addMouseListener(this);
    back.setEnabled(false);
    forward.setEnabled(false);
    forward.setMargin(new Insets(0, 2, 0, 2));
    back.setMargin(new Insets(0, 2, 0, 2));
    menubar.add(forward);
    JLabel empty4 = new JLabel("  ");
    empty4.setOpaque(false);
    empty4.setEnabled(false);
    menubar.add(empty4);
    menubar.add(zoomout);
    JLabel empty5 = new JLabel("  ");
    empty5.setEnabled(false);
    empty5.setOpaque(false);
    menubar.add(empty5);
    positionField.setEditable(false);
    positionField.setBackground(new Color(250, 250, 250));

    positionField.setMargin(new Insets(0, 2, 0, 0));
    positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(positionField);
    widthLabel.setEditable(false);
    widthLabel.setBackground(new Color(250, 250, 250));
    widthLabel.setMargin(new Insets(0, 2, 0, 0));
    widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    JLabel empty6 = new JLabel("  ");
    empty6.setEnabled(false);
    empty6.setOpaque(false);
    menubar.add(empty6);
    menubar.add(widthLabel);
    JLabel empty7 = new JLabel("  ");
    empty7.setOpaque(false);
    empty7.setEnabled(false);
    menubar.add(empty7);
}

From source file:org.languagetool.gui.ConfigurationDialog.java

private JPanel getSpecialRuleValuePanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = 0;//from w  w w .j  a  v a2s.  co  m
    cons.gridy = 0;
    cons.weightx = 0.0f;
    cons.anchor = GridBagConstraints.WEST;

    List<JCheckBox> ruleCheckboxes = new ArrayList<JCheckBox>();
    List<JLabel> ruleLabels = new ArrayList<JLabel>();
    List<JTextField> ruleValueFields = new ArrayList<JTextField>();

    for (int i = 0; i < configurableRules.size(); i++) {
        Rule rule = configurableRules.get(i);
        JCheckBox ruleCheckbox = new JCheckBox(rule.getDescription());
        ruleCheckboxes.add(ruleCheckbox);
        ruleCheckbox.setSelected(getEnabledState(rule));
        cons.insets = new Insets(3, 0, 0, 0);
        panel.add(ruleCheckbox, cons);

        cons.insets = new Insets(0, 24, 0, 0);
        cons.gridy++;
        JLabel ruleLabel = new JLabel(rule.getConfigureText());
        ruleLabels.add(ruleLabel);
        ruleLabel.setEnabled(ruleCheckbox.isSelected());
        panel.add(ruleLabel, cons);

        cons.gridx++;
        int value = config.getConfigurableValue(rule.getId());
        if (config.getConfigurableValue(rule.getId()) < 0) {
            value = rule.getDefaultValue();
        }
        JTextField ruleValueField = new JTextField(Integer.toString(value), 2);
        ruleValueFields.add(ruleValueField);
        ruleValueField.setEnabled(ruleCheckbox.isSelected());
        ruleValueField.setMinimumSize(new Dimension(35, 25)); // without this the box is just a few pixels small, but why?
        panel.add(ruleValueField, cons);

        ruleCheckbox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                ruleValueField.setEnabled(ruleCheckbox.isSelected());
                ruleLabel.setEnabled(ruleCheckbox.isSelected());
                if (ruleCheckbox.isSelected()) {
                    config.getEnabledRuleIds().add(rule.getId());
                    config.getDisabledRuleIds().remove(rule.getId());
                } else {
                    config.getEnabledRuleIds().remove(rule.getId());
                    config.getDisabledRuleIds().add(rule.getId());
                }
            }
        });

        ruleValueField.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                changedUpdate(e);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                changedUpdate(e);
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                try {
                    int num = Integer.parseInt(ruleValueField.getText());
                    if (num < rule.getMinConfigurableValue()) {
                        num = rule.getMinConfigurableValue();
                        ruleValueField.setForeground(Color.RED);
                    } else if (num > rule.getMaxConfigurableValue()) {
                        num = rule.getMaxConfigurableValue();
                        ruleValueField.setForeground(Color.RED);
                    } else {
                        ruleValueField.setForeground(null);
                    }
                    config.setConfigurableValue(rule.getId(), num);
                } catch (Exception ex) {
                    ruleValueField.setForeground(Color.RED);
                }
            }
        });

        cons.gridx = 0;
        cons.gridy++;

    }
    return panel;
}

From source file:org.nuclos.client.ui.collect.SubForm.java

private void init() {
    contentPane.add(toolbar,/*  ww w.ja  v  a2  s. c o m*/
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    scrollPane.getViewport().setBackground(subformtbl.getBackground());
    subformtbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    subformtbl.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //      subformtbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    scrollPane.getViewport().setView(subformtbl);
    JLabel labCorner = new JLabel();
    labCorner.setEnabled(false);
    labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
    labCorner.setBackground(Color.LIGHT_GRAY);
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

    rowHeader = createTableRowHeader(subformtbl, scrollPane);
    subformtbl.setRowHeaderTable(rowHeader);

    // subformtbl.addMouseListener(newToolbarContextMenuListener(subformtbl, subformtbl));
    addToolbarMouseListener(subformtbl, subformtbl, subformtbl);
    // scrollPane.getViewport().addMouseListener(newToolbarContextMenuListener(scrollPane.getViewport(), subformtbl));
    addToolbarMouseListener(scrollPane.getViewport(), scrollPane.getViewport(), subformtbl);
}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void initUI() {
    setLayout(new GridBagLayout());

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    components = new ArrayList<JComponent>();
    checks = new ArrayList<JCheckBox>();

    int size = paramList.size();
    boolean shouldExpand = false;
    boolean needScroll = false;
    for (int i = 0; i < size; i++) {
        final int pos = i;
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            components.add(null);/*from   www .j a v a2s  .c o  m*/
            checks.add(null);
            initHiddenParameterValues(param);
            continue;
        }
        String source = param.getSource();
        String defaultSource = param.getDefaultSource();

        if ((defaultSource != null) && !defaultSource.trim().equals("")) {
            try {
                param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param));
            } catch (NextSqlException e) {
                Show.error(e);
            }
        }

        final JComponent component;
        int anchor = GridBagConstraints.WEST;
        double y = 0.0;
        int expand = GridBagConstraints.HORIZONTAL;
        if ((source != null) && !source.equals("")) {
            List<IdName> values = new ArrayList<IdName>();
            try {
                if (param.isManualSource()) {
                    if (!param.isDependent()) {
                        values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy());
                    }
                } else {
                    int index = source.indexOf(".");
                    int index2 = source.lastIndexOf(".");
                    String tableName = source.substring(0, index);
                    String columnName;
                    String shownColumnName = null;
                    if (index == index2) {
                        columnName = source.substring(index + 1);
                    } else {
                        columnName = source.substring(index + 1, index2);
                        shownColumnName = source.substring(index2 + 1);
                    }
                    values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName,
                            columnName, shownColumnName, param.getOrderBy());
                }
            } catch (NextSqlException e) {
                error = true;
                Show.error(e);
            } catch (InvalidSqlException e) {
                String m = I18NSupport.getString("source.dialog.valid");
                Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
            }
            if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) {
                component = new JComboBox();
                final JComboBox combo = (JComboBox) component;
                combo.setRenderer(new IdNameRenderer());
                combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
                for (int j = 0, len = values.size(); j < len; j++) {
                    combo.addItem(values.get(j));
                }

                combo.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            IdName in = null;
                            if (combo.getSelectedIndex() > 0) {
                                in = (IdName) combo.getSelectedItem();
                            }
                            parameterSelection(pos, in);
                        }
                    }
                });
                AutoCompleteDecorator.decorate(combo);
                needScroll = false;
            } else {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;

                DefaultListModel model = new DefaultListModel();
                for (int j = 0, len = values.size(); j < len; j++) {
                    model.addElement(values.get(j));
                }
                List srcList = Arrays.asList(model.toArray());
                component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    // needed for saved parameters on rerun
                    protected void onSetRight() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getDestinationElements().toArray();
                            if (values.length == 0) {
                                values = new Object[] { ParameterUtil.NULL };
                            }
                            parameterSelection(pos, values);
                        }
                    }
                };
                ((ListSelectionPanel) component).setListSize(scrListDim);
                ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(),
                        new IdNameComparator(param.getOrderBy()));

                shouldExpand = true;
            }

        } else {
            if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;
                ;
                component = new ListAddPanel(param) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getElements().toArray();
                            parameterSelection(pos, values);
                        }
                    }
                };
            } else {
                needScroll = false;
                if (param.getValueClassName().equals("java.util.Date")) {
                    component = new JXDatePicker();
                    ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent e) {
                            if ("date".equals(e.getPropertyName())) {
                                parameterSelection(pos, ((JXDatePicker) component).getDate());
                            }
                        }
                    });
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) component.getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.sql.Timestamp")
                        || param.getValueClassName().equals("java.sql.Time")) {
                    component = new JDateTimePicker() {
                        protected void onChange() {
                            parameterSelection(pos, getDate());
                        }
                    };
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker())
                            .getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.lang.Boolean")) {
                    component = new JCheckBox();
                    ((JCheckBox) component).addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
                            boolean selected = abstractButton.getModel().isSelected();
                            parameterSelection(pos, selected);
                        }
                    });
                } else {
                    component = new JTextField(25);
                    ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() {

                        @Override
                        public void changedUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void insertUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void removeUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        private void updateFromTextField(DocumentEvent e) {
                            java.awt.EventQueue.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Object value = null;
                                    try {
                                        if ("".equals(((JTextField) component).getText().trim())) {
                                            value = null;
                                        } else {
                                            value = ParameterUtil.getParameterValueFromString(
                                                    param.getValueClassName(),
                                                    ((JTextField) component).getText());
                                        }
                                        parameterSelection(pos, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        LOG.error(e.getMessage(), e);
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
        components.add(component);
        final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore"));
        checks.add(cb);

        final JLabel label = new JLabel(getRuntimeParameterName(param));
        panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5), 0, 0));
        final JComponent addComponent;
        if (needScroll) {
            JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scr.setPreferredSize(listDim);
            addComponent = scr;
        } else {
            addComponent = component;
        }
        panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand,
                new Insets(5, 0, 5, 5), 0, 0));
        int checkAnchor = GridBagConstraints.WEST;
        if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) {
            checkAnchor = GridBagConstraints.NORTHWEST;
        }

        if (Globals.getParametersIgnore()) {
            panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE,
                    new Insets(5, 0, 5, 5), 0, 0));
        }

        cb.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (cb.isSelected()) {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(false);
                    }
                    label.setEnabled(false);
                    addComponent.setEnabled(false);
                    param.setIgnore(true);
                } else {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(true);
                    }
                    label.setEnabled(true);
                    addComponent.setEnabled(true);
                    param.setIgnore(false);
                }
            }
        });
    }

    // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter)
    // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here
    for (int i = 0; i < size; i++) {
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            populateDependentParameters(param, false);
        }
    }

    if (!shouldExpand) {
        panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }

    JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrPanel.setPreferredSize(scrDim);
    scrPanel.setMinimumSize(scrDim);

    add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
    setParameterValues(parametersValues);
    setParameterIgnore(parametersIgnore);
}