Example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel

List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel

Introduction

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

Prototype

public DefaultComboBoxModel() 

Source Link

Document

Constructs an empty DefaultComboBoxModel object.

Usage

From source file:co.com.soinsoftware.hotelero.view.JFRoomPayment.java

private void validateBillToCompany(final Invoice invoice) {
    if (invoice.getCompany() != null) {
        if (!this.invoiceStatusList.contains(this.statusBillToCompany)) {
            this.invoiceStatusList.add(statusBillToCompany);
        }//from   w ww.ja v  a2  s  .co m
    } else {
        if (this.invoiceStatusList.contains(this.statusBillToCompany)) {
            this.invoiceStatusList.remove(statusBillToCompany);
        }
    }
    final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    for (final InvoiceStatus invoiceStatus : this.invoiceStatusList) {
        model.addElement(invoiceStatus.getName());
    }
    this.jcbAccountState.setModel(model);
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatDlg.java

@Override
public void createUI() {
    super.createUI();

    JLabel titleLbl = createLabel(getResourceString("DOF_TITLE") + ":");
    titleText = createTextField(32);//from   www .ja  va 2  s  . co m

    JLabel nameLbl = createLabel(getResourceString("DOF_NAME") + ":");
    nameText = createTextField(32);

    // radio buttons (single/multiple/external object display formats
    JLabel typeLbl = createLabel(getResourceString("DOF_TYPE") + ":");
    singleDisplayBtn = createRadioButton(getResourceString("DOF_SINGLE"));
    multipleDisplayBtn = createRadioButton(getResourceString("DOF_MULTIPLE") + ":");
    singleDisplayBtn.setSelected(true);

    CellConstraints cc = new CellConstraints();

    if (dataObjFormatter.getFormatters().size() == 1) {
        DataObjDataFieldFormatIFace dof = dataObjFormatter.getFormatters().iterator().next();
        if (dof.isCustom()) {
            if (dof.hasEditor()) {
                customEditor = dof.getCustomEditor(new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                        setHasChanged(true);
                    }
                });
            } else {
                isEditable = false;
                UIRegistry.showLocalizedMsg("DOF_NO_CST_EDT");
                return;
            }
        }
    }

    if (customEditor == null) {
        ButtonGroup displayTypeGrp = new ButtonGroup();
        displayTypeGrp.add(singleDisplayBtn);
        displayTypeGrp.add(multipleDisplayBtn);
        addDisplayTypeRadioButtonListeners();

        // combo box that lists fields that can be selected when multiple
        // display radio button is selected
        DefaultComboBoxModel cboModel = new DefaultComboBoxModel();
        valueFieldCbo = createComboBox(cboModel);
        addValueFieldsToCombo(null);
        addValueFieldCboAL();

        // little panel to hold multiple display radio button and its combo box
        PanelBuilder multipleDisplayPB = new PanelBuilder(new FormLayout("l:p,f:p:g", "p"));
        multipleDisplayPB.add(multipleDisplayBtn, cc.xy(1, 1));
        multipleDisplayPB.add(valueFieldCbo, cc.xy(2, 1));

        // format editing panels (dependent on the type for format: single/multiple)
        DataObjSwitchFormatterContainerIface formatterContainer = new DataObjSwitchFormatterSingleContainer(
                dataObjFormatter);
        fmtSingleEditingPanel = new DataObjFieldFormatSinglePanel(tableInfo, formatterContainer,
                dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, this, getOkBtn());
        fmtMultipleEditingPanel = new DataObjFieldFormatMultiplePanel(tableInfo, formatterContainer,
                dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, this, getOkBtn());

        // Panel for radio buttons and display formatting editing panel
        PanelBuilder pb = new PanelBuilder(new FormLayout("r:p,4px,f:p:g", "p,2px,p,10px,p,p,10px,f:p:g"));

        int y = 1;
        pb.add(nameLbl, cc.xy(1, y));
        pb.add(nameText, cc.xy(3, y));
        y += 2;

        pb.add(titleLbl, cc.xy(1, y));
        pb.add(titleText, cc.xy(3, y));
        y += 2;

        pb.add(typeLbl, cc.xy(1, y));
        pb.add(singleDisplayBtn, cc.xy(3, y));
        y += 1;
        pb.add(multipleDisplayPB.getPanel(), cc.xy(3, y));
        y += 2;

        // both panels occupy the same space
        pb.add(fmtSingleEditingPanel, cc.xyw(1, y, 3));
        pb.add(fmtMultipleEditingPanel, cc.xyw(1, y, 3));

        pb.setDefaultDialogBorder();

        contentPanel = pb.getPanel();

    } else {
        PanelBuilder pb = new PanelBuilder(new FormLayout("r:p,4px,f:p:g", "p,6px,p,2px,p,4px,p,10px"));

        int y = 1;
        pb.addSeparator(getResourceString("DOF_CST_ED"), cc.xyw(1, y, 3));
        y += 2;

        pb.add(nameLbl, cc.xy(1, y));
        pb.add(nameText, cc.xy(3, y));
        y += 2;

        pb.add(titleLbl, cc.xy(1, y));
        pb.add(titleText, cc.xy(3, y));
        y += 2;

        String labelStr = dataObjFormatter.getFormatters().iterator().next().getLabel();
        if (StringUtils.isNotEmpty(labelStr)) {
            pb.add(UIHelper.createFormLabel(labelStr), cc.xy(1, y));
            pb.add(customEditor, cc.xy(3, y));
            y += 2;

        } else {
            pb.add(customEditor, cc.xyw(1, y, 3));
            y += 2;
        }

        pb.setDefaultDialogBorder();

        contentPanel = pb.getPanel();
    }

    mainPanel.add(contentPanel, BorderLayout.CENTER);

    // after all is created, set initial selection on format list
    fillWithObjFormatter(dataObjFormatter, true);

    // title text field
    DocumentAdaptor nameChangedDL = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent ev) {
            String name = nameText.getText();
            String title = titleText.getText();

            isInError = (StringUtils.isEmpty(name)
                    || dataObjFieldFormatMgrCache.getDataFormatter(name) != null);

            dataObjFormatter.setName(name);
            dataObjFormatter.setTitle(title);

            setHasChanged(true);
        }
    };

    titleText.getDocument().addDocumentListener(nameChangedDL);
    nameText.getDocument().addDocumentListener(nameChangedDL);

    updateUIEnabled();

    packWithLargestPanel();
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DViewTopComponent.java

