Example usage for javax.swing Box createHorizontalGlue

List of usage examples for javax.swing Box createHorizontalGlue

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalGlue.

Prototype

public static Component createHorizontalGlue() 

Source Link

Document

Creates a horizontal glue component.

Usage

From source file:org.zaproxy.zap.extension.fuzz.httpfuzzer.ui.HttpFuzzResultsContentPanel.java

public HttpFuzzResultsContentPanel() {
    super(new BorderLayout());

    tabbedPane = new JTabbedPane();

    toolbar = new JToolBar();
    toolbar.setFloatable(false);//www.  j a v a 2  s . c o  m
    toolbar.setRollover(true);

    messageCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.messagesSent"));
    messageCountValueLabel = new JLabel("0");

    errorCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.errors"));
    errorCountValueLabel = new JLabel("0");

    showErrorsToggleButton = new ZapToggleButton(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.label"));
    showErrorsToggleButton.setEnabled(false);
    showErrorsToggleButton.setToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip"));
    showErrorsToggleButton.setSelectedToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.selected"));
    showErrorsToggleButton.setDisabledToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.disabled"));
    showErrorsToggleButton
            .setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/050.png")));
    showErrorsToggleButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (ItemEvent.SELECTED == e.getStateChange()) {
                showTabs();
            } else {
                hideErrorsTab();
            }
        }
    });

    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountValueLabel);
    toolbar.add(Box.createHorizontalStrut(32));

    toolbar.add(errorCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(errorCountValueLabel);

    toolbar.add(Box.createHorizontalStrut(16));
    toolbar.add(showErrorsToggleButton);

    JButton button = new JButton(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export"));
    button.setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/115.png")));
    button.addActionListener((new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            WritableFileChooser chooser = new WritableFileChooser(
                    Model.getSingleton().getOptionsParam().getUserDirectory()) {

                private static final long serialVersionUID = -1660943014924270012L;

                @Override
                public void approveSelection() {
                    File file = getSelectedFile();
                    if (file != null) {
                        String filePath = file.getAbsolutePath();
                        if (!filePath.toLowerCase(Locale.ROOT).endsWith(CSV_EXTENSION)) {
                            setSelectedFile(new File(filePath + CSV_EXTENSION));
                        }
                    }

                    super.approveSelection();
                }
            };
            chooser.setSelectedFile(new File(
                    Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export.defaultName")));
            if (chooser
                    .showSaveDialog(View.getSingleton().getMainFrame()) == WritableFileChooser.APPROVE_OPTION) {

                boolean success = true;
                try (CSVPrinter pw = new CSVPrinter(
                        Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8),
                        CSVFormat.DEFAULT)) {
                    pw.printRecord(currentFuzzer.getMessagesModel().getHeaders());
                    int count = currentFuzzer.getMessagesModel().getRowCount();
                    for (int i = 0; i < count; i++) {
                        List<Object> valueOfRow = currentFuzzer.getMessagesModel().getEntry(i)
                                .getValuesOfHeaders();
                        String customStateValue = fuzzResultTable.getCustomStateValue(
                                currentFuzzer.getMessagesModel().getEntry(i).getCustomStates());
                        valueOfRow.add(13, customStateValue);
                        pw.printRecord(valueOfRow);
                    }
                } catch (Exception ex) {
                    success = false;
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(),
                            Constant.messages
                                    .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageError")
                                    + "\n" + ex.getLocalizedMessage());
                    logger.error("Export Failed: " + ex);
                }
                // Delay the presentation of success message, to ensure all the data was
                // already flushed.
                if (success) {
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(), Constant.messages
                            .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageSuccessful"));
                }
            }
        }
    }));
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(button);
    mainPanel = new JPanel(new BorderLayout());

    fuzzResultTable = new HttpFuzzerResultsTable(RESULTS_PANEL_NAME, EMPTY_RESULTS_MODEL);
    errorsTable = new HttpFuzzerErrorsTable(ERRORS_PANEL_NAME, EMPTY_ERRORS_MODEL);

    fuzzResultTableScrollPane = new JScrollPane();
    fuzzResultTableScrollPane.setViewportView(fuzzResultTable);

    errorsTableScrollPane = new JScrollPane();
    errorsTableScrollPane.setViewportView(errorsTable);

    mainPanel.add(fuzzResultTableScrollPane);

    add(toolbar, BorderLayout.PAGE_START);
    add(mainPanel, BorderLayout.CENTER);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java

