List of usage examples for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER
int HORIZONTAL_SCROLLBAR_NEVER
To view the source code for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER.
Click Source Link
From source file:com.mirth.connect.client.ui.NotificationDialog.java
private void initComponents() { setLayout(new MigLayout("insets 12", "[]", "[fill][]")); notificationPanel = new JPanel(); notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]")); notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR); archiveAll = new JLabel("Archive All"); archiveAll.setForeground(java.awt.Color.blue); archiveAll.setText("<html><u>Archive All</u></html>"); archiveAll.setToolTipText("Archive all notifications below."); archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); newNotificationsLabel = new JLabel(); newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD)); headerListPanel = new JPanel(); headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR); headerListPanel.setLayout(new MigLayout("insets 2, fill")); headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor)); list = new JList(); list.setCellRenderer(new NotificationListCellRenderer()); list.addListSelectionListener(new ListSelectionListener() { @Override/*from w w w.j a va 2 s. c om*/ public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { currentNotification = (Notification) list.getSelectedValue(); if (currentNotification != null) { notificationNameTextField.setText(currentNotification.getName()); contentTextPane.setText(currentNotification.getContent()); archiveSelected(); } } } }); listScrollPane = new JScrollPane(); listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor)); listScrollPane.setViewportView(list); listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); archiveLabel = new JLabel(); archiveLabel.setForeground(java.awt.Color.blue); archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); notificationNameTextField = new JTextField(); notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD)); notificationNameTextField.setEditable(false); notificationNameTextField.setFocusable(false); notificationNameTextField.setBorder(BorderFactory.createEmptyBorder()); notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR); DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret(); nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); headerContentPanel = new JPanel(); headerContentPanel.setLayout(new MigLayout("insets 2, fill")); headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor)); headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR); contentTextPane = new JTextPane(); contentTextPane.setContentType("text/html"); contentTextPane.setEditable(false); contentTextPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(evt.getURL().toURI()); } else { BareBonesBrowserLaunch.openURL(evt.getURL().toString()); } } catch (Exception e) { e.printStackTrace(); } } } }); DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret(); contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); contentScrollPane = new JScrollPane(); contentScrollPane.setViewportView(contentTextPane); contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor)); archiveLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int index = list.getSelectedIndex(); if (currentNotification.isArchived()) { notificationModel.setArchived(false, index); unarchivedCount++; } else { notificationModel.setArchived(true, index); unarchivedCount--; } archiveSelected(); updateUnarchivedCountLabel(); } }); archiveAll.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { for (int i = 0; i < notificationModel.getSize(); i++) { notificationModel.setArchived(true, i); } unarchivedCount = 0; archiveSelected(); updateUnarchivedCountLabel(); } }); notificationCheckBox = new JCheckBox("Show new notifications on login"); notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR); if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) { checkForNotificationsSetting = true; if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) { notificationCheckBox.setSelected(true); } else { notificationCheckBox.setSelected(false); } } else { notificationCheckBox.setSelected(false); } notificationCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) { alertSettingsChange(); } } }); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { doSave(); } }); }
From source file:forge.gui.ImportDialog.java
@SuppressWarnings("serial") public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) { this.forcedSrcDir = forcedSrcDir; _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill")); _topPanel.setOpaque(false);/* www. j av a 2 s . c om*/ _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE)); isMigration = !StringUtils.isEmpty(forcedSrcDir); // header _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15) .build(), "center"); // add some help text if this is for the initial data migration if (isMigration) { final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill")); blurbPanel.setOpaque(false); final JPanel blurbPanelInterior = new JPanel( new MigLayout("insets dialog, gap 10, center, wrap, fill")); blurbPanelInterior.setOpaque(false); blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder() .text("<html>Over the last several years, people have had to jump through a lot of hoops to" + " update to the most recent version. We hope to reduce this workload to a point where a new" + " user will find that it is fairly painless to update. In order to make this happen, Forge" + " has changed where it stores your data so that it is outside of the program installation directory." + " This way, when you upgrade, you will no longer need to import your data every time to get things" + " working. There are other benefits to having user data separate from program data, too, and it" + " lays the groundwork for some cool new features.</html>") .build(), "growx, w 50:50:"); blurbPanelInterior.add( new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder().text( "<html>Forge will now store your data in the same place as other applications on your system." + " Specifically, your personal data, like decks, quest progress, and program preferences will be" + " stored in <b>" + ForgeConstants.USER_DIR + "</b> and all downloaded content, such as card pictures," + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR + "</b>. If, for whatever" + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>" + ForgeConstants.PROFILE_TEMPLATE_FILE + "</b> file in the program installation directory. Copy or rename" + " it to <b>" + ForgeConstants.PROFILE_FILE + "</b> and edit the paths inside it. Then restart Forge and use" + " this dialog to move your data to the paths that you set. Keep in mind that if you install a future" + " version of Forge into a different directory, you'll need to copy this file over so Forge will know" + " where to find your data.</html>") .build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder().text( "<html><b>Remember, your data won't be available until you complete this step!</b></html>") .build(), "growx, w 50:50:"); final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5"); _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:"); } // import source widgets final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10")); importSourcePanel.setOpaque(false); importSourcePanel.add(new FLabel.Builder().text("Import from:").build()); _txfSrc = new FTextField.Builder().readonly().build(); importSourcePanel.add(_txfSrc, "pushx, growx"); _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build(); final JFileChooser _fileChooser = new JFileChooser(); _fileChooser.setMultiSelectionEnabled(false); _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); _btnChooseDir.setCommand(new UiCommand() { @Override public void run() { // bring up a file open dialog and, if the OK button is selected, apply the filename // to the import source text field if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) { final File f = _fileChooser.getSelectedFile(); if (!f.canRead()) { FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied)."); } else { _txfSrc.setText(f.getAbsolutePath()); } } } }); importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!"); // add change handler to the import source text field that starts up a // new analyzer. it also interacts with the current active analyzer, // if any, to make sure it cancels out before the new one is initiated _txfSrc.getDocument().addDocumentListener(new DocumentListener() { boolean _analyzerActive; // access synchronized on _onAnalyzerDone String prevText; private final Runnable _onAnalyzerDone = new Runnable() { @Override public synchronized void run() { _analyzerActive = false; notify(); } }; @Override public void removeUpdate(final DocumentEvent e) { } @Override public void changedUpdate(final DocumentEvent e) { } @Override public void insertUpdate(final DocumentEvent e) { // text field is read-only, so the only time this will get updated // is when _btnChooseDir does it final String text = _txfSrc.getText(); if (text.equals(prevText)) { // only restart the analyzer if the directory has changed return; } prevText = text; // cancel any active analyzer _cancel = true; if (!text.isEmpty()) { // ensure we don't get two instances of this function running at the same time _btnChooseDir.setEnabled(false); // re-disable the start button. it will be enabled if the previous analyzer has // already successfully finished _btnStart.setEnabled(false); // we have to wait in a background thread since we can't block in the GUI thread final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { // wait for active analyzer (if any) to quit synchronized (_onAnalyzerDone) { while (_analyzerActive) { _onAnalyzerDone.wait(); } } return null; } // executes in gui event loop thread @Override protected void done() { _cancel = false; synchronized (_onAnalyzerDone) { // this will populate the panel with data selection widgets final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone, isMigration); analyzer.run(); _analyzerActive = true; } if (!isMigration) { // only enable the directory choosing button if this is not a migration dialog // since in that case we're permanently locked to the starting directory _btnChooseDir.setEnabled(true); } } }; analyzerStarter.execute(); } } }); _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx"); // prepare import selection panel (will be cleared and filled in later by an analyzer) _selectionPanel = new JPanel(); _selectionPanel.setOpaque(false); _topPanel.add(_selectionPanel, "growx, growy, gaptop 10"); // action button widgets final Runnable cleanup = new Runnable() { @Override public void run() { SOverlayUtils.hideOverlay(); } }; _btnStart = new FButton("Start import"); _btnStart.setEnabled(false); _btnCancel = new FButton("Cancel"); _btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { _cancel = true; cleanup.run(); if (null != onDialogClose) { onDialogClose.run(); } } }); final JPanel southPanel = new JPanel(new MigLayout("ax center")); southPanel.setOpaque(false); southPanel.add(_btnStart, "center, w pref+144!, h pref+12!"); southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72"); _topPanel.add(southPanel, "growx"); }
From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java
protected void createUI(final ChartPanel chartPanel, final JPanel optionsPanel, BindingContext bindingContext) { roiMaskSelector = new RoiMaskSelector(bindingContext); final JPanel extendedOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints( "insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1"); GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0"); GridBagUtils.addToPanel(extendedOptionsPanel, roiMaskSelector.createPanel(), extendedOptionsPanelConstraints, "gridy=1,insets.left=-4"); GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints, "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1"); GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST"); final JScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); optionsScrollPane.setBorder(null);//w ww. jav a 2s . c om final JPanel rightPanel = new JPanel(new BorderLayout()); rightPanel.add(createTopPanel(), BorderLayout.NORTH); rightPanel.add(optionsScrollPane, BorderLayout.CENTER); rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH); final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png"); final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon); final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png"); final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon); hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false); hideAndShowButton.setToolTipText("Collapse Options Panel"); hideAndShowButton.setName("switchToChartButton"); hideAndShowButton.addActionListener(new ActionListener() { public boolean rightPanelShown; @Override public void actionPerformed(ActionEvent e) { rightPanel.setVisible(rightPanelShown); if (rightPanelShown) { hideAndShowButton.setIcon(collapseIcon); hideAndShowButton.setRolloverIcon(collapseRolloverIcon); hideAndShowButton.setToolTipText("Collapse Options Panel"); } else { hideAndShowButton.setIcon(expandIcon); hideAndShowButton.setRolloverIcon(expandRolloverIcon); hideAndShowButton.setToolTipText("Expand Options Panel"); } rightPanelShown = !rightPanelShown; } }); backgroundPanel = new JPanel(new BorderLayout()); backgroundPanel.add(chartPanel, BorderLayout.CENTER); backgroundPanel.add(rightPanel, BorderLayout.EAST); JLayeredPane layeredPane = new JLayeredPane(); layeredPane.add(backgroundPanel, new Integer(0)); layeredPane.add(hideAndShowButton, new Integer(1)); add(layeredPane); }
From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java
/** * Customization of external program paths. * * @param prefs a <code>JabRefPreferences</code> value *//*from w ww. ja v a 2s .c o m*/ public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) { this.prefs = prefs; this.frame = frame; setLayout(new BorderLayout()); TableModel tm = new AbstractTableModel() { @Override public int getRowCount() { return rowCount; } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { int internalRow = row; if (internalRow == 0) { return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth); } internalRow--; if (internalRow >= tableRows.size()) { return ""; } Object rowContent = tableRows.get(internalRow); if (rowContent == null) { return ""; } TableRow tr = (TableRow) rowContent; // Only two columns if (column == 0) { return tr.getName(); } else { return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : ""; } } @Override public String getColumnName(int col) { return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width"); } @Override public Class<?> getColumnClass(int column) { if (column == 0) { return String.class; } return Integer.class; } @Override public boolean isCellEditable(int row, int col) { return !((row == 0) && (col == 0)); } @Override public void setValueAt(Object value, int row, int col) { tableChanged = true; // Make sure the vector is long enough. while (row >= tableRows.size()) { tableRows.add(new TableRow("", -1)); } if ((row == 0) && (col == 1)) { ncWidth = Integer.parseInt(value.toString()); return; } TableRow rowContent = tableRows.get(row - 1); if (col == 0) { rowContent.setName(value.toString()); if ("".equals(getValueAt(row, 1))) { setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1); } } else { if (value == null) { rowContent.setLength(-1); } else { rowContent.setLength(Integer.parseInt(value.toString())); } } } }; colSetup = new JTable(tm); TableColumnModel cm = colSetup.getColumnModel(); cm.getColumn(0).setPreferredWidth(140); cm.getColumn(1).setPreferredWidth(80); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); JPanel pan = new JPanel(); JPanel tabPanel = new JPanel(); tabPanel.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200)); sp.setMinimumSize(new Dimension(250, 300)); tabPanel.add(sp, BorderLayout.CENTER); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setFloatable(false); AddRowAction addRow = new AddRowAction(); DeleteRowAction deleteRow = new DeleteRowAction(); MoveRowUpAction moveUp = new MoveRowUpAction(); MoveRowDownAction moveDown = new MoveRowDownAction(); toolBar.setBorder(null); toolBar.add(addRow); toolBar.add(deleteRow); toolBar.addSeparator(); toolBar.add(moveUp); toolBar.add(moveDown); tabPanel.add(toolBar, BorderLayout.EAST); fileColumn = new JCheckBox(Localization.lang("Show file column")); urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column")); preferUrl = new JRadioButton(Localization.lang("Show URL first")); preferDoi = new JRadioButton(Localization.lang("Show DOI first")); ButtonGroup preferUrlDoiGroup = new ButtonGroup(); preferUrlDoiGroup.add(preferUrl); preferUrlDoiGroup.add(preferDoi); urlColumn.addChangeListener(arg0 -> { preferUrl.setEnabled(urlColumn.isSelected()); preferDoi.setEnabled(urlColumn.isSelected()); }); arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column")); Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); String[] fileTypeNames = new String[fileTypes.size()]; int i = 0; for (ExternalFileType fileType : fileTypes) { fileTypeNames[i++] = fileType.getName(); } listOfFileColumns = new JList<>(fileTypeNames); JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns); listOfFileColumns.setVisibleRowCount(3); extraFileColumns = new JCheckBox(Localization.lang("Show extra columns")); extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected())); /*** begin: special table columns and special fields ***/ JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS) .getHelpButton(); rankingColumn = new JCheckBox(Localization.lang("Show rank")); qualityColumn = new JCheckBox(Localization.lang("Show quality")); priorityColumn = new JCheckBox(Localization.lang("Show priority")); relevanceColumn = new JCheckBox(Localization.lang("Show relevance")); printedColumn = new JCheckBox(Localization.lang("Show printed status")); readStatusColumn = new JCheckBox(Localization.lang("Show read status")); // "sync keywords" and "write special" fields may be configured mutually exclusive only // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense) // To avoid confusion, we opted to make the setting mutually exclusive syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords")); writeSpecialFields = new JRadioButton( Localization.lang("Write values of special fields as separate fields to BibTeX")); ButtonGroup group = new ButtonGroup(); group.add(syncKeywords); group.add(writeSpecialFields); specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields")); specialFieldsEnabled.addChangeListener(event -> { boolean isEnabled = specialFieldsEnabled.isSelected(); rankingColumn.setEnabled(isEnabled); qualityColumn.setEnabled(isEnabled); priorityColumn.setEnabled(isEnabled); relevanceColumn.setEnabled(isEnabled); printedColumn.setEnabled(isEnabled); readStatusColumn.setEnabled(isEnabled); syncKeywords.setEnabled(isEnabled); writeSpecialFields.setEnabled(isEnabled); }); builder.appendSeparator(Localization.lang("Special table columns")); builder.nextLine(); builder.append(pan); DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder( new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref")); CellConstraints cc = new CellConstraints(); specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3)); specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2)); specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2)); specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2)); specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2)); specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2)); specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2)); specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2)); specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2)); specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2)); specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2)); specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2)); specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3)); specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4)); specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2)); specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2)); specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6)); builder.append(specialTableColumnsBuilder.getPanel()); builder.nextLine(); /*** end: special table columns and special fields ***/ builder.appendSeparator(Localization.lang("Entry table columns")); builder.nextLine(); builder.append(pan); builder.append(tabPanel); builder.nextLine(); builder.append(pan); JButton buttonWidth = new JButton(new UpdateWidthsAction()); JButton buttonOrder = new JButton(new UpdateOrderAction()); builder.append(buttonWidth); builder.nextLine(); builder.append(pan); builder.append(buttonOrder); builder.nextLine(); builder.append(pan); builder.nextLine(); pan = builder.getPanel(); pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(pan, BorderLayout.CENTER); }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) * @param useSeparator use non-border separator titles */// w ww.jav a 2 s .c o m public StatGroupTable(final String name, final String[] columnNames, final boolean useSeparator, final int numRows) { this.name = name; this.useSeparator = useSeparator; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } setLayout(new BorderLayout()); setBackground(Color.WHITE); model = new StatGroupTableModel(this, columnNames); //table = numRows > SCROLLPANE_THRESOLD ? (new SortableJTable(new SortableTableModel(model))) : (new JTable(model)); if (numRows > SCROLLPANE_THRESOLD) { table = new SortableJTable(new SortableTableModel(model)) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } else { table = new JTable(model) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } table.setShowVerticalLines(false); table.setShowHorizontalLines(false); if (SkinsMgr.shouldBeOpaque(skinItem)) { table.setOpaque(false); setOpaque(false); } else { table.setOpaque(true); setOpaque(true); } table.addMouseMotionListener(new TableMouseMotion()); table.addMouseListener(new LinkListener()); if (table.getColumnModel().getColumnCount() == 1) { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.CENTER, 1)); } else { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.LEFT, 2)); table.getColumnModel().getColumn(1) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.RIGHT, 2)); } //table.setRowSelectionAllowed(true); if (numRows > SCROLLPANE_THRESOLD) { scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); if (table instanceof SortableJTable) { ((SortableJTable) table).installColumnHeaderListeners(); } scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(BorderFactory.createEmptyBorder()); //scrollPane.getViewport().setBorder(BorderFactory.createEmptyBorder()); } if (useSeparator) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); CellConstraints cc = new CellConstraints(); if (StringUtils.isNotEmpty(name)) { builder.addSeparator(name, cc.xy(1, 1)); } builder.add(scrollPane != null ? scrollPane : table, cc.xy(1, 2)); builder.getPanel().setOpaque(false); add(builder.getPanel()); } else { setBorder(BorderFactory.createEmptyBorder(15, 2, 2, 2)); setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160, 160, 160)), getBorder())); add(scrollPane != null ? scrollPane : table, BorderLayout.CENTER); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java
private void applyScrollBarPolicy(ScrollBarPolicy scrollBarPolicy) { switch (scrollBarPolicy) { case BOTH:/*from w w w.j ava 2s. c om*/ impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); content.setWidth("-1px"); content.setHeight("-1px"); break; case HORIZONTAL: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); content.setWidth("-1px"); content.setHeight("100%"); break; case VERTICAL: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); content.setWidth("100%"); content.setHeight("-1px"); break; case NONE: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); content.setWidth("100%"); content.setHeight("100%"); break; } }
From source file:edu.ku.brc.specify.ui.LoanReturnDlg.java
/** * @return//from ww w . j ava 2 s.co m */ public boolean createUI() { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); loan = session.merge(loan); setTitle(getResourceString("LOANRET_TITLE")); validator.addValidationListener(new ValidationListener() { public void wasValidated(UIValidator val) { doEnableOKBtn(); } }); JPanel contentPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(); System.out.println("Num Loan Preps for Loan: " + loan.getLoanPreparations()); HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>> colObjHash = new HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>>(); for (LoanPreparation loanPrep : loan.getLoanPreparations()) { CollectionObject colObj = loanPrep.getPreparation().getCollectionObject(); System.out.println("For LoanPrep ColObj Is: " + colObj.getIdentityTitle()); Vector<LoanPreparation> list = null; Pair<CollectionObject, Vector<LoanPreparation>> pair = colObjHash.get(colObj.getId()); if (pair == null) { list = new Vector<LoanPreparation>(); colObjHash.put(colObj.getId(), new Pair<CollectionObject, Vector<LoanPreparation>>(colObj, list)); } else { list = pair.second; } list.add(loanPrep); } int colObjCnt = colObjHash.size(); String rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px,p,4px", (colObjCnt * 2) - 1); PanelBuilder pbuilder = new PanelBuilder(new FormLayout("f:p:g", rowDef), mainPanel); CellConstraints cc = new CellConstraints(); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { doEnableOKBtn(); } }; ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent ae) { doEnableOKBtn(); } }; int i = 0; int y = 1; Vector<Pair<CollectionObject, Vector<LoanPreparation>>> pairList = new Vector<Pair<CollectionObject, Vector<LoanPreparation>>>( colObjHash.values()); Collections.sort(pairList, new Comparator<Pair<CollectionObject, Vector<LoanPreparation>>>() { @Override public int compare(Pair<CollectionObject, Vector<LoanPreparation>> o1, Pair<CollectionObject, Vector<LoanPreparation>> o2) { return o1.first.getIdentityTitle().compareTo(o2.first.getIdentityTitle()); } }); for (Pair<CollectionObject, Vector<LoanPreparation>> pair : pairList) { CollectionObject co = pair.first; if (i > 0) { pbuilder.addSeparator("", cc.xy(1, y)); y += 2; } ColObjPanel panel = new ColObjPanel(session, this, co, colObjHash.get(co.getId()).second); colObjPanels.add(panel); panel.addActionListener(al, cl); pbuilder.add(panel, cc.xy(1, y)); y += 2; i++; } JButton selectAllBtn = createButton(getResourceString("SELECTALL")); okBtn = createButton(getResourceString("SAVE")); JButton cancel = createButton(getResourceString("CANCEL")); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,p,2px,p,2px,p,2px,p", "p")); dateClosed = new ValFormattedTextFieldSingle("Date", false, false, 10); dateClosed.setNew(true); dateClosed.setValue(null, ""); dateClosed.setRequired(true); validator.hookupTextField(dateClosed, "2", true, UIValidator.Type.Changed, "", false); summaryLabel = createLabel(""); pb.add(summaryLabel, cc.xy(1, 1)); pb.add(createI18NLabel("LOANRET_AGENT"), cc.xy(3, 1)); pb.add(agentCBX = createAgentCombobox(), cc.xy(5, 1)); pb.add(createI18NLabel("ON"), cc.xy(7, 1)); pb.add(dateClosed, cc.xy(9, 1)); contentPanel.add(pb.getPanel(), BorderLayout.NORTH); contentPanel.add(new JScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 0)); p.add(ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancel, selectAllBtn), BorderLayout.CENTER); contentPanel.add(p, BorderLayout.SOUTH); contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 12, 2, 12)); setContentPane(contentPanel); doEnableOKBtn(); //setIconImage(IconManager.getIcon("Preparation", IconManager.IconSize.Std16).getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); doEnableOKBtn(); okBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); isCancelled = false; } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); } }); selectAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { selectAllItems(); } }); pack(); Dimension size = getPreferredSize(); size.width += 20; size.height = size.height > 500 ? 500 : size.height; setSize(size); return true; } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LoanReturnDlg.class, ex); // Error Dialog ex.printStackTrace(); } finally { if (session != null) { session.close(); } } return false; }
From source file:eu.dety.burp.joseph.attacks.bleichenbacher_pkcs1.gui.BleichenbacherPkcs1DecryptionAttackPanel.java
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this * method is always regenerated by the Form Editor. *//*from w w w.j a v a 2 s. c o m*/ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" // desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { cekFormatButtonGroup = new javax.swing.ButtonGroup(); startAttackButton = new javax.swing.JButton(); cancelAttackButton = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); timeElapsedLabel = new javax.swing.JLabel(); amountRequestsLabel = new javax.swing.JLabel(); currentSLabel = new javax.swing.JLabel(); resultKeyLabel = new javax.swing.JLabel(); cekFormatHex = new javax.swing.JRadioButton(); cekFormatB64 = new javax.swing.JRadioButton(); attackDescription = new javax.swing.JLabel(); timeElapsedValue = new javax.swing.JLabel(); amountRequestsValue = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); currentSValue = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); resultContentValue = new javax.swing.JTextArea(); resultContentLabel = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); resultKeyValue = new javax.swing.JTextArea(); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("JOSEPH"); // NOI18N startAttackButton.setText(bundle.getString("STARTATTACKBUTTON")); // NOI18N startAttackButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startAttackButtonActionPerformed(evt); } }); cancelAttackButton.setText(bundle.getString("CANCELATTACKBUTTON")); // NOI18N cancelAttackButton.setEnabled(false); cancelAttackButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelAttackButtonActionPerformed(evt); } }); timeElapsedLabel.setText(bundle.getString("TIME_ELAPSED")); // NOI18N amountRequestsLabel.setText(bundle.getString("AMOUNT_REQUESTS")); // NOI18N currentSLabel.setText(bundle.getString("FOUND_S")); // NOI18N resultKeyLabel.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N resultKeyLabel.setText(bundle.getString("RESULT_CEK")); // NOI18N cekFormatButtonGroup.add(cekFormatHex); cekFormatHex.setSelected(true); cekFormatHex.setText(bundle.getString("HEX")); // NOI18N cekFormatHex.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cekFormatHexActionPerformed(evt); } }); cekFormatButtonGroup.add(cekFormatB64); cekFormatB64.setText(bundle.getString("BASE64URL")); // NOI18N cekFormatB64.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cekFormatB64ActionPerformed(evt); } }); attackDescription.setText( "<html><em>Note: This attack will take several minutes and performs thousands of requests to the server!</em><br />This attack is only successful, if the valid oracle responses are correctly marked.</html>"); timeElapsedValue.setText("00:00:00"); timeElapsedValue.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); amountRequestsValue.setText("0"); amountRequestsValue.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); jScrollPane1.setBackground(new java.awt.Color(251, 251, 251)); jScrollPane1.setBorder(null); jScrollPane1.setForeground(new java.awt.Color(0, 0, 0)); currentSValue.setEditable(false); currentSValue.setBackground(new java.awt.Color(251, 251, 251)); currentSValue.setColumns(20); currentSValue.setForeground(new java.awt.Color(0, 0, 0)); currentSValue.setLineWrap(true); currentSValue.setRows(4); currentSValue.setTabSize(4); currentSValue.setText("0"); currentSValue.setWrapStyleWord(true); currentSValue.setBorder(null); jScrollPane1.setViewportView(currentSValue); jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resultContentValue.setEditable(false); resultContentValue.setColumns(20); resultContentValue.setLineWrap(true); resultContentValue.setRows(5); resultContentValue.setWrapStyleWord(true); resultContentValue.setBorder(null); jScrollPane2.setViewportView(resultContentValue); resultContentLabel.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N resultContentLabel.setText(bundle.getString("RESULT_CONTENT")); // NOI18N jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resultKeyValue.setEditable(false); resultKeyValue.setColumns(20); resultKeyValue.setLineWrap(true); resultKeyValue.setRows(5); resultKeyValue.setWrapStyleWord(true); resultKeyValue.setBorder(null); jScrollPane3.setViewportView(resultKeyValue); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(attackDescription, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE) .addComponent(jSeparator1) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(startAttackButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelAttackButton)) .addGroup(layout.createSequentialGroup().addComponent(cekFormatHex) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cekFormatB64)) .addComponent(resultKeyLabel) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(currentSLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(amountRequestsLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(timeElapsedLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(timeElapsedValue, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE) .addComponent(amountRequestsValue, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING))) .addComponent(resultContentLabel)).addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) .addGroup(layout.createSequentialGroup().addGap(6, 6, 6) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 700, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 700, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(attackDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(startAttackButton).addComponent(cancelAttackButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(timeElapsedLabel).addComponent(timeElapsedValue)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(amountRequestsLabel).addComponent(amountRequestsValue)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(currentSLabel).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(resultKeyLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cekFormatHex).addComponent(cekFormatB64)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(resultContentLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(68, Short.MAX_VALUE))); }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
@Override public void createUI() { this.setHelpContext("Import"); super.createUI(); CellConstraints cc = new CellConstraints(); levelCBX = createComboBox();/*from w ww . j a v a2s. co m*/ DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); for (SpAppResourceDir curDir : contextMgr.getSpAppResourceList()) { SpAppResourceDir dir; if (curDir.getId() != null) { dir = session.get(SpAppResourceDir.class, curDir.getId()); dir.setTitle(curDir.getTitle()); // Force Load dir.getSpAppResources().size(); dir.getSpPersistedAppResources().size(); dir.getSpPersistedViewSets().size(); for (SpAppResource appRes : curDir.getSpAppResources()) { if (appRes.getId() == null) { dir.getSpAppResources().add(appRes); } } for (SpViewSetObj vso : curDir.getSpViewSets()) { if (vso.getId() == null) { dir.getSpViewSets().add(vso); } } } else { dir = (SpAppResourceDir) curDir.clone(); } dirs.add(dir); levelCBX.addItem(dir); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); } finally { if (session != null) { session.close(); } } PanelBuilder centerPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p,10px,p")); centerPB.add(createLabel(UIRegistry.getLocalizedMessage("RIE_USR_LBL", userName)), cc.xy(2, 1)); centerPB.add(levelCBX, cc.xy(2, 3)); tabbedPane = new JTabbedPane(); PanelBuilder viewPanel = new PanelBuilder(new FormLayout("f:p:g,10px,f:p:g", "p,2px,f:p:g")); viewPanel.add(createLabel(getResourceString("RIE_VIEWSETS"), SwingConstants.CENTER), cc.xy(1, 1)); viewSetsList = new JList(viewSetsModel); viewSetsList.setCellRenderer(new ARListRenderer()); JScrollPane sp = new JScrollPane(viewSetsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(1, 3)); viewPanel.add(createLabel(getResourceString("RIE_VIEWS"), SwingConstants.CENTER), cc.xy(3, 1)); viewsList = new JList(viewsModel); viewsList.setCellRenderer(new ViewRenderer()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(3, 3)); viewsList.setEnabled(false); PanelBuilder resPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p")); resPane.add(createLabel(getResourceString("RIE_OTHER_RES"), SwingConstants.CENTER), cc.xy(1, 1)); resList = new JList(resModel); resList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(resList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resPane.add(sp, cc.xy(1, 3)); PanelBuilder repPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g")); repPane.add(createLabel(getResourceString("RIE_REPORT_RES"), SwingConstants.CENTER), cc.xy(1, 1)); repList = new JList(repModel); repList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); repList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(repList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); repPane.add(sp, cc.xy(1, 3)); boolean addResourcesPanel = AppPreferences.getLocalPrefs().getBoolean("ADD_IMP_RES", false); viewsPanel = viewPanel.getPanel(); tabbedPane.addTab(getResourceString("RIE_VIEWSETS"), viewsPanel); if (addResourcesPanel) { resPanel = resPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_OTHER_RES"), resPanel); } repPanel = repPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_REPORT_RES"), repPanel); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p")); pb.add(centerPB.getPanel(), cc.xy(1, 1)); pb.add(tabbedPane, cc.xy(1, 3)); exportBtn = createButton(getResourceString("RIE_EXPORT")); importBtn = createButton(getResourceString("RIE_IMPORT")); revertBtn = createButton(getResourceString("RIE_REVERT")); PanelBuilder btnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p,10px")); btnPB.add(exportBtn, cc.xy(2, 1)); btnPB.add(importBtn, cc.xy(4, 1)); btnPB.add(revertBtn, cc.xy(6, 1)); pb.add(btnPB.getPanel(), cc.xy(1, 5)); pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Component selectedComp = tabbedPane.getSelectedComponent(); if (selectedComp != null) { if (selectedComp == viewsPanel) { viewSetsList.setSelectedIndex(-1); } else if (selectedComp == resPanel) { resList.setSelectedIndex(-1); } else { repList.setSelectedIndex(-1); } //revertBtn.setVisible(selectedComp != repPanel); } enableUI(); // JGoodies Resizes the panel in the Dialog and // partially hides the buttons, this fixes that. Dimension size = ResourceImportExportDlg.this.getSize(); //ResourceImportExportDlg.this.pack(); //Dimension newSize = ResourceImportExportDlg.this.getSize(); Dimension newSize = ResourceImportExportDlg.this.getPreferredSize(); size.height = newSize.height; ResourceImportExportDlg.this.setSize(size); } }); levelCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { levelSelected(); } }); } }); levelCBX.setSelectedIndex(0); pack(); exportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportResource(); } }); importBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importResource(); } }); revertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { revertResource(); } }); viewSetsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (viewSetsList.getSelectedIndex() > -1) { resList.clearSelection(); repList.clearSelection(); } fillViewsList(); enableUI(); } } }); resList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); repList.clearSelection(); } enableUI(); } } }); repList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); resList.clearSelection(); } enableUI(); } } }); pack(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java
@Override public void createUI() { super.createUI(); databaseSchema = WorkbenchTask.getDatabaseSchema(); int disciplineeId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId(); SchemaI18NService.getInstance().loadWithLocale(SpLocaleContainer.WORKBENCH_SCHEMA, disciplineeId, databaseSchema, SchemaI18NService.getCurrentLocale()); // Create the Table List Vector<TableInfo> tableInfoList = new Vector<TableInfo>(); for (DBTableInfo ti : databaseSchema.getTables()) { if (StringUtils.isNotEmpty(ti.toString())) { TableInfo tableInfo = new TableInfo(ti, IconManager.STD_ICON_SIZE); tableInfoList.add(tableInfo); Vector<FieldInfo> fldList = new Vector<FieldInfo>(); for (DBFieldInfo fi : ti.getFields()) { String fldTitle = fi.getTitle().replace(" ", ""); if (fldTitle.equalsIgnoreCase(fi.getName())) { //get title from mapped field UploadInfo upInfo = getUploadInfo(fi); DBFieldInfo mInfo = getMappedFieldInfo(fi); if (mInfo != null) { String title = mInfo.getTitle(); if (upInfo != null && upInfo.getSequence() != -1) { title += " " + (upInfo.getSequence() + 1); }//from w ww. ja va 2s . c o m //if mapped-to table is different than the container table used // in the wb, add the mapped-to table's title if (mInfo.getTableInfo().getTableId() != ti.getTableId()) { title = mInfo.getTableInfo().getTitle() + " " + title; } fi.setTitle(title); } } fldList.add(new FieldInfo(ti, fi)); } //Collections.sort(fldList); tableInfo.setFieldItems(fldList); } } Collections.sort(tableInfoList); fieldModel = new DefaultModifiableListModel<FieldInfo>(); tableModel = new DefaultModifiableListModel<TableInfo>(); for (TableInfo ti : tableInfoList) { tableModel.add(ti); // only added for layout for (FieldInfo fi : ti.getFieldItems()) { fieldModel.add(fi); } } tableList = new JList(tableModel); tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tableList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE)); JScrollPane tableScrollPane = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selObj = tableList.getSelectedValue(); if (selObj != null) { fillFieldList((TableInfo) selObj); } updateEnabledState(); } } }); fieldList = new JList(fieldModel); fieldList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE)); fieldList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); JScrollPane fieldScrollPane = new JScrollPane(fieldList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); fieldList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateEnabledState(); updateFieldDescription(); } } }); mapModel = new DefaultModifiableListModel<FieldMappingPanel>(); mapList = new JList(mapModel); mapList.setCellRenderer(new MapCellRenderer()); mapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mapScrollPane = new JScrollPane(mapList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); mapList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { FieldMappingPanel fmp = (FieldMappingPanel) mapList.getSelectedValue(); if (fmp != null) { ignoreMapListUpdate = true; FieldInfo fldInfo = fmp.getFieldInfo(); if (fldInfo != null) { for (int i = 0; i < tableModel.size(); i++) { TableInfo tblInfo = (TableInfo) tableModel.get(i); if (fldInfo.getTableinfo() == tblInfo.getTableInfo()) { tableList.setSelectedValue(tblInfo, true); fillFieldList(tblInfo); //System.out.println(fldInfo.hashCode()+" "+fldInfo.getFieldInfo().hashCode()); fieldList.setSelectedValue(fldInfo, true); updateFieldDescription(); break; } } } ignoreMapListUpdate = false; updateEnabledState(); } } } }); upBtn = createIconBtn("ReorderUp", "WB_MOVE_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = mapList.getSelectedIndex(); FieldMappingPanel fmp = mapModel.getElementAt(inx); mapModel.remove(fmp); mapModel.insertElementAt(fmp, inx - 1); mapList.setSelectedIndex(inx - 1); updateEnabledState(); setChanged(true); } }); downBtn = createIconBtn("ReorderDown", "WB_MOVE_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = mapList.getSelectedIndex(); FieldMappingPanel fmp = mapModel.getElementAt(inx); mapModel.remove(fmp); mapModel.insertElementAt(fmp, inx + 1); mapList.setSelectedIndex(inx + 1); updateEnabledState(); setChanged(true); } }); JButton dumpMappingBtn = createIconBtn("BlankIcon", IconManager.IconSize.Std16, "WB_MAPPING_DUMP", new ActionListener() { public void actionPerformed(ActionEvent ae) { dumpMapping(); } }); dumpMappingBtn.setEnabled(true); dumpMappingBtn.setFocusable(false); dumpMappingBtn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16)); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("BlankIcon", IconManager.IconSize.Std16)); super.mouseExited(e); } }); mapToBtn = createIconBtn("Map", "WB_ADD_MAPPING_ITEM", new ActionListener() { public void actionPerformed(ActionEvent ae) { map(); } }); unmapBtn = createIconBtn("Unmap", "WB_REMOVE_MAPPING_ITEM", new ActionListener() { public void actionPerformed(ActionEvent ae) { unmap(); } }); // Adjust all Labels depending on whether we are creating a new template or not // and whether it is from a file or not String mapListLeftLabel; String mapListRightLabel; // Note: if workbenchTemplate is null then it is String dataTypeLabel = getResourceString("WB_DATA_TYPE"); String fieldsLabel = getResourceString("WB_FIELDS"); mapListLeftLabel = fieldsLabel; mapListRightLabel = getResourceString("WB_COLUMNS"); CellConstraints cc = new CellConstraints(); JPanel mainLayoutPanel = new JPanel(); PanelBuilder labelsBldr = new PanelBuilder(new FormLayout("p, f:p:g, p", "p")); labelsBldr.add(createLabel(mapListLeftLabel, SwingConstants.LEFT), cc.xy(1, 1)); labelsBldr.add(createLabel(mapListRightLabel, SwingConstants.RIGHT), cc.xy(3, 1)); PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p,f:p:g, p, 2px, p, f:p:g")); upDownPanel.add(dumpMappingBtn, cc.xy(1, 1)); upDownPanel.add(upBtn, cc.xy(1, 3)); upDownPanel.add(downBtn, cc.xy(1, 5)); PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "p, 2px, p")); middlePanel.add(mapToBtn, cc.xy(1, 1)); middlePanel.add(unmapBtn, cc.xy(1, 3)); btnPanel = middlePanel.getPanel(); btnPanel.setOpaque(false); PanelBuilder outerMiddlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, f:p:g")); outerMiddlePanel.add(btnPanel, cc.xy(1, 2)); outerMiddlePanel.getPanel().setOpaque(false); // Main Pane Layout PanelBuilder builder = new PanelBuilder( new FormLayout("f:max(200px;p):g, 5px, max(200px;p), 5px, p:g, 5px, f:max(250px;p):g, 2px, p", "p, 2px, f:max(350px;p):g"), mainLayoutPanel); builder.add(createLabel(dataTypeLabel, SwingConstants.CENTER), cc.xy(1, 1)); builder.add(createLabel(fieldsLabel, SwingConstants.CENTER), cc.xy(3, 1)); builder.add(labelsBldr.getPanel(), cc.xy(7, 1)); builder.add(tableScrollPane, cc.xy(1, 3)); builder.add(fieldScrollPane, cc.xy(3, 3)); builder.add(outerMiddlePanel.getPanel(), cc.xy(5, 3)); builder.add(mapScrollPane, cc.xy(7, 3)); builder.add(upDownPanel.getPanel(), cc.xy(9, 3)); mainLayoutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel megaPanel = new JPanel(new BorderLayout()); megaPanel.add(mainLayoutPanel, BorderLayout.CENTER); descriptionLbl = createLabel(" ", SwingConstants.LEFT); //PanelBuilder descBuilder = new PanelBuilder(new FormLayout("f:p:g, 3dlu","p")); //descBuilder.add(descriptionLbl, cc.xy(1, 1)); //megaPanel.add(descBuilder.getPanel(), BorderLayout.SOUTH); megaPanel.add(descriptionLbl, BorderLayout.SOUTH); //contentPanel = mainLayoutPanel; contentPanel = megaPanel; Color bgColor = btnPanel.getBackground(); int inc = 16; btnPanelColor = new Color(Math.min(255, bgColor.getRed() + inc), Math.min(255, bgColor.getGreen() + inc), Math.min(255, bgColor.getBlue() + inc)); btnPanel.setBackground(btnPanelColor); btnPanel.setBorder(BorderFactory.createEmptyBorder(4, 6, 4, 6)); okBtn.setEnabled(false); HelpMgr.registerComponent(helpBtn, helpContext); if (dataFileInfo != null) { autoMapFromDataFile(dataFileInfo.getColInfo()); } if (workbenchTemplate != null) { fillFromTemplate(); setChanged(false); } mainPanel.add(contentPanel, BorderLayout.CENTER); if (dataFileInfo == null) //can't add new mappings when importing. { FieldMappingPanel fmp = addMappingItem(null, IconManager.getIcon("BlankIcon", IconManager.STD_ICON_SIZE), null); fmp.setAdded(true); fmp.setNew(true); } pack(); SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { cancelBtn.requestFocus(); fieldModel.clear(); fieldList.clearSelection(); updateFieldDescription(); updateEnabledState(); if (mapModel.size() > 1) { mapList.clearSelection(); } } }); }