Example usage for javax.swing JTable setModel

List of usage examples for javax.swing JTable setModel

Introduction

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

Prototype

@BeanProperty(description = "The model that is the source of the data for this view.")
public void setModel(final TableModel dataModel) 

Source Link

Document

Sets the data model for this table to dataModel and registers with it for listener notifications from the new data model.

Usage

From source file:app.RunApp.java

/**
 * Set frequency of labelsets//from   w  w  w. ja v a 2 s  .  co m
 * 
 * @param jtable Table
 * @param dataset Dataset
 * @param stat Statistics
 * @param cp Plot
 * @return Generated TableModel
 * @throws Exception 
 */
private TableModel labelsetsFrequencyTableModel(JTable jtable, MultiLabelInstances dataset, Statistics stat,
        CategoryPlot cp) throws Exception {
    DefaultTableModel tableModel = new DefaultTableModel() {
        @Override
        public boolean isCellEditable(int row, int column) {
            //This causes all cells to be not editable
            return false;
        }
    };

    DefaultCategoryDataset myData = new DefaultCategoryDataset();

    tableModel.addColumn("Labelset Id");
    tableModel.addColumn("# Examples");
    tableModel.addColumn("Frequency");

    double freq;

    //Labelsets frequency
    HashMap<LabelSet, Integer> result = stat.labelCombCount();
    labelsetStringsByFreq = new ArrayList<>(result.size());

    double sum = 0.0;
    Set<LabelSet> keysets = result.keySet();

    Object[] row = new Object[3];

    int count = 1;

    ArrayList<ImbalancedFeature> listImbalanced = new ArrayList();
    ImbalancedFeature temp;

    int value;
    for (LabelSet current : keysets) {
        value = result.get(current);
        temp = new ImbalancedFeature(current.toString(), value);
        listImbalanced.add(temp);
    }

    labelsetsSorted = new ImbalancedFeature[listImbalanced.size()];
    labelsetsFrequency = new double[listImbalanced.size()];

    while (!listImbalanced.isEmpty()) {
        temp = Utils.getMax(listImbalanced);
        labelsetsSorted[count - 1] = temp;
        value = temp.getAppearances();
        labelsetsFrequency[count - 1] = value;
        row[0] = count;
        freq = value * 1.0 / dataset.getNumInstances();
        sum += freq;

        String valueFreq = Double.toString(freq);
        row[1] = value;

        row[2] = MetricUtils.getValueFormatted(valueFreq, 4);
        tableModel.addRow(row);

        String id = "ID: " + Integer.toString(count);

        myData.setValue(freq, id, "");
        labelsetStringsByFreq.add(temp.getName());

        count++;
        listImbalanced.remove(temp);
    }

    jtable.setModel(tableModel);
    jtable.setBounds(jtable.getBounds());

    TableColumnModel tcm = jtable.getColumnModel();
    tcm.getColumn(0).setPreferredWidth(50);
    tcm.getColumn(1).setPreferredWidth(50);
    tcm.getColumn(2).setPreferredWidth(60);

    //graph
    cp.setDataset(myData);

    sum = sum / keysets.size();
    Marker start = new ValueMarker(sum);
    start.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    start.setLabel("                        Mean: " + MetricUtils.truncateValue(sum, 4));
    start.setPaint(Color.red);
    cp.addRangeMarker(start);

    return jtable.getModel();
}

From source file:app.RunApp.java

/**
 * Set label IR/*w w w  . j  a v a  2 s.c o  m*/
 * 
 * @param jtable Table
 * @param stat Statistics
 * @param cp CategoryPlot
 * @return Generated TableModel
 * @throws Exception 
 */
