Example usage for javax.swing SpringLayout SpringLayout

List of usage examples for javax.swing SpringLayout SpringLayout

Introduction

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

Prototype

public SpringLayout() 

Source Link

Document

Constructs a new SpringLayout.

Usage

From source file:forms.frDados.java

/**
 * Inicializa o grfico de intensidade de sinal dos satlites.
 *///from ww w .ja  v a2 s.c  om
private void initSatGrafico() {
    dadosGraficoSats.clear();
    plot = ChartFactory.createBarChart("Intensidade do sinal", "PRN", "SNR", dadosGraficoSats,
            PlotOrientation.VERTICAL, false, true, true);

    plot.getTitle().setFont(Font.decode("arial-16"));
    plot.getTitle().setPadding(5, 20, 5, 20);
    plot.setPadding(new RectangleInsets(10, 10, 0, 10));
    //plot.setBackgroundPaint(new Color(255,255,255,0));

    BarRenderer br = (BarRenderer) plot.getCategoryPlot().getRenderer();
    br.setSeriesPaint(0, Color.BLUE);
    br.setMaximumBarWidth(0.05);

    plot.getCategoryPlot().getRangeAxis().setRange(new Range(0, 50), true, true);
    br.setBaseItemLabelsVisible(true);
    br.setSeriesItemLabelFont(0, Font.decode("arial-12"));
    br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    br.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));

    SpringLayout lm = new SpringLayout();
    ChartPanel cp = new ChartPanel(plot);
    cp.setBorder(LineBorder.createGrayLineBorder());

    lm.putConstraint(SpringLayout.EAST, pnlSatPlot, 10, SpringLayout.EAST, cp);
    lm.putConstraint(SpringLayout.WEST, cp, 10, SpringLayout.WEST, pnlSatPlot);
    lm.putConstraint(SpringLayout.SOUTH, pnlSatPlot, 10, SpringLayout.SOUTH, cp);
    lm.putConstraint(SpringLayout.NORTH, cp, 10, SpringLayout.NORTH, pnlSatPlot);

    pnlSatPlot.setLayout(lm);
    pnlSatPlot.add(cp);
}

From source file:lcmc.common.ui.EditableInfo.java

