Search in sources :

Example 16 with ListSelectionModel

use of javax.swing.ListSelectionModel in project pcgen by PCGen.

the class SkillInfoTab method createModels.

@Override
public ModelMap createModels(final CharacterFacade character) {
    ModelMap models = new ModelMap();
    ListSelectionModel listModel = new DefaultListSelectionModel();
    listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    models.put(ListSelectionModel.class, listModel);
    models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
    models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
    models.put(FilterHandler.class, new FilterHandler(character, listModel));
    models.put(InfoHandler.class, new InfoHandler(character));
    models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
    models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));
    SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
    models.put(SkillSheetHandler.class, skillSheetHandler);
    models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
    return models;
}
Also used : SkillPointTableModel(pcgen.gui2.tabs.skill.SkillPointTableModel) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) SkillTreeViewModel(pcgen.gui2.tabs.skill.SkillTreeViewModel)

Example 17 with ListSelectionModel

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

the class Info method jbInit.

/**
	 *	Static Init
	 *  @throws Exception
	 */
protected void jbInit() throws Exception {
    this.getContentPane().add(parameterPanel, BorderLayout.NORTH);
    this.getContentPane().add(scrollPane, BorderLayout.CENTER);
    this.getContentPane().add(southPanel, BorderLayout.SOUTH);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    //
    AppsAction aa = new AppsAction(ConfirmPanel.A_RESET, null, "reset");
    bReset = (CButton) aa.getButton();
    bReset.setMargin(ConfirmPanel.s_insets);
    bReset.setSize(bReset.getHeight(), bReset.getHeight());
    Dimension bSize = bReset.getSize();
    bSize.height = bReset.getHeight();
    bSize.width = bReset.getHeight();
    // Make it square
    bReset.setMaximumSize(bSize);
    bReset.addActionListener(this);
    //
    buttonPanel = new CPanel(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.add(bReset, FlowLayout.LEFT);
    //
    // p_criteriaGrid is filled by the subordinate class
    p_criteriaGrid.setLayout(new ALayout());
    //
    parameterPanel.setLayout(new BorderLayout());
    parameterPanel.add(buttonPanel, BorderLayout.WEST);
    parameterPanel.add(p_criteriaGrid, BorderLayout.CENTER);
    //
    // Setup the detail panel if used
    p_detailTaskPane.setVisible(false);
    p_detailTaskPane.setCollapsed(true);
    p_detailTaskPane.setLayout(new BorderLayout());
    p_detailTaskPane.setUI(new AdempiereTaskPaneUI());
    p_detailTaskPane.getContentPane().setBackground(new ColorUIResource(251, 248, 241));
    p_detailTaskPane.getContentPane().setForeground(new ColorUIResource(251, 0, 0));
    addonPanel.setLayout(new BorderLayout());
    // Allow auto resizing of the panel
    addonPanel.add(p_detailTaskPane, BorderLayout.CENTER);
    southPanel.setLayout(southLayout);
    southPanel.add(addonPanel, BorderLayout.NORTH);
    southPanel.add(confirmPanel, BorderLayout.CENTER);
    southPanel.add(statusBar, BorderLayout.SOUTH);
    scrollPane.getViewport().add(p_table, null);
    //
    confirmPanel.addActionListener(this);
    confirmPanel.getResetButton().setVisible(hasReset());
    confirmPanel.getCustomizeButton().setVisible(hasCustomize());
    confirmPanel.getHistoryButton().setVisible(hasHistory());
    confirmPanel.getZoomButton().setVisible(hasZoom());
    //  Only show the OK button if we intend to save
    confirmPanel.setOKVisible(p_saveResults);
    //
    JButton print = ConfirmPanel.createPrintButton(true);
    print.addActionListener(this);
    confirmPanel.addButton(print);
    //
    checkAutoQuery.setText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
    checkAutoQuery.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
    checkAutoQuery.setName("AutoQuery");
    checkAutoQuery.setSelected(MSysConfig.getValue(SYSCONFIG_INFO_AUTO_QUERY, "Y", Env.getAD_Client_ID(Env.getCtx())).equals("Y"));
    checkAutoQuery.addActionListener(this);
    // Index 0 is OK-Cancel on the right
    CPanel leftButtons = (CPanel) confirmPanel.getComponent(1);
    // Add the check box on the very left before the refresh icon
    leftButtons.add(checkAutoQuery, 0);
    //
    popup.add(zoomMenu);
    zoomMenu.setText(Msg.getMsg(Env.getCtx(), "Zoom"));
    zoomMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Zoom16.gif")));
    zoomMenu.addActionListener(this);
    //
    popup.add(calcMenu);
    calcMenu.setText(Msg.getMsg(Env.getCtx(), "Calculator"));
    calcMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Calculator16.gif")));
    calcMenu.addActionListener(this);
    //
    //  Table Selection (Invoked before setting column class so that row selection is enabled)
    p_table.setKeyColumnIndex(-1);
    p_table.setCellSelectionEnabled(false);
    p_table.setColumnSelectionAllowed(false);
    p_table.setRowSelectionAllowed(true);
    //  Override the Enter key input and action map
    if (p_saveResults) {
        p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doDispose");
    } else {
        p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing");
    }
    p_table.getActionMap().put("doDispose", doDispose);
    // To enable buttons
    ((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
    p_table.addMouseListener(this);
    // Listen to changes in the table
    p_table.addPropertyChangeListener("p_table_update", this);
    ((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
    //
    //  Set default location where focus will go. See property change listener.
    m_parentPanel = p_criteriaGrid;
    //
    enableButtons();
}
Also used : AdempiereTaskPaneUI(org.adempiere.plaf.AdempiereTaskPaneUI) ImageIcon(javax.swing.ImageIcon) AppsAction(org.compiere.apps.AppsAction) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) CPanel(org.compiere.swing.CPanel) JButton(javax.swing.JButton) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) ColorUIResource(javax.swing.plaf.ColorUIResource) ALayout(org.compiere.apps.ALayout)

Example 18 with ListSelectionModel

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

the class MiniTable method toggleRowChecked.

/**
     * Toggles the selection checkbox of the given row. Adds or removes the row from
     * the selection accordingly.
     * @param row - the row in the view to toggle  
     */
private void toggleRowChecked(int row) {
    //  Range check
    int rows = this.getRowCount();
    if (this.getShowTotals())
        rows = rows - 1;
    if (row < 0 || row >= rows)
        return;
    ListSelectionModel rsm = this.getSelectionModel();
    //  Toggle
    setRowChecked(row, !isRowChecked(row));
    if (isRowChecked(row)) {
        if (isMultiSelection())
            rsm.addSelectionInterval(row, row);
        else
            rsm.setSelectionInterval(row, row);
    } else {
        rsm.removeSelectionInterval(row, row);
    }
}
Also used : DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel)

Example 19 with ListSelectionModel

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

the class MiniTable method toggleLeadRowChecked.

/**
     * Toggles the selection checkbox of the current lead row. Adds or removes the lead row from
     * the selection accordingly.  
     */
private void toggleLeadRowChecked() {
    // Check if the lead row is selected, if not, select it
    ListSelectionModel rsm = this.getSelectionModel();
    int leadRow = rsm.getLeadSelectionIndex();
    if (leadRow == -1)
        return;
    //  Toggle
    setRowChecked(leadRow, !isRowChecked(leadRow));
    if (isRowChecked(leadRow)) {
        if (isMultiSelection())
            rsm.addSelectionInterval(leadRow, leadRow);
        else
            rsm.setSelectionInterval(leadRow, leadRow);
    } else {
        rsm.removeSelectionInterval(leadRow, leadRow);
        rsm.setLeadSelectionIndex(leadRow);
    }
}
Also used : DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel)

Example 20 with ListSelectionModel

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

the class MiniTable method toggleRowCheckedRange.

/**
     * Toggles the selection checkbox of a range or rows. Adds or removes the rows from
     * the selection accordingly.
     * @param index0 - one end of the range
     * @param index1 - the other end of the range. Can be less than, equal or greater than index0.
     */
private void toggleRowCheckedRange(int index0, int index1) {
    if (isMultiSelection()) {
        if (getKeyColumnIndex() >= 0) {
            int rows = this.getRowCount();
            if (this.getShowTotals())
                rows = rows - 1;
            if (index0 < 0 || index0 >= rows || index1 < 0 || index1 >= rows)
                return;
            ListSelectionModel rsm = this.getSelectionModel();
            int leadRow = rsm.getLeadSelectionIndex();
            int low = index0 <= index1 ? index0 : index1;
            int high = index0 <= index1 ? index1 : index0;
            // Limit the number of row selection events to once per change
            m_changingMultipleRows = true;
            for (int row = low; row <= high; row++) {
                toggleRowChecked(row);
            }
            //  Return the lead to its original location
            rsm.setLeadSelectionIndex(leadRow);
            fireRowSelectionEvent();
            m_changingMultipleRows = false;
        }
    }
}
Also used : DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel)

Aggregations

ListSelectionModel (javax.swing.ListSelectionModel)21 DefaultListSelectionModel (javax.swing.DefaultListSelectionModel)10 JScrollPane (javax.swing.JScrollPane)5 BorderLayout (java.awt.BorderLayout)4 Dimension (java.awt.Dimension)4 JButton (javax.swing.JButton)4 JLabel (javax.swing.JLabel)3 JTable (javax.swing.JTable)3 FlowLayout (java.awt.FlowLayout)2 ArrayList (java.util.ArrayList)2 JDialog (javax.swing.JDialog)2 JPanel (javax.swing.JPanel)2 TableColumnModel (javax.swing.table.TableColumnModel)2 TableModel (javax.swing.table.TableModel)2 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Container (java.awt.Container)1 Font (java.awt.Font)1