List of usage examples for javax.swing.table TableColumn setMaxWidth
@BeanProperty(description = "The maximum width of the column.") public void setMaxWidth(int maxWidth)
TableColumn
's maximum width to maxWidth
or, if maxWidth
is less than the minimum width, to the minimum width. From source file:org.datanucleus.ide.idea.ui.v10x.DNEConfigFormV10x.java
public void setData(@NotNull final GuiState data) { this.guiState = new GuiState(data); ///* w ww . j a v a2s . c o m*/ // Basic panels this.indexNotReadyPanel.setVisible(!data.isIndexReady()); this.contentPanel.setVisible(data.isIndexReady()); // // Enable enhancer checkbox this.enableEnhancerCheckBox.setSelected(data.isEnhancerEnabled()); // // Persistence implementation selection final EnhancerSupportRegistry enhancerSupportRegistry = data.getEnhancerSupportRegistry(); final Set<EnhancerSupport> supportedEnhancers = enhancerSupportRegistry.getSupportedEnhancers(); if (this.persistenceImplComboBox.getItemCount() == 0) { for (final EnhancerSupport support : supportedEnhancers) { this.persistenceImplComboBox.addItem(support.getName()); } } final EnhancerSupport enhancerSupport = data.getEnhancerSupport(); this.persistenceImplComboBox.setSelectedItem(enhancerSupport.getName()); if (supportedEnhancers.size() <= 1) { this.persistenceImplComboBox.setVisible(false); } else { this.persistenceImplComboBox.setVisible(true); } // just to be sure -> validate persistence settings from config file PersistenceApi persistenceApi = data.getApi(); if (!enhancerSupport.isSupported(persistenceApi)) { persistenceApi = enhancerSupport.getDefaultPersistenceApi(); } this.jDORadioButton.setSelected(PersistenceApi.JDO == persistenceApi); this.jPARadioButton.setSelected(PersistenceApi.JPA == persistenceApi); this.jDORadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JDO)); this.jPARadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JPA)); // // Metadata file extensions text field this.metadataExtensionTextField.setText(data.getMetaDataExtensions().trim()); // // Compiler resource file extensions control final boolean metadataExtensionsEnabled = data.getMetaDataExtensions() != null && !data.getMetaDataExtensions().trim().isEmpty(); this.addToCompilerResourceCheckBox.setSelected(data.isAddToCompilerResourcePatterns()); this.addToCompilerResourceCheckBox.setEnabled(metadataExtensionsEnabled); // // Test classes inclusion this.includeTestClassesCheckBox.setSelected(data.isIncludeTestClasses()); // // Panel displaying an info message if enhancer is not initialized this.infoPanel.setVisible(!data.isEnhancerInitialized()); this.infoPanel.setEnabled(!data.isEnhancerInitialized()); // // Table displaying affected modules if enhancer is initialized final TableModel affectedModulesRowModel = new AffectedModulesRowModel(data.getAffectedModules()); // modules affected by class enhancement this.affectedModulesTable.setModel(affectedModulesRowModel); // set column appearance final TableColumnModel columnModel = this.affectedModulesTable.getColumnModel(); final TableColumn firstColumn = columnModel.getColumn(0); firstColumn.setMinWidth(50); firstColumn.setMaxWidth(50); firstColumn.setPreferredWidth(50); this.affectedModulesTable.setDefaultEditor(Boolean.class, new BooleanTableCellEditor(false)); setPreferredTableHeight(this.affectedModulesTable, this.affectedModulesTable.getRowCount()); // // Table displaying affected files/classes/.. if enhancer is initialized final TableModel metadataOrClassFilesRowModel = new MetadataOrClassFilesRowModel(data.getMetadataFiles(), data.getAnnotatedClassFiles()); // files affected by class enhancement this.metadataAndClassesTable.setModel(metadataOrClassFilesRowModel); // set column appearance this.metadataAndClassesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // adjust column sizes (after being rendered the first time - necessary for ColumnAdjuster to work) final ColumnAdjuster columnAdjuster = new ColumnAdjuster(this.metadataAndClassesTable); //columnAdjuster.setOnlyAdjustLarger(false); columnAdjuster.setDynamicAdjustment(true); columnAdjuster.adjustColumns(); setPreferredTableHeight(this.metadataAndClassesTable, this.metadataAndClassesTable.getRowCount()); this.metadataAndClassesTable.setVisible(data.isEnhancerInitialized()); // only display detected classes if initialized this.metaDataAndClassesScrollPane.setVisible(data.isEnhancerInitialized()); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java
/** * Lists the buckets in the user's S3 account and refreshes the GUI to display * these buckets. Any buckets or objects already listed in the GUI are cleared first. *//* w w w. jav a 2 s.c o m*/ private void listAllBuckets() { // Remove current bucket and object data from models. cachedBuckets.clear(); bucketsTable.clearSelection(); bucketTableModel.removeAllBuckets(); objectTableModel.removeAllObjects(); final Cockpit myself = this; // This is all very convoluted. This was necessary so we can display the status dialog box. runInBackgroundThread(new Runnable() { public void run() { if (!cloudFrontMembershipChecked) { // Check whether the user is signed-up for CloudFront. startProgressDialog("Checking for CloudFront account membership"); try { cloudFrontService = new CloudFrontService(s3ServiceMulti.getAWSCredentials(), APPLICATION_DESCRIPTION, myself, null, null); cloudFrontService.listDistributions(); } catch (CloudFrontServiceException e) { stopProgressDialog(); if ("OptInRequired".equals(e.getErrorCode())) { log.debug("Your AWS account is not subscribed to the Amazon CloudFront service, " + "you will not be able to manage distributions"); } cloudFrontService = null; } finally { stopProgressDialog(); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { cloudFrontMembershipChecked = true; // Update the bucket table to show, or not show, distributions bucketTableModel = new BucketTableModel(cloudFrontService != null); bucketTableModelSorter = new TableSorter(bucketTableModel); bucketsTable.setModel(bucketTableModelSorter); bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader()); if (cloudFrontService != null) { // Set column width for Cloud Front distributions indicator. TableColumn distributionFlagColumn = bucketsTable.getColumnModel() .getColumn(1); int distributionFlagColumnWidth = 18; distributionFlagColumn.setPreferredWidth(distributionFlagColumnWidth); distributionFlagColumn.setMaxWidth(distributionFlagColumnWidth); distributionFlagColumn.setMinWidth(0); } manageDistributionsMenuItem.setEnabled(cloudFrontService != null); } }); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } startProgressDialog("Listing buckets for " + s3ServiceMulti.getAWSCredentials().getAccessKey()); try { final S3Bucket[] buckets = s3ServiceMulti.getS3Service().listAllBuckets(); // Lookup user's CloudFront distributions. Distribution[] distributions = new Distribution[] {}; if (cloudFrontService != null) { updateProgressDialog( "Listing distributions for " + cloudFrontService.getAWSCredentials().getAccessKey(), "", 0); distributions = cloudFrontService.listDistributions(); } final Distribution[] finalDistributions = distributions; runInDispatcherThreadImmediately(new Runnable() { public void run() { for (int i = 0; i < buckets.length; i++) { // Determine whether each bucket has one or more CloudFront distributions. boolean bucketHasDistribution = false; for (int j = 0; j < finalDistributions.length; j++) { if (finalDistributions[j].getOrigin() .equals(buckets[i].getName() + ".s3.amazonaws.com")) { bucketHasDistribution = true; } } bucketTableModel.addBucket(buckets[i], bucketHasDistribution); if (i == 0) { ownerFrame.setTitle( APPLICATION_TITLE + " : " + buckets[i].getOwner().getDisplayName()); } } } }); } catch (final Exception e) { stopProgressDialog(); SwingUtilities.invokeLater(new Runnable() { public void run() { logoutEvent(); String message = "Unable to list your buckets in S3, please log in again"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, null, message, e); loginEvent(null); } }); } finally { stopProgressDialog(); } }; }); }
From source file:org.executequery.gui.browser.ConnectionPanel.java
private void init() { // --------------------------------- // create the basic props panel // initialise the fields nameField = createTextField();/*from w ww . ja va 2 s .co m*/ passwordField = createPasswordField(); hostField = createTextField(); portField = createNumberTextField(); sourceField = createMatchedWidthTextField(); userField = createTextField(); urlField = createMatchedWidthTextField(); nameField.addFocusListener(new ConnectionNameFieldListener(this)); savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword"); encryptPwdCheck = ActionUtilities.createCheckBox("Encrypt Password", "setEncryptPassword"); savePwdCheck.addActionListener(this); encryptPwdCheck.addActionListener(this); // retrieve the drivers buildDriversList(); // --------------------------------- // add the basic connection fields TextFieldPanel mainPanel = new TextFieldPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(10, 10, 10, 10); gbc.gridy = 0; gbc.gridx = 0; statusLabel = new DefaultFieldLabel(); addLabelFieldPair(mainPanel, "Status:", statusLabel, "Current connection status", gbc); gbc.insets.bottom = 5; addLabelFieldPair(mainPanel, "Connection Name:", nameField, "A friendly name for this connection", gbc); addLabelFieldPair(mainPanel, "User Name:", userField, "Login user name", gbc); addLabelFieldPair(mainPanel, "Password:", passwordField, "Login password", gbc); JButton showPassword = new LinkButton("Show Password"); showPassword.setActionCommand("showPassword"); showPassword.addActionListener(this); JPanel passwordOptionsPanel = new JPanel(new GridBagLayout()); addComponents(passwordOptionsPanel, new ComponentToolTipPair[] { new ComponentToolTipPair(savePwdCheck, "Store the password with the connection information"), new ComponentToolTipPair(encryptPwdCheck, "Encrypt the password when saving"), new ComponentToolTipPair(showPassword, "Show the password in plain text") }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(passwordOptionsPanel, gbc); addLabelFieldPair(mainPanel, "Host Name:", hostField, "Server host name or IP address", gbc); addLabelFieldPair(mainPanel, "Port:", portField, "Database port number", gbc); addLabelFieldPair(mainPanel, "Data Source:", sourceField, "Data source name", gbc); addLabelFieldPair(mainPanel, "JDBC URL:", urlField, "The full JDBC URL for this connection (optional)", gbc); addDriverFields(mainPanel, gbc); connectButton = createButton("Connect", CONNECT_ACTION_COMMAND, 'T'); disconnectButton = createButton("Disconnect", "disconnect", 'D'); JPanel buttons = new JPanel(new GridBagLayout()); gbc.gridy++; gbc.gridx = 0; gbc.insets.top = 5; gbc.insets.left = 0; gbc.insets.right = 10; gbc.gridwidth = 1; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.anchor = GridBagConstraints.NORTHEAST; gbc.fill = GridBagConstraints.NONE; buttons.add(connectButton, gbc); gbc.gridx++; gbc.weightx = 0; buttons.add(disconnectButton, gbc); gbc.insets.right = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(buttons, gbc); // --------------------------------- // create the advanced panel model = new JdbcPropertiesTableModel(); JTable table = new DefaultTable(model); table.getTableHeader().setReorderingAllowed(false); TableColumnModel tcm = table.getColumnModel(); TableColumn column = tcm.getColumn(2); column.setCellRenderer(new DeleteButtonRenderer()); column.setCellEditor(new DeleteButtonEditor(table, new JCheckBox())); column.setMaxWidth(24); column.setMinWidth(24); JScrollPane scroller = new JScrollPane(table); // advanced jdbc properties JPanel advPropsPanel = new JPanel(new GridBagLayout()); advPropsPanel.setBorder(BorderFactory.createTitledBorder("JDBC Properties")); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.insets.top = 0; gbc.insets.left = 10; gbc.insets.right = 10; gbc.weighty = 0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; advPropsPanel.add(new DefaultFieldLabel("Enter any key/value pair properties for this connection"), gbc); gbc.gridy++; advPropsPanel.add( new DefaultFieldLabel("Refer to the relevant JDBC driver documentation for possible entries"), gbc); gbc.gridy++; gbc.insets.bottom = 10; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; advPropsPanel.add(scroller, gbc); // transaction isolation txApplyButton = WidgetFactory.createInlineFieldButton("Apply", "transactionLevelChanged"); txApplyButton.setToolTipText("Apply this level to all open connections of this type"); txApplyButton.setEnabled(false); txApplyButton.addActionListener(this); // add a dummy select value to the tx levels String[] txLevels = new String[Constants.TRANSACTION_LEVELS.length + 1]; txLevels[0] = "Database Default"; for (int i = 1; i < txLevels.length; i++) { txLevels[i] = Constants.TRANSACTION_LEVELS[i - 1]; } txCombo = WidgetFactory.createComboBox(txLevels); JPanel advTxPanel = new JPanel(new GridBagLayout()); advTxPanel.setBorder(BorderFactory.createTitledBorder("Transaction Isolation")); gbc.gridx = 0; gbc.gridy = 0; gbc.insets.top = 0; gbc.insets.left = 10; gbc.insets.right = 10; gbc.insets.bottom = 5; gbc.weighty = 0; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; advTxPanel.add(new DefaultFieldLabel("Default transaction isolation level for this connection"), gbc); gbc.gridy++; gbc.insets.bottom = 10; advTxPanel.add( new DefaultFieldLabel( "Note: the selected isolation level " + "will apply to ALL open connections of this type."), gbc); gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.insets.top = 0; gbc.insets.left = 10; gbc.weightx = 0; advTxPanel.add(new DefaultFieldLabel("Isolation Level:"), gbc); gbc.gridx = 1; gbc.insets.left = 5; gbc.weightx = 1.0; gbc.insets.right = 5; gbc.fill = GridBagConstraints.HORIZONTAL; advTxPanel.add(txCombo, gbc); gbc.gridx = 2; gbc.weightx = 0; gbc.insets.left = 0; gbc.insets.right = 10; advTxPanel.add(txApplyButton, gbc); JPanel advancedPanel = new JPanel(new BorderLayout()); advancedPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); advancedPanel.add(advPropsPanel, BorderLayout.CENTER); advancedPanel.add(advTxPanel, BorderLayout.SOUTH); JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setBorder(null); sshTunnelConnectionPanel = new SSHTunnelConnectionPanel(); tabPane = new JTabbedPane(JTabbedPane.BOTTOM); tabPane.addTab("Basic", scrollPane); tabPane.addTab("Advanced", advancedPanel); tabPane.addTab("SSH Tunnel", sshTunnelConnectionPanel); tabPane.addChangeListener(this); add(tabPane, BorderLayout.CENTER); EventMediator.registerListener(this); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java
/** * Set up the GUI//from ww w. j a v a 2 s .c o m * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel(manager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel.HyperLink.class, new HyperLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int selectedRow = table.getSelectedRow(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow), CCMTableModel.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent event) { launchBrowser(); } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel.TUTORIAL_URL_INDEX); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel.TOOL_URL_INDEX); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,200dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(6, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(8, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(10, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
/** * Set up the GUI/* ww w . j a v a 2s. c o m*/ * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); componentUpdateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { componentRemoteUpdate_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel2(manager.componentConfigurationManager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel2>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel2.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.HyperLink.class, new HyperLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.DownloadLink.class, new DownloadLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int[] selectedRow = table.getSelectedRows(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow[0]), CCMTableModel2.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } if (table.getSelectedRow() >= 0) { int modelColumn = table.convertColumnIndexToModel(table.getSelectedColumn()); if (modelColumn == CCMTableModel2.AVAILABLE_UPDATE_INDEX) installRemoteComponent(); else launchBrowser(); } } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel2.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel2.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.AVAILABLE_UPDATE_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.TUTORIAL_URL_INDEX_2); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel2.TOOL_URL_INDEX_2); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,100dlu, " + // Component Update "default, 4dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- componentUpdateButton ---- bottompanel.add(componentUpdateButton, cc.xy(6, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(8, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(10, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(12, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }
From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java
/** * Initialize the source list table.//from w w w . j a va 2s . c om */ private void initSourceList() { try { ComponentSourceTableModel cstm = new ComponentSourceTableModel(); _sourceList = new JTable(cstm); _sourceList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); _sourceList.setShowGrid(true); _sourceList.setShowHorizontalLines(true); _sourceList.setShowVerticalLines(true); _sourceList.setGridColor(Color.lightGray); _sourceList.setIntercellSpacing(new Dimension(5, 5)); _sourceList.setRowHeight(_sourceList.getRowHeight() + 10); _sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (isDebugging) { log.debug("intercellspacing: " + _sourceList.getIntercellSpacing().toString()); log.debug("getRowHeight(): " + _sourceList.getRowHeight()); } // Search column TableColumn c0 = _sourceList.getColumnModel().getColumn(0); c0.setMinWidth(50); c0.setPreferredWidth(60); c0.setMaxWidth(100); c0.setResizable(true); // Save column TableColumn c1 = _sourceList.getColumnModel().getColumn(1); c1.setMinWidth(50); c1.setPreferredWidth(60); c1.setMaxWidth(100); c1.setResizable(true); // Type column TableColumn c2 = _sourceList.getColumnModel().getColumn(2); c2.setMinWidth(50); c2.setPreferredWidth(60); c2.setMaxWidth(100); c2.setResizable(true); // Name column TableColumn c3 = _sourceList.getColumnModel().getColumn(3); c3.setMinWidth(50); c3.setPreferredWidth(100); c3.setMaxWidth(200); c3.setResizable(true); // Source column TableColumn c4 = _sourceList.getColumnModel().getColumn(4); c4.setMinWidth(200); c4.setPreferredWidth(600); c4.setMaxWidth(2000); c4.setResizable(true); JScrollPane sourceListSP = new JScrollPane(_sourceList); sourceListSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sourceListSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sourceListSP.setBackground(TabManager.BGCOLOR); add(sourceListSP); } catch (Exception e) { System.out.println(e.toString()); } }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
private void setColumnWidth(TableColumn column, int initial, int max, int min) { if (initial != 0) { column.setPreferredWidth(initial); }// w w w .j a v a 2 s. c om if (max != 0) { column.setMaxWidth(max); } if (min != 0) { column.setMinWidth(min); } }
From source file:org.omegat.gui.align.AlignPanelController.java
/** * Reloads the beads with the current settings. The loading itself takes place on a background thread. * Calls {@link #updatePanel(AlignPanel, AlignMenuFrame)} afterwards. * // w w w.ja v a2 s. com * @param panel * @param frame */ private void reloadBeads() { if (loader != null) { loader.cancel(true); } phase = Phase.ALIGN; panel.progressBar.setVisible(true); panel.continueButton.setEnabled(false); panel.controlsPanel.setVisible(false); loader = new SwingWorker<List<MutableBead>, Object>() { @Override protected List<MutableBead> doInBackground() throws Exception { return aligner.alignImpl().filter(o -> !isCancelled()).map(MutableBead::new) .collect(Collectors.toList()); } @Override protected void done() { List<MutableBead> beads = null; try { beads = get(); } catch (CancellationException ex) { // Ignore } catch (Exception e) { Log.log(e); JOptionPane.showMessageDialog(panel, OStrings.getString("ALIGNER_ERROR_LOADING"), OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); } panel.continueButton.setEnabled(true); panel.progressBar.setVisible(false); panel.comparisonComboBox .setModel(new DefaultComboBoxModel<>(aligner.allowedModes.toArray(new ComparisonMode[0]))); String distanceValue = null; if (beads != null) { double avgDist = MutableBead.calculateAvgDist(beads); distanceValue = StringUtil.format(OStrings.getString("ALIGNER_PANEL_LABEL_AVGSCORE"), avgDist == Long.MAX_VALUE ? "-" : String.format("%.3f", avgDist)); panel.table.setModel(new BeadTableModel(beads)); for (int i = 0; i < BeadTableModel.COL_SRC; i++) { TableColumn col = panel.table.getColumnModel().getColumn(i); col.setMaxWidth(col.getWidth()); } modified = false; } panel.averageDistanceLabel.setText(distanceValue); updatePanel(); } }; loader.execute(); }
From source file:org.openconcerto.task.TodoListPanel.java
private void initTable(int mode) { this.t.setBlockRepaint(true); this.t.setBlockEventOnColumn(true); this.model.setMode(mode); this.t.getColumnModel().getColumn(0).setCellRenderer(this.a); this.t.getColumnModel().getColumn(0).setCellEditor(this.a); this.t.setBlockEventOnColumn(true); setIconForColumn(0, this.iconTache); setIconForColumn(1, this.iconPriorite); this.t.setBlockEventOnColumn(true); this.t.getColumnModel().getColumn(1).setCellEditor(this.iconEditor); final JTextField textField = new JTextField() { @Override//from ww w. j ava2 s . co m public void paint(Graphics g) { super.paint(g); g.setColor(TodoListPanel.this.t.getGridColor()); g.fillRect(getWidth() - 19, 0, 1, getHeight()); g.setColor(new Color(250, 250, 250)); g.fillRect(getWidth() - 18, 0, 18, getHeight()); g.setColor(Color.BLACK); for (int i = 0; i < 3; i++) { int x = getWidth() - 14 + i * 4; int y = getHeight() - 5; g.fillRect(x, y, 1, 2); } } }; textField.setBorder(BorderFactory.createEmptyBorder()); final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(textField); textField.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (e.getX() > textField.getWidth() - 19) { TodoListElement l = getTaskAt( SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TodoListPanel.this.t)); TodoListPanel.this.t.editingCanceled(new ChangeEvent(this)); JFrame f = new JFrame(TM.tr("details")); f.setContentPane(new TodoListElementEditorPanel(l)); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setSize(500, 200); f.setLocation(50, e.getYOnScreen() + TodoListPanel.this.t.getRowHeight()); f.setVisible(true); } } }); this.t.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor); this.t.getColumnModel().getColumn(3).setMaxWidth(300); this.t.getColumnModel().getColumn(3).setMinWidth(100); this.timestampTableCellEditorCreated.stopCellEditing(); this.timestampTableCellEditorDone.stopCellEditing(); this.timestampTableCellEditorDeadLine.stopCellEditing(); if (this.model.getMode() == TodoListModel.EXTENDED_MODE) { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererCreated); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorCreated); this.t.getColumnModel().getColumn(4).setCellRenderer(this.timestampTableCellRendererDone); this.t.getColumnModel().getColumn(4).setCellEditor(this.timestampTableCellEditorDone); this.t.getColumnModel().getColumn(5).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(5).setCellEditor(this.timestampTableCellEditorDeadLine); } else { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorDeadLine); } final TableColumn userColumn = this.t.getColumnModel() .getColumn(this.t.getColumnModel().getColumnCount() - 1); userColumn.setCellRenderer(this.userTableCellRenderer); userColumn.setMaxWidth(150); userColumn.setMinWidth(100); t.setEnabled(false); initUserCellEditor(userColumn); this.t.setBlockEventOnColumn(false); this.t.setBlockRepaint(false); this.t.getColumnModel().getColumn(1).setCellRenderer(this.iconRenderer); // Better look this.t.setShowHorizontalLines(false); this.t.setGridColor(new Color(230, 230, 230)); this.t.setRowHeight(new JTextField(" ").getPreferredSize().height + 4); AlternateTableCellRenderer.UTILS.setAllColumns(this.t); this.t.repaint(); }
From source file:org.openconcerto.task.TodoListPanel.java
private void setIconForColumn(int i, ImageIcon icon) { TableCellRenderer renderer = new JComponentTableCellRenderer(icon); TableColumnModel columnModel = this.t.getColumnModel(); TableColumn column = columnModel.getColumn(i); column.setHeaderRenderer(renderer);//from w w w . j a v a 2 s. c o m column.setMaxWidth(icon.getIconWidth() + 16); column.setMinWidth(icon.getIconWidth() + 8); }