private TableModel irLabelsetsTableModel(JTable jtable, Statistics stat, CategoryPlot cp) throws Exception {
    DefaultTableModel tableModel = new DefaultTableModel() {
        @Override
        public boolean isCellEditable(int row, int column) {
            //This causes all cells to be not editable
            return false;
        }
    };

    DefaultCategoryDataset myData = new DefaultCategoryDataset();

    tableModel.addColumn("Labelset id");
    tableModel.addColumn("IR values");

    //Labelsets frequency
    HashMap<LabelSet, Integer> labelsetsFrequency = stat.labelCombCount();
    labelsetStringByIR = new ArrayList<>(labelsetsFrequency.size());

    Set<LabelSet> keysets = labelsetsFrequency.keySet();

    Object[] row = new Object[2];

    int count = 1;
    double IR_labelset;
    int max = getMax(keysets, labelsetsFrequency);

    ArrayList<ImbalancedFeature> listImbalanced = new ArrayList();
    ImbalancedFeature temp;

    int value;

    for (LabelSet current : keysets) {
        value = labelsetsFrequency.get(current);
        IR_labelset = max / (value * 1.0);
        String temp1 = MetricUtils.truncateValue(IR_labelset, 4);
        IR_labelset = Double.parseDouble(temp1);

        temp = new ImbalancedFeature(current.toString(), value, IR_labelset);
        listImbalanced.add(temp);
    }

    labelsetsIRSorted = new ImbalancedFeature[listImbalanced.size()];
    labelsetsByIR = new double[listImbalanced.size()]; //stores IR per labelset

    String truncate;

    while (!listImbalanced.isEmpty()) {
        temp = Utils.getMin(listImbalanced);

        labelsetsIRSorted[count - 1] = temp;
        labelsetsByIR[count - 1] = temp.getIRIntraClass();

        row[0] = count;

        truncate = Double.toString(temp.getIRIntraClass());
        row[1] = MetricUtils.getValueFormatted(truncate, 3);

        tableModel.addRow(row);

        myData.setValue(temp.getIRIntraClass(), Integer.toString(count), "");
        labelsetStringByIR.add(temp.getName());

        count++;
        listImbalanced.remove(temp);
    }

    jtable.setModel(tableModel);
    jtable.setBounds(jtable.getBounds());

    //Resize columns
    TableColumnModel tcm = jtable.getColumnModel();

    tcm.getColumn(0).setPreferredWidth(50);
    tcm.getColumn(1).setPreferredWidth(50);

    //graph
    cp.setDataset(myData);

    //get mean
    double sum = 0;
    for (int i = 0; i < labelsetsIRSorted.length; i++) {
        sum += labelsetsIRSorted[i].getIRIntraClass();
    }
    sum = sum / labelsetsIRSorted.length;

    Marker start = new ValueMarker(sum);
    start.setPaint(Color.blue);
    start.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    start.setLabel("                        Mean: " + MetricUtils.truncateValue(sum, 4));
    cp.addRangeMarker(start);

    return jtable.getModel();
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void parseELF(File elfFile) {
    jELFDumpPanel.remove(jTabbedPane4);/*from   w ww  .  j av a 2s.  com*/
    jTabbedPane4 = null;
    jELFDumpPanel.add(getJTabbedPane4(), BorderLayout.CENTER);

    HashMap map = ElfUtil.getELFDetail(elfFile);
    if (map != null) {
        // header
        DefaultTableModel model = (DefaultTableModel) jELFHeaderTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        Set entries = ((HashMap) map.get("header")).entrySet();
        Iterator it = entries.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();

            Vector<String> v = new Vector<String>();
            v.add(entry.getKey().toString());

            String bytesStr = "";

            if (entry.getValue().getClass() == Short.class) {
                jStatusLabel.setText("header " + Long.toHexString((Short) entry.getValue()));
                bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
            } else if (entry.getValue().getClass() == Integer.class) {
                bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
            } else if (entry.getValue().getClass() == Long.class) {
                bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
            } else {
                int b[] = (int[]) entry.getValue();
                for (int x = 0; x < b.length; x++) {
                    bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                }
            }

            v.add(bytesStr);
            model.addRow(v);
        }
        // end header

        // section
        model = (DefaultTableModel) jELFSectionTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        int sectionNo = 0;
        while (map.get("section" + sectionNo) != null) {
            entries = ((HashMap) map.get("section" + sectionNo)).entrySet();
            it = entries.iterator();
            Vector<String> v = new Vector<String>();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();

                String bytesStr = "";
                if (entry.getValue().getClass() == Short.class) {
                    jStatusLabel.setText("section " + Long.toHexString((Short) entry.getValue()));
                    bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
                } else if (entry.getValue().getClass() == Integer.class) {
                    bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
                } else if (entry.getValue().getClass() == String.class) {
                    bytesStr = (String) entry.getValue();
                } else if (entry.getValue().getClass() == Long.class) {
                    bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
                } else {
                    int b[] = (int[]) entry.getValue();
                    for (int x = 0; x < b.length; x++) {
                        bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                    }
                }

                v.add(bytesStr);
            }
            model.addRow(v);
            sectionNo++;
        }
        // end section

        // program header
        model = (DefaultTableModel) jProgramHeaderTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        int programHeaderNo = 0;
        while (map.get("programHeader" + programHeaderNo) != null) {
            entries = ((HashMap) map.get("programHeader" + programHeaderNo)).entrySet();
            it = entries.iterator();
            Vector<String> v = new Vector<String>();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();

                String bytesStr = "";
                if (entry.getValue().getClass() == Short.class) {
                    jStatusLabel.setText("Program header " + Long.toHexString((Short) entry.getValue()));
                    bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
                } else if (entry.getValue().getClass() == Integer.class) {
                    bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
                } else if (entry.getValue().getClass() == Long.class) {
                    bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
                } else if (entry.getValue().getClass() == String.class) {
                    bytesStr += "0x" + entry.getValue();
                } else {
                    int b[] = (int[]) entry.getValue();
                    for (int x = 0; x < b.length; x++) {
                        bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                    }
                }

                v.add(bytesStr);
            }
            model.addRow(v);
            programHeaderNo++;
        }
        // program header

        // symbol table
        int symbolTableNo = 0;
        while (map.get("symbolTable" + symbolTableNo) != null) {
            DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "st_name",
                    "st_value", "st_size", "st_info", "st_other", "p_st_shndx" });
            JTable tempTable = new JTable();
            HashMap tempMap = (HashMap) map.get("symbolTable" + symbolTableNo);
            Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector");
            for (int x = 0; x < v.size(); x++) {
                Vector tempV = new Vector();
                jStatusLabel.setText("Symbol table " + x);
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No.")));
                tempV.add(v.get(x).get("st_name"));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_value")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_size")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_info")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_other")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("p_st_shndx")));

                tempTableModel.addRow(tempV);
            }

            tempTable.setModel(tempTableModel);
            JScrollPane tempScrollPane = new JScrollPane();
            tempScrollPane.setViewportView(tempTable);
            jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null);

            symbolTableNo++;
        }
        // end symbol table

        // note
        int noteSectionNo = 0;
        while (map.get("note" + noteSectionNo) != null) {
            DefaultTableModel tempTableModel = new DefaultTableModel(null,
                    new String[] { "No.", "namesz", "descsz", "type", "name", "desc" });
            JTable tempTable = new JTable();
            HashMap tempMap = (HashMap) map.get("note" + noteSectionNo);
            Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector");
            for (int x = 0; x < v.size(); x++) {
                Vector tempV = new Vector();
                jStatusLabel.setText("Note " + x);
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No.")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("namesz")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("descsz")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("type")));
                tempV.add(v.get(x).get("name"));
                tempV.add(v.get(x).get("desc"));

                tempTableModel.addRow(tempV);
            }

            tempTable.setModel(tempTableModel);
            JScrollPane tempScrollPane = new JScrollPane();
            tempScrollPane.setViewportView(tempTable);
            jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null);

            noteSectionNo++;
        }
        // end note
    }

    try {
        jStatusLabel.setText("running objdump -DS");
        Process process = Runtime.getRuntime().exec("objdump -DS " + elfFile.getAbsolutePath());
        InputStream input = process.getInputStream();
        String str = "";
        byte b[] = new byte[102400];
        int len;
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        jEditorPane1.setText(str);

        jStatusLabel.setText("readelf -r");
        process = Runtime.getRuntime().exec("readelf -r " + elfFile.getAbsolutePath());
        input = process.getInputStream();
        str = "";
        b = new byte[102400];
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        jSearchRelPltEditorPane.setText(str);

        jStatusLabel.setText("readelf -d");
        process = Runtime.getRuntime().exec("readelf -d " + elfFile.getAbsolutePath());
        input = process.getInputStream();
        str = "";
        b = new byte[102400];
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        input.close();
        jSearchDynamicEditorPane.setText(str);

        jStatusLabel.setText("");
    } catch (IOException e) {
        e.printStackTrace();
    }
    // end symbol table
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private void setJobQueueTableDefaults(JTable jobQueueTable, JobQueueTableModel jobQueueTableModel) {
    jobQueueTableModel.addTableModelListener(new JobQueueTableModelListener());
    jobQueueTable.setModel(jobQueueTableModel);
    jobQueueTable.setSurrendersFocusOnKeystroke(true);
    jobQueueTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    jobQueueTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    jobQueueTable.setColumnSelectionAllowed(true);
    jobQueueTable.setRowSelectionAllowed(true);
    TableRenderer renderer = new TableRenderer();
    TableColumn col = jobQueueTable.getColumnModel().getColumn(0);
    int width = 200;
    col.setPreferredWidth(width);/*from   www .  j  ava  2 s .  com*/
    col.setWidth(width);
    col.setCellRenderer(renderer);

    col = jobQueueTable.getColumnModel().getColumn(1);
    width = 1400;
    col.setPreferredWidth(width);
    col.setWidth(width);
    col.setCellRenderer(renderer);
}

