Example usage for javax.swing.table TableColumn setMinWidth

List of usage examples for javax.swing.table TableColumn setMinWidth

Introduction

In this page you can find the example usage for javax.swing.table TableColumn setMinWidth.

Prototype

@BeanProperty(description = "The minimum width of the column.")
public void setMinWidth(int minWidth) 

Source Link

Document

Sets the TableColumn's minimum width to minWidth, adjusting the new minimum width if necessary to ensure that 0 <= minWidth <= maxWidth.

Usage

From source file:ome.formats.importer.gui.ErrorTable.java

/**
 * Constructor for class/*from  ww w .jav a 2 s .co m*/
 */
public ErrorTable() {
    // set to layout that will maximize on resizing
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    this.setOpaque(false);

    // Main Panel containing all elements  
    // Set up the main panel layout
    double mainTable[][] = { { 5, 200, 140, TableLayout.FILL, 140, 5 }, // columns
            { 5, TableLayout.PREFERRED, TableLayout.FILL, 5, 29, 5 } }; // rows

    mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug);

    String message = "All errors accumulated during your import are displayed here, "
            + "and will be uploaded to us if check-marked. You can send us feedback on "
            + "these problems by clicking the 'Send Feedback' button.";

    JTextPane instructions = GuiCommonElements.addTextPane(mainPanel, message, "1,1,4,0", debug);
    instructions.setMargin(new Insets(10, 10, 10, 10));

    TableColumnModel cModel = eTable.getColumnModel();

    // *** remove last 3 rows from display ***
    TableColumn hiddenColumn = cModel.getColumn(6);
    cModel.removeColumn(hiddenColumn);
    hiddenColumn = cModel.getColumn(5);
    cModel.removeColumn(hiddenColumn);
    hiddenColumn = cModel.getColumn(4);
    cModel.removeColumn(hiddenColumn);

    MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer();
    //LeftTableHeaderRenderer leftHeader = new LeftTableHeaderRenderer();

    // Create a custom header for the table
    cModel.getColumn(0).setHeaderRenderer(myHeader);
    cModel.getColumn(1).setHeaderRenderer(myHeader);
    cModel.getColumn(2).setHeaderRenderer(myHeader);
    cModel.getColumn(3).setHeaderRenderer(myHeader);

    cbe = new CheckboxCellEditor(new JCheckBox());
    cbe.checkbox.addMouseListener(this);
    cbr = new CheckboxRenderer();

    cModel.getColumn(0).setCellEditor(cbe);
    cModel.getColumn(0).setCellRenderer(cbr);
    cModel.getColumn(1).setCellRenderer(new LeftDotRenderer());
    cModel.getColumn(2).setCellRenderer(new TextLeftRenderer());
    cModel.getColumn(3).setCellRenderer(new StatusRenderer());

    // Set the width of the status column
    TableColumn statusColumn = eTable.getColumnModel().getColumn(3);
    statusColumn.setPreferredWidth(statusWidth);
    statusColumn.setMaxWidth(statusWidth);
    statusColumn.setMinWidth(statusWidth);

    // Set the width of the error column
    TableColumn dateColumn = eTable.getColumnModel().getColumn(2);
    dateColumn.setPreferredWidth(errorWidth);
    dateColumn.setMaxWidth(errorWidth);
    dateColumn.setMinWidth(errorWidth);

    // Set the width of the upload column
    TableColumn uploadColumn = eTable.getColumnModel().getColumn(0);
    uploadColumn.setPreferredWidth(uploadWidth);
    uploadColumn.setMaxWidth(uploadWidth);
    uploadColumn.setMinWidth(uploadWidth);

    eTable.setRowSelectionAllowed(false);

    // Add the table to the scollpane
    JScrollPane scrollPane = new JScrollPane(eTable);

    mainPanel.add(scrollPane, "1,2,4,1");

    double progressTable[][] = { { 200 }, // columns
            { 12, 5, 12 } }; // rows

    progressPanel = GuiCommonElements.addPlanePanel(mainPanel, progressTable, debug);

    runThread = new Thread() {
        public void run() {
            try {
                bytesProgressBar = new JProgressBar();
                progressPanel.add(bytesProgressBar, "0,0");

                filesProgressBar = new JProgressBar(0, 20);
                progressPanel.add(filesProgressBar, "0,2");
            } catch (Throwable error) {
            }
        }
    };
    runThread.start();

    mainPanel.add(progressPanel, "1,4");

    progressPanel.setVisible(false);

    cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'c', "Cancel sending", "2,4,L,C", debug);
    cancelBtn.addActionListener(this);

    cancelBtn.setVisible(false);

    clearDoneBtn = GuiCommonElements.addButton(mainPanel, "Clear Done", 'd', "Clear done", "3,4,R,C", debug);
    clearDoneBtn.addActionListener(this);
    clearDoneBtn.setOpaque(false);
    clearDoneBtn.setEnabled(false);
    //clearDoneBtn.setVisible(false); // Disabled (See #5250)

    sendBtn = GuiCommonElements.addButton(mainPanel, "Send Feedback", 's', "Send your errors to the OMERO team",
            "4,4,R,C", debug);
    sendBtn.setOpaque(false);
    sendBtn.addActionListener(this);
    sendBtn.setEnabled(false);

    this.add(mainPanel);
}

From source file:ome.formats.importer.gui.FileQueueTable.java

/**
 * Set up and display the file queue table
 *//*from   w w  w.ja  v a2  s.c  o  m*/