/** Adds parameters to the panel. */
private void addParams(final JPanel optionsPanel, final String prefix, final String[] params,
        final MyButton thisApplyButton, final int leftWidth, final int rightWidth,
        final Map<String, Widget> sameAsFields) {
    swingUtils.isSwingThread();//from ww  w  . j av  a  2  s .  c  om
    if (params == null) {
        return;
    }
    final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
    final Collection<PanelPart> panelPartsList = new ArrayList<PanelPart>();
    final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();

    for (final String param : params) {
        final Widget paramWi = createWidget(param, prefix, rightWidth);
        /* sub panel */
        final String section = getSection(param);
        final JPanel panel;
        final AccessMode.Type accessType = getAccessType(param);
        final String accessTypeString = accessType.toString();
        final Boolean advanced = isAdvanced(param);
        final String advancedString = advanced.toString();
        if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
            panel = panelPartsMap.get(section, accessTypeString, advancedString);
            panelPartRowsMap.put(section, accessTypeString, advancedString,
                    panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
        } else {
            panel = new JPanel(new SpringLayout());

            panel.setBackground(getSectionColor(section));
            if (advanced) {
                advancedPanelList.add(panel);
                panel.setVisible(access.isAdvancedMode());
            }
            panelPartsMap.put(section, accessTypeString, advancedString, panel);
            panelPartsList.add(new PanelPart(section, accessType, advanced));
            panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
        }

        /* label */
        final JLabel label = new JLabel(getParamShortDesc(param));
        final String longDesc = getParamLongDesc(param);
        paramWi.setLabel(label, longDesc);

        /* tool tip */
        paramWi.setToolTipText(getToolTipText(param, paramWi));
        label.setToolTipText(longDesc + additionalToolTip(param));
        int height = 0;
        if (paramWi instanceof Label) {
            height = application.getDefaultSize("Browser.LabelFieldHeight");
        }
        addField(panel, label, paramWi.getComponent(), leftWidth, rightWidth, height);
    }
    final boolean wizard = Widget.WIZARD_PREFIX.equals(prefix);
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        if (wizard) {
            final Widget rpwi = getWidget(param, null);
            if (rpwi == null) {
                LOG.error("addParams: unknown param: " + param);
                continue;
            }
            if (paramWi.getValue() == null || paramWi.getValue().isNothingSelected()) {
                rpwi.setValueAndWait(null);
            } else {
                final Value value = paramWi.getValue();
                rpwi.setValueAndWait(value);
            }
        }
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if (wizard) {
            rpwi = getWidget(param, null);
        }
        final Widget realParamWi = rpwi;
        paramWi.addListeners(new WidgetListener() {
            @Override
            public void check(final Value value) {
                checkParameterFields(paramWi, realParamWi, param, getParametersFromXML(), thisApplyButton);
            }
        });
    }

    /* add sub panels to the option panel */
    final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
    final Collection<JPanel> notAdvancedSections = new HashSet<JPanel>();
    final Collection<JPanel> advancedSections = new HashSet<JPanel>();
    for (final PanelPart panelPart : panelPartsList) {
        final String section = panelPart.getSection();
        final AccessMode.Type accessType = panelPart.getType();
        final String accessTypeString = accessType.toString();
        final Boolean advanced = panelPart.isAdvanced();
        final String advancedString = advanced.toString();

        final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
        final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
        final int columns = 2;
        SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY
                1, 1); // xPad, yPad
        final JPanel sectionPanel;
        if (sectionMap.containsKey(section)) {
            sectionPanel = sectionMap.get(section);
        } else {
            sectionPanel = getParamPanel(getSectionDisplayName(section), getSectionColor(section));
            sectionMap.put(section, sectionPanel);
            addSectionPanel(section, wizard, sectionPanel);
            optionsPanel.add(sectionPanel);
            if (sameAsFields != null) {
                final Widget sameAsCombo = sameAsFields.get(section);
                if (sameAsCombo != null) {
                    final JPanel saPanel = new JPanel(new SpringLayout());
                    saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                    final JLabel label = new JLabel(Tools.getString("ClusterBrowser.SameAs"));
                    sameAsCombo.setLabel(label, "");
                    addField(saPanel, label, sameAsCombo.getComponent(), leftWidth, rightWidth, 0);
                    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
                            1, 1); // xPad, yPad
                    sectionPanel.add(saPanel);
                }
            }
        }
        sectionPanel.setVisible(isSectionEnabled(section));
        sectionPanel.add(panel);
        if (advanced) {
            advancedSections.add(sectionPanel);
        } else {
            notAdvancedSections.add(sectionPanel);
        }
    }
    boolean advanced = false;
    for (final Map.Entry<String, JPanel> sectionEntry : sectionMap.entrySet()) {
        final JPanel sectionPanel = sectionEntry.getValue();
        if (advancedSections.contains(sectionPanel)) {
            advanced = true;
        }
        if (!notAdvancedSections.contains(sectionPanel)) {
            advancedOnlySectionList.add(sectionEntry.getKey());
            sectionPanel.setVisible(access.isAdvancedMode() && isSectionEnabled(sectionEntry.getKey()));
        }
    }
    moreOptionsPanel.setVisible(advanced && !access.isAdvancedMode());
}

From source file:lcmc.gui.resources.EditableInfo.java