public void initialize(final IChromAUIProject project, final List<IChromatogramDescriptor> filename,
        final ADataset1D<IChromatogram1D, IScan> ds) {
    boolean initializedSucccess = initialized.compareAndSet(false, true);
    if (initializedSucccess) {
        final Chromatogram1DViewTopComponent instance = this;
        final ProgressHandle handle = ProgressHandleFactory.createHandle("Loading chart");
        final JComponent progressComponent = ProgressHandleFactory.createProgressComponent(handle);
        final JPanel box = new JPanel();
        box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
        box.add(Box.createHorizontalGlue());
        box.add(progressComponent);/*from  ww  w  . j av  a2 s . co  m*/
        box.add(Box.createHorizontalGlue());
        add(box, BorderLayout.CENTER);
        AProgressAwareRunnable runnable = new AProgressAwareRunnable() {
            @Override
            public void run() {
                try {
                    handle.start();
                    handle.progress("Initializing Overlays...");
                    if (project != null) {
                        ic.add(project);
                    }
                    dataset = ds;
                    annotations = new ArrayList<>(0);
                    final DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
                    for (IChromatogramDescriptor descr : filename) {
                        ic.add(descr);
                        List<ChartOverlay> overlays = new LinkedList<>();
                        if (project != null) {
                            Collection<Peak1DContainer> peaks = project.getPeaks(descr);
                            for (Peak1DContainer container : peaks) {
                                Peak1DOverlay overlay = new Peak1DOverlay(descr, container.getName(),
                                        container.getDisplayName(), container.getShortDescription(), true,
                                        container);
                                ic.add(overlay);
                                overlays.add(overlay);
                            }
                        }
                        /*
                         * Virtual overlay that groups all related overlays
                         */
                        ChromatogramDescriptorOverlay cdo = new ChromatogramDescriptorOverlay(descr,
                                descr.getName(), descr.getDisplayName(), descr.getShortDescription(), true,
                                overlays);
                        ic.add(cdo);
                        // create node children for display in navigator view
                        Children children = Children.create(new ChartOverlayChildFactory(overlays), true);
                        // create the actual node for this chromatogram
                        ic.add(Charts.overlayNode(cdo, children));
                        for (int i = 0; i < ds.getSeriesCount(); i++) {
                            if (ds.getSeriesKey(i).toString().equals(descr.getDisplayName())) {
                                dcbm.addElement(new SeriesItem(cdo, ds.getSeriesKey(i), true));
                            }
                        }
                    }
                    ic.add(ds);
                    handle.progress("Initializing Settings and Properties...");
                    ic.add(new Properties());
                    sp = new SettingsPanel();
                    ic.add(sp);
                    result = Utilities.actionsGlobalContext().lookupResult(ChromatogramViewViewport.class);
                    result.addLookupListener(instance);
                    handle.progress("Creating panel...");
                    jp = new Chromatogram1DViewPanel(ic, getLookup(), ds);
                    ic.add(jp);
                    ic.add(this);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            //EDT stuff
                            setDisplayName("Chromatogram View of " + new File(
                                    getLookup().lookup(IChromatogramDescriptor.class).getResourceLocation())
                                            .getName());
                            setToolTipText(
                                    getLookup().lookup(IChromatogramDescriptor.class).getResourceLocation());
                            seriesComboBox.setModel(dcbm);
                            remove(box);
                            add(new JScrollPane(jp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
                            load();
                        }
                    });
                } finally {
                    handle.finish();
                }
            }
        };
        runnable.setProgressHandle(handle);
        AProgressAwareRunnable.createAndRun("Creating chart", runnable);
    }
}