FileQueueTable() {

    // ----- Variables -----
    // Debug Borders
    Boolean debugBorders = false;

    // Size of the add/remove/refresh buttons (which are square).
    int buttonSize = 40;
    // Add graphic for the refresh button
    //String refreshIcon = "gfx/recycled.png";
    // Add graphic for add button
    String addIcon = "gfx/add.png";
    // Remove graphics for remove button
    String removeIcon = "gfx/remove.png";

    // Width of the status columns
    int statusWidth = 100;

    // ----- GUI Layout Elements -----

    // Start layout here
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(6, 5, 9, 8));

    JPanel buttonPanel = new JPanel();
    if (debugBorders == true)
        buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red, 1));
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS));

    //        refreshBtn = addButton("+", refreshIcon, null);
    //        refreshBtn.setMaximumSize(new Dimension(buttonSize, buttonSize));
    //        refreshBtn.setPreferredSize(new Dimension(buttonSize, buttonSize));
    //        refreshBtn.setMinimumSize(new Dimension(buttonSize, buttonSize));
    //        refreshBtn.setSize(new Dimension(buttonSize, buttonSize));
    //        refreshBtn.setActionCommand(Actions.REFRESH);
    //        refreshBtn.addActionListener(this);

    addBtn = GuiCommonElements.addBasicButton(null, addIcon, null);
    addBtn.setMaximumSize(new Dimension(buttonSize, buttonSize));
    addBtn.setPreferredSize(new Dimension(buttonSize, buttonSize));
    addBtn.setMinimumSize(new Dimension(buttonSize, buttonSize));
    addBtn.setSize(new Dimension(buttonSize, buttonSize));
    addBtn.setActionCommand(FileQueueHandler.ADD);
    addBtn.addActionListener(this);
    addBtn.setToolTipText("Add files to the import queue.");

    removeBtn = GuiCommonElements.addBasicButton(null, removeIcon, null);
    removeBtn.setMaximumSize(new Dimension(buttonSize, buttonSize));
    removeBtn.setPreferredSize(new Dimension(buttonSize, buttonSize));
    removeBtn.setMinimumSize(new Dimension(buttonSize, buttonSize));
    removeBtn.setSize(new Dimension(buttonSize, buttonSize));
    removeBtn.setActionCommand(FileQueueHandler.REMOVE);
    removeBtn.addActionListener(this);
    removeBtn.setToolTipText("Remove files from the import queue.");

    buttonPanel.add(Box.createRigidArea(new Dimension(0, 60)));
    //buttonPanel.add(refreshBtn);
    buttonPanel.add(Box.createVerticalGlue());
    buttonPanel.add(addBtn);
    buttonPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    buttonPanel.add(removeBtn);
    buttonPanel.add(Box.createVerticalGlue());
    buttonPanel.add(Box.createRigidArea(new Dimension(0, 60)));
    add(buttonPanel);
    add(Box.createRigidArea(new Dimension(5, 0)));

    JPanel queuePanel = new JPanel();
    if (debugBorders == true)
        queuePanel.setBorder(BorderFactory.createLineBorder(Color.red, 1));
    queuePanel.setLayout(new BoxLayout(queuePanel, BoxLayout.PAGE_AXIS));
    //queuePanel.add(Box.createRigidArea(new Dimension(0,10)));
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS));
    JLabel label = new JLabel("Import Queue:");
    labelPanel.add(label);
    labelPanel.add(Box.createHorizontalGlue());
    groupBtn = GuiCommonElements.addBasicButton("Group: ", null, "Current Group");
    groupBtn.setToolTipText("The user group you are logged into.");
    //groupBtn.setEnabled(false);
    labelPanel.add(groupBtn);
    queuePanel.add(labelPanel);
    queuePanel.add(Box.createRigidArea(new Dimension(0, 5)));

    TableColumnModel cModel = getQueue().getColumnModel();

    headerCellRenderer = new MyTableHeaderRenderer();
    fileCellRenderer = new LeftDotRenderer();
    dpCellRenderer = new CenterTextRenderer();
    statusCellRenderer = new CenterTextRenderer();

    // Create a custom header for the table
    cModel.getColumn(0).setHeaderRenderer(headerCellRenderer);
    cModel.getColumn(1).setHeaderRenderer(headerCellRenderer);
    cModel.getColumn(2).setHeaderRenderer(headerCellRenderer);
    cModel.getColumn(0).setCellRenderer(fileCellRenderer);
    cModel.getColumn(1).setCellRenderer(dpCellRenderer);
    cModel.getColumn(2).setCellRenderer(statusCellRenderer);

    // Set the width of the status column
    TableColumn statusColumn = getQueue().getColumnModel().getColumn(2);
    statusColumn.setPreferredWidth(statusWidth);
    statusColumn.setMaxWidth(statusWidth);
    statusColumn.setMinWidth(statusWidth);

    SelectionListener listener = new SelectionListener(getQueue());
    getQueue().getSelectionModel().addListSelectionListener(listener);
    //queue.getColumnModel().getSelectionModel()
    //    .addListSelectionListener(listener);

    // Hide 3rd to 6th columns
    TableColumnModel tcm = getQueue().getColumnModel();
    TableColumn projectColumn = tcm.getColumn(6);
    tcm.removeColumn(projectColumn);
    TableColumn userPixelColumn = tcm.getColumn(6);
    tcm.removeColumn(userPixelColumn);
    TableColumn userSpecifiedNameColumn = tcm.getColumn(6);
    tcm.removeColumn(userSpecifiedNameColumn);
    TableColumn datasetColumn = tcm.getColumn(3);
    tcm.removeColumn(datasetColumn);
    TableColumn pathColumn = tcm.getColumn(3);
    tcm.removeColumn(pathColumn);
    TableColumn archiveColumn = tcm.getColumn(3);
    tcm.removeColumn(archiveColumn);

    // Add the table to the scollpane
    JScrollPane scrollPane = new JScrollPane(getQueue());

    queuePanel.add(scrollPane);

    JPanel importPanel = new JPanel();
    importPanel.setLayout(new BoxLayout(importPanel, BoxLayout.LINE_AXIS));
    clearDoneBtn = GuiCommonElements.addBasicButton("Clear Done", null, null);
    clearFailedBtn = GuiCommonElements.addBasicButton("Clear Failed", null, null);
    importBtn = GuiCommonElements.addBasicButton("Import", null, null);
    importPanel.add(Box.createHorizontalGlue());
    importPanel.add(clearDoneBtn);
    clearDoneBtn.setEnabled(false);
    clearDoneBtn.setActionCommand(FileQueueHandler.CLEARDONE);
    clearDoneBtn.addActionListener(this);
    clearDoneBtn.setToolTipText("Clear all 'done' entries from the import queue.");
    importPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    importPanel.add(clearFailedBtn);
    clearFailedBtn.setEnabled(false);
    clearFailedBtn.setActionCommand(FileQueueHandler.CLEARFAILED);
    clearFailedBtn.addActionListener(this);
    clearFailedBtn.setToolTipText("Clear all 'failed' entries from the import queue.");
    importPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    importPanel.add(importBtn);
    importBtn.setEnabled(false);
    importBtn.setActionCommand(FileQueueHandler.IMPORT);
    importBtn.addActionListener(this);
    importBtn.setToolTipText("Begin importing files.");
    GuiCommonElements.enterPressesWhenFocused(importBtn);
    queuePanel.add(Box.createRigidArea(new Dimension(0, 5)));
    queuePanel.add(importPanel);
    add(queuePanel);
}

From source file:ome.formats.importer.gui.HistoryTable.java

/**
 * Create history table//from   www  . ja  va  2 s. c  o m
 * 
 * @param viewer- GuiImporter parent
 */