/**
 * Creates and lays out the controls inside this panel.
 * <p>//  w  ww  .  j av a  2  s .c  o  m
 * This method is called upon initialization only.
 * </p>
 */
private void initControls() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    add(createChartPanel());

    final Box buttonPanel = Box.createVerticalBox();
    final List<JButton> buttons = new ArrayList<JButton>(8);
    btnEnlarged = Utils.createButton(Messages.DI_VIEWENLARGED, Messages.TT_VIEWENLARGED, this);
    if (Plugin.hasFilter(originalParam.getClass())) {
        btnFilter = Utils.createButton(Messages.DI_FILTERDATA, Messages.TT_FILTERDATA, this);
    } else {
        btnFilter = null;
    }
    btnSaveChart = Utils.createButton(Messages.DI_EXPORTCHART, Messages.TT_SAVECHART, this);
    btnSaveData = Utils.createButton(Messages.DI_EXPORTDATA, Messages.TT_SAVEDATA, this);
    btnChartSettings = Utils.createButton(Messages.DI_CHARTSETTINGS, Messages.TT_CHARTSETTINGS, this);

    buttonPanel.add(btnChartSettings);
    buttons.add(btnChartSettings);
    buttonPanel.add(btnEnlarged);
    buttons.add(btnEnlarged);
    if (btnFilter != null) {
        buttonPanel.add(btnFilter);
        buttons.add(btnFilter);
    }
    buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2));
    if (decorators != null) {
        btnsDec = new JButton[decorators.length];
        for (int i = 0; i < decorators.length; ++i) {
            Decorator d = decorators[i];
            btnsDec[i] = Utils.createButton(d.getButtonLabel(), d.getButtonToolTip(), this);
            buttonPanel.add(btnsDec[i]);
            buttons.add(btnsDec[i]);
        }
        buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2));
    }
    buttonPanel.add(btnSaveChart);
    buttons.add(btnSaveChart);
    buttonPanel.add(btnSaveData);
    buttons.add(btnSaveData);
    buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2));
    buttonPanel.add(Box.createVerticalGlue());
    // Ensure buttons are large enough to fit all possible messages
    final JButton[] btnsArray = new JButton[buttons.size()];
    Utils.setSizes(buttons.toArray(btnsArray), preferred, preferred);
    add(buttonPanel);
    add(Box.createHorizontalGlue());
}

From source file:pcgen.gui2.tabs.EquipInfoTab.java