/** Adds parameters to the panel. */
private void addParams(final JPanel optionsPanel, final String prefix, final String[] params,
        final MyButton thisApplyButton, final int leftWidth, final int rightWidth,
        final Map<String, Widget> sameAsFields) {
    if (params == null) {
        return;/*from  www  .ja  va 2  s .  com*/
    }
    final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
    final List<PanelPart> panelPartsList = new ArrayList<PanelPart>();
    final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();

    for (final String param : params) {
        final Widget paramWi = createWidget(param, prefix, rightWidth);
        /* sub panel */
        final String section = getSection(param);
        JPanel panel;
        final ConfigData.AccessType accessType = getAccessType(param);
        final String accessTypeString = accessType.toString();
        final Boolean advanced = isAdvanced(param);
        final String advancedString = advanced.toString();
        if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
            panel = panelPartsMap.get(section, accessTypeString, advancedString);
            panelPartRowsMap.put(section, accessTypeString, advancedString,
                    panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
        } else {
            panel = new JPanel(new SpringLayout());
            panel.setBackground(Browser.PANEL_BACKGROUND);
            if (advanced) {
                advancedPanelList.add(panel);
                final JPanel p = panel;
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        p.setVisible(Tools.getConfigData().isAdvancedMode());
                    }
                });
            }
            panelPartsMap.put(section, accessTypeString, advancedString, panel);
            panelPartsList.add(new PanelPart(section, accessType, advanced));
            panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
        }

        /* label */
        final JLabel label = new JLabel(getParamShortDesc(param));
        final String longDesc = getParamLongDesc(param);
        paramWi.setLabel(label, longDesc);

        /* tool tip */
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.setToolTipText(getToolTipText(param));
                label.setToolTipText(longDesc);
            }
        });
        int height = 0;
        if (paramWi.getType() == Widget.Type.LABELFIELD) {
            height = Tools.getDefaultSize("Browser.LabelFieldHeight");
        }
        addField(panel, label, paramWi, leftWidth, rightWidth, height);
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
            if (rpwi == null) {
                Tools.appError("unkown param: " + param + ". Man pages not installed?");
                continue;
            }
            int height = 0;
            if (rpwi.getType() == Widget.Type.LABELFIELD) {
                height = Tools.getDefaultSize("Browser.LabelFieldHeight");
            }
            final Widget rpwi0 = rpwi;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (paramWi.getValue() == null || paramWi.getValue() == Widget.NOTHING_SELECTED) {
                        rpwi0.setValueAndWait(null);
                    } else {
                        final Object value = paramWi.getStringValue();
                        rpwi0.setValueAndWait(value);
                    }
                }
            });
        }
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
        }
        final Widget realParamWi = rpwi;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.addListeners(new WidgetListener() {
                    @Override
                    public void check(final Object value) {
                        checkParameterFields(paramWi, realParamWi, param, params, thisApplyButton);
                    }
                });

            }
        });
    }

    /* add sub panels to the option panel */
    final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
    final Set<JPanel> notAdvancedSections = new HashSet<JPanel>();
    final Set<JPanel> advancedSections = new HashSet<JPanel>();
    for (final PanelPart panelPart : panelPartsList) {
        final String section = panelPart.getSection();
        final ConfigData.AccessType accessType = panelPart.getAccessType();
        final String accessTypeString = accessType.toString();
        final Boolean advanced = panelPart.isAdvanced();
        final String advancedString = advanced.toString();

        final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
        final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
        final int columns = 2;
        SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY
                1, 1); // xPad, yPad
        JPanel sectionPanel;
        if (sectionMap.containsKey(section)) {
            sectionPanel = sectionMap.get(section);
        } else {
            sectionPanel = getParamPanel(section);
            sectionMap.put(section, sectionPanel);
            optionsPanel.add(sectionPanel);
            if (sameAsFields != null) {
                final Widget sameAsCombo = sameAsFields.get(section);
                if (sameAsCombo != null) {
                    final JPanel saPanel = new JPanel(new SpringLayout());
                    saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                    final JLabel label = new JLabel("Same As");
                    sameAsCombo.setLabel(label, "");
                    addField(saPanel, label, sameAsCombo, leftWidth, rightWidth, 0);
                    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
                            1, 1); // xPad, yPad
                    sectionPanel.add(saPanel);
                }
            }
        }
        sectionPanel.add(panel);
        if (advanced) {
            advancedSections.add(sectionPanel);
        } else {
            notAdvancedSections.add(sectionPanel);
        }
    }
    boolean advanced = false;
    for (final JPanel sectionPanel : sectionMap.values()) {
        if (advancedSections.contains(sectionPanel)) {
            advanced = true;
        }
        if (!notAdvancedSections.contains(sectionPanel)) {
            advancedOnlySectionList.add(sectionPanel);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    sectionPanel.setVisible(Tools.getConfigData().isAdvancedMode());
                }
            });
        }
    }
    final boolean a = advanced;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            moreOptionsPanel.setVisible(a && !Tools.getConfigData().isAdvancedMode());
        }
    });
}

From source file:org.onesun.sdi.swing.app.views.DataServicesView.java