HistoryTable(GuiImporter viewer) {
    this.viewer = viewer;
    try {
        historyTaskBar.addPropertyChangeListener(this);
    } catch (Exception ex) {
        log.error("Exception adding property change listener.", ex);
    }

    HistoryTableStore db = null;
    //HistoryDB db = null;
    try {
        db = new HistoryTableStore();
        db.addObserver(this);
    } catch (Exception e) {
        db = null;
        log.error("Could not start history DB.", e);
        if (HistoryDB.alertOnce == false) {
            JOptionPane.showMessageDialog(null,
                    "We were not able to connect to the history DB.\n"
                            + "In the meantime, you will still be able to use \n"
                            + "the importer, but the history feature will be disable.",
                    "Warning", JOptionPane.ERROR_MESSAGE);
            HistoryDB.alertOnce = true;
        }
    }

    this.db = db;

    // set to layout that will maximize on resizing
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    this.setOpaque(false);

    // Main Panel containing all elements  
    // Set up the main panel layout
    /* Disabled till #2308 fixed
    double mainTable[][] =
        {{170, 10, TableLayout.FILL, 80}, // columns
        { 5, 30, 35, 40, TableLayout.FILL, 35, 5}}; // rows
        */
    double mainTable[][] = { { 170, 10, TableLayout.FILL, 90 }, // columns
            { 5, 30, 35, 70, TableLayout.FILL, 35, 5 } }; // rows

    mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug);

    // *****Side Panel****
    double topSideTable[][] = { { TableLayout.FILL }, // columns
            { 20, 20, 20, 20, 35 } }; // rows      

    topSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, topSideTable, " Date Filter ", debug);

    String[] dateFormats = new String[1];
    dateFormats[0] = DATE_FORMAT;

    fromDate = new JXDatePicker();
    fromDate.setToolTipText("Pick a from date.");
    //fromDate.getEditor().setEditable(false);
    //fromDate.setEditable(false);
    fromDate.setFormats(dateFormats);

    toDate = new JXDatePicker();
    toDate.setToolTipText("Pick a to date.");
    //toDate.getEditor().setEditable(false);
    //toDate.setEditable(false);
    toDate.setFormats(dateFormats);

    fromLabel = new JLabel("From (yy/mm/dd):");

    topSidePanel.add(fromLabel, "0,0");
    topSidePanel.add(fromDate, "0,1");

    toLabel = new JLabel("To (yy/mm/dd):");

    topSidePanel.add(toLabel, "0,2");
    topSidePanel.add(toDate, "0,3");

    double bottomSideTable[][] = { { TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows 

    historyTaskBar.addTaskPane("Today", historyTaskBar.getList(todayList));
    historyTaskBar.addTaskPane("Yesterday", historyTaskBar.getList(yesterdayList));
    historyTaskBar.addTaskPane("This Week", historyTaskBar.getList(thisWeekList));
    historyTaskBar.addTaskPane("Last Week", historyTaskBar.getList(lastWeekList));
    historyTaskBar.addTaskPane("This Month", historyTaskBar.getList(thisMonthList));

    bottomSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, bottomSideTable, " Quick Date ", debug);

    /*
    JPanel taskPanel = new JPanel( new BorderLayout() );
    JScrollPane taskScrollPane = new JScrollPane();
    taskScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    taskScrollPane.getViewport().add(historyTaskBar);
    taskPanel.add(taskScrollPane);
            
    bottomSidePanel.add(taskPanel, "f,f");
    taskPanel.validate();
    */

    bottomSidePanel.add(historyTaskBar, "0,0");

    clearBtn = GuiCommonElements.addIconButton(mainPanel, "Wipe History", clearIcon, 130, 32, (int) 'S',
            "Click here to clear your history log.", "0,5,C,C", debug);

    clearBtn.setActionCommand(HistoryHandler.CLEARHISTORY);
    clearBtn.addActionListener(this);

    // *****Top right most row containing search field and buttons*****
    /*// Disabled till #2308 fixed
    searchField = GuiCommonElements.addTextField(mainPanel, "Name Filter: ", "*.*", 'N', 
        "Type in a file name to search for here.", "", 
        TableLayout.PREFERRED, "2,1, 0, 0", debug);
    */

    searchField = new JTextField("*.*");
    searchField.setVisible(false);

    searchBtn = GuiCommonElements.addButton(topSidePanel, "Search", 'S', "Click here to search", "0,4,C,C",
            debug);

    searchBtn.setActionCommand(HistoryHandler.HISTORYSEARCH);
    searchBtn.addActionListener(this);

    // *****Middle right row containing the filter options*****
    // Since this panel has a different layout, use a new panel for it

    /* Disabled till #2308 fixed
    // Set up the filterTable layout
    double filterTable[][] =
        {{100, 80, 80, 80, 90, TableLayout.FILL}, // columns
        { 30 }}; // rows
            
    filterPanel = GuiCommonElements.addPlanePanel(mainPanel, filterTable, debug);     
    filterLabel = GuiCommonElements.addTextPane(filterPanel, "Status Filters: ", "0,0,r,c", debug);
            
    doneCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Done", "1,0,L,C", debug);
    failedCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Failed", "2,0,L,C", debug);
    invalidCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Invalid", "3,0,L,C", debug);
    pendingCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Pending", "4,0,L,C", debug);
            
    // Default filters to 'on'
    doneCheckBox.setSelected(true);
    failedCheckBox.setSelected(true);
    invalidCheckBox.setSelected(true);
    pendingCheckBox.setSelected(true);
            
    doneCheckBox.addActionListener(this);
    failedCheckBox.addActionListener(this);
    invalidCheckBox.addActionListener(this);
    pendingCheckBox.addActionListener(this);
    filterPanel.setVisible(false);
    */

    // *****Bottom right most row containing the history table*****
    TableColumnModel cModel = eTable.getColumnModel();

    // *** remove last 4 rows from display ***
    TableColumn hiddenColumn = cModel.getColumn(6);
    cModel.removeColumn(hiddenColumn);
    hiddenColumn = cModel.getColumn(5);
    cModel.removeColumn(hiddenColumn);
    hiddenColumn = cModel.getColumn(4);
    cModel.removeColumn(hiddenColumn);

    MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer();

    // Create a custom header for the table
    cModel.getColumn(0).setHeaderRenderer(myHeader);
    cModel.getColumn(1).setHeaderRenderer(myHeader);
    cModel.getColumn(2).setHeaderRenderer(myHeader);
    cModel.getColumn(3).setHeaderRenderer(myHeader);

    cModel.getColumn(0).setCellRenderer(new LeftDotRenderer());
    cModel.getColumn(1).setCellRenderer(new TextCellCenter());
    cModel.getColumn(2).setCellRenderer(new TextCellCenter());
    cModel.getColumn(3).setCellRenderer(new TextCellCenter());

    // Set the width of the status column
    TableColumn statusColumn = eTable.getColumnModel().getColumn(3);
    statusColumn.setPreferredWidth(statusWidth);
    statusColumn.setMaxWidth(statusWidth);
    statusColumn.setMinWidth(statusWidth);

    // Set the width of the status column
    TableColumn dateColumn = eTable.getColumnModel().getColumn(2);
    dateColumn.setPreferredWidth(dateWidth);
    dateColumn.setMaxWidth(dateWidth);
    dateColumn.setMinWidth(dateWidth);

    // Add the table to the scollpane
    JScrollPane scrollPane = new JScrollPane(eTable);

    // disabled till #2308 fixed
    //reimportBtn = GuiCommonElements.addButton(filterPanel, "Reimport", 'R', "Click here to reimport selected images", "5,0,R,C", debug);
    reimportBtn = GuiCommonElements.addButton(mainPanel, "Reimport", 'R',
            "Click here to reimport selected images", "3,5,C,C", debug);
    reimportBtn.setEnabled(false);

    reimportBtn.setActionCommand(HistoryHandler.HISTORYREIMPORT);
    reimportBtn.addActionListener(this);

    // Handle the listener
    ListSelectionModel selectionModel = this.eTable.getSelectionModel();
    selectionModel.addListSelectionListener(this);

    //mainPanel.add(scrollPane, "2,3,3,5"); Disabled till #2308 fixed
    mainPanel.add(scrollPane, "2,1,3,4");
    mainPanel.add(bottomSidePanel, "0,4,0,0");
    mainPanel.add(topSidePanel, "0,0,0,3");
    //mainPanel.add(filterPanel, "2,2,3,1");

    this.add(mainPanel);
}

