Search in sources :

Example 21 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.

the class CPrinter method refresh.

//	getPrintService
/**
	 * 	Refresh printer list
	 */
public void refresh() {
    String current = (String) getSelectedItem();
    removeAllItems();
    setModel(new DefaultComboBoxModel(getPrinterNames()));
    if (current != null) {
        for (int i = 0; i < getItemCount(); i++) {
            String item = (String) getItemAt(i);
            if (item.equals(current))
                setSelectedIndex(i);
        }
    }
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 22 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.

the class VMatch method actionPerformed.

//	dispose
/**************************************************************************
	 *  Action Listener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Integer product = onlyProduct.getValue() != null ? (Integer) onlyProduct.getValue() : null;
    Integer vendor = onlyVendor.getValue() != null ? (Integer) onlyVendor.getValue() : null;
    Timestamp from = dateFrom.getValue() != null ? (Timestamp) dateFrom.getValue() : null;
    Timestamp to = dateTo.getValue() != null ? (Timestamp) dateTo.getValue() : null;
    if (e.getSource() == matchFrom) {
        String selection = (String) matchFrom.getSelectedItem();
        matchTo.setModel(new DefaultComboBoxModel(cmd_matchFrom(selection)));
        //  Set Title
        xMatchedBorder.setTitle(selection);
        xMatchedScrollPane.repaint();
        //  Reset Table
        xMatchedTable.setRowCount(0);
        //  sync To
        cmd_matchTo();
    } else if (e.getSource() == matchTo)
        cmd_matchTo();
    else if (e.getSource() == bSearch) {
        xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String) matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED);
        xMatched.setValue(Env.ZERO);
        //  Status Info
        statusBar.setStatusLine(matchFrom.getSelectedItem().toString() + "# = " + xMatchedTable.getRowCount(), xMatchedTable.getRowCount() == 0);
        statusBar.setStatusDB(0);
    } else if (e.getSource() == bProcess) {
        cmd_process(xMatchedTable, xMatchedToTable, matchMode.getSelectedIndex(), matchFrom.getSelectedIndex(), matchTo.getSelectedItem(), m_xMatched);
        xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String) matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED);
        xMatched.setValue(Env.ZERO);
        //  Status Info
        statusBar.setStatusLine(matchFrom.getSelectedItem().toString() + "# = " + xMatchedTable.getRowCount(), xMatchedTable.getRowCount() == 0);
        statusBar.setStatusDB(0);
    } else if (e.getSource() == sameBPartner || e.getSource() == sameProduct || e.getSource() == sameQty)
        xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String) matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED);
    panel.setCursor(Cursor.getDefaultCursor());
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Timestamp(java.sql.Timestamp) MiniTable(org.compiere.minigrid.MiniTable)

Example 23 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project adempiere by adempiere.

the class WFActivity method display.

//	loadActivities
/**
	 * 	Display.
	 * 	@param index index of table
	 * 	Fill Editors
	 */
public void display(IDColumn id) {
    log.fine("ID=" + id);
    m_activity = resetDisplay(id);
    //
    if (m_menu != null) {
        m_menu.updateActivities(selTable.getModel().getRowCount());
    }
    if (m_activity == null)
        return;
    //	Display Activity
    fNode.setText(m_activity.getNodeName());
    fDescription.setText(m_activity.getNodeDescription());
    fHelp.setText(m_activity.getNodeHelp());
    //
    fHistory.setText(m_activity.getHistoryHTML());
    //	User Actions
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
        if (m_column == null)
            m_column = node.getColumn();
        if (m_column != null && m_column.get_ID() != 0) {
            int dt = m_column.getAD_Reference_ID();
            if (dt == DisplayType.YesNo) {
                //	_YesNo
                ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false);
                fAnswerList.setModel(new DefaultComboBoxModel(values));
                fAnswerList.setVisible(true);
            } else if (dt == DisplayType.List) {
                ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false);
                fAnswerList.setModel(new DefaultComboBoxModel(values));
                fAnswerList.setVisible(true);
            } else //	other display types come here
            {
                fAnswerText.setText("");
                fAnswerText.setVisible(true);
            }
        }
    } else //	--
    if (MWFNode.ACTION_UserWindow.equals(node.getAction()) || MWFNode.ACTION_UserForm.equals(node.getAction())) {
        fAnswerButton.setText(node.getName());
        fAnswerButton.setToolTipText(node.getDescription());
        fAnswerButton.setVisible(true);
    } else
        /*
		else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
			log.log(Level.SEVERE, "Workflow Action not implemented yet"); */
        log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction());
    statusBar.setStatusDB(String.valueOf(selTable.getSelectedRow() + 1) + "/" + selTable.getRowCount());
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities"));
}
Also used : MWFNode(org.compiere.wf.MWFNode) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 24 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jmeter by apache.