private void initComponents() {
    FontManipulation.small(newSetButton);
    newSetButton.setMargin(new Insets(0, 0, 0, 0));
    FontManipulation.small(removeSetButton);
    removeSetButton.setMargin(new Insets(0, 0, 0, 0));

    exportTemplateButton.setText(LanguageBundle.getString("in_equipExportTemplate")); //$NON-NLS-1$
    viewBrowserButton.setText(LanguageBundle.getString("in_equipViewBrowser")); //$NON-NLS-1$
    exportFileButton.setText(LanguageBundle.getString("in_equipExportFile")); //$NON-NLS-1$
    setNoteButton.setText(LanguageBundle.getString("in_equipSetNote")); //$NON-NLS-1$

    setOrientation(HORIZONTAL_SPLIT);/*  ww  w  .  java2  s  .c om*/
    FlippingSplitPane splitPane = new FlippingSplitPane(VERTICAL_SPLIT, "EquipMain");

    JPanel panel = new JPanel(new BorderLayout());

    Box bar = Box.createHorizontalBox();
    bar.add(Box.createHorizontalStrut(5));
    bar.add(new JLabel(LanguageBundle.getString("in_equipView"))); //$NON-NLS-1$
    bar.add(Box.createHorizontalStrut(5));
    bar.add(equipViewBox);
    bar.add(Box.createHorizontalStrut(5));
    tableFilter = new SearchFilterPanel();
    bar.add(tableFilter.getFilterComponent());
    bar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    panel.add(bar, BorderLayout.NORTH);

    equipmentTable.setAutoCreateColumnsFromModel(false);
    equipmentTable.setColumnModel(createEquipmentColumnModel());
    equipmentTable.setAutoCreateRowSorter(true);
    panel.add(new JScrollPane(equipmentTable), BorderLayout.CENTER);

    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    equipButton.setHorizontalTextPosition(SwingConstants.LEADING);
    buttonsBox.add(equipButton);
    buttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(buttonsBox, BorderLayout.SOUTH);

    splitPane.setTopComponent(panel);
    splitPane.setBottomComponent(infoPane);

    setLeftComponent(splitPane);

    panel = new JPanel(new BorderLayout());

    Box equipPane = Box.createVerticalBox();
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipSetLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(3));
    box.add(equipSetBox);
    box.add(Box.createHorizontalStrut(3));
    box.add(newSetButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(removeSetButton);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipWeightLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(weightLabel);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipLoadLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(loadLabel);
    box.add(Box.createHorizontalStrut(5));
    box.add(limitLabel);
    box.add(Box.createHorizontalGlue());

    equipPane.add(Box.createVerticalStrut(3));
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    box = Box.createHorizontalBox();
    box.add(exportTemplateButton);
    exportTemplateButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(viewBrowserButton);
    viewBrowserButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(exportFileButton);
    exportFileButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(setNoteButton);
    setNoteButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(expandAllButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(collapseAllButton);
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    panel.add(equipPane, BorderLayout.NORTH);

    EquipmentModel.initializeTreeTable(equipmentSetTable);
    panel.add(new JScrollPane(equipmentSetTable), BorderLayout.CENTER);

    Box selPanelbuttonsBox = Box.createHorizontalBox();
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipAllButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveUpButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveDownButton);
    selPanelbuttonsBox.add(Box.createHorizontalGlue());
    selPanelbuttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(selPanelbuttonsBox, BorderLayout.SOUTH);
    setRightComponent(panel);
}

From source file:es.emergya.ui.gis.popups.GenericDialog.java

protected void addString_Fixed(String texto, String label) {
    rows++;/*from w  ww.j  a  v  a  2  s  . c  om*/
    mid.add(new JLabel(i18n.getString(label), JLabel.RIGHT));
    JTextField jtextField = new JTextField(texto);
    jtextField.setEditable(false);
    mid.add(jtextField);
    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}

From source file:org.ut.biolab.medsavant.client.view.dialog.IndividualSelector.java