From source file:org.codinjutsu.tools.mongo.view.MongoConfigurable.java

@Nullable
@Override//from w w  w .j av a  2  s .c o m
public JComponent createComponent() {
    JPanel mongoShellOptionsPanel = new JPanel();
    mongoShellOptionsPanel.setLayout(new BoxLayout(mongoShellOptionsPanel, BoxLayout.X_AXIS));
    shellPathField = createShellPathField();
    mongoShellOptionsPanel.add(new JLabel("Path to Mongo executable:"));
    mongoShellOptionsPanel.add(shellPathField);
    mongoShellOptionsPanel.add(createTestButton());
    mongoShellOptionsPanel.add(createFeedbackLabel());

    mainPanel.add(mongoShellOptionsPanel, BorderLayout.NORTH);

    PanelWithButtons panelWithButtons = new PanelWithButtons() {

        {
            initPanel();
        }

        @Nullable
        @Override
        protected String getLabelText() {
            return "Servers";
        }

        @Override
        protected JButton[] createButtons() {
            return new JButton[] {};
        }

        @Override
        protected JComponent createMainComponent() {
            table = new JBTable(tableModel);
            table.getEmptyText().setText("No server configuration set");
            table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            TableColumn autoConnectColumn = table.getColumnModel().getColumn(2);
            int width = table.getFontMetrics(table.getFont()).stringWidth(table.getColumnName(2)) + 10;
            autoConnectColumn.setPreferredWidth(width);
            autoConnectColumn.setMaxWidth(width);
            autoConnectColumn.setMinWidth(width);

            return ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    ServerConfiguration serverConfiguration = ServerConfiguration.byDefault();

                    ConfigurationDialog dialog = new ConfigurationDialog(mainPanel, mongoManager,
                            serverConfiguration);
                    dialog.setTitle("Add a Mongo Server");
                    dialog.show();
                    if (!dialog.isOK()) {
                        return;
                    }

                    configurations.add(serverConfiguration);
                    int index = configurations.size() - 1;
                    tableModel.fireTableRowsInserted(index, index);
                    table.getSelectionModel().setSelectionInterval(index, index);
                    table.scrollRectToVisible(table.getCellRect(index, 0, true));
                }
            }).setAddActionName("addServer").setEditAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    int selectedIndex = table.getSelectedRow();
                    if (selectedIndex < 0 || selectedIndex >= tableModel.getRowCount()) {
                        return;
                    }
                    ServerConfiguration sourceConfiguration = configurations.get(selectedIndex);
                    ServerConfiguration copiedCconfiguration = sourceConfiguration.clone();

                    ConfigurationDialog dialog = new ConfigurationDialog(mainPanel, mongoManager,
                            copiedCconfiguration);
                    dialog.setTitle("Edit a Mongo Server");
                    dialog.show();
                    if (!dialog.isOK()) {
                        return;
                    }

                    configurations.set(selectedIndex, copiedCconfiguration);
                    tableModel.fireTableRowsUpdated(selectedIndex, selectedIndex);
                    table.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
                }
            }).setEditActionName("editServer").setRemoveAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    int selectedIndex = table.getSelectedRow();
                    if (selectedIndex < 0 || selectedIndex >= tableModel.getRowCount()) {
                        return;
                    }
                    TableUtil.removeSelectedItems(table);
                }
            }).setRemoveActionName("removeServer").disableUpDownActions().createPanel();
        }
    };

    mainPanel.add(panelWithButtons, BorderLayout.CENTER);

    return mainPanel;
}

From source file:org.codinjutsu.tools.nosql.NoSqlConfigurable.java