the class TestActionGui method init.

private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
    setBorder(makeBorder());
    add(makeTitlePanel());
    // Target
    HorizontalPanel targetPanel = new HorizontalPanel();
    targetPanel.add(new JLabel(targetLabel));
    DefaultComboBoxModel<String> targetModel = new DefaultComboBoxModel<>();
    targetModel.addElement(threadTarget);
    targetModel.addElement(testTarget);
    targetBox = new JComboBox<>(targetModel);
    targetBox.addActionListener(evt -> {
        if (((String) targetBox.getSelectedItem()).equals(threadTarget)) {
            target = TestAction.THREAD;
        } else {
            target = TestAction.TEST;
        }
    });
    targetPanel.add(targetBox);
    add(targetPanel);
    // Action
    HorizontalPanel actionPanel = new HorizontalPanel();
    ButtonGroup actionButtons = new ButtonGroup();
    pauseButton = new JRadioButton(pauseAction, true);
    pauseButton.addChangeListener(evt -> {
        if (pauseButton.isSelected()) {
            action = TestAction.PAUSE;
            durationField.setEnabled(true);
            targetBox.setEnabled(true);
        }
    });
    stopButton = new JRadioButton(stopAction, false);
    stopButton.addChangeListener(evt -> {
        if (stopButton.isSelected()) {
            action = TestAction.STOP;
            durationField.setEnabled(false);
            targetBox.setEnabled(true);
        }
    });
    stopNowButton = new JRadioButton(stopNowAction, false);
    stopNowButton.addChangeListener(evt -> {
        if (stopNowButton.isSelected()) {
            action = TestAction.STOP_NOW;
            durationField.setEnabled(false);
            targetBox.setEnabled(true);
        }
    });
    restartNextLoopButton = new JRadioButton(restartNextLoopAction, false);
    restartNextLoopButton.addChangeListener(evt -> {
        if (restartNextLoopButton.isSelected()) {
            action = TestAction.RESTART_NEXT_LOOP;
            durationField.setEnabled(false);
            targetBox.setSelectedIndex(TestAction.THREAD);
            targetBox.setEnabled(false);
        }
    });
    actionButtons.add(pauseButton);
    actionButtons.add(stopButton);
    actionButtons.add(stopNowButton);
    actionButtons.add(restartNextLoopButton);
    actionPanel.add(new JLabel(actionLabel));
    actionPanel.add(pauseButton);
    actionPanel.add(stopButton);
    actionPanel.add(stopNowButton);
    actionPanel.add(restartNextLoopButton);
    add(actionPanel);
    // Duration
    HorizontalPanel durationPanel = new HorizontalPanel();
    durationField = new JTextField(15);
    // $NON-NLS-1$
    durationField.setText("");
    durationPanel.add(new JLabel(durationLabel));
    durationPanel.add(durationField);
    add(durationPanel);
}
Also used : JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel) VerticalLayout(org.apache.jorphan.gui.layout.VerticalLayout) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JTextField(javax.swing.JTextField)

Example 25 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jgnash by ccavanaugh.

the class DynamicJasperReportPanel method initializeUI.