From source file:com.qualixium.executor.ToolbarPanel.java

public void initializeCbxCommands() {
    DefaultComboBoxModel<Command> modelCommands = new DefaultComboBoxModel<>();
    String jsonCustomCommands = NbPreferences.forModule(CommandsConfigurationDialog.class).get(CUSTOM_COMMANDS,
            "");/*from  w  ww.j a  v  a2 s  . c  o  m*/

    if (!jsonCustomCommands.isEmpty()) {
        try {
            JsonNode jsonData = MAPPER.readTree(jsonCustomCommands);
            for (JsonNode node : jsonData) {
                modelCommands.addElement(
                        new Command(node.get(COLUMN_NAME).textValue(), node.get(COLUMN_COMMAND).textValue()));
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    cbxCommands.setModel(modelCommands);
    cbxCommands.addPopupMenuListener(popupMenuListener);
    cbxCommands.setPrototypeDisplayValue("scrot -cd 5 /home/pedro/Desktop/file1.png");
}

From source file:com.anrisoftware.prefdialog.fields.historycombobox.HistoryComboBoxField.java

private MutableComboBoxModel<?> createMutableModel(ComboBoxModel<?> model) {
    if (model instanceof MutableComboBoxModel) {
        return (MutableComboBoxModel<?>) model;
    }//from  ww w .j av a 2s  .c o m
    DefaultComboBoxModel<Object> mutableModel = new DefaultComboBoxModel<Object>();
    for (int i = 0; i < model.getSize(); i++) {
        mutableModel.addElement(model.getElementAt(i));
    }
    return mutableModel;
}

From source file:CSSDFarm.UserInterface.java

/**
 * Displays the Manager Screen /*from  w  w  w. ja v a  2s .c o  m*/
 */
public void selectManagerView() {
    //remove old panel details
    if (panelReport.isVisible()) {
        comboReportFieldStations.setModel(new DefaultComboBoxModel());
    }

    //Disable the other panels
    panelReport.setVisible(false);
    panelManager.setVisible(true);
    userFieldStations = server.loadData();

    //Set the user lists renderer
    listUserStations.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            Component renderer = super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            if (renderer instanceof JLabel && value instanceof FieldStation) {
                // Here value will be of the Type 'FieldStation'
                ((JLabel) renderer).setText(((FieldStation) value).getName());
            }
            return renderer;
        }
    });

    //If users is a food processing manager then disable the farmer buttons
    if (server.getUsersRole() == 1) {
        btnAddSensor.setVisible(false);
        btnRemoveSensor.setVisible(false);
        btnAddFieldStation.setVisible(false);
        btnRemoveFieldStation.setVisible(false);
    }

    //Set the manager panel to visible
    panelManager.setVisible(true);

    //Load the users last selected values
    int pos = loadUserData("data/userSettings.ser");
    try {
        listUserStations.setSelectedIndex(pos);
    } catch (Exception eX) {

    }

}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *//*from  w  w  w.  ja  va2s  . c o m*/
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java