@Nullable
@Override/*from  w w w .  j a  v  a2s. com*/
public JComponent createComponent() {
    JPanel databaseVendorShellOptionsPanel = new JPanel();
    databaseVendorShellOptionsPanel.setLayout(new BoxLayout(databaseVendorShellOptionsPanel, BoxLayout.Y_AXIS));
    mongoShellPanel = new ShellPathPanel(DatabaseVendor.MONGO, "--version");
    databaseVendorShellOptionsPanel.add(mongoShellPanel);
    redisShellPanel = new ShellPathPanel(DatabaseVendor.REDIS, "--version");
    databaseVendorShellOptionsPanel.add(redisShellPanel);

    mainPanel.add(databaseVendorShellOptionsPanel, BorderLayout.NORTH);

    PanelWithButtons panelWithButtons = new PanelWithButtons() {

        {
            initPanel();
        }

        @Nullable
        @Override
        protected String getLabelText() {
            return "Servers";
        }

        @Override
        protected JButton[] createButtons() {
            return new JButton[] {};
        }

        @Override
        protected JComponent createMainComponent() {
            table = new JBTable(tableModel);
            table.getEmptyText().setText("No server configuration set");
            table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            table.setDefaultRenderer(DatabaseVendor.class, new ColoredTableCellRenderer() {
                @Override
                protected void customizeCellRenderer(JTable jTable, Object value, boolean b, boolean b1, int i,
                        int i1) {
                    DatabaseVendor databaseVendor = (DatabaseVendor) value;
                    this.setIcon(databaseVendor.icon);
                    this.append(databaseVendor.name);
                }
            });

            TableColumn autoConnectColumn = table.getColumnModel().getColumn(3);
            int autoConnectColumnWidth = table.getFontMetrics(table.getFont())
                    .stringWidth(table.getColumnName(3)) + 10;
            autoConnectColumn.setPreferredWidth(autoConnectColumnWidth);
            autoConnectColumn.setMaxWidth(autoConnectColumnWidth);
            autoConnectColumn.setMinWidth(autoConnectColumnWidth);

            return ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    SelectDatabaseVendorDialog databaseVendorDialog = new SelectDatabaseVendorDialog(mainPanel);
                    databaseVendorDialog.setTitle("Add a NoSql Server");
                    databaseVendorDialog.show();
                    if (!databaseVendorDialog.isOK()) {
                        return;
                    }

                    DatabaseVendor selectedDatabaseVendor = databaseVendorDialog.getSelectedDatabaseVendor();
                    ServerConfiguration serverConfiguration = databaseVendorClientManager
                            .get(selectedDatabaseVendor).defaultConfiguration();
                    serverConfiguration.setDatabaseVendor(selectedDatabaseVendor);

                    ConfigurationDialog dialog = new ConfigurationDialog(mainPanel,
                            serverConfigurationPanelFactory, serverConfiguration);
                    dialog.setTitle("Add a NoSql Server");
                    dialog.show();
                    if (!dialog.isOK()) {
                        return;
                    }

                    configurations.add(serverConfiguration);
                    int index = configurations.size() - 1;
                    tableModel.fireTableRowsInserted(index, index);
                    table.getSelectionModel().setSelectionInterval(index, index);
                    table.scrollRectToVisible(table.getCellRect(index, 0, true));
                }
            }).setAddActionName("addServer").setEditAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    int selectedIndex = table.getSelectedRow();
                    if (selectedIndex < 0 || selectedIndex >= tableModel.getRowCount()) {
                        return;
                    }
                    ServerConfiguration sourceConfiguration = configurations.get(selectedIndex);
                    ServerConfiguration copiedConfiguration = sourceConfiguration.clone();

                    ConfigurationDialog dialog = new ConfigurationDialog(mainPanel,
                            serverConfigurationPanelFactory, copiedConfiguration);
                    dialog.setTitle("Edit a NoSql Server");
                    dialog.show();
                    if (!dialog.isOK()) {
                        return;
                    }

                    configurations.set(selectedIndex, copiedConfiguration);
                    tableModel.fireTableRowsUpdated(selectedIndex, selectedIndex);
                    table.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
                }
            }).setEditActionName("editServer").setRemoveAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    stopEditing();

                    int selectedIndex = table.getSelectedRow();
                    if (selectedIndex < 0 || selectedIndex >= tableModel.getRowCount()) {
                        return;
                    }
                    TableUtil.removeSelectedItems(table);
                }
            }).setRemoveActionName("removeServer").disableUpDownActions().createPanel();
        }
    };

    mainPanel.add(panelWithButtons, BorderLayout.CENTER);

    return mainPanel;
}

From source file:org.datanucleus.ide.idea.ui.DNEConfigForm.java

public void setData(@NotNull final GuiState data) {
    this.guiStateBeforeChanges = new GuiState(data);

    ///*w  ww .  ja v  a2 s  .  com*/
    // Basic panels
    this.indexNotReadyPanel.setVisible(!data.isIndexReady());
    this.contentPanel.setVisible(data.isIndexReady());

    //
    // Enable enhancer checkbox
    this.enableEnhancerCheckBox.setSelected(data.isEnhancerEnabled());

    //
    // Persistence implementation selection
    final EnhancerSupportRegistry enhancerSupportRegistry = data.getEnhancerSupportRegistry();
    final Set<EnhancerSupport> supportedEnhancers = enhancerSupportRegistry.getSupportedEnhancers();
    this.persistenceImplComboBox.removeAllItems();
    for (final EnhancerSupport support : supportedEnhancers) {
        this.persistenceImplComboBox.addItem(support.getName());
    }
    final EnhancerSupport enhancerSupport = data.getEnhancerSupport();
    this.persistenceImplComboBox.setSelectedItem(enhancerSupport.getName());
    if (supportedEnhancers.size() <= 1) {
        this.persistenceImplComboBox.setVisible(false);
    } else {
        this.persistenceImplComboBox.setVisible(true);
    }

    // just to be sure -> validate persistence settings from config file
    PersistenceApi persistenceApi = data.getApi();
    if (!enhancerSupport.isSupported(persistenceApi)) {
        persistenceApi = enhancerSupport.getDefaultPersistenceApi();
    }

    this.jDORadioButton.setSelected(PersistenceApi.JDO == persistenceApi);
    this.jPARadioButton.setSelected(PersistenceApi.JPA == persistenceApi);
    this.jDORadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JDO));
    this.jPARadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JPA));

    //
    // Metadata file extensions text field
    this.metadataExtensionTextField.setText(data.getMetaDataExtensions().trim());

    //
    // Compiler resource file extensions control
    final boolean metadataExtensionsEnabled = data.getMetaDataExtensions() != null
            && !data.getMetaDataExtensions().trim().isEmpty();
    this.addToCompilerResourceCheckBox.setSelected(data.isAddToCompilerResourcePatterns());
    this.addToCompilerResourceCheckBox.setEnabled(metadataExtensionsEnabled);

    //
    // Test classes inclusion
    this.includeTestClassesCheckBox.setSelected(data.isIncludeTestClasses());

    //
    // Panel displaying an info message if enhancer is not initialized

    this.infoPanel.setVisible(!data.isEnhancerInitialized());
    this.infoPanel.setEnabled(!data.isEnhancerInitialized());

    //
    // Table displaying affected modules if enhancer is initialized

    final TableModel affectedModulesRowModel = new AffectedModulesRowModel(data.getAffectedModules());
    // modules affected by class enhancement
    this.affectedModulesTable.setModel(affectedModulesRowModel);
    // set column appearance
    final TableColumnModel columnModel = this.affectedModulesTable.getColumnModel();
    final TableColumn firstColumn = columnModel.getColumn(0);
    firstColumn.setMinWidth(50);
    firstColumn.setMaxWidth(50);
    firstColumn.setPreferredWidth(50);
    this.affectedModulesTable.setDefaultEditor(Boolean.class, new BooleanTableCellEditor(false));
    setPreferredTableHeight(this.affectedModulesTable, this.affectedModulesTable.getRowCount());

    //
    // Table displaying affected files/classes/.. if enhancer is initialized

    final TableModel metadataOrClassFilesRowModel = new MetadataOrClassFilesRowModel(data.getMetadataFiles(),
            data.getAnnotatedClassFiles());
    // files affected by class enhancement
    this.metadataAndClassesTable.setModel(metadataOrClassFilesRowModel);
    // set column appearance
    this.metadataAndClassesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    // adjust column sizes (after being rendered the first time - necessary for ColumnAdjuster to work)
    final ColumnAdjuster columnAdjuster = new ColumnAdjuster(this.metadataAndClassesTable);
    //columnAdjuster.setOnlyAdjustLarger(false);
    columnAdjuster.setDynamicAdjustment(true);
    columnAdjuster.adjustColumns();
    setPreferredTableHeight(this.metadataAndClassesTable, this.metadataAndClassesTable.getRowCount());

    this.metadataAndClassesTable.setVisible(data.isEnhancerInitialized());

    // only display detected classes if initialized
    this.metaDataAndClassesScrollPane.setVisible(data.isEnhancerInitialized());

    if (enhancerSupport.getVersion() == EnhancerSupportVersion.V1_1_X) {
        this.depProjectModuleRadioButton.setSelected(!data.isDependenciesManual());
        this.depManualRadioButton.setSelected(data.isDependenciesManual());
        this.depManualRadioButton.setEnabled(true);
        this.depManualUnsupportedLabel.setVisible(false);
    } else {
        this.depProjectModuleRadioButton.setSelected(true);
        this.depManualRadioButton.setSelected(false);
        this.depManualRadioButton.setEnabled(false);
        this.depManualUnsupportedLabel.setVisible(true);
    }

    this.dependenciesAddDeletePanel.resetDependencyList(enhancerSupport.getId(), persistenceApi,
            data.getDependencies());
}