private void initializeUI() {
    GridBagConstraints gridBagConstraints;
    JToolBar toolBar = new JToolBar();
    firstButton = new JButton();
    previousButton = new JButton();
    nextButton = new JButton();
    lastButton = new JButton();
    actualSizeButton = new JToggleButton();
    fitPageButton = new JToggleButton();
    fitWidthButton = new JToggleButton();
    zoomInButton = new JButton();
    DefaultComboBoxModel<String> zoomModel = new DefaultComboBoxModel<>();
    for (int z : ZOOM) {
        zoomModel.addElement(z + "%");
    }
    zoomComboBox = new JComboBox<>(zoomModel);
    DefaultComboBoxModel<Integer> fontModel = new DefaultComboBoxModel<>();
    for (int i = 0; i <= 10; i++) {
        fontModel.addElement(5 + i);
    }
    fontSizeComboBox = new JComboBox<>(fontModel);
    fontSizeComboBox.setToolTipText(ResourceUtils.getString("ToolTip.FontSize"));
    fontSizeComboBox.setSelectedItem(report.getBaseFontSize());
    fontSizeComboBox.addActionListener(this);
    zoomOutButton = new JButton();
    mainPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    scrollPanePanel = new JPanel();
    pageGluePanel = new JPanel();
    JPanel pagePanel = new JPanel();
    JPanel shadowPanel1 = new JPanel();
    JPanel shadowPanel2 = new JPanel();
    JPanel shadowPanel3 = new JPanel();
    JPanel shadowPanel4 = new JPanel();
    JPanel shadowPanel5 = new JPanel();
    setLayout(new BorderLayout());
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    saveButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-save-as.png")));
    saveButton.setToolTipText(resourceBundle.getString("save"));
    saveButton.setFocusable(false);
    saveButton.addActionListener(this);
    toolBar.add(saveButton);
    printButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-print.png")));
    printButton.setToolTipText(resourceBundle.getString("print"));
    printButton.setFocusable(false);
    printButton.addActionListener(this);
    toolBar.add(printButton);
    toolBar.add(new JToolBar.Separator());
    pageSetupButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-properties.png")));
    pageSetupButton.setToolTipText(ResourceUtils.getString("ToolTip.PageSetup"));
    pageSetupButton.setFocusable(false);
    pageSetupButton.addActionListener(this);
    toolBar.add(pageSetupButton);
    fontSizeComboBox.setMaximumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setMinimumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setPreferredSize(new Dimension(50, pageSetupButton.getPreferredSize().height));
    toolBar.add(fontSizeComboBox);
    toolBar.add(new JToolBar.Separator());
    firstButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-first.png")));
    firstButton.setToolTipText(resourceBundle.getString("first.page"));
    firstButton.setFocusable(false);
    firstButton.setEnabled(false);
    firstButton.addActionListener(this);
    toolBar.add(firstButton);
    previousButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-previous.png")));
    previousButton.setToolTipText(resourceBundle.getString("previous.page"));
    previousButton.setFocusable(false);
    previousButton.setEnabled(false);
    previousButton.addActionListener(this);
    toolBar.add(previousButton);
    nextButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-next.png")));
    nextButton.setToolTipText(resourceBundle.getString("next.page"));
    nextButton.setFocusable(false);
    nextButton.setEnabled(false);
    nextButton.addActionListener(this);
    toolBar.add(nextButton);
    lastButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-last.png")));
    lastButton.setToolTipText(resourceBundle.getString("last.page"));
    lastButton.setFocusable(false);
    lastButton.setEnabled(false);
    lastButton.addActionListener(this);
    toolBar.add(lastButton);
    toolBar.add(new JToolBar.Separator());
    actualSizeButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF")));
    actualSizeButton.setToolTipText(resourceBundle.getString("actual.size"));
    actualSizeButton.setFocusable(false);
    actualSizeButton.addActionListener(this);
    toolBar.add(actualSizeButton);
    fitPageButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF")));
    fitPageButton.setToolTipText(resourceBundle.getString("fit.page"));
    fitPageButton.setFocusable(false);
    fitPageButton.addActionListener(this);
    toolBar.add(fitPageButton);
    fitWidthButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF")));
    fitWidthButton.setToolTipText(resourceBundle.getString("fit.width"));
    fitWidthButton.setFocusable(false);
    fitWidthButton.addActionListener(this);
    toolBar.add(fitWidthButton);
    toolBar.add(new JToolBar.Separator());
    zoomInButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-in.png")));
    zoomInButton.setToolTipText(resourceBundle.getString("zoom.in"));
    zoomInButton.setFocusable(false);
    zoomInButton.addActionListener(this);
    toolBar.add(zoomInButton);
    zoomComboBox.setEditable(true);
    zoomComboBox.setToolTipText(resourceBundle.getString("zoom.ratio"));
    zoomComboBox.setMaximumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setMinimumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setPreferredSize(new Dimension(90, zoomInButton.getPreferredSize().height));
    zoomComboBox.addItemListener(evt -> zoomStateChange());
    zoomComboBox.addActionListener(this);
    toolBar.add(zoomComboBox);
    zoomOutButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-out.png")));
    zoomOutButton.setToolTipText(resourceBundle.getString("zoom.out"));
    zoomOutButton.setFocusable(false);
    zoomOutButton.addActionListener(this);
    toolBar.add(zoomOutButton);
    JPanel reportController = report.getReportController();
    if (reportController != null) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(toolBar, BorderLayout.NORTH);
        panel.add(reportController, BorderLayout.CENTER);
        add(panel, BorderLayout.NORTH);
    } else {
        add(toolBar, BorderLayout.NORTH);
    }
    mainPanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(final ComponentEvent evt) {
            pnlMainComponentResized();
        }
    });
    mainPanel.setLayout(new BorderLayout());
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPanePanel.setLayout(new GridBagLayout());
    pageGluePanel.setLayout(new BorderLayout());
    pagePanel.setLayout(new GridBagLayout());
    spaceHoldPanel = new JPanel();
    spaceHoldPanel.setMinimumSize(new Dimension(5, 5));
    spaceHoldPanel.setOpaque(false);
    spaceHoldPanel.setPreferredSize(new Dimension(5, 5));
    spaceHoldPanel.setLayout(null);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    pagePanel.add(spaceHoldPanel, gridBagConstraints);
    shadowPanel1.setBackground(java.awt.Color.gray);
    shadowPanel1.setMinimumSize(new Dimension(5, 5));
    shadowPanel1.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.VERTICAL;
    pagePanel.add(shadowPanel1, gridBagConstraints);
    shadowPanel2.setMinimumSize(new Dimension(5, 5));
    shadowPanel2.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel2, gridBagConstraints);
    shadowPanel3.setBackground(Color.gray);
    shadowPanel3.setMinimumSize(new Dimension(5, 5));
    shadowPanel3.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pagePanel.add(shadowPanel3, gridBagConstraints);
    shadowPanel4.setBackground(Color.gray);
    shadowPanel4.setMinimumSize(new Dimension(5, 5));
    shadowPanel4.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel4, gridBagConstraints);
    shadowPanel5.setMinimumSize(new Dimension(5, 5));
    shadowPanel5.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    pagePanel.add(shadowPanel5, gridBagConstraints);
    pageRenderer = new PageRenderer(this);
    pageRenderer.setBackground(Color.white);
    pageRenderer.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    pageRenderer.setOpaque(true);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pagePanel.add(pageRenderer, gridBagConstraints);
    pageGluePanel.add(pagePanel, BorderLayout.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    scrollPanePanel.add(pageGluePanel, gridBagConstraints);
    scrollPane.setViewportView(scrollPanePanel);
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    add(mainPanel, BorderLayout.CENTER);
    zoomComboBox.setSelectedIndex(DEFAULT_ZOOM_INDEX);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JToggleButton(javax.swing.JToggleButton) BorderLayout(java.awt.BorderLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8