private void addControlsToPanel() {
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setAutoscrolls(true);//from   w  w w.ja  v  a  2  s.  co m

    JPanel panel = null;

    panel = new JPanel(new SpringLayout());
    panel.add(copyDataButton);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    panel.add(containerPanel);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel.add(executeButton);
    panel.add(computeMetricsButton);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    JLabel label = new JLabel("Enriched Data", JLabel.LEADING);
    label.setPreferredSize(new Dimension(150, 24));
    scrollPane.setPreferredSize(new Dimension(250, 900));

    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    panel.add(label);
    label.setLabelFor(scrollPane);
    panel.add(scrollPane);
    SpringLayoutUtils.makeCompactGrid(panel, 2, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(rowCountLabel);
    this.add(panel);
}

From source file:lcmc.gui.resources.ServiceInfo.java

/**
 * Creates host score combo boxes with labels, one per host.
 *//*w ww  . j  a  v a2s  .c om*/
protected void addHostLocations(final JPanel optionsPanel, final int leftWidth, final int rightWidth) {
    int rows = 0;

    final JPanel panel = getParamPanel(Tools.getString("ClusterBrowser.HostLocations"));
    panel.setLayout(new SpringLayout());

    for (final Host host : getBrowser().getClusterHosts()) {
        final HostInfo hi = host.getBrowser().getHostInfo();
        final Map<String, String> abbreviations = new HashMap<String, String>();
        abbreviations.put("i", CRMXML.INFINITY_STRING);
        abbreviations.put("+", CRMXML.PLUS_INFINITY_STRING);
        abbreviations.put("I", CRMXML.INFINITY_STRING);
        abbreviations.put("a", "ALWAYS");
        abbreviations.put("n", "NEVER");
        final Widget wi = new Widget(null,
                new String[] { null, "0", "2", "ALWAYS", "NEVER", CRMXML.INFINITY_STRING,
                        CRMXML.MINUS_INFINITY_STRING, CRMXML.INFINITY_STRING },
                null, /* units */
                null, /* type */
                "^((-?\\d*|(-|\\+)?" + CRMXML.INFINITY_STRING + "))|ALWAYS|NEVER|@NOTHING_SELECTED@$",
                rightWidth, abbreviations, new AccessMode(ConfigData.AccessType.ADMIN, false));
        wi.setEditable(true);
        final Widget prevWi = scoreComboBoxHash.get(hi);
        scoreComboBoxHash.put(hi, wi);

        /* set selected host scores in the combo box from
         * savedHostLocations */
        if (prevWi == null) {
            final HostLocation hl = savedHostLocations.get(hi);
            String hsSaved = null;
            if (hl != null) {
                hsSaved = hl.getScore();
            }
            wi.setValue(hsSaved);
        } else {
            wi.setValue(prevWi.getValue());
        }
    }

    /* host score combo boxes */
    for (Host host : getBrowser().getClusterHosts()) {
        final HostInfo hi = host.getBrowser().getHostInfo();
        final Widget wi = scoreComboBoxHash.get(hi);
        String op = null;
        final HostLocation hl = savedHostLocations.get(hi);
        if (hl != null) {
            op = hl.getOperation();
        }
        final String text = getHostLocationLabel(hi.getName(), op);
        final JLabel label = new JLabel(text);
        final String onText = getHostLocationLabel(hi.getName(), "eq");
        final String notOnText = getHostLocationLabel(hi.getName(), "ne");
        label.addMouseListener(new MouseListener() {
            @Override
            public final void mouseClicked(final MouseEvent e) {
                /* do nothing */
            }

            @Override
            public final void mouseEntered(final MouseEvent e) {
                /* do nothing */
            }

            @Override
            public final void mouseExited(final MouseEvent e) {
                /* do nothing */
            }

            @Override
            public final void mousePressed(final MouseEvent e) {
                final String currentText = label.getText();
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (currentText.equals(onText)) {
                            label.setText(notOnText);
                        } else if (currentText.equals(notOnText)) {
                            label.setText(onText);
                        } else {
                            /* wierd things */
                            label.setText(onText);
                        }
                        final String[] params = getParametersFromXML();
                        setApplyButtons(CACHED_FIELD, params);
                    }
                });
            }

            @Override
            public final void mouseReleased(final MouseEvent e) {
                /* do nothing */
            }
        });
        wi.setLabel(label, "");
        addField(panel, label, wi, leftWidth, rightWidth, 0);
        rows++;
    }
    rows += addPingField(panel, leftWidth, rightWidth);

    SpringUtilities.makeCompactGrid(panel, rows, 2, /* rows, cols */
            1, 1, /* initX, initY */
            1, 1); /* xPad, yPad */
    optionsPanel.add(panel);
}