private void initUI() {

    JPanel p = new JPanel();
    ViewUtil.applyVerticalBoxLayout(p);/*w w  w .j a va2s  .  c  om*/
    this.add(p);

    topPanel = ViewUtil.getClearPanel();
    middlePanel = ViewUtil.getClearPanel();
    bottomPanel = ViewUtil.getClearPanel();

    p.add(topPanel);
    p.add(middlePanel);
    p.add(bottomPanel);

    // Only display the bottom panel for multiple patient selection
    if (onlyOnePatient) {
        bottomPanel.setVisible(false);
    }

    // middle
    middlePanel.setLayout(new BorderLayout());

    individualsRetriever = new IndividualsReceiver();
    individualsSTP = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true,
            true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE,
            individualsRetriever);
    individualsSTP.setExportButtonVisible(false);

    //If patients or cohorts are edited, update the searchabletable.
    CacheController.getInstance().addListener(new Listener<ModificationType>() {
        @Override
        public void handleEvent(ModificationType event) {
            if (event == ModificationType.PATIENT || event == ModificationType.COHORT) {
                if (!individualsSTP.isUpdating()) {
                    forceRefresh = true;
                    individualsSTP.forceRefreshData();
                }
            }
        }

    });

    middlePanel.add(individualsSTP, BorderLayout.CENTER);

    // bottom
    ViewUtil.applyVerticalBoxLayout(bottomPanel);

    numselections = ViewUtil.getTitleLabel("0 individual(s) selected");

    JPanel text = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(text);

    JButton clearIndividuals = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE));
    clearIndividuals.setToolTipText("Clear selections");
    clearIndividuals.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            clearSelections();
        }
    });

    text.add(numselections);
    text.add(Box.createHorizontalStrut(5));
    text.add(clearIndividuals);
    bottomPanel.add(ViewUtil.centerHorizontally(text));

    final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All");
    bottomPanel.add(addAllIndividuals);

    final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected");
    bottomPanel.add(addIndividuals);

    final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected");
    bottomPanel.add(removeIndividuals);

    final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All");
    bottomPanel.add(removeAllIndividuals);

    JPanel buttons = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttons);

    buttons.add(addAllIndividuals);
    buttons.add(addIndividuals);
    buttons.add(removeIndividuals);
    buttons.add(removeAllIndividuals);

    JPanel windowControlPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(windowControlPanel);
    windowControlPanel.add(Box.createHorizontalGlue());

    JButton cancel = new JButton("Cancel");
    bottomPanel.add(ViewUtil.centerHorizontally(buttons));

    ok = new JButton("OK");
    bottomPanel.add(ViewUtil.alignRight(ok));
    ok.setEnabled(false);

    windowControlPanel.add(cancel);
    windowControlPanel.add(ok);

    bottomPanel.add(windowControlPanel);

    final JDialog instance = this;

    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(true);
        }
    });

    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(false || hasMadeSelections);
        }
    });

    addIndividuals.setEnabled(false);
    removeIndividuals.setEnabled(false);

    individualsSTP.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {

                int rows[] = individualsSTP.getTable().getSelectedRows();

                boolean someSelection = rows.length > 0;

                addIndividuals.setEnabled(someSelection);
                removeIndividuals.setEnabled(someSelection);

                if (someSelection) {
                    addIndividuals.setText("Add Selected (" + rows.length + ")");
                    removeIndividuals.setText("Remove Selected (" + rows.length + ")");
                } else {
                    addIndividuals.setText("Add Selected");
                    removeIndividuals.setText("Remove Selected");
                }

                /* Close the dialog if only a single individual is requested. */
                if (onlyOnePatient && rows.length == 1) {
                    selectedRows.clear();
                    selectedHospitalIDs.clear();

                    int realRow = individualsSTP.getActualRowAt(rows[0]);
                    selectedRows.add(realRow);
                    Object[] o = individualsRetriever.getIndividuals().get(realRow);
                    selectedHospitalIDs.add(o[INDEX_OF_HOSPITAL_ID].toString());

                    instance.setVisible(false);
                    setIndividualsChosen(true);

                    individualsSTP.getTable().clearSelection(); // if errors crop up, this line may be causing ListSelectionEvents - can be removed
                }
            }
        }
    });

    individualsSTP.getTable().getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")");
            //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")");
        }
    });

    ActionListener addAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(false);
        }
    };

    ActionListener addAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(true);
        }
    };

    ActionListener removeAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(false);
        }
    };

    ActionListener removeAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(true);
        }
    };

    addIndividuals.addActionListener(addAction);
    addAllIndividuals.addActionListener(addAllAction);
    removeIndividuals.addActionListener(removeAction);
    removeAllIndividuals.addActionListener(removeAllAction);

    this.pack();
    this.setLocationRelativeTo(MedSavantFrame.getInstance());
}

From source file:org.ut.biolab.medsavant.client.filter.TagFilterView.java