From source file:nz.govt.natlib.ndha.manualdeposit.MetaDataTest.java

@Test
public final void testMetaDataCellEditor() {
    loadConfigFile();// w  ww.ja v a  2s.  c o  m
    AppProperties appProperties = null;
    try {
        appProperties = new AppProperties();
        appProperties.setLoggedOnUser("mngroot");
        appProperties.setLoggedOnUserPassword("mngroot");
    } catch (Exception ex) {
        fail();
    }
    MetaDataTableModel model = null;
    try {
        UserGroupData userGroupData = appProperties.getUserData().getUser(appProperties.getLoggedOnUser())
                .getUserGroupData();
        model = MetaDataTableModel.create(userGroupData, MetaDataFields.ECMSSystem.CMS2);
    } catch (Exception ex) {
        fail();
    }
    Font standardFont = new Font("Arial", 0, 12);
    MetaDataElementCellEditor editor = new MetaDataElementCellEditor(standardFont);
    JTable table = new JTable();
    table.setModel(model);
    IMetaDataTypeExtended meta = model.getRow(0);

    meta.setDataType(EDataType.Boolean);
    String value = "true";
    Component comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof JCheckBox);
    JCheckBox chk = (JCheckBox) comp;
    assertTrue(chk.getSelectedObjects() != null);
    value = "false";
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(editor.getCellEditorValue().equals(value));

    meta.setDataType(EDataType.Date);
    String dateFormat = "dd/MM/yyyy";
    SimpleDateFormat f = new SimpleDateFormat(dateFormat);
    value = "09/04/2008";
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof JXDatePicker);
    JXDatePicker dt = (JXDatePicker) comp;
    Date theDate = dt.getDate();
    String theDateString = f.format(theDate);
    assertTrue(value.equals(theDateString));
    assertTrue(editor.getCellEditorValue().equals(value));

    meta.setDataType(EDataType.Integer);
    value = "15";
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof WholeNumberField);
    WholeNumberField num = (WholeNumberField) comp;
    assertTrue(num.getValue() == 15);
    assertTrue(editor.getCellEditorValue().equals(value));

    meta.setDataType(EDataType.MultiSelect);
    ArrayList<MetaDataListValues> values = new ArrayList<MetaDataListValues>();
    MetaDataListValues value1 = new MetaDataListValues("Item 1", "Item 1", 0);
    values.add(value1);
    MetaDataListValues value2 = new MetaDataListValues("Item 2", "Item 2", 1);
    values.add(value2);
    MetaDataListValues value3 = new MetaDataListValues("Item 3", "Item 3", 2);
    values.add(value3);
    meta.setListItems(values);
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof JComboBox);
    JComboBox cmb = (JComboBox) comp;
    cmb.setSelectedIndex(3);
    MetaDataListValues valueTest = (MetaDataListValues) cmb.getSelectedItem();
    assertTrue(valueTest.equals(value3));
    assertTrue(editor.getCellEditorValue().equals(value3));

    meta.setDataType(EDataType.RealNumber);
    value = "30.5";
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof DecimalNumberField);
    DecimalNumberField num2 = (DecimalNumberField) comp;
    assertTrue(num2.getValue() == 30.5);
    assertTrue(editor.getCellEditorValue().equals("30.50000"));

    meta.setDataType(EDataType.Text);
    value = "Hello World";
    comp = editor.getTableCellEditorComponent(table, value, true, 0, 1);
    assertTrue(comp instanceof JTextField);
    JTextField txt = (JTextField) comp;
    assertTrue(txt.getText().equals(value));
    assertTrue(editor.getCellEditorValue().equals(value));
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipPanel.java

