List of usage examples for javax.swing JToolBar JToolBar
public JToolBar()
HORIZONTAL
. From source file:org.zaproxy.zap.view.MainToolbarPanel.java
public void initialise() { setLayout(new java.awt.GridBagLayout()); setPreferredSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25)); setMaximumSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25)); this.setBorder(BorderFactory.createEtchedBorder()); expandButtons = new ButtonGroup(); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints1.gridx = 0;//from w w w . j a v a2 s. c om gridBagConstraints1.gridy = 0; gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints2.gridx = 1; gridBagConstraints2.gridy = 0; gridBagConstraints2.weightx = 1.0; gridBagConstraints2.weighty = 1.0; gridBagConstraints2.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; JToolBar t1 = new JToolBar(); t1.setEnabled(true); t1.setPreferredSize(new java.awt.Dimension(80000, 25)); t1.setMaximumSize(new java.awt.Dimension(80000, 25)); add(getToolbar(), gridBagConstraints1); add(t1, gridBagConstraints2); toolbar.add(getModeSelect()); toolbar.add(getBtnNew()); toolbar.add(getBtnOpen()); toolbar.add(getBtnSave()); toolbar.add(getBtnSnapshot()); toolbar.add(getBtnSession()); toolbar.add(getBtnOptions()); toolbar.addSeparator(); toolbar.add(getShowAllTabs()); toolbar.add(getHideAllTabs()); toolbar.add(getShowTabIconNames()); toolbar.addSeparator(); toolbar.add(getBtnExpandSites()); toolbar.add(getBtnExpandReports()); toolbar.add(getBtnExpandFull()); toolbar.addSeparator(); }
From source file:org.zaproxy.zap.view.MainToolbarPanel.java
private JToolBar getToolbar() { if (toolbar == null) { toolbar = new JToolBar(); toolbar.setEnabled(true);/*w ww .j a va 2 s . c o m*/ toolbar.setFloatable(false); toolbar.setRollover(true); toolbar.setName("Main Toolbar"); toolbar.setBorder(BorderFactory.createEmptyBorder()); } return toolbar; }
From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java
public void goToLiveMode() { JToolBar jToolBar = new JToolBar(); createFollowCheckBox();// w w w . j a v a 2 s. c o m createPauseCheckBox(); createReadingProgressBar(); jToolBar.add(playTailing); jToolBar.add(follow); JButton clear = new JButton(new ClearLogTableAction(otrosApplication)); clear.setBorderPainted(false); jToolBar.add(clear); jToolBar.add(progressBar); logViewPanel.add(jToolBar, BorderLayout.NORTH); logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout()); TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel()); logViewPanel.getLogsMarkersPanel().add(markersPanel); switchToContentView(); addRowAutoScroll(); }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private void initToolbar() { toolBar = new JToolBar(); final JComboBox searchMode = new JComboBox( new String[] { "String contains search: ", "Regex search: ", "Query search: " }); final SearchAction searchActionForward = new SearchAction(otrosApplication, SearchDirection.FORWARD); final SearchAction searchActionBackward = new SearchAction(otrosApplication, SearchDirection.REVERSE); searchFieldCbxModel = new DefaultComboBoxModel(); searchField = new JXComboBox(searchFieldCbxModel); searchField.setEditable(true);//ww w . j a v a 2s. c o m AutoCompleteDecorator.decorate(searchField); searchField.setMinimumSize(new Dimension(150, 10)); searchField.setPreferredSize(new Dimension(250, 10)); searchField.setToolTipText( "<HTML>Enter text to search.<BR/>" + "Enter - search next,<BR/>Alt+Enter search previous,<BR/>" + "Ctrl+Enter - mark all found</HTML>"); final DelayedSwingInvoke delayedSearchResultUpdate = new DelayedSwingInvoke() { @Override protected void performActionHook() { JTextComponent editorComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); int stringEnd = editorComponent.getSelectionStart(); if (stringEnd < 0) { stringEnd = editorComponent.getText().length(); } try { String selectedText = editorComponent.getText(0, stringEnd); if (StringUtils.isBlank(selectedText)) { return; } OtrosJTextWithRulerScrollPane<JTextPane> logDetailWithRulerScrollPane = otrosApplication .getSelectedLogViewPanel().getLogDetailWithRulerScrollPane(); MessageUpdateUtils.highlightSearchResult(logDetailWithRulerScrollPane, otrosApplication.getAllPluginables().getMessageColorizers()); RulerBarHelper.scrollToFirstMarker(logDetailWithRulerScrollPane); } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "Can't update search highlight", e); } } }; JTextComponent searchFieldTextComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); searchFieldTextComponent.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { delayedSearchResultUpdate.performAction(); } }); final MarkAllFoundAction markAllFoundAction = new MarkAllFoundAction(otrosApplication); final SearchModeValidatorDocumentListener searchValidatorDocumentListener = new SearchModeValidatorDocumentListener( (JTextField) searchField.getEditor().getEditorComponent(), observer, SearchMode.STRING_CONTAINS); SearchMode searchModeFromConfig = configuration.get(SearchMode.class, "gui.searchMode", SearchMode.STRING_CONTAINS); final String lastSearchString; int selectedSearchMode = 0; if (searchModeFromConfig.equals(SearchMode.STRING_CONTAINS)) { selectedSearchMode = 0; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_STRING, ""); } else if (searchModeFromConfig.equals(SearchMode.REGEX)) { selectedSearchMode = 1; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_REGEX, ""); } else if (searchModeFromConfig.equals(SearchMode.QUERY)) { selectedSearchMode = 2; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_QUERY, ""); } else { LOGGER.warning("Unknown search mode " + searchModeFromConfig); lastSearchString = ""; } Component editorComponent = searchField.getEditor().getEditorComponent(); if (editorComponent instanceof JTextField) { final JTextField sfTf = (JTextField) editorComponent; sfTf.getDocument().addDocumentListener(searchValidatorDocumentListener); sfTf.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { try { int length = e.getDocument().getLength(); if (length > 0) { searchResultColorizer.setSearchString(e.getDocument().getText(0, length)); } } catch (BadLocationException e1) { LOGGER.log(Level.SEVERE, "Error: ", e1); } } }); sfTf.addKeyListener(new SearchFieldKeyListener(searchActionForward, sfTf)); sfTf.setText(lastSearchString); } searchMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SearchMode mode = null; boolean validationEnabled = false; String confKey = null; String lastSearch = ((JTextField) searchField.getEditor().getEditorComponent()).getText(); if (searchMode.getSelectedIndex() == 0) { mode = SearchMode.STRING_CONTAINS; searchValidatorDocumentListener.setSearchMode(mode); validationEnabled = false; searchMode.setToolTipText("Checking if log message contains string (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_STRING; } else if (searchMode.getSelectedIndex() == 1) { mode = SearchMode.REGEX; validationEnabled = true; searchMode .setToolTipText("Checking if log message matches regular expression (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_REGEX; } else if (searchMode.getSelectedIndex() == 2) { mode = SearchMode.QUERY; validationEnabled = true; String querySearchTooltip = "<HTML>" + // "Advance search using SQL-like quries (i.e. level>=warning && msg~=failed && thread==t1)<BR/>" + // "Valid operator for query search is ==, ~=, !=, LIKE, EXISTS, <, <=, >, >=, &&, ||, ! <BR/>" + // "See wiki for more info<BR/>" + // "</HTML>"; searchMode.setToolTipText(querySearchTooltip); confKey = ConfKeys.SEARCH_LAST_QUERY; } searchValidatorDocumentListener.setSearchMode(mode); searchValidatorDocumentListener.setEnable(validationEnabled); searchActionForward.setSearchMode(mode); searchActionBackward.setSearchMode(mode); markAllFoundAction.setSearchMode(mode); configuration.setProperty("gui.searchMode", mode); searchResultColorizer.setSearchMode(mode); List<Object> list = configuration.getList(confKey); searchFieldCbxModel.removeAllElements(); for (Object o : list) { searchFieldCbxModel.addElement(o); } searchField.setSelectedItem(lastSearch); } }); searchMode.setSelectedIndex(selectedSearchMode); final JCheckBox markFound = new JCheckBox("Mark search result"); markFound.setMnemonic(KeyEvent.VK_M); searchField.addKeyListener(markAllFoundAction); configuration.addConfigurationListener(markAllFoundAction); JButton markAllFoundButton = new JButton(markAllFoundAction); final JComboBox markColor = new JComboBox(MarkerColors.values()); markFound.setSelected(configuration.getBoolean("gui.markFound", true)); markFound.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { boolean selected = markFound.isSelected(); searchActionForward.setMarkFound(selected); searchActionBackward.setMarkFound(selected); configuration.setProperty("gui.markFound", markFound.isSelected()); } }); markColor.setRenderer(new MarkerColorsComboBoxRenderer()); // markColor.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); // searchActionForward.setMarkerColors(markerColors); // searchActionBackward.setMarkerColors(markerColors); // markAllFoundAction.setMarkerColors(markerColors); // configuration.setProperty("gui.markColor", markColor.getSelectedItem()); // otrosApplication.setSelectedMarkColors(markerColors); // } // }); markColor.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); searchActionForward.setMarkerColors(markerColors); searchActionBackward.setMarkerColors(markerColors); markAllFoundAction.setMarkerColors(markerColors); configuration.setProperty("gui.markColor", markColor.getSelectedItem()); otrosApplication.setSelectedMarkColors(markerColors); } }); markColor.getModel() .setSelectedItem(configuration.get(MarkerColors.class, "gui.markColor", MarkerColors.Aqua)); buttonSearch = new JButton(searchActionForward); buttonSearch.setMnemonic(KeyEvent.VK_N); JButton buttonSearchPrev = new JButton(searchActionBackward); buttonSearchPrev.setMnemonic(KeyEvent.VK_P); enableDisableComponetsForTabs.addComponet(buttonSearch); enableDisableComponetsForTabs.addComponet(buttonSearchPrev); enableDisableComponetsForTabs.addComponet(searchField); enableDisableComponetsForTabs.addComponet(markFound); enableDisableComponetsForTabs.addComponet(markAllFoundButton); enableDisableComponetsForTabs.addComponet(searchMode); enableDisableComponetsForTabs.addComponet(markColor); toolBar.add(searchMode); toolBar.add(searchField); toolBar.add(buttonSearch); toolBar.add(buttonSearchPrev); toolBar.add(markFound); toolBar.add(markAllFoundButton); toolBar.add(markColor); JButton nextMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.FORWARD)); nextMarked.setToolTipText(nextMarked.getText()); nextMarked.setText(""); nextMarked.setMnemonic(KeyEvent.VK_E); enableDisableComponetsForTabs.addComponet(nextMarked); toolBar.add(nextMarked); JButton prevMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.BACKWARD)); prevMarked.setToolTipText(prevMarked.getText()); prevMarked.setText(""); prevMarked.setMnemonic(KeyEvent.VK_R); enableDisableComponetsForTabs.addComponet(prevMarked); toolBar.add(prevMarked); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.SEVERE))); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.SEVERE))); }
From source file:pl.otros.logview.gui.LogViewPanelWrapper.java
public void goToLiveMode() { mode = Mode.Live;/*from w w w. j a va2 s.c o m*/ JToolBar jToolBar = new JToolBar(); createFollowCheckBox(); createPauseCheckBox(); jToolBar.add(playTailing); jToolBar.add(follow); JButton clear = new JButton(new ClearLogTableAction(otrosApplication)); clear.setBorderPainted(false); jToolBar.add(clear); logViewPanel.add(jToolBar, BorderLayout.NORTH); logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout()); TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel()); logViewPanel.getLogsMarkersPanel().add(markersPanel); switchToContentView(); addRowScroller(); }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
public MessageColorizerBrowser(OtrosApplication otrosApplication) { super(new BorderLayout()); this.container = otrosApplication.getAllPluginables().getMessageColorizers(); this.otrosApplication = otrosApplication; toolBar = new JToolBar(); editor = new MessageColorizerEditor(container, otrosApplication.getStatusObserver()); JLabel noEditable = new JLabel("Selected MessageColorizer is not editable.", SwingConstants.CENTER); JLabel nothingSelected = new JLabel("Nothing selected", SwingConstants.CENTER); listModel = new PluginableElementListModel<MessageColorizer>(container); jList = new JList(listModel); jList.setCellRenderer(new PluginableElementNameListRenderer()); cardLayout = new CardLayout(); contentPanel = new JPanel(cardLayout); contentPanel.add(editor, CARD_LAYOUT_EDITOR); contentPanel.add(noEditable, CARD_LAYOUT_NOT_EDITABLE); contentPanel.add(nothingSelected, CARD_LAYOUT_NO_SELECTED); cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE); JSplitPane mainSplitPane = new JSplitPane(SwingConstants.VERTICAL, new JScrollPane(jList), contentPanel); mainSplitPane.setDividerLocation(220); jList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override//from w w w . j a v a 2 s . c om public void valueChanged(ListSelectionEvent e) { showSelected(); enableDisableButtonsForSelectedColorizer(); } }); jList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_DELETE) { ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, ""); deleteAction.actionPerformed(actionEvent); } } }); JButton createNew = new JButton("Create new", Icons.ADD); createNew.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAsButton.setEnabled(false); createNew(); } }); saveButton = new JButton("Save and use", Icons.DISK); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { PropertyPatternMessageColorizer mc = editor.createMessageColorizer(); File selectedFile = null; String f = mc.getFile(); if (StringUtils.isNotBlank(f)) { selectedFile = new File(mc.getFile()); } else { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(mc, true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); saveAsButton = new JButton("Save as", Icons.DISK_PLUS); saveAsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = chooser.getSelectedFile(); selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(editor.createMessageColorizer(), true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); useButton = new JButton("Use without saving"); useButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { removeMessageColorizerWithNullFile(); applyMessageColorizer(File.createTempFile("messageColorizer", "pattern")); } catch (Exception e) { LOGGER.severe("Cannot create message colorizer: " + e.getMessage()); } } }); deleteAction = new DeleteSelected(otrosApplication); deleteButton = new JButton(deleteAction); toolBar.setFloatable(false); toolBar.add(createNew); toolBar.add(saveButton); toolBar.add(saveAsButton); toolBar.add(useButton); toolBar.add(deleteButton); enableDisableButtonsForSelectedColorizer(); initFileChooser(); this.add(mainSplitPane); this.add(toolBar, BorderLayout.SOUTH); }
From source file:plugin.notes.gui.NotesView.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.// w w w. java 2 s. co m */ private void initComponents() { //GEN-BEGIN:initComponents jSplitPane1 = new FlippingSplitPane(); jScrollPane1 = new JScrollPane(); notesTree = new JTree(); jPanel1 = new JPanel(); jScrollPane2 = new JScrollPane(); editor = new JTextPane(); jPanel2 = new JPanel(); fileBar = new JToolBar(); newButton = new JButton(); saveButton = new JButton(); exportButton = new JButton(); revertButton = new JButton(); deleteButton = new JButton(); clipboardBar = new JToolBar(); cutButton = new JButton(); copyButton = new JButton(); pasteButton = new JButton(); formatBar = new JToolBar(); sizeCB = new JComboBox(); boldButton = new JButton(); italicButton = new JButton(); underlineButton = new JButton(); colorButton = new JButton(); bulletButton = new JButton(); enumButton = new JButton(); imageButton = new JButton(); alignmentBar = new JToolBar(); leftJustifyButton = new JButton(); centerJustifyButton = new JButton(); rightJustifyButton = new JButton(); filePane = new JPanel(); fileLeft = new JButton(); fileRight = new JButton(); filesBar = new JToolBar(); setLayout(new java.awt.BorderLayout()); jSplitPane1.setDividerLocation(175); jSplitPane1.setDividerSize(5); jScrollPane1.setViewportView(notesTree); jSplitPane1.setLeftComponent(jScrollPane1); jPanel1.setLayout(new java.awt.BorderLayout()); editor.addCaretListener(this::editorCaretUpdate); jScrollPane2.setViewportView(editor); jPanel1.add(jScrollPane2, java.awt.BorderLayout.CENTER); jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0)); newButton.setIcon(Icons.stock_new.getImageIcon()); newButton.setToolTipText("New Node"); newButton.setBorder(new EtchedBorder()); newButton.setEnabled(false); newButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { newButtonActionPerformed(); } }); fileBar.add(newButton); saveButton.setIcon(Icons.stock_save.getImageIcon()); saveButton.setToolTipText("Save Node"); saveButton.setBorder(new EtchedBorder()); saveButton.setEnabled(false); saveButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { saveButtonActionPerformed(); } }); fileBar.add(saveButton); exportButton.setIcon(Icons.stock_export.getImageIcon()); exportButton.setToolTipText("Export"); exportButton.setBorder(new EtchedBorder()); exportButton.setEnabled(false); exportButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { exportButtonActionPerformed(); } }); fileBar.add(exportButton); revertButton.setIcon(Icons.stock_revert.getImageIcon()); revertButton.setToolTipText("Revert to Saved"); revertButton.setBorder(new EtchedBorder()); revertButton.setEnabled(false); revertButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { revertButtonActionPerformed(); } }); fileBar.add(revertButton); deleteButton.setIcon(Icons.stock_broken_image.getImageIcon()); deleteButton.setToolTipText("Delete Node"); deleteButton.setBorder(new EtchedBorder()); deleteButton.setEnabled(false); deleteButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { deleteButtonActionPerformed(); } }); fileBar.add(deleteButton); jPanel2.add(fileBar); cutButton.setIcon(Icons.stock_cut.getImageIcon()); cutButton.setToolTipText("Cut"); cutButton.setBorder(new EtchedBorder()); cutButton.addActionListener(this::cutButtonActionPerformed); clipboardBar.add(cutButton); copyButton.setIcon(Icons.stock_copy.getImageIcon()); copyButton.setToolTipText("Copy"); copyButton.setBorder(new EtchedBorder()); copyButton.addActionListener(this::copyButtonActionPerformed); clipboardBar.add(copyButton); pasteButton.setIcon(Icons.stock_paste.getImageIcon()); pasteButton.setToolTipText("Paste"); pasteButton.setBorder(new EtchedBorder()); pasteButton.addActionListener(this::pasteButtonActionPerformed); clipboardBar.add(pasteButton); jPanel2.add(clipboardBar); sizeCB.setToolTipText("Size"); sizeCB.setBorder(new EtchedBorder()); sizeCB.addActionListener(this::sizeCBActionPerformed); formatBar.add(sizeCB); boldButton.setIcon(Icons.stock_text_bold.getImageIcon()); boldButton.setToolTipText("Bold"); boldButton.setBorder(new EtchedBorder()); boldButton.addActionListener(this::boldButtonActionPerformed); formatBar.add(boldButton); italicButton.setIcon(Icons.stock_text_italic.getImageIcon()); italicButton.setToolTipText("Italic"); italicButton.setBorder(new EtchedBorder()); italicButton.addActionListener(this::italicButtonActionPerformed); formatBar.add(italicButton); underlineButton.setIcon(Icons.stock_text_underline.getImageIcon()); underlineButton.setToolTipText("Underline"); underlineButton.setBorder(new EtchedBorder()); underlineButton.addActionListener(this::underlineButtonActionPerformed); formatBar.add(underlineButton); colorButton.setForeground(java.awt.SystemColor.text); colorButton.setIcon(Icons.createImageIcon("menu-mode-RGB-alt.png")); colorButton.setToolTipText("Color"); colorButton.setBorder(new EtchedBorder()); colorButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { colorButtonActionPerformed(); } }); formatBar.add(colorButton); bulletButton.setIcon(Icons.stock_list_bulet.getImageIcon()); bulletButton.setToolTipText("Bulleted List"); bulletButton.setAction(actionListUnordered); bulletButton.setBorder(new EtchedBorder()); formatBar.add(bulletButton); enumButton.setIcon(Icons.stock_list_enum.getImageIcon()); enumButton.setToolTipText("Numbered List"); enumButton.setAction(actionListOrdered); enumButton.setBorder(new EtchedBorder()); formatBar.add(enumButton); imageButton.setIcon(Icons.stock_insert_graphic.getImageIcon()); imageButton.setBorder(new EtchedBorder()); imageButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { imageButtonActionPerformed(); } }); formatBar.add(imageButton); jPanel2.add(formatBar); leftJustifyButton.setIcon(Icons.stock_text_align_left.getImageIcon()); leftJustifyButton.setToolTipText("Left Justify"); leftJustifyButton.setBorder(new EtchedBorder()); leftJustifyButton.addActionListener(this::leftJustifyButtonActionPerformed); alignmentBar.add(leftJustifyButton); centerJustifyButton.setIcon(Icons.stock_text_align_center.getImageIcon()); centerJustifyButton.setToolTipText("Center"); centerJustifyButton.setBorder(new EtchedBorder()); centerJustifyButton.addActionListener(this::centerJustifyButtonActionPerformed); alignmentBar.add(centerJustifyButton); rightJustifyButton.setIcon(Icons.stock_text_align_right.getImageIcon()); rightJustifyButton.setToolTipText("Right Justify"); rightJustifyButton.setBorder(new EtchedBorder()); rightJustifyButton.addActionListener(this::rightJustifyButtonActionPerformed); alignmentBar.add(rightJustifyButton); jPanel2.add(alignmentBar); jPanel1.add(jPanel2, java.awt.BorderLayout.NORTH); filePane.setLayout(new BoxLayout(filePane, BoxLayout.X_AXIS)); fileLeft.setText("<"); fileLeft.setBorder(new EtchedBorder()); fileLeft.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { fileLeftActionPerformed(); } }); filePane.add(fileLeft); fileRight.setText(">"); fileRight.setBorder(new EtchedBorder()); fileRight.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { fileRightActionPerformed(); } }); filePane.add(fileRight); filePane.add(filesBar); jPanel1.add(filePane, java.awt.BorderLayout.SOUTH); jSplitPane1.setRightComponent(jPanel1); add(jSplitPane1, java.awt.BorderLayout.CENTER); }
From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java
private void initUI() { JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(250);/*from w ww .ja va2 s.c o m*/ split.setOneTouchExpandable(true); JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); // add refresh action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("refresh"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.refresh"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { try { if (Globals.getConnection() == null) { return; } // refresh tables, views, procedures TreeUtil.refreshDatabase(); // add new queries to tree TreeUtil.refreshQueries(); // add new reports to tree TreeUtil.refreshReports(); // add new charts to tree TreeUtil.refreshCharts(); } catch (Exception ex) { Show.error(ex); } } }); // add expand action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("expandall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.expand.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.expandAll(dbBrowserTree); } }); // add collapse action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("collapseall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.collapse.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.collapseAll(dbBrowserTree); } }); // add properties button /* JButton propButton = new MagicButton(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("properties"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { DBBrowserPropertiesPanel joinPanel = new DBBrowserPropertiesPanel(); JDialog dlg = new DBBrowserPropertiesDialog(joinPanel); dlg.pack(); dlg.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dlg); dlg.setVisible(true); } }); propButton.setToolTipText(I18NSupport.getString("querybuilder.properties")); */ //browserButtonsPanel.add(propButton); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(browserButtonsPanel); browserPanel = new JXPanel(new BorderLayout()); browserPanel.add(toolBar, BorderLayout.NORTH); // browser tree JScrollPane scroll = new JScrollPane(dbBrowserTree); browserPanel.add(scroll, BorderLayout.CENTER); split.setLeftComponent(browserPanel); tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); // tabbedPane.putClientProperty(Options.EMBEDDED_TABS_KEY, Boolean.TRUE); // look like eclipse JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split2.setResizeWeight(0.66); split2.setOneTouchExpandable(true); // desktop pane desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.setDropTarget( new DropTarget(desktop, DnDConstants.ACTION_MOVE, new DesktopPaneDropTargetListener(), true)); // create the toolbar JToolBar toolBar2 = new JToolBar(); toolBar2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar2.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar2.setBorderPainted(false); Action distinctAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (distinctButton.isSelected()) { selectQuery.setDistinct(true); } else { selectQuery.setDistinct(false); } } }; distinctAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.distinct")); distinctAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.distinct")); toolBar2.add(distinctButton = new JToggleButton(distinctAction)); Action groupByAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { groupBy = groupByButton.isSelected(); Globals.getEventBus().publish(new GroupByEvent(QueryBuilderPanel.this.desktop, groupBy)); } }; groupByAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.group_by")); groupByAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.group.by")); toolBar2.add(groupByButton = new JToggleButton(groupByAction)); Action clearAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { clear(false); } }; clearAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("clear")); clearAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.clear")); toolBar2.add(clearAction); // add separator SwingUtil.addCustomSeparator(toolBar2); // add run button Action runQueryAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { selectSQLViewTab(); sqlView.doRun(); } }; runQueryAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); KeyStroke ks = KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")); runQueryAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); runQueryAction.putValue(Action.ACCELERATOR_KEY, ks); toolBar2.add(runQueryAction); // register run query shortcut GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance(); InputMap inputMap = hotkeyManager.getInputMap(); ActionMap actionMap = hotkeyManager.getActionMap(); inputMap.put((KeyStroke) runQueryAction.getValue(Action.ACCELERATOR_KEY), "runQueryAction"); actionMap.put("runQueryAction", runQueryAction); JScrollPane scroll2 = new JScrollPane(desktop, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll2.setPreferredSize(DBTablesDesktopPane.PREFFERED_SIZE); DecoratedScrollPane.decorate(scroll2); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar2, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(scroll2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); split2.setTopComponent(topPanel); designPanel = new DesignerTablePanel(selectQuery); split2.setBottomComponent(designPanel); split2.setDividerLocation(400); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.designer"), ImageUtil.getImageIcon("designer"), split2); tabbedPane.setMnemonicAt(0, 'D'); sqlView = new SQLViewPanel(); sqlView.getEditorPane().setDropTarget(new DropTarget(sqlView.getEditorPane(), DnDConstants.ACTION_MOVE, new SQLViewDropTargetListener(), true)); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.editor"), ImageUtil.getImageIcon("sql"), sqlView); tabbedPane.setMnemonicAt(1, 'E'); split.setRightComponent(tabbedPane); // register a change listener tabbedPane.addChangeListener(new ChangeListener() { // this method is called whenever the selected tab changes public void stateChanged(ChangeEvent ev) { if (ev.getSource() == QueryBuilderPanel.this.tabbedPane) { // get current tab int sel = QueryBuilderPanel.this.tabbedPane.getSelectedIndex(); if (sel == 1) { // sql view String query; if (!synchronizedPanels) { query = sqlView.getQueryString(); synchronizedPanels = true; } else { if (Globals.getConnection() != null) { query = getSelectQuery().toString(); } else { query = ""; } // if (query.equals("")) { // query = sqlView.getQueryString(); // } } if (resetTable) { sqlView.clear(); resetTable = false; } //System.out.println("query="+query); sqlView.setQueryString(query); } else if (sel == 0) { // design view if (queryWasModified(false)) { Object[] options = { I18NSupport.getString("optionpanel.yes"), I18NSupport.getString("optionpanel.no") }; String m1 = I18NSupport.getString("querybuilder.lost"); String m2 = I18NSupport.getString("querybuilder.continue"); int option = JOptionPane.showOptionDialog(Globals.getMainFrame(), "<HTML>" + m1 + "<BR>" + m2 + "</HTML>", I18NSupport.getString("querybuilder.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (option != JOptionPane.YES_OPTION) { synchronizedPanels = false; tabbedPane.setSelectedIndex(1); } else { resetTable = true; } } } else if (sel == 2) { // report view } } } }); // this.add(split, BorderLayout.CENTER); parametersPanel = new ParametersPanel(); }
From source file:ro.nextreports.designer.querybuilder.SQLViewPanel.java
private void initUI() { sqlEditor = new Editor() { public void afterCaretMove() { removeHighlightErrorLine();/* w w w . j a va2 s . c om*/ } }; this.queryArea = sqlEditor.getEditorPanel().getEditorPane(); queryArea.setText(DEFAULT_QUERY); errorPainter = new javax.swing.text.Highlighter.HighlightPainter() { @Override public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { try { Rectangle r = c.modelToView(c.getCaretPosition()); g.setColor(Color.RED.brighter().brighter()); g.fillRect(0, r.y, c.getWidth(), r.height); } catch (BadLocationException e) { // ignore } } }; ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap(); // create the toolbar JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); // add cut action Action cutAction = actionMap.get(BaseEditorKit.cutAction); cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut")); cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut")); toolBar.add(cutAction); // add copy action Action copyAction = actionMap.get(BaseEditorKit.copyAction); copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy")); copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy")); toolBar.add(copyAction); // add paste action Action pasteAction = actionMap.get(BaseEditorKit.pasteAction); pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste")); pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste")); toolBar.add(pasteAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add undo action Action undoAction = actionMap.get(BaseEditorKit.undoAction); undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo")); undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo")); toolBar.add(undoAction); // add redo action Action redoAction = actionMap.get(BaseEditorKit.redoAction); redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo")); redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo")); toolBar.add(redoAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add find action Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction); findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find")); findReplaceAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqleditor.findReplaceActionName")); toolBar.add(findReplaceAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add run action runAction = new SQLRunAction(); runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); runAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4"))); runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); // runAction is globally registered in QueryBuilderPanel ! toolBar.add(runAction); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel); // create the table resultTable = new JXTable(); resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators resultTable.setDefaultRenderer(Long.class, new ToStringRenderer()); resultTable.setDefaultRenderer(Date.class, new DateRenderer()); resultTable.setDefaultRenderer(Double.class, new DoubleRenderer()); resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable)); TableUtil.setRowHeader(resultTable); resultTable.setColumnControlVisible(true); // resultTable.getTableHeader().setReorderingAllowed(false); resultTable.setHorizontalScrollEnabled(true); // highlight table Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR); Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter()); Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter()); Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter()); resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter); resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR); resultTable.setGridColor(Color.LIGHT_GRAY); resultTable.setRolloverEnabled(true); resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.66); split.setOneTouchExpandable(true); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); statusPanel = new SQLStatusPanel(); bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); split.setTopComponent(topPanel); split.setBottomComponent(bottomPanel); split.setDividerLocation(400); setLayout(new BorderLayout()); this.add(split, BorderLayout.CENTER); }
From source file:savant.agp.HTTPBrowser.java
private Component getToolBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false);/* www . j av a 2s . com*/ JButton butt_track = new JButton("Open as track"); butt_track.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.TRACK); } }); butt_track.setBorder(new LineBorder(Color.gray, 1)); JButton butt_bkmks = new JButton("Open as bookmarks"); butt_bkmks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.BOOKMARK); } }); butt_bkmks.setBorder(new LineBorder(Color.gray, 1)); JButton butt_doc = new JButton("Open as document"); butt_doc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.DOCUMENT); } }); butt_doc.setBorder(new LineBorder(Color.gray, 1)); bar.add(butt_track); bar.addSeparator(new Dimension(5, 5)); bar.add(butt_bkmks); bar.addSeparator(new Dimension(5, 5)); bar.add(butt_doc); return bar; }