/**
 * Creates the component./*ww w .j a v a2 s.c o m*/
 */
public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) {
    this.rendererRegistry = rendererRegistry;
    setLayout(new BorderLayout());

    // Results type combo box
    renderersComboBox = new JComboBox<>();
    renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty

    renderersComboBox.setRenderer(new ColorCellRenderer());
    renderersComboBox.setEditable(false);
    renderersComboBox.setEnabled(false); // initially disabled

    // Set the new listener - listen for changes in the currently selected renderer
    renderersComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem()))
                // render the result using the newly selected renderer
                renderResult();
        }
    });

    JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    resultsTypePanel.add(new JLabel("Value type"));
    resultsTypePanel.add(renderersComboBox);

    // Refresh (re-render) button
    refreshButton = new JButton("Refresh", refreshIcon);
    refreshButton.setEnabled(false);
    refreshButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderResult();
            refreshButton.getParent().requestFocusInWindow();
            /*
             * so that the button does not stay focused after it is clicked
             * on and did its action
             */
        }
    });
    resultsTypePanel.add(refreshButton);

    // Check box for wrapping text if result is of type "text/plain"
    wrapTextCheckBox = new JCheckBox(WRAP_TEXT);
    wrapTextCheckBox.setVisible(false);
    wrapTextCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            // Should have only one child component holding the rendered result
            // Check for empty just as well
            if (renderedResultPanel.getComponents().length == 0)
                return;
            Component component = renderedResultPanel.getComponent(0);
            if (component instanceof DialogTextArea) {
                nodeToWrapSelection.put(path, e.getStateChange() == SELECTED);
                renderResult();
            }
        }
    });

    resultsTypePanel.add(wrapTextCheckBox);

    // 'Save result' buttons panel
    saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    for (SaveIndividualResultSPI action : saveActions) {
        action.setResultReference(null);
        final JButton saveButton = new JButton(action.getAction());
        saveButton.setEnabled(false);
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveButton.getParent().requestFocusInWindow();
                /*
                 * so that the button does not stay focused after it is
                 * clicked on and did its action
                 */
            }
        });
        saveButtonsPanel.add(saveButton);
    }

    // Top panel contains result type combobox and various save buttons
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS));
    topPanel.add(resultsTypePanel);
    topPanel.add(saveButtonsPanel);

    // Rendered results panel - initially empty
    renderedResultPanel = new JPanel(new BorderLayout());

    // Add all components
    add(topPanel, NORTH);
    add(new JScrollPane(renderedResultPanel), CENTER);
}

From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java

/**
 * Creates the component.//from   www .  java2s.c om
 */