protected void rebuildTable(ObjEntity entity) {
    final ObjRelationshipTableModel model = new ObjRelationshipTableModel(entity, mediator, this);

    model.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRow() >= 0) {
                ObjRelationship rel = model.getRelationship(table.getSelectedRow());
                enabledResolve = rel.getSourceEntity().getDbEntity() != null;
                resolveMenu.setEnabled(enabledResolve);
            }//from w ww  .  j a  v  a  2 s  . c  om
        }
    });

    table.setModel(model);
    table.setRowHeight(25);
    table.setRowMargin(3);

    TableColumn col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_TARGET_PATH);
    col.setCellEditor(new DbRelationshipPathComboBoxEditor());
    col.setCellRenderer(new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
            setToolTipText(
                    "To choose relationship press enter two times.To choose next relationship press dot.");
            return this;
        }
    });

    col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_DELETE_RULE);
    JComboBox deleteRulesCombo = Application.getWidgetFactory().createComboBox(DELETE_RULES, false);
    deleteRulesCombo.setFocusable(false);
    deleteRulesCombo.setEditable(true);
    ((JComponent) deleteRulesCombo.getEditor().getEditorComponent()).setBorder(null);
    deleteRulesCombo.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    deleteRulesCombo.setSelectedIndex(0); // Default to the first value
    col.setCellEditor(Application.getWidgetFactory().createCellEditor(deleteRulesCombo));

    tablePreferences.bind(table, null, null, null, ObjRelationshipTableModel.REL_NAME, true);
}