From source file:org.datanucleus.ide.idea.ui.v10x.DNEConfigFormV10x.java

public void setData(@NotNull final GuiState data) {
    this.guiState = new GuiState(data);

    ////ww  w. j a v  a  2  s  .c o  m
    // Basic panels
    this.indexNotReadyPanel.setVisible(!data.isIndexReady());
    this.contentPanel.setVisible(data.isIndexReady());

    //
    // Enable enhancer checkbox
    this.enableEnhancerCheckBox.setSelected(data.isEnhancerEnabled());

    //
    // Persistence implementation selection
    final EnhancerSupportRegistry enhancerSupportRegistry = data.getEnhancerSupportRegistry();
    final Set<EnhancerSupport> supportedEnhancers = enhancerSupportRegistry.getSupportedEnhancers();
    if (this.persistenceImplComboBox.getItemCount() == 0) {
        for (final EnhancerSupport support : supportedEnhancers) {
            this.persistenceImplComboBox.addItem(support.getName());
        }
    }
    final EnhancerSupport enhancerSupport = data.getEnhancerSupport();
    this.persistenceImplComboBox.setSelectedItem(enhancerSupport.getName());
    if (supportedEnhancers.size() <= 1) {
        this.persistenceImplComboBox.setVisible(false);
    } else {
        this.persistenceImplComboBox.setVisible(true);
    }

    // just to be sure -> validate persistence settings from config file
    PersistenceApi persistenceApi = data.getApi();
    if (!enhancerSupport.isSupported(persistenceApi)) {
        persistenceApi = enhancerSupport.getDefaultPersistenceApi();
    }

    this.jDORadioButton.setSelected(PersistenceApi.JDO == persistenceApi);
    this.jPARadioButton.setSelected(PersistenceApi.JPA == persistenceApi);
    this.jDORadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JDO));
    this.jPARadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JPA));

    //
    // Metadata file extensions text field
    this.metadataExtensionTextField.setText(data.getMetaDataExtensions().trim());

    //
    // Compiler resource file extensions control
    final boolean metadataExtensionsEnabled = data.getMetaDataExtensions() != null
            && !data.getMetaDataExtensions().trim().isEmpty();
    this.addToCompilerResourceCheckBox.setSelected(data.isAddToCompilerResourcePatterns());
    this.addToCompilerResourceCheckBox.setEnabled(metadataExtensionsEnabled);

    //
    // Test classes inclusion
    this.includeTestClassesCheckBox.setSelected(data.isIncludeTestClasses());

    //
    // Panel displaying an info message if enhancer is not initialized

    this.infoPanel.setVisible(!data.isEnhancerInitialized());
    this.infoPanel.setEnabled(!data.isEnhancerInitialized());

    //
    // Table displaying affected modules if enhancer is initialized

    final TableModel affectedModulesRowModel = new AffectedModulesRowModel(data.getAffectedModules());
    // modules affected by class enhancement
    this.affectedModulesTable.setModel(affectedModulesRowModel);
    // set column appearance
    final TableColumnModel columnModel = this.affectedModulesTable.getColumnModel();
    final TableColumn firstColumn = columnModel.getColumn(0);
    firstColumn.setMinWidth(50);
    firstColumn.setMaxWidth(50);
    firstColumn.setPreferredWidth(50);
    this.affectedModulesTable.setDefaultEditor(Boolean.class, new BooleanTableCellEditor(false));
    setPreferredTableHeight(this.affectedModulesTable, this.affectedModulesTable.getRowCount());

    //
    // Table displaying affected files/classes/.. if enhancer is initialized

    final TableModel metadataOrClassFilesRowModel = new MetadataOrClassFilesRowModel(data.getMetadataFiles(),
            data.getAnnotatedClassFiles());
    // files affected by class enhancement
    this.metadataAndClassesTable.setModel(metadataOrClassFilesRowModel);
    // set column appearance
    this.metadataAndClassesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    // adjust column sizes (after being rendered the first time - necessary for ColumnAdjuster to work)
    final ColumnAdjuster columnAdjuster = new ColumnAdjuster(this.metadataAndClassesTable);
    //columnAdjuster.setOnlyAdjustLarger(false);
    columnAdjuster.setDynamicAdjustment(true);
    columnAdjuster.adjustColumns();
    setPreferredTableHeight(this.metadataAndClassesTable, this.metadataAndClassesTable.getRowCount());

    this.metadataAndClassesTable.setVisible(data.isEnhancerInitialized());

    // only display detected classes if initialized
    this.metaDataAndClassesScrollPane.setVisible(data.isEnhancerInitialized());
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java

