Search in sources :

Example 81 with TableColumnModel

use of javax.swing.table.TableColumnModel in project processdash by dtuma.

the class WBSColumnSelectorDialog method buildTreeModel.

/**
     * Construct the TreeNode structure for the available columns
     * @param availableTabs
     * @return TreeNode
     */
private TreeNode buildTreeModel(Map availableTabs) {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Tabs");
    for (Iterator iter = availableTabs.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iter.next();
        DefaultMutableTreeNode tabNode = new DefaultMutableTreeNode(entry.getKey());
        TableColumnModel tableColumnModel = (TableColumnModel) entry.getValue();
        for (Enumeration e = tableColumnModel.getColumns(); e.hasMoreElements(); ) {
            DefaultMutableTreeNode columnNode = new DefaultMutableTreeNode(e.nextElement());
            tabNode.add(columnNode);
        }
        rootNode.add(tabNode);
    }
    return rootNode;
}
Also used : Enumeration(java.util.Enumeration) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Iterator(java.util.Iterator) TableColumnModel(javax.swing.table.TableColumnModel) Map(java.util.Map)

Example 82 with TableColumnModel

use of javax.swing.table.TableColumnModel in project processdash by dtuma.

the class WBSTabPanel method getTabData.

public LinkedHashMap<String, TableColumnModel> getTabData() {
    LinkedHashMap<String, TableColumnModel> result = new LinkedHashMap<String, TableColumnModel>();
    for (int i = 0; i < tabbedPane.getTabCount() - 1; i++) {
        String tabName = tabbedPane.getTitleAt(i);
        String key = tabName;
        int j = 0;
        while (result.containsKey(key)) {
            key = tabName + " (" + (++j) + ")";
        }
        TableColumnModel colModel = (TableColumnModel) tableColumnModels.get(i);
        result.put(key, colModel);
    }
    return result;
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) LinkedHashMap(java.util.LinkedHashMap)

Example 83 with TableColumnModel

use of javax.swing.table.TableColumnModel in project processdash by dtuma.

the class WBSTabPanel method copyColumnsDeep.

private TableColumnModel copyColumnsDeep(TableColumnModel tableColumnModel) {
    TableColumnModel newTableColumnModel = new DefaultTableColumnModel();
    for (Enumeration columns = tableColumnModel.getColumns(); columns.hasMoreElements(); ) {
        DataTableColumn existingColumn = (DataTableColumn) columns.nextElement();
        newTableColumnModel.addColumn(new DataTableColumn(existingColumn));
    }
    return newTableColumnModel;
}
Also used : Enumeration(java.util.Enumeration) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel)

Example 84 with TableColumnModel

use of javax.swing.table.TableColumnModel in project processdash by dtuma.

the class SaveAsExcelAction method writeData.

private void writeData(File f) {
    DataJTable dataTable = getDataJTable();
    WBSTabPanel tabPanel = getWBSTabPanel();
    WBSExcelWriter writer = new WBSExcelWriter(dataTable);
    LinkedHashMap<String, TableColumnModel> tabs = tabPanel.getTabData();
    for (Map.Entry<String, TableColumnModel> e : tabs.entrySet()) {
        writer.addData(e.getKey(), e.getValue());
    }
    try {
        writer.save(f);
    } catch (IOException ioe) {
        Object message = resources.formatStrings("Error.Message_FMT", f.getAbsolutePath());
        JOptionPane.showMessageDialog(tabPanel, message, resources.getString("Error.Title"), JOptionPane.ERROR_MESSAGE);
    }
}
Also used : WBSTabPanel(teamdash.wbs.WBSTabPanel) DataJTable(teamdash.wbs.DataJTable) TableColumnModel(javax.swing.table.TableColumnModel) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 85 with TableColumnModel

use of javax.swing.table.TableColumnModel in project processdash by dtuma.

the class QuickLauncher method buildUI.

private void buildUI() throws Exception {
    String windowTitle;
    String versionNumber = getVersionNumber();
    if (versionNumber == null)
        windowTitle = resources.getString("Window_Title");
    else
        windowTitle = resources.format("Window_Title2_FMT", versionNumber);
    frame = new JFrame(windowTitle);
    DashboardIconFactory.setLauncherWindowIcon(frame);
    JPanel contents = new JPanel();
    contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS));
    launcherFactory = new InstanceLauncherFactory();
    DropTransferHandler th = new DropTransferHandler(this, launcherFactory);
    contents.setTransferHandler(th);
    contents.add(new JLabel(resources.getString("Window_Prompt")));
    contents.add(new OptionCheckbox("Read_Only", "-DreadOnly=true\n" + "-Dteamdash.wbs.readOnly=true", null, processFactory, false));
    contents.add(new OptionCheckbox("Disable_Export", "-D" + Settings.SYS_PROP_PREFIX + "export.disableAutoExport=true\n" + "-D" + Settings.SYS_PROP_PREFIX + "backup.extraDirectories=", null, processFactory, true));
    contents.add(new OptionCheckbox("Use_External_Templates", null, "-D" + Settings.SYS_PROP_PREFIX + "templates.disableSearchPath=true", processFactory, false));
    JTable table = new JTable(instanceList);
    TableColumnModel cols = table.getColumnModel();
    for (int i = 0; i < InstanceList.COLUMN_WIDTHS.length; i++) {
        int width = InstanceList.COLUMN_WIDTHS[i];
        cols.getColumn(i).setPreferredWidth(width);
    }
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setTransferHandler(th);
    table.setPreferredScrollableViewportSize(new Dimension(380, 100));
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBackground(Color.WHITE);
    contents.add(scrollPane);
    actionHandler = new InstanceActionHandler(table, instanceList);
    instanceList.addTableModelListener((TableModelListener) EventHandler.create(TableModelListener.class, this, "updateCursor"));
    frame.getContentPane().add(contents);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) TableColumnModel(javax.swing.table.TableColumnModel) Dimension(java.awt.Dimension) JFrame(javax.swing.JFrame) JTable(javax.swing.JTable)

Aggregations

TableColumnModel (javax.swing.table.TableColumnModel)168 TableColumn (javax.swing.table.TableColumn)66 JTable (javax.swing.JTable)34 JScrollPane (javax.swing.JScrollPane)31 JButton (javax.swing.JButton)30 BoxLayout (javax.swing.BoxLayout)24 TableCellEditor (javax.swing.table.TableCellEditor)23 ButtonEditor (jmri.util.table.ButtonEditor)23 ButtonRenderer (jmri.util.table.ButtonRenderer)23 JLabel (javax.swing.JLabel)22 JPanel (javax.swing.JPanel)22 ActionEvent (java.awt.event.ActionEvent)20 ActionListener (java.awt.event.ActionListener)16 FlowLayout (java.awt.FlowLayout)15 Border (javax.swing.border.Border)13 Iterator (java.util.Iterator)12 Set (java.util.Set)12 JTableHeader (javax.swing.table.JTableHeader)12 TableCellRenderer (javax.swing.table.TableCellRenderer)12 Container (java.awt.Container)10