From source file:org.apache.cayenne.swing.TableBinding.java

public TableBinding(JTable table, String listBinding, String[] headers, BindingExpression[] columns,
        Class[] columnClass, boolean[] editableState, Object[] sampleLongValues) {

    super(listBinding);
    this.table = table;
    this.headers = headers;
    this.columns = columns;
    this.editableState = editableState;
    this.columnClass = columnClass;

    table.setModel(new BoundTableModel());
    resizeColumns(sampleLongValues);//from w ww.j  a  v a  2s  .co  m
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JTable createTable(final ViewState state) {
    JTable table;
    final ModelGraph selected = state.getSelected();
    if (selected != null) {
        final Vector<Vector<String>> rows = new Vector<Vector<String>>();
        ConcurrentHashMap<String, String> keyToGroupMap = new ConcurrentHashMap<String, String>();
        Metadata staticMet = selected.getModel().getStaticMetadata();
        Metadata inheritedMet = selected.getInheritedStaticMetadata(state);
        Metadata completeMet = new Metadata();
        if (staticMet != null) {
            completeMet.replaceMetadata(staticMet.getSubMetadata(state.getCurrentMetGroup()));
        }//w  w w . ja va2s .c  o  m
        if (selected.getModel().getExtendsConfig() != null) {
            for (String configGroup : selected.getModel().getExtendsConfig()) {
                Metadata extendsMetadata = state.getGlobalConfigGroups().get(configGroup).getMetadata()
                        .getSubMetadata(state.getCurrentMetGroup());
                for (String key : extendsMetadata.getAllKeys()) {
                    if (!completeMet.containsKey(key)) {
                        keyToGroupMap.put(key, configGroup);
                        completeMet.replaceMetadata(key, extendsMetadata.getAllMetadata(key));
                    }
                }
            }
        }
        if (inheritedMet != null) {
            Metadata inheritedMetadata = inheritedMet.getSubMetadata(state.getCurrentMetGroup());
            for (String key : inheritedMetadata.getAllKeys()) {
                if (!completeMet.containsKey(key)) {
                    keyToGroupMap.put(key, "__inherited__");
                    completeMet.replaceMetadata(key, inheritedMetadata.getAllMetadata(key));
                }
            }
        }
        List<String> keys = completeMet.getAllKeys();
        Collections.sort(keys);
        for (String key : keys) {
            if (key.endsWith("/envReplace")) {
                continue;
            }
            String values = StringUtils.join(completeMet.getAllMetadata(key), ",");
            Vector<String> row = new Vector<String>();
            row.add(keyToGroupMap.get(key));
            row.add(key);
            row.add(values);
            row.add(Boolean.toString(Boolean.parseBoolean(completeMet.getMetadata(key + "/envReplace"))));
            rows.add(row);
        }
        table = new JTable();// rows, new Vector<String>(Arrays.asList(new
                             // String[] { "key", "values", "envReplace" })));
        table.setModel(new AbstractTableModel() {
            public String getColumnName(int col) {
                switch (col) {
                case 0:
                    return "group";
                case 1:
                    return "key";
                case 2:
                    return "values";
                case 3:
                    return "envReplace";
                default:
                    return null;
                }
            }

            public int getRowCount() {
                return rows.size() + 1;
            }

            public int getColumnCount() {
                return 4;
            }

            public Object getValueAt(int row, int col) {
                if (row >= rows.size()) {
                    return null;
                }
                String value = rows.get(row).get(col);
                if (value == null && col == 3) {
                    return "false";
                }
                if (value == null && col == 0) {
                    return "__local__";
                }
                return value;
            }

            public boolean isCellEditable(int row, int col) {
                if (row >= rows.size()) {
                    return selected.getModel().getStaticMetadata().containsGroup(state.getCurrentMetGroup());
                }
                if (col == 0) {
                    return false;
                }
                String key = rows.get(row).get(1);
                return key == null || (selected.getModel().getStaticMetadata() != null
                        && selected.getModel().getStaticMetadata().containsKey(getKey(key, state)));
            }

            public void setValueAt(Object value, int row, int col) {
                if (row >= rows.size()) {
                    Vector<String> newRow = new Vector<String>(
                            Arrays.asList(new String[] { null, null, null, null }));
                    newRow.add(col, (String) value);
                    rows.add(newRow);
                } else {
                    Vector<String> rowValues = rows.get(row);
                    rowValues.add(col, (String) value);
                    rowValues.remove(col + 1);
                }
                this.fireTableCellUpdated(row, col);
            }

        });
        MyTableListener tableListener = new MyTableListener(state);
        table.getModel().addTableModelListener(tableListener);
        table.getSelectionModel().addListSelectionListener(tableListener);
    } else {
        table = new JTable(new Vector<Vector<String>>(),
                new Vector<String>(Arrays.asList(new String[] { "key", "values", "envReplace" })));
    }

    // table.setFillsViewportHeight(true);
    table.setSelectionBackground(Color.cyan);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableCellRenderer cellRenderer = new TableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel field = new JLabel((String) value);
            if (column == 0) {
                field.setForeground(Color.gray);
            } else {
                if (isSelected) {
                    field.setBorder(new EtchedBorder(1));
                }
                if (table.isCellEditable(row, 1)) {
                    field.setForeground(Color.black);
                } else {
                    field.setForeground(Color.gray);
                }
            }
            return field;
        }

    };
    TableColumn groupCol = table.getColumnModel().getColumn(0);
    groupCol.setPreferredWidth(75);
    groupCol.setCellRenderer(cellRenderer);
    TableColumn keyCol = table.getColumnModel().getColumn(1);
    keyCol.setPreferredWidth(200);
    keyCol.setCellRenderer(cellRenderer);
    TableColumn valuesCol = table.getColumnModel().getColumn(2);
    valuesCol.setPreferredWidth(300);
    valuesCol.setCellRenderer(cellRenderer);
    TableColumn envReplaceCol = table.getColumnModel().getColumn(3);
    envReplaceCol.setPreferredWidth(75);
    envReplaceCol.setCellRenderer(cellRenderer);

    table.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultPropView.this.table.getSelectedRow() != -1) {
                int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
                String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
                Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
                override.setVisible(staticMet == null || !staticMet.containsKey(key));
                delete.setVisible(staticMet != null && staticMet.containsKey(key));
                tableMenu.show(DefaultPropView.this.table, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });

    return table;
}

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