public TagFilterView(int queryID) {
    super(FILTER_NAME, queryID);

    setLayout(new BorderLayout());
    setBorder(ViewUtil.getBigBorder());/*from   w  ww. j a  va2  s  . co m*/
    setMaximumSize(new Dimension(200, 80));

    JPanel cp = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = 0;

    cp.setLayout(gbl);

    variantTags = new ArrayList<VariantTag>();
    appliedTags = new ArrayList<VariantTag>();

    clear = new JButton("Clear");
    applyButton = new JButton("Apply");

    try {
        final JComboBox tagNameCB = new JComboBox();
        //tagNameCB.setMaximumSize(new Dimension(1000,30));

        final JComboBox tagValueCB = new JComboBox();
        //tagValueCB.setMaximumSize(new Dimension(1000,30));

        JPanel bottomContainer = new JPanel();
        ViewUtil.applyHorizontalBoxLayout(bottomContainer);

        List<String> tagNames = MedSavantClient.VariantManager
                .getDistinctTagNames(LoginController.getSessionID());

        for (String tag : tagNames) {
            tagNameCB.addItem(tag);
        }

        ta = new JTextArea();
        ta.setRows(10);
        ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        ta.setEditable(false);

        applyButton.setEnabled(false);

        JLabel addButton = ViewUtil
                .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD));
        addButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

                if (tagNameCB.getSelectedItem() == null || tagValueCB.getSelectedItem() == null) {
                    return;
                }

                VariantTag tag = new VariantTag((String) tagNameCB.getSelectedItem(),
                        (String) tagValueCB.getSelectedItem());
                if (variantTags.isEmpty()) {
                    ta.append(tag.toString() + "\n");
                } else {
                    ta.append("AND " + tag.toString() + "\n");
                }
                variantTags.add(tag);
                applyButton.setEnabled(true);
            }
        });

        clear.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                variantTags.clear();
                ta.setText("");
                applyButton.setEnabled(true);
            }
        });

        int width = 150;

        ta.setPreferredSize(new Dimension(width, width));
        ta.setMaximumSize(new Dimension(width, width));
        tagNameCB.setPreferredSize(new Dimension(width, 25));
        tagValueCB.setPreferredSize(new Dimension(width, 25));
        tagNameCB.setMaximumSize(new Dimension(width, 25));
        tagValueCB.setMaximumSize(new Dimension(width, 25));

        cp.add(new JLabel("Name"), c);
        c.gridx++;
        cp.add(tagNameCB, c);
        c.gridx++;

        c.gridx = 0;
        c.gridy++;

        cp.add(new JLabel("Value"), c);
        c.gridx++;
        cp.add(tagValueCB, c);
        c.gridx++;
        cp.add(addButton, c);

        tagNameCB.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent ie) {
                updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB);
            }
        });

        if (tagNameCB.getItemCount() > 0) {
            tagNameCB.setSelectedIndex(0);
            updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB);
        }

        al = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                applyButton.setEnabled(false);

                appliedTags = new ArrayList<VariantTag>(variantTags);

                Filter f = new Filter() {

                    @Override
                    public Condition[] getConditions() {
                        try {
                            List<Integer> uploadIDs = MedSavantClient.VariantManager
                                    .getUploadIDsMatchingVariantTags(LoginController.getSessionID(),
                                            TagFilterView.tagsToStringArray(variantTags));

                            Condition[] uploadIDConditions = new Condition[uploadIDs.size()];

                            TableSchema table = MedSavantClient.CustomTablesManager.getCustomTableSchema(
                                    LoginController.getSessionID(),
                                    MedSavantClient.ProjectManager.getVariantTableName(
                                            LoginController.getSessionID(),
                                            ProjectController.getInstance().getCurrentProjectID(),
                                            ReferenceController.getInstance().getCurrentReferenceID(), true));

                            for (int i = 0; i < uploadIDs.size(); i++) {
                                uploadIDConditions[i] = BinaryCondition.equalTo(
                                        table.getDBColumn(BasicVariantColumns.UPLOAD_ID), uploadIDs.get(i));
                            }

                            return new Condition[] { ComboCondition.or(uploadIDConditions) };
                        } catch (Exception ex) {
                            ClientMiscUtils.reportError("Error getting upload IDs: %s", ex);
                        }
                        return new Condition[0];
                    }

                    @Override
                    public String getName() {
                        return FILTER_NAME;
                    }

                    @Override
                    public String getID() {
                        return FILTER_ID;
                    }
                };
                FilterController.getInstance().addFilter(f, TagFilterView.this.queryID);
            }
        };

        applyButton.addActionListener(al);

        bottomContainer.add(Box.createHorizontalGlue());
        bottomContainer.add(clear);
        bottomContainer.add(applyButton);

        add(ViewUtil.getClearBorderedScrollPane(ta), BorderLayout.CENTER);
        add(bottomContainer, BorderLayout.SOUTH);

    } catch (Exception ex) {
        ClientMiscUtils.checkSQLException(ex);
    }

    add(cp, BorderLayout.NORTH);

    this.showViewCard();
}