From source file:lcmc.gui.resources.ServiceInfo.java

/** Creates operations combo boxes with labels. */
protected void addOperations(final JPanel optionsPanel, final int leftWidth, final int rightWidth) {
    int rows = 0;
    final JPanel sectionPanel = getParamPanel(Tools.getString("ClusterBrowser.Operations"));
    String defaultOpIdRef = null;
    final Info savedOpIdRef = getSameServiceOpIdRef();
    if (savedOpIdRef != null) {
        defaultOpIdRef = savedOpIdRef.toString();
    }//from w ww . j  av a  2 s  . c  o m
    sameAsOperationsWi = new Widget(defaultOpIdRef, getSameServicesOperations(), null, /* units */
            null, /* type */
            null, /* regexp */
            rightWidth, null, /* abbrv */
            new AccessMode(ConfigData.AccessType.ADMIN, false));
    sameAsOperationsWi.setToolTipText(defaultOpIdRef);
    final JLabel label = new JLabel(Tools.getString("ClusterBrowser.OperationsSameAs"));
    sameAsOperationsWi.setLabel(label, "");
    final JPanel saPanel = new JPanel(new SpringLayout());
    saPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    addField(saPanel, label, sameAsOperationsWi, leftWidth, rightWidth, 0);
    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
            1, 1); // xPad, yPad
    sectionPanel.add(saPanel);
    boolean allAreDefaultValues = true;
    mSavedOperationsLock.lock();
    final JPanel normalOpPanel = new JPanel(new SpringLayout());
    normalOpPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
    int normalRows = 0;
    final JPanel advancedOpPanel = new JPanel(new SpringLayout());
    advancedOpPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
    addToAdvancedList(advancedOpPanel);
    advancedOpPanel.setVisible(Tools.getConfigData().isAdvancedMode());
    int advancedRows = 0;
    for (final String op : getResourceAgent().getOperationNames()) {
        for (final String param : getBrowser().getCRMOperationParams(op)) {
            String defaultValue = resourceAgent.getOperationDefault(op, param);
            if (defaultValue == null) {
                continue;
            }
            if (ClusterBrowser.HB_OP_IGNORE_DEFAULT.contains(op)) {
                defaultValue = "";
            }
            Widget.Type type;
            final String regexp = "^-?\\d*$";
            type = Widget.Type.TEXTFIELDWITHUNIT;
            // TODO: old style resources
            if (defaultValue == null) {
                defaultValue = "0";
            }
            String savedValue = null;
            mOperationsComboBoxHashWriteLock.lock();
            try {
                final Widget prevWi = operationsComboBoxHash.get(op, param);
                if (prevWi != null) {
                    savedValue = prevWi.getStringValue();
                }
            } finally {
                mOperationsComboBoxHashWriteLock.unlock();
            }
            if (savedValue == null) {
                savedValue = savedOperation.get(op, param);
            }
            if (!getService().isNew() && (savedValue == null || "".equals(savedValue))) {
                savedValue = getOpDefaultsDefault(param);
                if (savedValue == null) {
                    savedValue = "";
                }
            }
            if (!defaultValue.equals(savedValue)) {
                allAreDefaultValues = false;
            }
            if (savedValue != null) {
                defaultValue = savedValue;
            }
            final Widget wi = new Widget(defaultValue, null, /* items */
                    getUnits(), type, regexp, rightWidth, null, /* abbrv */
                    new AccessMode(ConfigData.AccessType.ADMIN, false));
            wi.setEnabled(savedOpIdRef == null);

            mOperationsComboBoxHashWriteLock.lock();
            try {
                operationsComboBoxHash.put(op, param, wi);
            } finally {
                mOperationsComboBoxHashWriteLock.unlock();
            }
            rows++;
            final JLabel wiLabel = new JLabel(Tools.ucfirst(op) + " / " + Tools.ucfirst(param));
            wi.setLabel(wiLabel, "");
            JPanel panel;
            if (getBrowser().isCRMOperationAdvanced(op, param)) {
                panel = advancedOpPanel;
                advancedRows++;
            } else {
                panel = normalOpPanel;
                normalRows++;
            }
            addField(panel, wiLabel, wi, leftWidth, rightWidth, 0);
        }
    }
    SpringUtilities.makeCompactGrid(normalOpPanel, normalRows, 2, 1, 1, // initX, initY
            1, 1); // xPad, yPad
    SpringUtilities.makeCompactGrid(advancedOpPanel, advancedRows, 2, 1, 1, // initX, initY
            1, 1); // xPad, yPad
    sectionPanel.add(normalOpPanel);
    sectionPanel.add(getMoreOptionsPanel(leftWidth + rightWidth + 4));
    sectionPanel.add(advancedOpPanel);
    mSavedOperationsLock.unlock();
    if (allAreDefaultValues && savedOpIdRef == null) {
        sameAsOperationsWi.setValue(OPERATIONS_DEFAULT_VALUES_TEXT);
    }
    sameAsOperationsWi.addListeners(new WidgetListener() {
        @Override
        public void check(final Object value) {
            final Info info = sameAsOperationsWiValue();
            setOperationsSameAs(info);
            final String[] params = getParametersFromXML();
            setApplyButtons(CACHED_FIELD, params);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (info != null) {
                        sameAsOperationsWi.setToolTipText(info.toString());
                    }
                }
            });
        }
    });
    optionsPanel.add(sectionPanel);
}

