/** Initialise the GUI elements to display the given item. */ private void initGui() { this.setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel unmodifiableAttributesPanel = skinsFactory.createSkinnedJPanel("ObjectStaticAttributesPanel"); unmodifiableAttributesPanel.setLayout(new GridBagLayout()); JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataPanel"); metadataContainer.setLayout(new GridBagLayout()); metadataButtonsContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataButtonsPanel"); metadataButtonsContainer.setLayout(new GridBagLayout()); // Fields to display unmodifiable object details. JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel"); objectKeyLabel.setText("Object key:"); objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField"); objectKeyTextField.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:"); bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField"); bucketLocationTextField.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); int row = 0; unmodifiableAttributesPanel.add( objectKeyLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectKeyTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectContentLengthLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectContentLengthTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectLastModifiedLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectLastModifiedTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectETagLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectETagTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( ownerNameLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( ownerNameTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( ownerIdLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( ownerIdTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( bucketNameLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( bucketLocationTextField, new GridBagConstraints( 1, row, 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; public boolean isCellEditable(int row, int column) { return isModifyMode(); } }; metadataTableSorter = new TableSorter(objectMetadataTableModel); metadataTable = skinsFactory.createSkinnedJTable("MetadataTable"); metadataTable.setModel(metadataTableSorter); metadataTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && removeMetadataItemButton != null) { int row = metadataTable.getSelectedRow(); removeMetadataItemButton.setEnabled(row >= 0); } } }); metadataTableSorter.setTableHeader(metadataTable.getTableHeader()); metadataTableSorter.setSortingStatus(0, TableSorter.ASCENDING); metadataContainer.add( new JScrollPane(metadataTable), new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsHorizontalSpace, 0, 0)); // Add/remove buttons for metadata table. removeMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); removeMetadataItemButton.setEnabled(false); removeMetadataItemButton.setToolTipText("Remove the selected metadata item(s)"); guiUtils.applyIcon(removeMetadataItemButton, "/images/nuvola/16x16/actions/viewmag-.png"); removeMetadataItemButton.addActionListener(this); removeMetadataItemButton.setActionCommand("removeMetadataItem"); addMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); addMetadataItemButton.setToolTipText("Add a new metadata item"); guiUtils.applyIcon(addMetadataItemButton, "/images/nuvola/16x16/actions/viewmag+.png"); addMetadataItemButton.setActionCommand("addMetadataItem"); addMetadataItemButton.addActionListener(this); metadataButtonsContainer.add( removeMetadataItemButton, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataButtonsContainer.add( addMetadataItemButton, new GridBagConstraints( 1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataContainer.add( metadataButtonsContainer, new GridBagConstraints( 0, 1, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); metadataButtonsContainer.setVisible(false); // OK Button. okButton = skinsFactory.createSkinnedJButton("ObjectPropertiesOKButton"); okButton.setText("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(this); // Cancel Button. cancelButton = null; cancelButton = skinsFactory.createSkinnedJButton("ObjectPropertiesCancelButton"); cancelButton.setText("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); cancelButton.setVisible(false); // Recognize and handle ENTER, ESCAPE, PAGE_UP, and PAGE_DOWN key presses. this.getRootPane().setDefaultButton(okButton); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane() .getActionMap() .put( "ESCAPE", new AbstractAction() { private static final long serialVersionUID = -7768790936535999307L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("PAGE_UP"), "PAGE_UP"); this.getRootPane() .getActionMap() .put( "PAGE_UP", new AbstractAction() { private static final long serialVersionUID = -6324229423705756219L; public void actionPerformed(ActionEvent actionEvent) { previousObjectButton.doClick(); } }); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("PAGE_DOWN"), "PAGE_DOWN"); this.getRootPane() .getActionMap() .put( "PAGE_DOWN", new AbstractAction() { private static final long serialVersionUID = -5808972377672449421L; public void actionPerformed(ActionEvent actionEvent) { nextObjectButton.doClick(); } }); // Put it all together. row = 0; JPanel container = skinsFactory.createSkinnedJPanel("ObjectPropertiesPanel"); container.setLayout(new GridBagLayout()); container.add( unmodifiableAttributesPanel, new GridBagConstraints( 0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); // Object previous and next buttons, if we have multiple objects. previousObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesPreviousButton"); guiUtils.applyIcon(previousObjectButton, "/images/nuvola/16x16/actions/1leftarrow.png"); previousObjectButton.addActionListener(this); previousObjectButton.setEnabled(false); nextObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesNextButton"); guiUtils.applyIcon(nextObjectButton, "/images/nuvola/16x16/actions/1rightarrow.png"); nextObjectButton.addActionListener(this); nextObjectButton.setEnabled(false); currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectPropertiesCurrentObjectLabel"); currentObjectLabel.setHorizontalAlignment(JLabel.CENTER); nextPreviousPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesNextPreviousPanel"); nextPreviousPanel.setLayout(new GridBagLayout()); nextPreviousPanel.add( previousObjectButton, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); nextPreviousPanel.add( currentObjectLabel, new GridBagConstraints( 1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); nextPreviousPanel.add( nextObjectButton, new GridBagConstraints( 2, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); container.add( nextPreviousPanel, new GridBagConstraints( 0, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); nextPreviousPanel.setVisible(false); row++; JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel"); metadataLabel.setText("<html><b>Metadata Attributes</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)); // Destination Access Control List setting. destinationPanel = skinsFactory.createSkinnedJPanel("DestinationPanel"); destinationPanel.setLayout(new GridBagLayout()); JPanel actionButtonsPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesActionButtonsPanel"); actionButtonsPanel.setLayout(new GridBagLayout()); actionButtonsPanel.add( cancelButton, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); actionButtonsPanel.add( okButton, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); cancelButton.setVisible(false); container.add( actionButtonsPanel, new GridBagConstraints( 0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().add(container); this.pack(); this.setSize(new Dimension(450, 500)); this.setLocationRelativeTo(this.getOwner()); }