From source file:org.ecoinformatics.seek.ecogrid.EcogridPreferencesTab.java

/**
 * Description of the Method//from  w  w  w  . j  ava  2  s  .co m
 */
private void initTextPanel() {
    // text part of text panel
    JPanel textTopPanel = new JPanel();
    textTopPanel.setLayout(new BoxLayout(textTopPanel, BoxLayout.X_AXIS));
    textTopPanel.add(textLabel);
    textTopPanel.add(Box.createHorizontalGlue());
    // y box layout
    textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
    textPanel.add(textTopPanel);
    textPanel.add(Box.createVerticalStrut(GAP));
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

private JPanel getStatusIconPanel(final UserCommentGroup lcg, final UserComment lc) {
    JPanel sip = new JPanel();
    sip.setLayout(new BoxLayout(sip, BoxLayout.X_AXIS));

    JPanel statusIconPanel = new StatusIconPanel(ICON_WIDTH, ICON_HEIGHT, false, lc.isApproved(),
            lc.isIncluded(), lc.isDeleted());

    sip.add(statusIconPanel);/*from   w ww .  j a  v a  2 s  .  c om*/
    sip.add(Box.createHorizontalGlue());

    //technicains and admins can change status, but technicians can't.
    if (roleManager.checkRole(GENETIC_COUNSELLOR_ROLENAME) || roleManager.checkRole(RESIDENT_ROLENAME)) {
        JButton statusEditButton = new JButton(new ImageIcon(EDIT_STATUS_BUTTON_ICON.getImage()
                .getScaledInstance(ICON_WIDTH, ICON_HEIGHT, java.awt.Image.SCALE_SMOOTH)));

        statusEditButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                editStatus(lcg, lc);
            }
        });
        sip.add(statusEditButton);
    }

    return sip;
}

From source file:es.emergya.ui.plugins.forms.FormGeneric.java

protected void addDate(Date fecha, String title, boolean editable) {
    rows++;//from ww  w .  j a  v a  2s .  c  o  m
    // TODO editable
    mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT));
    JPanel panel = new JPanel();
    panel.setOpaque(false);
    JCalendarCombo calendar = new JCalendarCombo();
    calendar.setName(title);
    calendar.setEditable(editable);
    calendar.setPreferredSize(new Dimension(300, 30));
    calendar.setDate(fecha);
    panel.add(calendar);
    componentes.add(calendar);
    JSpinner res = new JSpinner(new SpinnerDateModel());
    res.setName(title);
    res.setPreferredSize(new Dimension(60, 30));
    res.setName(title);
    JSpinner.DateEditor startEditor = new JSpinner.DateEditor(res, "HH:mm:ss");
    startEditor.setEnabled(editable);
    res.setEditor(startEditor);
    if (fecha != null)
        res.setValue(fecha);
    componentes.add(res);
    panel.add(res);
    mid.add(panel);
    for (int i = 3; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}

From source file:es.emergya.ui.gis.popups.GenericDialog.java

protected void addComboBox(Object selected, Object[] options, String title) {
    rows++;/*from  w  w  w  .  j  a v  a2 s.c o  m*/
    mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT));
    JComboBox cb = new JComboBox(options);
    cb.setName(title);
    cb.setSelectedItem(selected);
    mid.add(cb);
    componentes.add(cb);
    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}