From source file:org.apache.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog/*from  w w w.j a v  a 2s.  c o  m*/
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);
    } catch (DAOException e) {

        displayError(e.getMessage());
    }

    /*
     * File[] documents = dir.listFiles(); Vector docVector = new Vector(); for (int i = 0; i <
     * documents.length; i++) { if (documents[i].isFile()) { docVector.add(documents[i].getName()); } }
     * final JList analyzedResultsList = new JList(docVector);
     */
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(analyzedResultsList, null);

    JPanel southernPanel = new JPanel();
    southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

    JPanel controlsPanel = new JPanel();
    controlsPanel.setLayout(new SpringLayout());

    Caption displayFormatLabel = new Caption("Results Display Format:");
    controlsPanel.add(displayFormatLabel);

    JPanel displayFormatPanel = new JPanel();
    displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    javaViewerRB = new JRadioButton("Java Viewer");
    javaViewerUCRB = new JRadioButton("JV user colors");
    htmlRB = new JRadioButton("HTML");
    xmlRB = new JRadioButton("XML");

    ButtonGroup displayFormatButtonGroup = new ButtonGroup();
    displayFormatButtonGroup.add(javaViewerRB);
    displayFormatButtonGroup.add(javaViewerUCRB);
    displayFormatButtonGroup.add(htmlRB);
    displayFormatButtonGroup.add(xmlRB);

    // select the appropraite viewer button according to user's prefs
    javaViewerRB.setSelected(true); // default, overriden below
    if ("Java Viewer".equals(med.getViewType())) {
        javaViewerRB.setSelected(true);
    } else if ("JV User Colors".equals(med.getViewType())) {
        javaViewerUCRB.setSelected(true);
    } else if ("HTML".equals(med.getViewType())) {
        htmlRB.setSelected(true);
    } else if ("XML".equals(med.getViewType())) {
        xmlRB.setSelected(true);
    }

    displayFormatPanel.add(javaViewerRB);
    displayFormatPanel.add(javaViewerUCRB);
    displayFormatPanel.add(htmlRB);
    displayFormatPanel.add(xmlRB);

    controlsPanel.add(displayFormatPanel);

    SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
            4, 4, // initX, initY
            0, 0); // xPad, yPad

    JButton editStyleMapButton = new JButton("Edit Style Map");

    // event for the editStyleMapButton button
    editStyleMapButton.addActionListener(this);

    southernPanel.add(controlsPanel);

    // southernPanel.add( new JSeparator() );

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // APL: edit style map feature disabled for SDK
    buttonsPanel.add(editStyleMapButton);

    if (performanceStats != null) {
        JButton perfStatsButton = new JButton("Performance Stats");
        perfStatsButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                        JOptionPane.PLAIN_MESSAGE);
            }
        });
        buttonsPanel.add(perfStatsButton);
    }

    JButton closeButton = new JButton("Close");
    buttonsPanel.add(closeButton);

    southernPanel.add(buttonsPanel);

    // add jlist and panel container to Dialog
    getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    getContentPane().add(southernPanel, BorderLayout.SOUTH);

    // event for the closeButton button
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            DBAnnotationViewerDialog.this.setVisible(false);
        }
    });

    // event for analyzedResultsDialog window closing
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setLF(); // set default look and feel
    analyzedResultsList.setCellRenderer(new MyListCellRenderer());

    // doubleclicking on document shows the annotated result
    MouseListener mouseListener = new ListMouseAdapter();
    // styleMapFile, analyzedResultsList,
    // inputDirPath,typeSystem , typesToDisplay ,
    // javaViewerRB , javaViewerUCRB ,xmlRB ,
    // viewerDirectory , this);

    // add mouse Listener to the list
    analyzedResultsList.addMouseListener(mouseListener);
}

