List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:com.digitalgeneralists.assurance.ui.components.ComparisonResultPanel.java
protected void initializeComponent(ComparisonResult result) { if (!this.initialized) { this.merging = false; this.numberOfLines = 0; this.setOpaque(true); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.basePanelConstraints.anchor = GridBagConstraints.WEST; this.basePanelConstraints.fill = GridBagConstraints.BOTH; this.basePanelConstraints.gridx = 0; this.basePanelConstraints.gridy = 0; this.basePanelConstraints.weightx = 1.0; this.basePanelConstraints.weighty = 1.0; this.basePanelConstraints.gridheight = 1; this.basePanelConstraints.gridwidth = 1; this.basePanelConstraints.insets = new Insets(0, 0, 0, 0); this.standardPanel.setOpaque(false); GridBagLayout basePanelGridbag = new GridBagLayout(); this.standardPanel.setLayout(basePanelGridbag); this.add(this.standardPanel, this.basePanelConstraints); GridBagConstraints sourcePanelConstraints = new GridBagConstraints(); sourcePanelConstraints.anchor = GridBagConstraints.WEST; sourcePanelConstraints.fill = GridBagConstraints.BOTH; sourcePanelConstraints.gridx = 0; sourcePanelConstraints.gridy = 0; sourcePanelConstraints.weightx = 0.4; sourcePanelConstraints.weighty = 1.0; sourcePanelConstraints.gridheight = 1; sourcePanelConstraints.gridwidth = 1; sourcePanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel sourcePanel = new JPanel(); sourcePanel.setOpaque(false);// w ww.j a va 2 s. co m GridBagLayout sourcePanelGridbag = new GridBagLayout(); sourcePanel.setLayout(sourcePanelGridbag); this.standardPanel.add(sourcePanel, sourcePanelConstraints); GridBagConstraints sourceFileLabelConstraints = new GridBagConstraints(); sourceFileLabelConstraints.anchor = GridBagConstraints.WEST; sourceFileLabelConstraints.gridx = 0; sourceFileLabelConstraints.gridy = 0; sourceFileLabelConstraints.weightx = 1.0; sourceFileLabelConstraints.weighty = 1.0; sourceFileLabelConstraints.gridheight = 1; sourceFileLabelConstraints.gridwidth = 1; sourceFileLabelConstraints.insets = new Insets(5, 5, 5, 5); String sourcePath = "No File Specified"; if ((result != null) && (result.getSource() != null)) { File sourceFile = result.getSource().getFile(); if ((sourceFile == null) || (!sourceFile.exists())) { sourcePath = "File does not exist in source location."; } else { sourcePath = sourceFile.getPath(); } sourceFile = null; } JLabel sourceFileLabel = new JLabel(sourcePath); sourcePath = null; sourcePanel.add(sourceFileLabel, sourceFileLabelConstraints); GridBagConstraints sourceAttributesPanelConstraints = new GridBagConstraints(); sourceAttributesPanelConstraints.anchor = GridBagConstraints.WEST; sourceAttributesPanelConstraints.fill = GridBagConstraints.BOTH; sourceAttributesPanelConstraints.gridx = 0; sourceAttributesPanelConstraints.gridy = 1; sourceAttributesPanelConstraints.weightx = 1.0; sourceAttributesPanelConstraints.weighty = 1.0; sourceAttributesPanelConstraints.gridheight = 1; sourceAttributesPanelConstraints.gridwidth = 1; sourceAttributesPanelConstraints.insets = new Insets(0, 0, 0, 0); FileReference sourceReference = null; if (result != null) { sourceReference = result.getSource(); } FileReference targetReference = null; if (result != null) { targetReference = result.getTarget(); } JPanel sourceAttributesPanel = this.createFileAttributesPanel(sourceReference, targetReference, GridBagConstraints.WEST); sourcePanel.add(sourceAttributesPanel, sourceAttributesPanelConstraints); this.moreSourceAttributesButton.setHorizontalAlignment(SwingConstants.LEFT); this.moreSourceAttributesButton.setBorderPainted(false); this.moreSourceAttributesButton.setOpaque(false); this.moreSourceAttributesButton.setForeground(Color.blue); if (this.editable) { this.moreSourceAttributesButton.setText("All attributes..."); this.moreSourceAttributesButton.addActionListener(this); this.moreSourceAttributesButton.setEnabled(true); } else { this.moreSourceAttributesButton.setText(" "); this.moreSourceAttributesButton.setEnabled(false); } this.moreSourceAttributesButton.setActionCommand(AssuranceActions.sourceAttributesAction); GridBagConstraints moreSourceAttributesButtonConstraints = new GridBagConstraints(); moreSourceAttributesButtonConstraints.anchor = GridBagConstraints.WEST; moreSourceAttributesButtonConstraints.fill = GridBagConstraints.BOTH; moreSourceAttributesButtonConstraints.gridx = 0; moreSourceAttributesButtonConstraints.gridy = 2; moreSourceAttributesButtonConstraints.weightx = 1.0; moreSourceAttributesButtonConstraints.weighty = 1.0; moreSourceAttributesButtonConstraints.gridheight = 1; moreSourceAttributesButtonConstraints.gridwidth = 1; moreSourceAttributesButtonConstraints.insets = new Insets(0, 0, 0, 0); sourcePanel.add(this.moreSourceAttributesButton, moreSourceAttributesButtonConstraints); this.buildMergePanel(result); GridBagConstraints targetPanelConstraints = new GridBagConstraints(); targetPanelConstraints.anchor = GridBagConstraints.EAST; targetPanelConstraints.fill = GridBagConstraints.BOTH; targetPanelConstraints.gridx = 2; targetPanelConstraints.gridy = 0; targetPanelConstraints.weightx = 0.4; targetPanelConstraints.weighty = 1.0; targetPanelConstraints.gridheight = 1; targetPanelConstraints.gridwidth = 1; targetPanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel targetPanel = new JPanel(); GridBagLayout targetPanelGridbag = new GridBagLayout(); targetPanel.setOpaque(false); targetPanel.setLayout(targetPanelGridbag); this.standardPanel.add(targetPanel, targetPanelConstraints); GridBagConstraints targetFileLabelConstraints = new GridBagConstraints(); targetFileLabelConstraints.anchor = GridBagConstraints.EAST; targetFileLabelConstraints.fill = GridBagConstraints.BOTH; targetFileLabelConstraints.gridx = 0; targetFileLabelConstraints.gridy = 0; targetFileLabelConstraints.weightx = 1.0; targetFileLabelConstraints.weighty = 1.0; targetFileLabelConstraints.gridheight = 1; targetFileLabelConstraints.gridwidth = 1; targetFileLabelConstraints.insets = new Insets(5, 5, 5, 5); // Create a label to put messages during an action event. String targetPath = "No File Specified"; if ((result != null) && (result.getTarget() != null)) { File targetFile = result.getTarget().getFile(); if ((targetFile == null) || (!targetFile.exists())) { targetPath = "File does not exist in target location."; } else { targetPath = targetFile.getPath(); } targetFile = null; } JLabel targetFileLabel = new JLabel(targetPath); targetPath = null; targetPanel.add(targetFileLabel, targetFileLabelConstraints); GridBagConstraints targetAttributesPanelConstraints = new GridBagConstraints(); targetAttributesPanelConstraints.anchor = GridBagConstraints.EAST; targetAttributesPanelConstraints.fill = GridBagConstraints.BOTH; targetAttributesPanelConstraints.gridx = 0; targetAttributesPanelConstraints.gridy = 1; targetAttributesPanelConstraints.weightx = 1.0; targetAttributesPanelConstraints.weighty = 1.0; targetAttributesPanelConstraints.gridheight = 1; targetAttributesPanelConstraints.gridwidth = 1; targetAttributesPanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel targetAttributesPanel = this.createFileAttributesPanel(targetReference, sourceReference, GridBagConstraints.EAST); targetPanel.add(targetAttributesPanel, targetAttributesPanelConstraints); sourceReference = null; targetReference = null; this.moreTargetAttributesButton.setHorizontalAlignment(SwingConstants.RIGHT); this.moreTargetAttributesButton.setBorderPainted(false); this.moreTargetAttributesButton.setOpaque(false); this.moreTargetAttributesButton.setForeground(Color.blue); if (this.editable) { this.moreTargetAttributesButton.setText("All attributes..."); this.moreTargetAttributesButton.addActionListener(this); this.moreTargetAttributesButton.setEnabled(true); } else { this.moreTargetAttributesButton.setText(" "); this.moreTargetAttributesButton.setEnabled(false); } this.moreTargetAttributesButton.setActionCommand(AssuranceActions.targetAttributesAction); GridBagConstraints moreTargetAttributesButtonConstraints = new GridBagConstraints(); moreTargetAttributesButtonConstraints.anchor = GridBagConstraints.EAST; moreTargetAttributesButtonConstraints.fill = GridBagConstraints.BOTH; moreTargetAttributesButtonConstraints.gridx = 0; moreTargetAttributesButtonConstraints.gridy = 2; moreTargetAttributesButtonConstraints.weightx = 1.0; moreTargetAttributesButtonConstraints.weighty = 1.0; moreTargetAttributesButtonConstraints.gridheight = 1; moreTargetAttributesButtonConstraints.gridwidth = 1; moreTargetAttributesButtonConstraints.insets = new Insets(0, 0, 0, 0); targetPanel.add(this.moreTargetAttributesButton, moreTargetAttributesButtonConstraints); GridBagLayout mergingPanelGridbag = new GridBagLayout(); this.mergingPanel.setLayout(mergingPanelGridbag); GridBagConstraints mergingLabelConstraints = new GridBagConstraints(); mergingLabelConstraints.anchor = GridBagConstraints.NORTH; mergingLabelConstraints.fill = GridBagConstraints.BOTH; mergingLabelConstraints.gridx = 0; mergingLabelConstraints.gridy = 0; mergingLabelConstraints.weightx = 1.0; mergingLabelConstraints.weighty = 1.0; mergingLabelConstraints.gridheight = 1; mergingLabelConstraints.gridwidth = 1; mergingLabelConstraints.insets = new Insets(10, 10, 10, 10); this.mergingLabel.setHorizontalAlignment(JLabel.CENTER); mergingPanel.add(this.mergingLabel, mergingLabelConstraints); GridBagConstraints mergingStatusIndicatorConstraints = new GridBagConstraints(); mergingStatusIndicatorConstraints.anchor = GridBagConstraints.SOUTH; mergingStatusIndicatorConstraints.fill = GridBagConstraints.BOTH; mergingStatusIndicatorConstraints.gridx = 0; mergingStatusIndicatorConstraints.gridy = 1; mergingStatusIndicatorConstraints.weightx = 1.0; mergingStatusIndicatorConstraints.weighty = 1.0; mergingStatusIndicatorConstraints.gridheight = 1; mergingStatusIndicatorConstraints.gridwidth = 1; mergingStatusIndicatorConstraints.insets = new Insets(10, 10, 10, 10); this.mergingProgressIndicator.setIndeterminate(true); mergingPanel.add(this.mergingProgressIndicator, mergingStatusIndicatorConstraints); this.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { if (applicationDelegate != null) { applicationDelegate.addEventObserver(ResultMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ResultMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } } public void ancestorRemoved(AncestorEvent event) { if (applicationDelegate != null) { applicationDelegate.removeEventObserver(ResultMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ResultMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } } public void ancestorMoved(AncestorEvent event) { } }); this.initialized = true; } }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void layoutUI() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); JScrollPane rawDataTreeScrollPane = new JScrollPane(rawDataTree); JScrollPane parametersTableScrollPane = new JScrollPane(parametersTable); JScrollPane resolvedDataTreeScrollPane = new JScrollPane(resolvedDataTree); Insets insets = new Insets(5, 5, 5, 5); panel.add(new JLabel("Raw Data:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(new JLabel("Resolved Data:"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(rawDataTreeScrollPane, new GridBagConstraints(0, 1, 1, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); panel.add(resolvedDataTreeScrollPane, new GridBagConstraints(1, 1, 1, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); panel.add(rawRecordCountLabel, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); JPanel resolvedLabelPanel = new JPanel(); resolvedLabelPanel.setLayout(new GridBagLayout()); resolvedLabelPanel.add(resolvedRecordCountLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, insets, 0, 0)); resolvedLabelPanel.add(filterForSelectedCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(resolvedLabelPanel, new GridBagConstraints(1, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); bottomPanel.add(new JLabel("Parameters:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); bottomPanel.add(parametersTableScrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); bottomPanel.add(resolveButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(bottomPanel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); this.setContentPane(panel); }
From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java
public SimilarityRetrievalGUI() { super("Similarity Retrieval GUI"); setLayout(new GridBagLayout()); GridBagConstraintsIFS gcMain = new GridBagConstraintsIFS(GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // the panel with the feature files, allows to load new ones JPanel panelFeatureFiles = UiUtils.makeBorderedPanel(new VerticalLayout(), "Feature files"); getContentPane().add(panelFeatureFiles, gcMain); panelLoadedFeatureFiles.add(labelNoInputData); panelFeatureFiles.add(panelLoadedFeatureFiles); JButton btnLoad = initButtonLoad(); panelFeatureFiles.add(btnLoad);/*www.ja v a 2 s.c o m*/ txtFieldMusicPath.setToolTipText("Path to the music"); // TODO: remove txtFieldMusicPath.setText("/data/music/ISMIRgenre/mp3_44khz_128kbit_stereo_30sec"); JButton btnBrowseMusicPath = UiUtils.createBrowseButton(txtFieldMusicPath, this, true); JPanel panelMusicPath = new JPanel(); panelMusicPath.add(new JLabel("Music path")); panelMusicPath.add(txtFieldMusicPath); panelMusicPath.add(btnBrowseMusicPath); panelFeatureFiles.add(panelMusicPath); initButtonStart(); initButtonSaveResults(); JRadioButton rbDistanceAbsolute = UiUtils.makeRadioButton("absolute", bgDistanceDisplay, true); bgDistanceDisplay.add(rbDistanceAbsolute); JRadioButton rbDistanceRelative = UiUtils.makeRadioButton("relative", bgDistanceDisplay); bgDistanceDisplay.add(rbDistanceRelative); initPanelRetrieval(); ((JSpinner.DefaultEditor) spinnerNumberNeighbours.getEditor()).getTextField().setColumns(6); panelRetrieval.setBorder(new TitledBorder("Options")); GridBagConstraintsIFS gc = new GridBagConstraintsIFS().setInsets(5, 2); panelRetrieval.add(new JLabel("# to retrieve"), gc); panelRetrieval.add(spinnerNumberNeighbours, gc.nextCol()); panelRetrieval.add(new JLabel("Query vector"), gc.nextRow()); panelRetrieval.add(comboQueryVector, gc.nextCol()); panelRetrieval.add(new JLabel("Distances"), gc.nextRow()); panelRetrieval.add(UiUtils.makeAndFillPanel(rbDistanceAbsolute, rbDistanceRelative), gc.nextCol()); boxMetric.setSelectedItem(L2Metric.class.getSimpleName()); panelRetrieval.add(new JLabel("Distance metric"), gc.nextRow()); panelRetrieval.add(boxMetric, gc.nextCol()); gc.nextRow().setGridWidth(2).setAnchor(GridBagConstraints.CENTER); panelRetrieval.add(UiUtils.makeAndFillPanel(btnStart, btnSaveResults), gc); panelRetrieval.setEnabled(false); getContentPane().add(panelRetrieval, gcMain.nextRow()); resizeResultTableColumns(); JScrollPane scrollPaneResults = new JScrollPane(resultsTable); scrollPaneResults.setBorder(new TitledBorder("Results")); getContentPane().add(scrollPaneResults, gcMain.nextRow()); databaseDetailsTable = new JTable(new DefaultTableModel(new Object[][] {}, databaseDetailsColumnNames)); databaseDetailsTable.setAutoCreateRowSorter(true); databaseDetailsTable.setDefaultEditor(JButton.class, new ButtonCellEditor()); resizeDatabaseDetailsTableColumns(); JScrollPane scrollPaneDatabaseDetails = new JScrollPane(databaseDetailsTable); // panel in the upper-right corner, holding the database table & buttons to load class assignment JPanel databaseDetailsPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Database Details"); GridBagConstraintsIFS gcDatabaseDetails = new GridBagConstraintsIFS(GridBagConstraints.CENTER, GridBagConstraints.BOTH); gcDatabaseDetails.setWeights(1, 1); databaseDetailsPanel.add(scrollPaneDatabaseDetails, gcDatabaseDetails); initButtonLoadClassInfo(); databaseDetailsPanel.add(buttonLoadClassInfo, gc.nextRow()); JPanel histogramPanel = UiUtils.makeBorderedPanel("Histogram of Distances"); histogramPanel.add(chartPanel); JPanel detailsPanel = new JPanel(new VerticalLayout()); gcMain.setGridHeight(3); gcMain.setWeights(1, 1); getContentPane().add(detailsPanel, gcMain.moveTo(1, 0)); detailsPanel.add(databaseDetailsPanel); detailsPanel.add(histogramPanel); }
From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java
/** * Description:/* w w w . j a v a 2 s . co m*/ * * @param name */ protected void initComponent() { setLayout(new GridBagLayout()); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridwidth = GridBagConstraints.REMAINDER; JPanel titlePanel = createTitlePanel(); add(titlePanel, gc); gc.gridwidth = 1; JPanel deviceTypePanel = createDeviceTypePanel(); add(deviceTypePanel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; JPanel flowTypePanel = createFlowTypePanel(); add(flowTypePanel, gc); gc.weighty = 1; gc.fill = GridBagConstraints.BOTH; add(Box.createGlue(), gc); }
From source file:com.digitalgeneralists.assurance.ui.components.FileAttributesPanel.java
private JPanel createFileAttributesPanel(FileReference fileReference) { JPanel attributePanel = new JPanel(); GridBagLayout attributePanelGridbag = new GridBagLayout(); attributePanel.setOpaque(false);/*from w ww. ja va 2s . com*/ attributePanel.setLayout(attributePanelGridbag); int anchor = GridBagConstraints.WEST; if (fileReference != null) { int index = 0; FileAttributes attributes = fileReference.getFileAttributes(); this.addFileAttributeToPanel(attributePanel, anchor, index, "Content Hash: ", (attributes.getContentsHash() != null) ? attributes.getContentsHash().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Creation Time: ", (attributes.getCreationTime() != null) ? attributes.getCreationTime().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Directory: ", (attributes.getIsDirectory() != null) ? attributes.getIsDirectory().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Other: ", (attributes.getIsOther() != null) ? attributes.getIsOther().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Regular File: ", (attributes.getIsRegularFile() != null) ? attributes.getIsRegularFile().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Symbolic Link: ", (attributes.getIsSymbolicLink() != null) ? attributes.getIsSymbolicLink().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Last Access Time: ", (attributes.getLastAccessTime() != null) ? attributes.getLastAccessTime().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Last Modified Time: ", (attributes.getLastModifiedTime() != null) ? attributes.getLastModifiedTime().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "File Size: ", (attributes.getSize() != null) ? attributes.getSize().toString() : ""); index++; // DOS Attributes this.addFileAttributeToPanel(attributePanel, anchor, index, "Archive: ", (attributes.getIsArchive() != null) ? attributes.getIsArchive().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Hidden: ", (attributes.getIsHidden() != null) ? attributes.getIsHidden().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Read Only: ", (attributes.getIsReadOnly() != null) ? attributes.getIsReadOnly().toString() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "System File: ", (attributes.getIsSystem() != null) ? attributes.getIsSystem().toString() : ""); index++; // POSIX Attributes this.addFileAttributeToPanel(attributePanel, anchor, index, "Group Name: ", (attributes.getGroupName() != null) ? attributes.getGroupName() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Owner: ", (attributes.getOwner() != null) ? attributes.getOwner() : ""); index++; this.addFileAttributeToPanel(attributePanel, anchor, index, "Permissions: ", (attributes.getPermissions() != null) ? attributes.getPermissions() : ""); index++; // File-owner Attributes this.addFileAttributeToPanel(attributePanel, anchor, index, "File Owner: ", (attributes.getFileOwner() != null) ? attributes.getFileOwner() : ""); index++; // ACL Attributes this.addFileAttributeToPanel(attributePanel, anchor, index, "ACLs: ", (attributes.getAclDescription() != null) ? attributes.getAclDescription() : ""); index++; // User-defined Attributes this.addFileAttributeToPanel(attributePanel, anchor, index, "User-defined Attributes Hash: ", (attributes.getUserDefinedAttributesHash() != null) ? attributes.getUserDefinedAttributesHash() : ""); attributes = null; } return attributePanel; }
From source file:com.qspin.qtaste.ui.MainPanel.java
public void genUI() { try {/*from w w w.j a v a 2 s . c om*/ getContentPane().setLayout(new BorderLayout()); // prepare the top panel that contains the following panes: // - logo // - ConfigInfopanel // - Current Date/time JPanel topanel = new JPanel(new BorderLayout()); JPanel center = new JPanel(new GridBagLayout()); ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin"); JLabel iconlabel = new JLabel(topLeftLogo); mHeaderPanel = new ConfigInfoPanel(this); mTestCasePanel = new TestCasePane(this); mTestCampaignPanel = new TestCampaignMainPanel(this); mHeaderPanel.init(); GridBagLineAdder centeradder = new GridBagLineAdder(center); JLabel sep = new JLabel(" "); sep.setFont(ResourceManager.getInstance().getSmallFont()); sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor())); centeradder.setWeight(1.0f, 0.0f); centeradder.add(mHeaderPanel); // prepare the right panels containg the main information: // the right pane is selected through the tabbed pane: // - Test cases: management of test cases and test suites // - Test campaign: management of test campaigns // - Interactive: ability to invoke QTaste verbs one by one mRightPanels = new JPanel(new CardLayout()); mRightPanels.add(mTestCasePanel, "Test Cases"); mRightPanels.add(mTestCampaignPanel, "Test Campaign"); final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel(); mRightPanels.add(testInterractivePanel, "Interactive"); mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM); mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT)); TestCaseTree tct = new TestCaseTree(mTestCasePanel); JScrollPane sp2 = new JScrollPane(tct); mTreeTabsPanel.addTab("Test Cases", sp2); // add tree view for test campaign definition com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree( mTestCampaignPanel.getTreeTable()); JScrollPane sp3 = new JScrollPane(mtct); mTreeTabsPanel.addTab("Test Campaign", sp3); genMenu(tct); // add another tab contain used for Interactive mode TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel); JScrollPane spInter = new JScrollPane(jInteractive); mTreeTabsPanel.addTab("Interactive", spInter); // init will do the link between the tree view and the pane testInterractivePanel.init(); // Define the listener to display the pane depending on the selected tab mTreeTabsPanel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex()); CardLayout rcl = (CardLayout) mRightPanels.getLayout(); rcl.show(mRightPanels, componentName); } }); mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() == TestCampaignMainPanel.RUN_ID) { if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) { // open the tab test cases SwingUtilities.invokeLater(new Runnable() { public void run() { mTreeTabsPanel.setSelectedIndex(0); mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX); } }); // update the buttons mTestCasePanel.setExecutingTestCampaign(true, ((TestCampaignMainPanel) e.getSource()).getExecutionThread()); mTestCasePanel.updateButtons(true); } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) { mTestCasePanel.setExecutingTestCampaign(false, null); mTestCasePanel.updateButtons(); } } } }); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels); splitPane.setDividerSize(4); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); int mainHorizontalSplitDividerLocation = guiConfiguration .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285); splitPane.setDividerLocation(mainHorizontalSplitDividerLocation); splitPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("dividerLocation")) { GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); if (evt.getSource() instanceof JSplitPane) { JSplitPane splitPane = (JSplitPane) evt.getSource(); guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, splitPane.getDividerLocation()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } } } }); topanel.add(iconlabel, BorderLayout.WEST); topanel.add(center); getContentPane().add(topanel, BorderLayout.NORTH); getContentPane().add(splitPane); this.pack(); this.setExtendedState(Frame.MAXIMIZED_BOTH); if (mTestSuiteDir != null) { DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir); if (testSuite != null) { testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour); setTestSuite(testSuite.getName()); mTestCasePanel.runTestSuite(testSuite, false); } } setVisible(true); //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT)); } catch (Exception e) { logger.fatal(e); e.printStackTrace(); TestEngine.shutdown(); System.exit(1); } }
From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java
private void buildAndShowGUI() { chartData = null;//www . ja v a2s.c o m int numScheduleRows = scheduleRows.size(); sumUpTotalTime(); originalTotalTime = totalRow.time; if (originalTotalTime == 0) // if the rows added up to zero, choose a nominal target total time // corresponding to 10 hours per included schedule originalTotalTime = numScheduleRows * 60 * 10; JPanel panel = new JPanel(new GridBagLayout()); if (numScheduleRows == 1) { totalRow.rowLabel = scheduleRows.get(0).rowLabel; } else { for (int i = 0; i < numScheduleRows; i++) scheduleRows.get(i).addToPanel(panel, i); scheduleRows.get(numScheduleRows - 1).showPercentageTickMarks(); addChartToPanel(panel, numScheduleRows + 1); } totalRow.addToPanel(panel, numScheduleRows); if (rowsAreEditable == false) { String title = TaskScheduleDialog.resources.getString("Balance.Read_Only_Title"); JOptionPane.showMessageDialog(parent.frame, panel, title, JOptionPane.PLAIN_MESSAGE); } else { String title = TaskScheduleDialog.resources.getString("Balance.Editable_Title"); JDialog dialog = new JDialog(parent.frame, title, true); addButtons(dialog, panel, numScheduleRows + 2); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); dialog.getContentPane().add(panel); dialog.pack(); dialog.setLocationRelativeTo(parent.frame); dialog.setResizable(true); dialog.setVisible(true); } }
From source file:com.sshtools.common.ui.SshToolsConnectionPanel.java
/** * * * @param parent/* w w w. j av a 2 s . co m*/ * @param profile * @param optionalTabs * * @return */ public static SshToolsConnectionProfile showConnectionDialog(Component parent, SshToolsConnectionProfile profile, SshToolsConnectionTab[] optionalTabs) { // If no properties are provided, then use the default if (profile == null) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile = new SshToolsConnectionProfile(); profile.setHost(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_HOST, "")); profile.setPort(PreferencesStore.getInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, port)); profile.setUsername(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_USER, "")); } final SshToolsConnectionPanel conx = new SshToolsConnectionPanel(true); if (optionalTabs != null) { for (int i = 0; i < optionalTabs.length; i++) { conx.addTab(optionalTabs[i]); } } conx.setConnectionProfile(profile); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Connection Profile", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Connection Profile", true); } else { d = new JDialog((JFrame) null, "Connection Profile", true); } final JDialog dialog = d; class UserAction { boolean connect; } final UserAction userAction = new UserAction(); // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { userAction.connect = false; dialog.setVisible(false); } }); final JButton connect = new JButton("Connect"); connect.setMnemonic('t'); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (conx.validateTabs()) { userAction.connect = true; dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(connect); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, connect, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(conx, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(false); UIUtil.positionComponent(SwingConstants.CENTER, dialog); //show the simple box and act on the answer. SshToolsSimpleConnectionPrompt stscp = SshToolsSimpleConnectionPrompt.getInstance(); StringBuffer sb = new StringBuffer(); userAction.connect = !stscp.getHostname(sb, profile.getHost()); boolean advanced = stscp.getAdvanced(); if (advanced) { userAction.connect = false; profile.setHost(sb.toString()); conx.hosttab.setConnectionProfile(profile); dialog.setVisible(true); } // Make sure we didn't cancel if (!userAction.connect) { return null; } conx.applyTabs(); if (!advanced) profile.setHost(sb.toString()); if (!advanced) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile.setPort(port); } if (!advanced) profile.setUsername(""); PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_HOST, profile.getHost()); // only save user inputed configuration if (advanced) { PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_USER, profile.getUsername()); PreferencesStore.putInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, profile.getPort()); } // Return the connection properties return profile; }
From source file:org.gvsig.remotesensing.profiles.gui.ZProfileOptionsPanel.java
public JPanel getControlPanel() { if (controlPanel == null) { controlPanel = new JPanel(); //controlPanel.setPreferredSize(new Dimension(80,20)); GridBagLayout gb = new GridBagLayout(); controlPanel.setLayout(gb);/*w w w . j av a 2s.c o m*/ GridBagConstraints constrains = new GridBagConstraints(); constrains.insets = new java.awt.Insets(1, 5, 1, 1); constrains.gridx = 0; constrains.gridy = 0; controlPanel.add(getNewButton(), constrains); constrains.insets = new java.awt.Insets(1, 5, 1, 1); constrains.gridx = 0; constrains.gridy = 1; controlPanel.add(getDeleteButton(), constrains); } return controlPanel; }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return//ww w.j ava2 s .co m */ private Component createTopPanel() { JPanel topPanel = new JPanel(new GridBagLayout()); List<ConfiguredLanguage> configuredLanguages = ConfiguredLanguage.getConfiguredLanguages(); languageSelector = new JComboBox(configuredLanguages.toArray()); languageSelector.setSelectedIndex(0); languageSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setSyntaxStyle(); } }); currentFileLabel = new JLabel(); final JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Tank XML Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith("_ts.xml"); } }); JButton button = new JButton("Select File..."); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int showOpenDialog = jFileChooser.showOpenDialog(ScriptFilterRunner.this); if (showOpenDialog == JFileChooser.APPROVE_OPTION) { loadTSXml(jFileChooser.getSelectedFile()); } } }); xmlViewDialog = new XMlViewDialog(this); xmlViewDialog.setSize(new Dimension(800, 500)); showXmlBT = new JButton("Show XML"); showXmlBT.setEnabled(false); showXmlBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayXml(); } }); saveBT = new JButton("Save XML"); saveBT.setEnabled(false); saveBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveXml(); } }); JPanel xmlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 20)); xmlPanel.add(button); xmlPanel.add(showXmlBT); xmlPanel.add(saveBT); int y = 0; topPanel.add(new JLabel("Current Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(currentFileLabel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Script Language: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(languageSelector, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(xmlPanel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); return topPanel; }