public RenderedProcessorResultComponent(RendererRegistry rendererRegistry,
        List<SaveIndividualResultSPI> saveActions) {
    this.rendererRegistry = rendererRegistry;
    setLayout(new BorderLayout());
    setBorder(new EtchedBorder());

    // Results type combo box
    renderersComboBox = new JComboBox<>();
    renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty

    renderersComboBox.setRenderer(new ColorCellRenderer());
    renderersComboBox.setEditable(false);
    renderersComboBox.setEnabled(false); // initially disabled

    // Set the new listener - listen for changes in the currently selected renderer
    renderersComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == SELECTED && !ERROR_DOCUMENT.equals(e.getItem()))
                // render the result using the newly selected renderer
                renderResult();
        }
    });

    JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    resultsTypePanel.add(new JLabel("Value type"));
    resultsTypePanel.add(renderersComboBox);

    // Refresh (re-render) button
    refreshButton = new JButton("Refresh", refreshIcon);
    refreshButton.setEnabled(false);
    refreshButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderResult();
            refreshButton.getParent().requestFocusInWindow();
            /*
             * so that the button does not stay focused after it is clicked
             * on and did its action
             */
        }
    });
    resultsTypePanel.add(refreshButton);

    // Check box for wrapping text if result is of type "text/plain"
    wrapTextCheckBox = new JCheckBox(WRAP_TEXT);
    wrapTextCheckBox.setVisible(false);
    wrapTextCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            // Should have only one child component holding the rendered result
            // Check for empty just as well
            if (renderedResultPanel.getComponents().length == 0)
                return;
            if (renderedResultPanel.getComponent(0) instanceof DialogTextArea) {
                nodeToWrapSelection.put(node.hashCode(), e.getStateChange() == SELECTED);
                renderResult();
            }
        }
    });

    resultsTypePanel.add(wrapTextCheckBox);
    // 'Save result' buttons panel
    saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    for (SaveIndividualResultSPI action : saveActions) {
        action.setResultReference(null);
        final JButton saveButton = new JButton(action.getAction());
        saveButton.setEnabled(false);
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveButton.getParent().requestFocusInWindow();
                /*
                 * so that the button does not stay focused after it is
                 * clicked on and did its action
                 */
            }
        });
        saveButtonsPanel.add(saveButton);
    }

    // Top panel contains result type combobox and various save buttons
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS));
    topPanel.add(resultsTypePanel);
    topPanel.add(saveButtonsPanel);

    // Rendered results panel - initially empty
    renderedResultPanel = new JPanel(new BorderLayout());
    renderedResultPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Add all components
    add(topPanel, NORTH);
    add(new JScrollPane(renderedResultPanel), CENTER);
}

From source file:org.geopublishing.atlasStyler.classification.FeatureClassification.java

/**
 * Return a {@link ComboBoxModel} that present all available attributes.
 * That excludes the attribute selected in
 * {@link #getValueFieldsComboBoxModel()}.
 *//*www.  j  a v a 2 s  .  c om*/
public ComboBoxModel createNormalizationFieldsComboBoxModel() {
    normlizationAttribsComboBoxModel = new DefaultComboBoxModel();
    normlizationAttribsComboBoxModel.addElement(NORMALIZE_NULL_VALUE_IN_COMBOBOX);
    normlizationAttribsComboBoxModel.setSelectedItem(NORMALIZE_NULL_VALUE_IN_COMBOBOX);
    for (final String fn : FeatureUtil.getNumericalFieldNames(getStyledFeatures().getSchema(), false)) {
        if (fn != valueAttribsComboBoxModel.getSelectedItem())

            if (FeatureUtil.checkAttributeNameRestrictions(fn))
                normlizationAttribsComboBoxModel.addElement(fn);
            else {
                LOGGER.info("Hidden attribut " + fn + " in createNormalizationFieldsComboBoxModel");
            }
        else {
            // System.out.println("Omittet field" + fn);
        }
    }
    return normlizationAttribsComboBoxModel;
}