private Object setTableResultsPanel(DatabaseObject databaseObject) {

    tableDataChanges.clear();//from   ww  w. j  a v a2 s .  c  o m
    primaryKeyColumns.clear();
    foreignKeyColumns.clear();

    this.databaseObject = databaseObject;
    try {

        initialiseModel();
        tableModel.setCellsEditable(false);
        tableModel.removeTableModelListener(this);

        if (isDatabaseTable()) {

            DatabaseTable databaseTable = asDatabaseTable();
            if (databaseTable.hasPrimaryKey()) {

                primaryKeyColumns = databaseTable.getPrimaryKeyColumnNames();
                canEditTableLabel.setText("This table has a primary key(s) and data may be edited here");
            }

            if (databaseTable.hasForeignKey()) {

                foreignKeyColumns = databaseTable.getForeignKeyColumnNames();
            }

            if (primaryKeyColumns.isEmpty()) {

                canEditTableLabel.setText("This table has no primary keys defined and is not editable here");
            }

            canEditTableNotePanel.setVisible(alwaysShowCanEditNotePanel);
        }

        if (!isDatabaseTable()) {

            canEditTableNotePanel.setVisible(false);
        }

        Log.debug("Retrieving data for table - " + databaseObject.getName());

        ResultSet resultSet = databaseObject.getData(true);
        tableModel.createTable(resultSet);
        if (table == null) {

            createResultSetTable();
        }
        tableModel.setNonEditableColumns(primaryKeyColumns);

        TableSorter sorter = new TableSorter(tableModel);
        table.setModel(sorter);
        sorter.setTableHeader(table.getTableHeader());

        if (isDatabaseTable()) {

            SortableHeaderRenderer renderer = new SortableHeaderRenderer(sorter) {

                private ImageIcon primaryKeyIcon = GUIUtilities
                        .loadIcon(BrowserConstants.PRIMARY_COLUMNS_IMAGE);
                private ImageIcon foreignKeyIcon = GUIUtilities
                        .loadIcon(BrowserConstants.FOREIGN_COLUMNS_IMAGE);

                @Override
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {

                    DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) super.getTableCellRendererComponent(
                            table, value, isSelected, hasFocus, row, column);

                    Icon keyIcon = iconForValue(value);
                    if (keyIcon != null) {

                        Icon icon = renderer.getIcon();
                        if (icon != null) {

                            BufferedImage image = new BufferedImage(
                                    icon.getIconWidth() + keyIcon.getIconWidth() + 2,
                                    Math.max(keyIcon.getIconHeight(), icon.getIconHeight()),
                                    BufferedImage.TYPE_INT_ARGB);

                            Graphics graphics = image.getGraphics();
                            keyIcon.paintIcon(null, graphics, 0, 0);
                            icon.paintIcon(null, graphics, keyIcon.getIconWidth() + 2, 5);

                            setIcon(new ImageIcon(image));

                        } else {

                            setIcon(keyIcon);
                        }

                    }

                    return renderer;
                }

                private ImageIcon iconForValue(Object value) {

                    if (value != null) {

                        String name = value.toString();
                        if (primaryKeyColumns.contains(name)) {

                            return primaryKeyIcon;

                        } else if (foreignKeyColumns.contains(name)) {

                            return foreignKeyIcon;
                        }

                    }

                    return null;
                }

            };
            sorter.setTableHeaderRenderer(renderer);

        }

        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        scroller.getViewport().add(table);
        removeAll();

        add(canEditTableNotePanel, canEditTableNoteConstraints);
        add(scroller, scrollerConstraints);

        if (displayRowCount && SystemProperties.getBooleanProperty("user", "browser.query.row.count")) {

            add(rowCountPanel, rowCountPanelConstraints);
            rowCountField.setText(String.valueOf(sorter.getRowCount()));
        }

    } catch (DataSourceException e) {

        if (!cancelled) {

            addErrorLabel(e);

        } else {

            addCancelledLabel();
        }

    } finally {

        tableModel.addTableModelListener(this);
    }

    setTableProperties();
    validate();
    repaint();

    return "done";
}