/**
 * Lists the buckets in the user's S3 account and refreshes the GUI to display
 * these buckets. Any buckets or objects already listed in the GUI are cleared first.
 *///from  w  w  w. j ava 2  s  . c o  m
private void listAllBuckets() {
    // Remove current bucket and object data from models.
    cachedBuckets.clear();
    bucketsTable.clearSelection();
    bucketTableModel.removeAllBuckets();
    objectTableModel.removeAllObjects();
    final Cockpit myself = this;

    // This is all very convoluted. This was necessary so we can display the status dialog box.
    runInBackgroundThread(new Runnable() {
        public void run() {
            if (!cloudFrontMembershipChecked) {
                // Check whether the user is signed-up for CloudFront.
                startProgressDialog("Checking for CloudFront account membership");
                try {
                    cloudFrontService = new CloudFrontService(s3ServiceMulti.getAWSCredentials(),
                            APPLICATION_DESCRIPTION, myself, null, null);
                    cloudFrontService.listDistributions();
                } catch (CloudFrontServiceException e) {
                    stopProgressDialog();

                    if ("OptInRequired".equals(e.getErrorCode())) {
                        log.debug("Your AWS account is not subscribed to the Amazon CloudFront service, "
                                + "you will not be able to manage distributions");
                    }
                    cloudFrontService = null;
                } finally {
                    stopProgressDialog();

                    try {
                        SwingUtilities.invokeAndWait(new Runnable() {
                            public void run() {
                                cloudFrontMembershipChecked = true;

                                // Update the bucket table to show, or not show, distributions
                                bucketTableModel = new BucketTableModel(cloudFrontService != null);
                                bucketTableModelSorter = new TableSorter(bucketTableModel);
                                bucketsTable.setModel(bucketTableModelSorter);
                                bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader());

                                if (cloudFrontService != null) {
                                    // Set column width for Cloud Front distributions indicator.
                                    TableColumn distributionFlagColumn = bucketsTable.getColumnModel()
                                            .getColumn(1);
                                    int distributionFlagColumnWidth = 18;
                                    distributionFlagColumn.setPreferredWidth(distributionFlagColumnWidth);
                                    distributionFlagColumn.setMaxWidth(distributionFlagColumnWidth);
                                    distributionFlagColumn.setMinWidth(0);
                                }

                                manageDistributionsMenuItem.setEnabled(cloudFrontService != null);

                            }
                        });
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            startProgressDialog("Listing buckets for " + s3ServiceMulti.getAWSCredentials().getAccessKey());
            try {
                final S3Bucket[] buckets = s3ServiceMulti.getS3Service().listAllBuckets();

                // Lookup user's CloudFront distributions.
                Distribution[] distributions = new Distribution[] {};
                if (cloudFrontService != null) {
                    updateProgressDialog(
                            "Listing distributions for " + cloudFrontService.getAWSCredentials().getAccessKey(),
                            "", 0);
                    distributions = cloudFrontService.listDistributions();
                }
                final Distribution[] finalDistributions = distributions;

                runInDispatcherThreadImmediately(new Runnable() {
                    public void run() {
                        for (int i = 0; i < buckets.length; i++) {
                            // Determine whether each bucket has one or more CloudFront distributions.
                            boolean bucketHasDistribution = false;
                            for (int j = 0; j < finalDistributions.length; j++) {
                                if (finalDistributions[j].getOrigin()
                                        .equals(buckets[i].getName() + ".s3.amazonaws.com")) {
                                    bucketHasDistribution = true;
                                }
                            }

                            bucketTableModel.addBucket(buckets[i], bucketHasDistribution);

                            if (i == 0) {
                                ownerFrame.setTitle(
                                        APPLICATION_TITLE + " : " + buckets[i].getOwner().getDisplayName());
                            }
                        }
                    }
                });
            } catch (final Exception e) {
                stopProgressDialog();

                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        logoutEvent();

                        String message = "Unable to list your buckets in S3, please log in again";
                        log.error(message, e);
                        ErrorDialog.showDialog(ownerFrame, null, message, e);

                        loginEvent(null);
                    }
                });
            } finally {
                stopProgressDialog();
            }
        };
    });
}

From source file:org.executequery.gui.browser.ConnectionPanel.java

