List of usage examples for com.jgoodies.looks HeaderStyle BOTH
HeaderStyle BOTH
To view the source code for com.jgoodies.looks HeaderStyle BOTH.
Click Source Link
From source file:at.lux.fotoannotation.AnnotationFrame.java
License:Open Source License
private void init() { try {/*from www. jav a2s .co m*/ LoggerInit.configureLog4j("log4j.properties", "INFO"); this.setIconImage(ImageIO.read(AnnotationFrame.class.getResource("data/caliph-icon.png"))); // this.setIconImage(ImageIO.read(AnnotationFrame.class.getResource("data/icon.gif"))); } catch (Exception e) { debug("Couldn't set Icon: IOException " + e.getMessage()); } df = (DecimalFormat) DecimalFormat.getInstance(); df.setMaximumFractionDigits(2); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { super.windowClosing(event); exitApplication(); } }); // ------------------------------------------------------------------------------- // Ueberpruefung ob das agent file existiert, sonst muss es angelegt werden ... // Eine sicherheitskopie befindet sich im package ... // ------------------------------------------------------------------------------- debug("Checking if agentfile is here ..."); File agentsFile = new File(AnnotationToolkit.AGENTS_FILE); if (!agentsFile.exists()) { try { debug("Generating sample agents file"); Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/agents.mp7.xml")); FileOutputStream fos = new FileOutputStream(agentsFile); OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8"); new XMLOutputter(Format.getPrettyFormat()).output(d, osw); osw.close(); fos.close(); debug("Finished generating sample agents file"); } catch (Exception e) { debug("Error generating sample agents file " + e.toString() + ", " + e.getMessage()); } } else { debug("agentfile found :)"); } debug("reading configurationfile ... "); // ------------------------------------------------------------------------------- // Ueberpruefung ob das base-object file existiert, sonst muss es angelegt werden. // Eine sicherheitskopie befindet sich im package ... // ------------------------------------------------------------------------------- debug("Checking if agentfile is here ..."); File baseobjectsFile = new File("base-objects.mp7.xml"); if (!baseobjectsFile.exists()) { try { debug("Generating sample base-objects file"); Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/base-objects.mp7.xml")); FileOutputStream fos = new FileOutputStream(baseobjectsFile); OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8"); new XMLOutputter(Format.getPrettyFormat()).output(d, osw); osw.close(); fos.close(); debug("Finished generating sample base-objects file"); } catch (Exception e) { debug("Error generating sample base-objects file " + e.toString() + ", " + e.getMessage()); } } else { debug("base-objects file found :)"); } debug("reading configurationfile ... "); // ------------------------------------------------------------------------------- // Ueberpruefung ob das property file existiert, sonst muss es angelegt werden ... // Eine sicherheitskopie befindet sich im package ... // ------------------------------------------------------------------------------- File pFile = new File("properties.xml"); if (!pFile.exists()) { try { debug("Generating sample property file"); Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/properties.xml")); FileOutputStream fos = new FileOutputStream(pFile); OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8"); new XMLOutputter(Format.getPrettyFormat()).output(d, osw); osw.close(); fos.close(); debug("Finished generating sample property file"); } catch (Exception e) { debug("Error generating sample property file " + e.toString() + ", " + e.getMessage()); } } properties = new AnnotationFrameProperties(new File("properties.xml"), this); debug("finished reading configurationfile"); JMenuBar menuBar = properties.getMenuBar(); // For JGoodies Look & Feel: menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); menuBar.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); this.setJMenuBar(menuBar); debug("finished creating menu"); fileTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent tse) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tse.getNewLeadSelectionPath() .getLastPathComponent(); if (node.getUserObject() instanceof FileNodeObject) { File f = ((FileNodeObject) node.getUserObject()).getContent(); if (!f.isDirectory()) { try { setCurrentFile(f); } catch (IOException e) { System.err.println("Error opening file: " + f.toString()); System.err.println(e.toString()); // e.printStackTrace(); } } } } }); setToCurrentLocation(fileTree); // ------------------------------------- // Initialising main Objects ... // ------------------------------------- // TextChangeListener intialization for detecting changes of the document. TextChangesListener.createInstance(this); // ------------------------------------- // Adding Components // ------------------------------------- beePanel = new IMBeeApplicationPanel(this); colorPanel = new ColorLayoutPanel(); lrSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); lrSplit.setBorder(BorderFactory.createEmptyBorder()); lrSplit.setDividerSize(3); tbSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); tbSplit.setBorder(BorderFactory.createEmptyBorder()); tbSplit.setDividerSize(3); mdPanel = new MetadataDescriptionPanel(new AgentComboBoxModel(this)); imagePanel = new ImageThumbPanel(); // fp = new FilePanel(new File("."), this); qualityPanel = new QualityPanel(new AgentComboBoxModel(this)); textPanel = new TextDescriptionPanel(this); creationPanel = new CreationPanel(new AgentComboBoxModel(this)); shapePanel = new ShapePanel(this); JPanel qualTextPanel = new JPanel(new BorderLayout()); qualTextPanel.add(qualityPanel, BorderLayout.SOUTH); qualTextPanel.add(textPanel, BorderLayout.CENTER); gridPanel1 = new JPanel(new GridLayout(0, 2)); JPanel _leftPanel1 = new JPanel(new BorderLayout()); // gridPanel2.add(textPanel); _leftPanel1.add(qualTextPanel, BorderLayout.CENTER); _leftPanel1.add(mdPanel, BorderLayout.SOUTH); gridPanel1.add(_leftPanel1); gridPanel1.add(creationPanel); JPanel gridPanel3 = new JPanel(new GridLayout(0, 1)); gridPanel3.add(colorPanel); // gridPanel3.add(qualTextPanel); tabs = new JTabbedPane(JTabbedPane.TOP); tabs.setBorder(BorderFactory.createEmptyBorder()); tabs.add("Image Information", gridPanel1); tabs.add("Semantics", beePanel); tabs.add("Shape", shapePanel); tabs.add("Visuals", gridPanel3); // file tree .... // --------------- JScrollPane fileTreeScrollPane = new JScrollPane(fileTree); JPanel filePanel = new JPanel(new BorderLayout()); filePanel.add(fileTreeScrollPane, BorderLayout.CENTER); // TODO: remove error here ... fileComboBox = new JComboBox(File.listRoots()); fileComboBox.setActionCommand("rootChanged"); fileComboBox.addActionListener(this); filePanel.add(fileComboBox, BorderLayout.NORTH); tbSplit.add(filePanel, JSplitPane.TOP); tbSplit.add(imagePanel, JSplitPane.BOTTOM); lrSplit.add(tbSplit, JSplitPane.LEFT); lrSplit.add(tabs, JSplitPane.RIGHT); lrSplit.setDividerLocation(properties.getLrSplit()); tbSplit.setDividerLocation(properties.getTbSplit()); status = new JLabel(TITLE_BAR); status.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); garbageState = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100); garbageState.setStringPainted(true); garbageState.setPreferredSize(new Dimension(100, 18)); garbageState.setToolTipText( "This bar shows the memory allocated by the VM and how much of it is already in use."); garbageState.setBorder(BorderFactory.createEmptyBorder()); gtracker = new GarbageTracker(garbageState); JPanel sgcPanel = new JPanel(new BorderLayout()); sgcPanel.add(garbageState, BorderLayout.EAST); sgcPanel.add(status, BorderLayout.CENTER); this.getContentPane().add(lrSplit, BorderLayout.CENTER); this.getContentPane().add(sgcPanel, BorderLayout.SOUTH); this.setSize(properties.getFrameWidth(), properties.getFrameHeigth()); this.setLocation(properties.getFrameLocationX(), properties.getFrameLocationY()); beePanel.reArrange(); //beePanel.revalidate(); gtracker.start(); // call init from global configuration while splash is on screen :) IconCache.getInstance(); }
From source file:com.eviware.soapui.SoapUI.java
License:EUPL
private JComponent buildToolbar() { mainToolbar = new JXToolBar(); mainToolbar.setFloatable(false);/* w w w. jav a 2 s . c o m*/ mainToolbar.setRollover(true); mainToolbar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); mainToolbar.add(new NewWsdlProjectActionDelegate()); mainToolbar.add(new ImportWsdlProjectActionDelegate()); mainToolbar.add(new SaveAllActionDelegate()); mainToolbar.addSpace(2); mainToolbar.add(new ShowOnlineHelpAction("Forum", HelpUrls.FORUMS_HELP_URL, "Opens the SoapUI Forum in a browser", "/group_go.png")); mainToolbar.addSpace(2); mainToolbar.add(new ShowOnlineHelpAction("Trial", HelpUrls.TRIAL_URL, "Apply for SoapUI Pro Trial License", "/favicon.png")); mainToolbar.addSpace(2); mainToolbar.add(new PreferencesActionDelegate()); applyProxyButton = (JToggleButton) mainToolbar.add(new JToggleButton(new ApplyProxyButtonAction())); updateProxyButtonAndTooltip(); mainToolbar.addGlue(); searchField = new JTextField(20); searchField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if (e.getKeyChar() == '\n') { doForumSearch(searchField.getText()); } } }); JLabel searchLabel = new JLabel("Search Forum"); // Extra width to avoid label to be truncated searchLabel.setPreferredSize(new Dimension((int) (searchLabel.getPreferredSize().getWidth() * 1.1), (int) searchLabel.getPreferredSize().getHeight())); mainToolbar.addFixed(searchLabel); mainToolbar.addSeparator(new Dimension(3, 3)); mainToolbar.addFixed(searchField); mainToolbar.add(new ToolbarForumSearchAction()); mainToolbar.add(new ShowOnlineHelpAction(HelpUrls.USERGUIDE_HELP_URL)); for (int i = 0; i < mainToolbar.getComponentCount(); i++) { if (mainToolbar.getComponent(i) instanceof JComponent) { ((JComponent) mainToolbar.getComponent(i)).setBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2)); } } mainToolbar.setBorder(BorderFactory.createEmptyBorder(3, 1, 3, 1)); return mainToolbar; }
From source file:com.eviware.soapui.SoapUI.java
License:EUPL
private JMenuBar buildMainMenu() { menuBar = new JMenuBar(); menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); menuBar.add(buildFileMenu());/*from ww w .ja v a2 s . c om*/ menuBar.add(buildToolsMenu()); menuBar.add(buildDesktopMenu()); menuBar.add(buildHelpMenu()); return menuBar; }
From source file:com.salas.bb.views.mainframe.BBMenuBuilder.java
License:Open Source License
/** * Build BlogBridge menu bar.//from www . j av a 2 s .c o m * * @return the resulting menu bar. */ public JMenuBar buildMenuBar() { JMenuBar myMenu = new JMenuBar(); myMenu.setMargin(MENUBAR_MARGIN); // Apply some special style hints for JGoodies myMenu.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); myMenu.putClientProperty(WindowsLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); myMenu.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); myMenu.add(buildGuidesMenu()); myMenu.add(buildFeedsMenu()); myMenu.add(buildArticlesMenu()); myMenu.add(buildToolsMenu()); myMenu.add(buildHelpMenu()); return myMenu; }
From source file:com.zeroc.IceGridGUI.LiveDeployment.GraphView.java
License:Open Source License
public GraphView(Coordinator coordinator, String title) { _coordinator = coordinator;/* www. ja v a 2 s .c o m*/ setTitle(title); _preferences = Preferences.userNodeForPackage(getClass()); // // Don't destroy JavaFX when the frame is disposed. // Platform.setImplicitExit(false); setIconImage(Utils.getIcon("/icons/16x16/metrics_graph.png").getImage()); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); // // Graph preferences. // Action preferences = new AbstractAction("Preferences") { @Override public void actionPerformed(ActionEvent event) { // // Set the title // JTextField title = new JTextField(getTitle()); JPanel titlePanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.append("Title:", title); titlePanel = builder.getPanel(); } // // SpinnerNumberModel to set a refresh period. // SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod, _maxRefreshPeriod, 1); // // SpinnerNumberModel to set the maximum number of samples to keep in X axis. // final SpinnerNumberModel samples = new SpinnerNumberModel(_samples, _minSamples, _maxSamples, 1); JPanel refreshPanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.rowGroupingEnabled(true); final JSpinner spinner = new JSpinner(refreshPeriod); builder.append("Sample interval:", spinner); builder.append("", new JLabel("<html><p>Sample interval in seconds; must be between 1" + "<br/>and 3600 seconds.</p></html>")); refreshPanel = builder.getPanel(); } // // JComboBox to select time format used in X Axis // JComboBox<String> dateFormats = new JComboBox<>(_dateFormats); dateFormats.setSelectedItem(getDateFormat()); JPanel xAxisPanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.append("Samples displayed:", new JSpinner(samples)); builder.append("", new JLabel("<html><p>The number of samples displayed on a graph;" + "<br/>must be between 2 and 300." + "</p></html>")); builder.append("Time format:", dateFormats); xAxisPanel = builder.getPanel(); } FormLayout layout = new FormLayout("fill:pref:grow", "pref"); final DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG); builder.append(titlePanel); builder.nextLine(); builder.append(refreshPanel); builder.nextLine(); builder.append(xAxisPanel); if (JOptionPane.showConfirmDialog(GraphView.this, builder.getPanel(), "Metrics Graph Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) { return; } setTitle(title.getText()); setRefreshPeriod(refreshPeriod.getNumber().intValue()); setMaximumSamples(samples.getNumber().intValue()); setDateFormat((String) dateFormats.getSelectedItem()); } }; _legendTable = new JTable(_legendModel) { //Implement table cell tool tips. @Override public String getToolTipText(java.awt.event.MouseEvent e) { if (convertColumnIndexToModel(columnAtPoint(e.getPoint())) == 6) { return _legendModel.getRows(new int[] { rowAtPoint(e.getPoint()) })[0].cell.getField() .getColumnToolTip(); } else { return null; } } }; // // Adjust row height for larger fonts // int fontSize = _legendTable.getFont().getSize(); int minRowHeight = fontSize + fontSize / 3; if (_legendTable.getRowHeight() < minRowHeight) { _legendTable.setRowHeight(minRowHeight); } // // Graph preferences. // final Action delete = new AbstractAction("Delete") { @Override public void actionPerformed(ActionEvent event) { int[] selectedRows = _legendTable.getSelectedRows(); for (int i = 0; i < selectedRows.length; ++i) { selectedRows[i] = _legendTable.convertRowIndexToModel(selectedRows[i]); } // // Remove selected rows from the legend model. // final MetricsRow[] rows = _legendModel.removeRows(selectedRows); // // Remove rows from series hash maps // for (MetricsRow row : rows) { Map<String, Map<String, Map<String, MetricsRow>>> j = _series.get(row.info); Map<String, Map<String, MetricsRow>> k = j.get(row.cell.getField().getMetricsName()); Map<String, MetricsRow> l = k.get(row.cell.getId()); l.remove(row.cell.getField().getFieldName()); if (l.size() == 0) { k.remove(row.cell.getId()); if (k.size() == 0) { j.remove(row.cell.getField().getMetricsName()); if (j.size() == 0) { _series.remove(row.info); if (_series.size() == 0) { stopRefresh(); } } } } } // // Remove series from the chart, in JavaFx thread. // enqueueJFX(new Runnable() { @Override public void run() { for (MetricsRow row : rows) { for (int i = 0; i < row.series.size(); ++i) { XYChart.Series<Number, Number> series = row.series.get(i); String seriesClass = getSeriesClass(series); if (seriesClass != null) { _styles.remove(seriesClass); } // // Don't remove the XYChart.Series object here, to avoid the series // style classes to be reasign by JavaFX. // // _chart.getData().remove(row.series); try { series.getData().clear(); } catch (NullPointerException ex) { // JavaFX bug } } } } }); } }; delete.setEnabled(false); delete.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); _legendTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { delete.setEnabled(_legendTable.getSelectedRows().length > 0); } } }); // // Create the tool bar // class ToolBar extends JToolBar { public ToolBar() { putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); setFloatable(false); putClientProperty("JToolBar.isRollover", Boolean.TRUE); JButton button = new JButton(delete); button.setText(null); button.setIcon(Utils.getIcon("/icons/24x24/delete.png")); add(button); } } // // Create menus // JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); fileMenu.add(preferences); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E); editMenu.add(delete); menuBar.add(editMenu); setJMenuBar(menuBar); // // Set default renderer for numeric values. // _legendTable.setDefaultRenderer(Double.class, new FormatedNumberRenderer("#0.000")); // // Set a combobox to edit the scale factors. // JComboBox<Double> scales = new JComboBox<>(_scales); scales.setRenderer(new DecimalRenderer(scales.getRenderer())); _legendTable.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(scales)); // // Set default renderer and editor for Color.class column. // _legendTable.setDefaultRenderer(Color.class, new ColorRenderer(true)); _legendTable.setDefaultEditor(Color.class, new ColorEditor()); _legendTable.setAutoCreateRowSorter(true); final JFXPanel fxPanel = new JFXPanel(); fxPanel.setMinimumSize(new Dimension(0, 200)); fxPanel.setPreferredSize(new Dimension(800, 400)); // // Build the split pane, with the chart graph and the legend table. // _splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); _splitPane.setTopComponent(fxPanel); JScrollPane scrollPane = new JScrollPane(_legendTable); scrollPane.setTransferHandler(new TransferHandler()); scrollPane.setMinimumSize(new Dimension(0, 50)); scrollPane.setPreferredSize(new Dimension(800, 200)); _splitPane.setBottomComponent(scrollPane); DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("fill:pref:grow", "fill:pref:grow, pref")); builder.append(_splitPane); builder.nextLine(); JPanel panel = builder.getPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); getContentPane().add(new ToolBar(), BorderLayout.PAGE_START); getContentPane().add(panel, BorderLayout.CENTER); setPreferredSize(new Dimension(800, 600)); // // initialize the scene in JavaFX thread. // enqueueJFX(() -> { _xAxis = new NumberAxis(); _yAxis = new NumberAxis(); _chart = new LineChart<>(_xAxis, _yAxis); _chart.setCreateSymbols(false); _xAxis.setLabel("Time (" + getDateFormat() + ")"); _xAxis.setTickLabelFormatter(_timeFormater); _xAxis.setForceZeroInRange(false); _chart.setAnimated(true); _chart.setLegendVisible(false); final Scene scene = new Scene(_chart); scene.setOnDragOver(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) { Object object = db.getContent(LocalObjectMimeType); if (object instanceof MetricsViewTransferableData) { event.acceptTransferModes(TransferMode.COPY); } } event.consume(); } }); scene.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { boolean success = false; Dragboard db = event.getDragboard(); if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) { Object object = db.getContent(LocalObjectMimeType); if (object instanceof MetricsViewTransferableData) { addSeries((MetricsViewTransferableData) object); success = true; } } event.setDropCompleted(success); event.consume(); } }); fxPanel.setScene(scene); }); pack(); if (!loadPreferences()) { _splitPane.setDividerLocation(400); } setVisible(true); // // Show info dialog if required. // if (showInfo()) { JCheckBox checkbox = new JCheckBox("Do not show this message again."); String message = "Drop metrics cells to add them to the graph."; JOptionPane.showConfirmDialog(this, new Object[] { message, checkbox }, "Information", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); if (checkbox.isSelected()) { _preferences.node("GraphView").putBoolean("showInfo", false); } } }
From source file:de.dal33t.powerfolder.ui.util.SimpleComponentFactory.java
License:Open Source License
/** * @return a popup menu// w w w .j a va 2 s.c o m */ public static JPopupMenu createPopupMenu() { JPopupMenu popupmenu = new JPopupMenu(); popupmenu.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); return popupmenu; }
From source file:fi.smaa.jsmaa.gui.AbstractGUIFactory.java
License:Open Source License
private JMenuBar buildMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); for (JMenuItem l : getEntityMenuList()) { menuBar.add(l);//from w ww . ja v a2s. co m } menuBar.add(buildResultsMenu()); menuBar.add(Box.createHorizontalGlue()); menuBar.add(buildHelpMenu()); return menuBar; }
From source file:IceGridGUI.LiveDeployment.GraphView.java
License:Open Source License
public GraphView(Coordinator coordinator, String title) { _coordinator = coordinator;/*from w w w . ja v a 2s .c om*/ setTitle(title); _preferences = Preferences.userNodeForPackage(getClass()); // // Don't destroy JavaFX when the frame is disposed. // Platform.setImplicitExit(false); setIconImage(Utils.getIcon("/icons/16x16/metrics_graph.png").getImage()); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); // // Graph preferences. // Action preferences = new AbstractAction("Preferences") { @Override public void actionPerformed(ActionEvent event) { // // Set the title // JTextField title = new JTextField(getTitle()); JPanel titlePanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.append("Title:", title); titlePanel = builder.getPanel(); } // // SpinnerNumberModel to set a refresh period. // SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod, _maxRefreshPeriod, 1); // // SpinnerNumberModel to set the maximum number of samples to keep in X axis. // final SpinnerNumberModel samples = new SpinnerNumberModel(_samples, _minSamples, _maxSamples, 1); JPanel refreshPanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.rowGroupingEnabled(true); final JSpinner spinner = new JSpinner(refreshPeriod); builder.append("Sample interval:", spinner); builder.append("", new JLabel("<html><p>Sample interval in seconds; must be between 1" + "<br/>and 3600 seconds.</p></html>")); refreshPanel = builder.getPanel(); } // // JComboBox to select time format used in X Axis // JComboBox<String> dateFormats = new JComboBox<String>(_dateFormats); dateFormats.setSelectedItem(getDateFormat()); JPanel xAxisPanel; { DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref,2dlu,pref:grow", "pref")); builder.append("Samples displayed:", new JSpinner(samples)); builder.append("", new JLabel("<html><p>The number of samples displayed on a graph;" + "<br/>must be between 2 and 300." + "</p></html>")); builder.append("Time format:", dateFormats); xAxisPanel = builder.getPanel(); } FormLayout layout = new FormLayout("fill:pref:grow", "pref"); final DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG); builder.append(titlePanel); builder.nextLine(); builder.append(refreshPanel); builder.nextLine(); builder.append(xAxisPanel); if (JOptionPane.showConfirmDialog(GraphView.this, builder.getPanel(), "Metrics Graph Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) { return; } setTitle(title.getText()); setRefreshPeriod(refreshPeriod.getNumber().intValue()); setMaximumSamples(samples.getNumber().intValue()); setDateFormat((String) dateFormats.getSelectedItem()); } }; _legendTable = new JTable(_legendModel) { //Implement table cell tool tips. @Override public String getToolTipText(java.awt.event.MouseEvent e) { if (convertColumnIndexToModel(columnAtPoint(e.getPoint())) == 6) { return _legendModel.getRows(new int[] { rowAtPoint(e.getPoint()) })[0].cell.getField() .getColumnToolTip(); } else { return null; } } }; // // Adjust row height for larger fonts // int fontSize = _legendTable.getFont().getSize(); int minRowHeight = fontSize + fontSize / 3; if (_legendTable.getRowHeight() < minRowHeight) { _legendTable.setRowHeight(minRowHeight); } // // Graph preferences. // final Action delete = new AbstractAction("Delete") { @Override public void actionPerformed(ActionEvent event) { int[] selectedRows = _legendTable.getSelectedRows(); for (int i = 0; i < selectedRows.length; ++i) { selectedRows[i] = _legendTable.convertRowIndexToModel(selectedRows[i]); } // // Remove selected rows from the legend model. // final MetricsRow[] rows = _legendModel.removeRows(selectedRows); // // Remove rows from series hash maps // for (MetricsRow row : rows) { Map<String, Map<String, Map<String, MetricsRow>>> j = _series.get(row.info); Map<String, Map<String, MetricsRow>> k = j.get(row.cell.getField().getMetricsName()); Map<String, MetricsRow> l = k.get(row.cell.getId()); l.remove(row.cell.getField().getFieldName()); if (l.size() == 0) { k.remove(row.cell.getId()); if (k.size() == 0) { j.remove(row.cell.getField().getMetricsName()); if (j.size() == 0) { _series.remove(row.info); if (_series.size() == 0) { stopRefresh(); } } } } } // // Remove series from the chart, in JavaFx thread. // enqueueJFX(new Runnable() { @Override public void run() { for (MetricsRow row : rows) { for (int i = 0; i < row.series.size(); ++i) { XYChart.Series<Number, Number> series = row.series.get(i); String seriesClass = getSeriesClass(series); if (seriesClass != null) { _styles.remove(seriesClass); } // // Don't remove the XYChart.Series object here, to avoid the series // style classes to be reasign by JavaFX. // // _chart.getData().remove(row.series); try { series.getData().clear(); } catch (NullPointerException ex) { // JavaFX bug } } } } }); } }; delete.setEnabled(false); delete.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); _legendTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { delete.setEnabled(_legendTable.getSelectedRows().length > 0); } } }); // // Create the tool bar // class ToolBar extends JToolBar { public ToolBar() { putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); setFloatable(false); putClientProperty("JToolBar.isRollover", Boolean.TRUE); JButton button = new JButton(delete); button.setText(null); button.setIcon(Utils.getIcon("/icons/24x24/delete.png")); add(button); } } // // Create menus // JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); fileMenu.add(preferences); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E); editMenu.add(delete); menuBar.add(editMenu); setJMenuBar(menuBar); // // Set default renderer for numeric values. // _legendTable.setDefaultRenderer(Double.class, new FormatedNumberRenderer("#0.000")); // // Set a combobox to edit the scale factors. // JComboBox<Double> scales = new JComboBox<Double>(_scales); scales.setRenderer(new DecimalRenderer(scales.getRenderer())); _legendTable.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(scales)); // //Set default renderer and editor for Color.class column. // _legendTable.setDefaultRenderer(Color.class, new ColorRenderer(true)); _legendTable.setDefaultEditor(Color.class, new ColorEditor()); _legendTable.setAutoCreateRowSorter(true); final JFXPanel fxPanel = new JFXPanel(); fxPanel.setMinimumSize(new Dimension(0, 200)); fxPanel.setPreferredSize(new Dimension(800, 400)); // // Build the split pane, with the chart graph and the legend table. // _splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); _splitPane.setTopComponent(fxPanel); JScrollPane scrollPane = new JScrollPane(_legendTable); scrollPane.setTransferHandler(new TransferHandler()); scrollPane.setMinimumSize(new Dimension(0, 50)); scrollPane.setPreferredSize(new Dimension(800, 200)); _splitPane.setBottomComponent(scrollPane); DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("fill:pref:grow", "fill:pref:grow, pref")); builder.append(_splitPane); builder.nextLine(); JPanel panel = builder.getPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); getContentPane().add(new ToolBar(), BorderLayout.PAGE_START); getContentPane().add(panel, BorderLayout.CENTER); setPreferredSize(new Dimension(800, 600)); // // initialize the scene in JavaFX thread. // enqueueJFX(new Runnable() { @Override public void run() { _xAxis = new NumberAxis(); _yAxis = new NumberAxis(); _chart = new LineChart<Number, Number>(_xAxis, _yAxis); _chart.setCreateSymbols(false); _xAxis.setLabel("Time (" + getDateFormat() + ")"); _xAxis.setTickLabelFormatter(_timeFormater); _xAxis.setForceZeroInRange(false); _chart.setAnimated(true); _chart.setLegendVisible(false); final Scene scene = new Scene(_chart); scene.setOnDragOver(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) { Object object = db.getContent(LocalObjectMimeType); if (object instanceof MetricsViewTransferableData) { event.acceptTransferModes(TransferMode.COPY); } } event.consume(); } }); scene.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { boolean success = false; Dragboard db = event.getDragboard(); if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) { Object object = db.getContent(LocalObjectMimeType); if (object instanceof MetricsViewTransferableData) { addSeries((MetricsViewTransferableData) object); success = true; } } event.setDropCompleted(success); event.consume(); } }); fxPanel.setScene(scene); } }); pack(); if (!loadPreferences()) { Rectangle otherRect = _coordinator.getMainFrame().getBounds(); Rectangle thisRect = getBounds(); if (otherRect.width < thisRect.width || otherRect.height < thisRect.height) { setLocationRelativeTo(null); } else { setLocationRelativeTo(_coordinator.getMainFrame()); } _splitPane.setDividerLocation(400); } setVisible(true); // // Show info dialog if required. // if (showInfo()) { JCheckBox checkbox = new JCheckBox("Do not show this message again."); String message = "Drop metrics cells to add them to the graph."; JOptionPane.showConfirmDialog(this, new Object[] { message, checkbox }, "Information", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); if (checkbox.isSelected()) { _preferences.node("GraphView").putBoolean("showInfo", false); } } }
From source file:net.sf.jabref.gui.JabRefFrame.java
License:Open Source License
private void createToolBar() { tlb.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); tlb.setBorder(null);//from w ww .j ava2s . c o m tlb.setRollover(true); tlb.setFloatable(false); if (Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) { tlb.addAction(newBiblatexDatabaseAction); } else { tlb.addAction(newBibtexDatabaseAction); } tlb.addAction(getOpenDatabaseAction()); tlb.addAction(save); tlb.addAction(saveAll); tlb.addSeparator(); tlb.addAction(cut); tlb.addAction(copy); tlb.addAction(paste); tlb.addAction(undo); tlb.addAction(redo); tlb.addSeparator(); tlb.addAction(getBackAction()); tlb.addAction(getForwardAction()); tlb.addSeparator(); tlb.addAction(newEntryAction); tlb.addAction(editEntry); tlb.addAction(editStrings); tlb.addAction(deleteEntry); tlb.addSeparator(); tlb.addAction(makeKeyAction); tlb.addAction(cleanupEntries); tlb.addAction(mergeEntries); tlb.addSeparator(); tlb.addAction(mark); tlb.addAction(unmark); tlb.addSeparator(); if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) { if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) { JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(Rank.getInstance(), this); tlb.add(button); specialFieldButtons.add(button); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) { tlb.addAction(toggleRelevance); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) { tlb.addAction(toggleQualityAssured); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) { JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(Priority.getInstance(), this); tlb.add(button); specialFieldButtons.add(button); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) { tlb.addAction(togglePrinted); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) { JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(ReadStatus.getInstance(), this); tlb.add(button); specialFieldButtons.add(button); } tlb.addSeparator(); } fetcherToggle = new JToggleButton(generalFetcher.getAction()); tlb.addJToogleButton(fetcherToggle); previewToggle = new JToggleButton(togglePreview); tlb.addJToogleButton(previewToggle); groupToggle = new JToggleButton(toggleGroups); tlb.addJToogleButton(groupToggle); tlb.addSeparator(); tlb.add(pushExternalButton.getComponent()); tlb.addSeparator(); tlb.add(donationAction); }
From source file:net.sf.jabref.JabRefFrame.java
License:Open Source License
private void createToolBar() { tlb.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); tlb.setBorder(null);/*from w ww. ja v a 2s.com*/ tlb.setRollover(true); //tlb.setBorderPainted(true); //tlb.setBackground(GUIGlobals.lightGray); //tlb.setForeground(GUIGlobals.lightGray); tlb.setFloatable(false); tlb.addAction(newDatabaseAction); tlb.addAction(open); tlb.addAction(save); tlb.addAction(saveAll); //tlb.addAction(dbConnect); //tlb.addAction(dbExport); tlb.addSeparator(); tlb.addAction(cut); tlb.addAction(copy); tlb.addAction(paste); tlb.addAction(undo); tlb.addAction(redo); tlb.addSeparator(); tlb.addAction(back); tlb.addAction(forward); tlb.addSeparator(); tlb.addAction(newEntryAction); tlb.addAction(editEntry); tlb.addAction(editPreamble); tlb.addAction(editStrings); tlb.addAction(makeKeyAction); tlb.addAction(Cleanup); tlb.addAction(mergeEntries); tlb.addSeparator(); tlb.addAction(mark); tlb.addAction(unmark); tlb.addSeparator(); if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) { if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) { tlb.add(net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(Rank.getInstance(), this)); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) { tlb.addAction(toggleRelevance); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) { tlb.addAction(toggleQualityAssured); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) { tlb.add(net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(Priority.getInstance(), this)); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) { tlb.addAction(togglePrinted); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) { tlb.add(net.sf.jabref.specialfields.SpecialFieldDropDown .generateSpecialFieldButtonWithDropDown(ReadStatus.getInstance(), this)); } } tlb.addSeparator(); searchToggle = new JToggleButton(toggleSearch); searchToggle.setText(null); if (!Globals.ON_MAC) { searchToggle.setMargin(marg); } tlb.add(searchToggle); previewToggle = new JToggleButton(togglePreview); previewToggle.setText(null); if (!Globals.ON_MAC) { previewToggle.setMargin(marg); } tlb.add(previewToggle); tlb.addSeparator(); groupToggle = new JToggleButton(toggleGroups); groupToggle.setText(null); if (!Globals.ON_MAC) { groupToggle.setMargin(marg); } tlb.add(groupToggle); highlightAny = new JToggleButton(toggleHighlightAny); highlightAny.setText(null); if (!Globals.ON_MAC) { highlightAny.setMargin(marg); } tlb.add(highlightAny); highlightAll = new JToggleButton(toggleHighlightAll); highlightAll.setText(null); if (!Globals.ON_MAC) { highlightAll.setMargin(marg); } tlb.add(highlightAll); tlb.addSeparator(); // Removing the separate push-to buttons, replacing them by the // multipurpose button: //tlb.addAction(emacsPushAction); //tlb.addAction(lyxPushAction); //tlb.addAction(winEdtPushAction); tlb.add(pushExternalButton.getComponent()); tlb.addAction(openFolder); tlb.addAction(openFile); //tlb.addAction(openPdf); //tlb.addAction(openUrl); //tlb.addSeparator(); //tlb.addAction(showPrefs); tlb.add(Box.createHorizontalGlue()); //tlb.add(new JabRefLabel(GUIGlobals.frameTitle+" "+GUIGlobals.version)); tlb.addAction(closeDatabaseAction); //Insets margin = new Insets(0, 0, 0, 0); //for (int i=0; i<tlb.getComponentCount(); i++) // ((JButton)tlb.getComponentAtIndex(i)).setMargin(margin); }