From source file:org.jets3t.gui.ItemPropertiesDialog.java

/**
 * Initialise the GUI elements to display the given item.
 *
 * @param s3Item//  w  w  w .j a  va 2  s . c om
 * the S3Bucket or an S3Object whose details will be displayed
 */
private void initGui(boolean isObjectBased) {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setResizable(true);
    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    JPanel commonPropertiesContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesCommonPanel");
    commonPropertiesContainer.setLayout(new GridBagLayout());
    JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesMetadataPanel");
    metadataContainer.setLayout(new GridBagLayout());
    JPanel grantsContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesGrantsPanel");
    grantsContainer.setLayout(new GridBagLayout());

    if (!isObjectBased) {
        // Display bucket details.
        JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel");
        bucketNameLabel.setText("Bucket name:");
        bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField");
        bucketNameTextField.setEditable(false);
        JLabel bucketLocationLabel = skinsFactory.createSkinnedJHtmlLabel("BucketLocationLabel");
        bucketLocationLabel.setText("Location:");
        bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField");
        bucketLocationTextField.setEditable(false);
        JLabel bucketCreationDateLabel = skinsFactory.createSkinnedJHtmlLabel("BucketCreationDateLabel");
        bucketCreationDateLabel.setText("Creation date:");
        bucketCreationDateTextField = skinsFactory.createSkinnedJTextField("BucketCreationDateTextField");
        bucketCreationDateTextField.setEditable(false);
        ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel");
        ownerNameLabel.setText("Owner name:");
        ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField");
        ownerNameTextField.setEditable(false);
        ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel");
        ownerIdLabel.setText("Owner ID:");
        ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField");
        ownerIdTextField.setEditable(false);

        bucketIsRequesterPaysLabel = skinsFactory.createSkinnedJHtmlLabel("BucketIsRequesterPaysLabel");
        bucketIsRequesterPaysLabel.setText("Requester Pays?");
        bucketIsRequesterPaysCheckBox = skinsFactory.createSkinnedJCheckBox("BucketIsRequesterPaysCheckBox");
        bucketIsRequesterPaysCheckBox.setEnabled(false);

        int row = 0;
        commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketLocationLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketLocationTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketCreationDateLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketCreationDateTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketIsRequesterPaysLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketIsRequesterPaysCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0,
                GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    } else {
        // Display object details.
        JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel");
        objectKeyLabel.setText("Object key:");
        objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField");
        objectKeyTextField.setEditable(false);
        JLabel objectContentTypeLabel = skinsFactory.createSkinnedJHtmlLabel("ContentTypeLabel");
        objectContentTypeLabel.setText("Content type:");
        objectContentTypeTextField = skinsFactory.createSkinnedJTextField("ContentTypeTextField");
        objectContentTypeTextField.setEditable(false);
        JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel");
        objectContentLengthLabel.setText("Size:");
        objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField");
        objectContentLengthTextField.setEditable(false);
        JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel");
        objectLastModifiedLabel.setText("Last modified:");
        objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField");
        objectLastModifiedTextField.setEditable(false);
        JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel");
        objectETagLabel.setText("ETag:");
        objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField");
        objectETagTextField.setEditable(false);
        JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel");
        bucketNameLabel.setText("Bucket name:");
        bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField");
        bucketNameTextField.setEditable(false);
        ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel");
        ownerNameLabel.setText("Owner name:");
        ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField");
        ownerNameTextField.setEditable(false);
        ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel");
        ownerIdLabel.setText("Owner ID:");
        ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField");
        ownerIdTextField.setEditable(false);

        commonPropertiesContainer.add(objectKeyLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectKeyTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectContentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectContentTypeTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectContentLengthLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectContentLengthTextField, new GridBagConstraints(1, 2, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectLastModifiedLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectLastModifiedTextField, new GridBagConstraints(1, 3, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectETagLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectETagTextField, new GridBagConstraints(1, 4, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, 5, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, 5, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, 7, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, 7, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, 8, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, 8, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        // Build metadata table.
        objectMetadataTableModel = new DefaultTableModel(new Object[] { "Name", "Value" }, 0) {
            private static final long serialVersionUID = -3762866886166776851L;

            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        TableSorter metadataTableSorter = new TableSorter(objectMetadataTableModel);
        JTable metadataTable = skinsFactory.createSkinnedJTable("MetadataTable");
        metadataTable.setModel(metadataTableSorter);
        metadataTableSorter.setTableHeader(metadataTable.getTableHeader());
        metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));
    }

    // Build grants table.
    grantsTableModel = new DefaultTableModel(new Object[] { "Grantee", "Permission" }, 0) {
        private static final long serialVersionUID = -5882427163845726770L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    TableSorter grantsTableSorter = new TableSorter(grantsTableModel);
    grantsTable = skinsFactory.createSkinnedJTable("GrantsTable");
    grantsTable.setModel(grantsTableSorter);
    grantsTableSorter.setTableHeader(grantsTable.getTableHeader());
    grantsContainer.add(new JScrollPane(grantsTable), new GridBagConstraints(0, 0, 1, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // OK Button.
    JButton okButton = skinsFactory.createSkinnedJButton("ItemPropertiesOKButton");
    okButton.setText("Finished");
    okButton.setActionCommand("OK");
    okButton.addActionListener(this);

    // Set default ENTER button.
    this.getRootPane().setDefaultButton(okButton);

    // Put it all together.
    int row = 0;
    JPanel container = skinsFactory.createSkinnedJPanel("ItemPropertiesPanel");
    container.setLayout(new GridBagLayout());
    container.add(commonPropertiesContainer, new GridBagConstraints(0, row++, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    if (isObjectBased) {

        if (includeMetadata) {
            JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel");
            metadataLabel.setText("<html><b>Metadata</b></html>");
            metadataLabel.setHorizontalAlignment(JLabel.CENTER);
            container.add(metadataLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0));
            container.add(metadataContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
        }

        // Object previous and next buttons, if we have multiple objects.
        previousObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesPreviousButton");
        previousObjectButton.setText("Previous");
        previousObjectButton.addActionListener(this);
        previousObjectButton.setEnabled(false);
        nextObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesNextButton");
        nextObjectButton.setText("Next");
        nextObjectButton.addActionListener(this);
        nextObjectButton.setEnabled(false);
        currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ItemPropertiesCurrentObjectLabel");
        currentObjectLabel.setHorizontalAlignment(JLabel.CENTER);

        nextPreviousPanel = skinsFactory.createSkinnedJPanel("ItemPropertiesNextPreviousPanel");
        nextPreviousPanel.setLayout(new GridBagLayout());
        nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 0, 0,
                GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
        nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
        nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0));

        container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
        row++;
    } else {
        JHtmlLabel grantsLabel = skinsFactory.createSkinnedJHtmlLabel("GrantsLabel");
        grantsLabel.setText("<html><b>Permissions</b></html>");
        grantsLabel.setHorizontalAlignment(JLabel.CENTER);
        container.add(grantsLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0));
        container.add(grantsContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, insetsZero, 0, 0));
    }
    container.add(okButton, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    this.getContentPane().add(container);

    this.pack();
    if (isObjectBased) {
        this.setSize(400, (includeMetadata ? 550 : 400));
    }
    this.setLocationRelativeTo(this.getOwner());
}