private void init() {

    // ---------------------------------
    // create the basic props panel

    // initialise the fields
    nameField = createTextField();//from  www .  j av  a  2 s .  co m
    passwordField = createPasswordField();
    hostField = createTextField();
    portField = createNumberTextField();
    sourceField = createMatchedWidthTextField();
    userField = createTextField();
    urlField = createMatchedWidthTextField();

    nameField.addFocusListener(new ConnectionNameFieldListener(this));

    savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword");
    encryptPwdCheck = ActionUtilities.createCheckBox("Encrypt Password", "setEncryptPassword");

    savePwdCheck.addActionListener(this);
    encryptPwdCheck.addActionListener(this);

    // retrieve the drivers
    buildDriversList();

    // ---------------------------------
    // add the basic connection fields

    TextFieldPanel mainPanel = new TextFieldPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.gridy = 0;
    gbc.gridx = 0;

    statusLabel = new DefaultFieldLabel();
    addLabelFieldPair(mainPanel, "Status:", statusLabel, "Current connection status", gbc);

    gbc.insets.bottom = 5;
    addLabelFieldPair(mainPanel, "Connection Name:", nameField, "A friendly name for this connection", gbc);

    addLabelFieldPair(mainPanel, "User Name:", userField, "Login user name", gbc);

    addLabelFieldPair(mainPanel, "Password:", passwordField, "Login password", gbc);

    JButton showPassword = new LinkButton("Show Password");
    showPassword.setActionCommand("showPassword");
    showPassword.addActionListener(this);

    JPanel passwordOptionsPanel = new JPanel(new GridBagLayout());
    addComponents(passwordOptionsPanel,
            new ComponentToolTipPair[] {
                    new ComponentToolTipPair(savePwdCheck,
                            "Store the password with the connection information"),
                    new ComponentToolTipPair(encryptPwdCheck, "Encrypt the password when saving"),
                    new ComponentToolTipPair(showPassword, "Show the password in plain text") });

    gbc.gridy++;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(passwordOptionsPanel, gbc);

    addLabelFieldPair(mainPanel, "Host Name:", hostField, "Server host name or IP address", gbc);

    addLabelFieldPair(mainPanel, "Port:", portField, "Database port number", gbc);

    addLabelFieldPair(mainPanel, "Data Source:", sourceField, "Data source name", gbc);

    addLabelFieldPair(mainPanel, "JDBC URL:", urlField, "The full JDBC URL for this connection (optional)",
            gbc);

    addDriverFields(mainPanel, gbc);

    connectButton = createButton("Connect", CONNECT_ACTION_COMMAND, 'T');
    disconnectButton = createButton("Disconnect", "disconnect", 'D');

    JPanel buttons = new JPanel(new GridBagLayout());
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.insets.top = 5;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    gbc.fill = GridBagConstraints.NONE;
    buttons.add(connectButton, gbc);
    gbc.gridx++;
    gbc.weightx = 0;
    buttons.add(disconnectButton, gbc);

    gbc.insets.right = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(buttons, gbc);

    // ---------------------------------
    // create the advanced panel

    model = new JdbcPropertiesTableModel();
    JTable table = new DefaultTable(model);
    table.getTableHeader().setReorderingAllowed(false);

    TableColumnModel tcm = table.getColumnModel();

    TableColumn column = tcm.getColumn(2);
    column.setCellRenderer(new DeleteButtonRenderer());
    column.setCellEditor(new DeleteButtonEditor(table, new JCheckBox()));
    column.setMaxWidth(24);
    column.setMinWidth(24);

    JScrollPane scroller = new JScrollPane(table);

    // advanced jdbc properties
    JPanel advPropsPanel = new JPanel(new GridBagLayout());
    advPropsPanel.setBorder(BorderFactory.createTitledBorder("JDBC Properties"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advPropsPanel.add(new DefaultFieldLabel("Enter any key/value pair properties for this connection"), gbc);
    gbc.gridy++;
    advPropsPanel.add(
            new DefaultFieldLabel("Refer to the relevant JDBC driver documentation for possible entries"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    advPropsPanel.add(scroller, gbc);

    // transaction isolation
    txApplyButton = WidgetFactory.createInlineFieldButton("Apply", "transactionLevelChanged");
    txApplyButton.setToolTipText("Apply this level to all open connections of this type");
    txApplyButton.setEnabled(false);
    txApplyButton.addActionListener(this);

    // add a dummy select value to the tx levels
    String[] txLevels = new String[Constants.TRANSACTION_LEVELS.length + 1];
    txLevels[0] = "Database Default";
    for (int i = 1; i < txLevels.length; i++) {
        txLevels[i] = Constants.TRANSACTION_LEVELS[i - 1];
    }
    txCombo = WidgetFactory.createComboBox(txLevels);

    JPanel advTxPanel = new JPanel(new GridBagLayout());
    advTxPanel.setBorder(BorderFactory.createTitledBorder("Transaction Isolation"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.insets.bottom = 5;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advTxPanel.add(new DefaultFieldLabel("Default transaction isolation level for this connection"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    advTxPanel.add(
            new DefaultFieldLabel(
                    "Note: the selected isolation level " + "will apply to ALL open connections of this type."),
            gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.weightx = 0;
    advTxPanel.add(new DefaultFieldLabel("Isolation Level:"), gbc);
    gbc.gridx = 1;
    gbc.insets.left = 5;
    gbc.weightx = 1.0;
    gbc.insets.right = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    advTxPanel.add(txCombo, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    advTxPanel.add(txApplyButton, gbc);

    JPanel advancedPanel = new JPanel(new BorderLayout());
    advancedPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    advancedPanel.add(advPropsPanel, BorderLayout.CENTER);
    advancedPanel.add(advTxPanel, BorderLayout.SOUTH);

    JScrollPane scrollPane = new JScrollPane(mainPanel);
    scrollPane.setBorder(null);

    sshTunnelConnectionPanel = new SSHTunnelConnectionPanel();

    tabPane = new JTabbedPane(JTabbedPane.BOTTOM);
    tabPane.addTab("Basic", scrollPane);
    tabPane.addTab("Advanced", advancedPanel);
    tabPane.addTab("SSH Tunnel", sshTunnelConnectionPanel);

    tabPane.addChangeListener(this);

    add(tabPane, BorderLayout.CENTER);

    EventMediator.registerListener(this);
}

From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java

/**
 * Initialize the source list table.//from ww  w  . j a va  2  s.c o  m
 */
private void initSourceList() {

    try {

        ComponentSourceTableModel cstm = new ComponentSourceTableModel();
        _sourceList = new JTable(cstm);
        _sourceList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        _sourceList.setShowGrid(true);
        _sourceList.setShowHorizontalLines(true);
        _sourceList.setShowVerticalLines(true);
        _sourceList.setGridColor(Color.lightGray);
        _sourceList.setIntercellSpacing(new Dimension(5, 5));
        _sourceList.setRowHeight(_sourceList.getRowHeight() + 10);
        _sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        if (isDebugging) {
            log.debug("intercellspacing: " + _sourceList.getIntercellSpacing().toString());
            log.debug("getRowHeight(): " + _sourceList.getRowHeight());
        }

        // Search column
        TableColumn c0 = _sourceList.getColumnModel().getColumn(0);
        c0.setMinWidth(50);
        c0.setPreferredWidth(60);
        c0.setMaxWidth(100);
        c0.setResizable(true);

        // Save column
        TableColumn c1 = _sourceList.getColumnModel().getColumn(1);
        c1.setMinWidth(50);
        c1.setPreferredWidth(60);
        c1.setMaxWidth(100);
        c1.setResizable(true);

        // Type column
        TableColumn c2 = _sourceList.getColumnModel().getColumn(2);
        c2.setMinWidth(50);
        c2.setPreferredWidth(60);
        c2.setMaxWidth(100);
        c2.setResizable(true);

        // Name column
        TableColumn c3 = _sourceList.getColumnModel().getColumn(3);
        c3.setMinWidth(50);
        c3.setPreferredWidth(100);
        c3.setMaxWidth(200);
        c3.setResizable(true);

        // Source column
        TableColumn c4 = _sourceList.getColumnModel().getColumn(4);
        c4.setMinWidth(200);
        c4.setPreferredWidth(600);
        c4.setMaxWidth(2000);
        c4.setResizable(true);

        JScrollPane sourceListSP = new JScrollPane(_sourceList);
        sourceListSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setBackground(TabManager.BGCOLOR);
        add(sourceListSP);
    } catch (Exception e) {
        System.out.println(e.toString());
    }

}