From source file:org.barcelonamedia.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog/*from  ww w  . j  a va 2 s. com*/
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.getViewport().add(analyzedResultsList, null);

        JPanel southernPanel = new JPanel();
        southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

        JPanel controlsPanel = new JPanel();
        controlsPanel.setLayout(new SpringLayout());

        Caption displayFormatLabel = new Caption("Results Display Format:");
        controlsPanel.add(displayFormatLabel);

        JPanel displayFormatPanel = new JPanel();
        displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        javaViewerRB = new JRadioButton("Java Viewer");
        javaViewerUCRB = new JRadioButton("JV user colors");
        htmlRB = new JRadioButton("HTML");
        xmlRB = new JRadioButton("XML");

        ButtonGroup displayFormatButtonGroup = new ButtonGroup();
        displayFormatButtonGroup.add(javaViewerRB);
        displayFormatButtonGroup.add(javaViewerUCRB);
        displayFormatButtonGroup.add(htmlRB);
        displayFormatButtonGroup.add(xmlRB);

        // select the appropraite viewer button according to user's prefs
        javaViewerRB.setSelected(true); // default, overriden below

        if ("Java Viewer".equals(med.getViewType())) {
            javaViewerRB.setSelected(true);
        } else if ("JV User Colors".equals(med.getViewType())) {
            javaViewerUCRB.setSelected(true);
        } else if ("HTML".equals(med.getViewType())) {
            htmlRB.setSelected(true);
        } else if ("XML".equals(med.getViewType())) {
            xmlRB.setSelected(true);
        }

        displayFormatPanel.add(javaViewerRB);
        displayFormatPanel.add(javaViewerUCRB);
        displayFormatPanel.add(htmlRB);
        displayFormatPanel.add(xmlRB);

        controlsPanel.add(displayFormatPanel);

        SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
                4, 4, // initX, initY
                0, 0); // xPad, yPad

        JButton editStyleMapButton = new JButton("Edit Style Map");

        // event for the editStyleMapButton button
        editStyleMapButton.addActionListener(this);

        southernPanel.add(controlsPanel);

        // southernPanel.add( new JSeparator() );

        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        // APL: edit style map feature disabled for SDK
        buttonsPanel.add(editStyleMapButton);

        if (performanceStats != null) {
            JButton perfStatsButton = new JButton("Performance Stats");
            perfStatsButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                            JOptionPane.PLAIN_MESSAGE);
                }
            });
            buttonsPanel.add(perfStatsButton);
        }

        JButton closeButton = new JButton("Close");
        buttonsPanel.add(closeButton);

        southernPanel.add(buttonsPanel);

        // add list and panel container to Dialog
        getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(southernPanel, BorderLayout.SOUTH);

        // event for the closeButton button
        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DBAnnotationViewerDialog.this.setVisible(false);
            }
        });

        // event for analyzedResultsDialog window closing
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLF(); // set default look and feel
        analyzedResultsList.setCellRenderer(new MyListCellRenderer());

        // doubleclicking on document shows the annotated result
        MouseListener mouseListener = new ListMouseAdapter();
        // styleMapFile, analyzedResultsList,
        // inputDirPath,typeSystem , typesToDisplay ,
        // javaViewerRB , javaViewerUCRB ,xmlRB ,
        // viewerDirectory , this);

        // add mouse Listener to the list
        analyzedResultsList.addMouseListener(mouseListener);
    } catch (DAOException e) {

        displayError(e.getMessage());

        this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:org.codinjutsu.tools.jenkins.view.BuildParamDialog.java

private void addParameterInputs() {
    contentPanel.setLayout(new SpringLayout());
    List<JobParameter> parameters = job.getParameters();

    for (JobParameter jobParameter : parameters) {
        JComponent inputField = createInputField(jobParameter);

        String name = jobParameter.getName();
        inputField.setName(name);//  ww  w  .  ja va2s  .c  o  m

        JLabel label = new JLabel();
        label.setHorizontalAlignment(JLabel.TRAILING);
        label.setLabelFor(inputField);

        if (StringUtils.isEmpty(name)) {
            name = MISSING_NAME_LABEL;
            label.setIcon(ERROR_ICON);
            hasError = true;
        }
        label.setText(name + ":");

        contentPanel.add(label);
        contentPanel.add(inputField);

        inputFieldByParameterMap.put(jobParameter, inputField);
    }

    SpringUtilities.makeCompactGrid(contentPanel, parameters.size(), 2, 6, 6, //initX, initY
            6, 6); //xPad, yPad

    if (hasError) {
        buttonOK.setEnabled(false);
    }
}

From source file:org.pegadi.client.LoginDialog.java

private void jbInit() {
    Locale.setDefault(new Locale("no", "NO"));
    this.setTitle(str.getString("title"));
    this.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(WindowEvent e) {
            this_windowOpened(e);
        }//from  w  w w .  j  a v  a 2  s.  co  m
    });
    loginLabel.setText(str.getString("login"));

    userNameLabel.setText(str.getString("username"));
    okButton.setText("OK");
    okButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okButton_actionPerformed(e);
        }
    });
    quitButton.setText(str.getString("quit"));
    quitButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(ActionEvent e) {
            quitButton_actionPerformed(e);
        }
    });
    userNameField.setColumns(10);
    userNameField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            userNameField_keyReleased(e);
        }
    });

    passwordLabel.setText(str.getString("password"));
    passwordField.setColumns(10);
    passwordField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            passwordField_keyReleased(e);
        }
    });

    serverLabel.setText(str.getString("server"));
    Set keyset = servers.keySet();
    for (Object aKeyset : keyset) {
        String serverKey = (String) aKeyset;
        serverChooser.addItem(serverKey);
    }
    serverChooser.setEnabled(false);

    // gui starts

    JPanel mainPanel = new JPanel();
    this.getContentPane().add(mainPanel);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    JPanel labelPanel = new JPanel();
    loginLabel.setFont(new Font(null, Font.PLAIN, 20));

    // add icon
    URL iu = getClass().getResource("/images/pegadi_icon.png");
    Image icon = Toolkit.getDefaultToolkit().getImage(iu);
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(icon, 0);
    try {
        mt.waitForID(0);
    } catch (InterruptedException ie) {
        icon = null;
    }

    if (icon != null) {
        loginLabel.setIcon(new ImageIcon(icon));
        loginLabel.setVerticalTextPosition(JLabel.BOTTOM);
        loginLabel.setHorizontalTextPosition(JLabel.CENTER);
    }

    labelPanel.add(loginLabel);
    labelPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    mainPanel.add(labelPanel);

    JPanel fieldPanel = new JPanel(new SpringLayout());
    fieldPanel.add(userNameLabel);
    fieldPanel.add(userNameField);
    fieldPanel.add(passwordLabel);
    fieldPanel.add(passwordField);
    fieldPanel.add(serverLabel);
    fieldPanel.add(serverChooser);
    SpringUtilities.makeCompactGrid(fieldPanel, 3, 2, //rows, cols
            5, 5, //initialX, initialY
            10, 5);//xPad, yPad
    mainPanel.add(fieldPanel);

    JPanel buttonPanel = new JPanel();
    JPanel buttonWrapperPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());
    buttonWrapperPanel.add(okButton);
    buttonWrapperPanel.add(quitButton);
    buttonPanel.add(buttonWrapperPanel, BorderLayout.CENTER);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    mainPanel.add(buttonPanel);
}