List of usage examples for javax.swing JToolBar JToolBar
public JToolBar()
HORIZONTAL
. From source file:org.rimudb.editor.RimuDBEditor.java
/** * Create and return a toolbar./*from w w w . j av a 2 s .com*/ */ protected JToolBar createToolbar() { log.debug("createToolbar()"); JToolBar toolbar = new JToolBar(); // Open openBtn = new ToolbarButton(new OpenDescriptorAction(this, loadIcon("/images/famfamfam/folder.png")), "Open Table Descriptor"); openBtn.setText("Open"); openBtn.setName("openBtn"); toolbar.add(openBtn); // Save saveBtn = new ToolbarButton(new SaveDescriptorAction(this, loadIcon("/images/famfamfam/disk.png")), "Save Table Descriptor"); saveBtn.setText("Save"); saveBtn.setName("saveBtn"); toolbar.add(saveBtn); // A space // toolbar.add(Box.createHorizontalStrut(5)); // Clear clearBtn = new ToolbarButton(new ClearTableAction(this, loadIcon("/images/famfamfam/bin_closed.png")), "Clear"); clearBtn.setText("Clear"); clearBtn.setName("clearBtn"); toolbar.add(clearBtn); // Save as // saveAsBtn = new ToolbarButton(new SaveAsDescriptorAction(this, loadIcon("/images/sun/SaveAs24.gif")), "Save Table Descriptor as"); // saveAsBtn.setName("saveAsBtn"); // toolbar.add(saveAsBtn); // A space toolbar.addSeparator(); // Import from a database importBtn = new ToolbarButton(new ImportAction(this, loadIcon("/images/famfamfam/database_go.png")), "Import from database"); importBtn.setText("Import"); importBtn.setName("importBtn"); importBtn.setEnabled(false); toolbar.add(importBtn); // A space toolbar.add(Box.createHorizontalStrut(5)); // Create classes createBtn = new ToolbarButton( new GenerateJavaAction(this, loadIcon("/images/famfamfam/page_white_cup.png")), "Create classes"); createBtn.setText("Create"); createBtn.setName("createBtn"); toolbar.add(createBtn); // Finish up the tool bar toolbar.add(Box.createHorizontalGlue()); toolbar.setFloatable(false); return toolbar; }
From source file:org.sikuli.ide.SikuliIDE.java
private JToolBar initToolbar() { if (ENABLE_UNIFIED_TOOLBAR) { MacUtils.makeWindowLeopardStyle(this.getRootPane()); }// w w w . j ava 2 s.com JToolBar toolbar = new JToolBar(); JButton btnInsertImage = new ButtonInsertImage(); _btnCapture = new ButtonCapture(); JButton btnSubregion = new ButtonSubregion(); toolbar.add(_btnCapture); toolbar.add(btnInsertImage); toolbar.add(btnSubregion); toolbar.add(Box.createHorizontalGlue()); _btnRun = new ButtonRun(); toolbar.add(_btnRun); _btnRunViz = new ButtonRunViz(); toolbar.add(_btnRunViz); toolbar.add(Box.createHorizontalGlue()); //TODO get it working for OSX 10.10 if (!Settings.isMac10()) { toolbar.add(createSearchField()); } toolbar.add(Box.createRigidArea(new Dimension(7, 0))); toolbar.setFloatable(false); //toolbar.setMargin(new Insets(0, 0, 0, 5)); return toolbar; }
From source file:org.sintef.thingml.ThingMLPanel.java
public ThingMLPanel(Boolean ArduinoPlugin, final ObservableString transferBuf) { try {/*from w w w . j av a 2 s. co m*/ this.setLayout(new BorderLayout()); jsyntaxpane.DefaultSyntaxKit.initKit(); jsyntaxpane.DefaultSyntaxKit.registerContentType("text/thingml", Class.forName("org.sintef.thingml.ThingMLJSyntaxKit").getName()); JScrollPane scrPane = new JScrollPane(codeEditor); codeEditor.setContentType("text/thingml; charset=UTF-8"); Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; reg.getExtensionToFactoryMap().put("thingml", new ThingmlResourceFactory()); //codeEditor.setBackground(Color.LIGHT_GRAY) JMenuBar menubar = new JMenuBar(); JInternalFrame menuframe = new JInternalFrame(); menuframe.setSize(getWidth(), getHeight()); menuframe.setJMenuBar(menubar); menuframe.setLayout(new BorderLayout()); menuframe.add(scrPane, BorderLayout.CENTER); if (!ArduinoPlugin) { try { this.transferBuf = transferBuf; EditorKit editorKit = codeEditor.getEditorKit(); JToolBar toolPane = new JToolBar(); ((ThingMLJSyntaxKit) editorKit).addToolBarActions(codeEditor, toolPane); menuframe.add(toolPane, BorderLayout.NORTH); } catch (Exception e) { if (ThingMLApp.debug) e.printStackTrace(); } } menuframe.setVisible(true); ((BasicInternalFrameUI) menuframe.getUI()).setNorthPane(null); menuframe.setBorder(BorderFactory.createEmptyBorder()); add(menuframe, BorderLayout.CENTER); if (!ArduinoPlugin) {//FIXME: Nicolas, avoid code duplication final ThingMLCompilerRegistry registry = ThingMLCompilerRegistry.getInstance(); JMenu newCompilersMenu = new JMenu("Compile to"); for (final String id : registry.getCompilerIds()) { JMenuItem item = new JMenuItem(id); ThingMLCompiler c = registry.createCompilerInstanceByName(id); if (c.getConnectorCompilers().size() > 0) { JMenu compilerMenu = new JMenu(c.getID()); newCompilersMenu.add(compilerMenu); compilerMenu.add(item); for (final Map.Entry<String, CfgExternalConnectorCompiler> connectorCompiler : c .getConnectorCompilers().entrySet()) { JMenuItem connectorMenu = new JMenuItem(connectorCompiler.getKey()); compilerMenu.add(connectorMenu); connectorMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile); for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) { final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id); for (NetworkPlugin np : loadedPlugins) { if (np.getTargetedLanguages().contains(compiler.getID())) { compiler.addNetworkPlugin(np); } } for (SerializationPlugin sp : loadedSerPlugins) { if (sp.getTargetedLanguages().contains(compiler.getID())) { compiler.addSerializationPlugin(sp); } } compiler.setOutputDirectory(new File(System.getProperty("java.io.tmpdir") + "/ThingML_temp/" + cfg.getName())); compiler.compileConnector(connectorCompiler.getKey(), cfg); } } }); } } else { newCompilersMenu.add(item); } item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Input file : " + targetFile); if (targetFile == null) return; try { ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile); if (thingmlModel != null) { for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) { final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id); for (NetworkPlugin np : loadedPlugins) { if (np.getTargetedLanguages().contains(compiler.getID())) { compiler.addNetworkPlugin(np); } } for (SerializationPlugin sp : loadedSerPlugins) { if (sp.getTargetedLanguages().contains(compiler.getID())) { compiler.addSerializationPlugin(sp); } } compiler.setOutputDirectory(new File(System.getProperty("java.io.tmpdir") + "/ThingML_temp/" + cfg.getName())); compiler.compile(cfg); } } } catch (Exception ex) { if (ThingMLApp.debug) ex.printStackTrace(); } } }); c = null; } menubar.add(newCompilersMenu); } else { final ThingMLCompilerRegistry registry = ThingMLCompilerRegistry.getInstance(); JMenu newCompilersMenu = new JMenu("Compile to"); for (final String id : registry.getCompilerIds()) { if (id.compareToIgnoreCase("arduino") == 0) { JMenuItem item = new JMenuItem(id); ThingMLCompiler c = registry.createCompilerInstanceByName(id); if (c.getConnectorCompilers().size() > 0) { JMenu compilerMenu = new JMenu(c.getID()); newCompilersMenu.add(compilerMenu); compilerMenu.add(item); for (final Map.Entry<String, CfgExternalConnectorCompiler> connectorCompiler : c .getConnectorCompilers().entrySet()) { JMenuItem connectorMenu = new JMenuItem(connectorCompiler.getKey()); compilerMenu.add(connectorMenu); connectorMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile); for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) { final ThingMLCompiler compiler = registry .createCompilerInstanceByName(id); for (NetworkPlugin np : loadedPlugins) { if (np.getTargetedLanguages().contains(compiler.getID())) { compiler.addNetworkPlugin(np); } } for (SerializationPlugin sp : loadedSerPlugins) { if (sp.getTargetedLanguages().contains(compiler.getID())) { compiler.addSerializationPlugin(sp); } } compiler.setOutputDirectory( new File(System.getProperty("java.io.tmpdir") + "/ThingML_temp/" + cfg.getName())); compiler.compileConnector(connectorCompiler.getKey(), cfg); } } }); } } else { newCompilersMenu.add(item); } item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Input file : " + targetFile); if (targetFile == null) return; try { ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile); for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) { final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id); for (NetworkPlugin np : loadedPlugins) { if (np.getTargetedLanguages().contains(compiler.getID())) { compiler.addNetworkPlugin(np); } } for (SerializationPlugin sp : loadedSerPlugins) { if (sp.getTargetedLanguages().contains(compiler.getID())) { compiler.addSerializationPlugin(sp); } } File myFileBuf = new File(System.getProperty("java.io.tmpdir") + "/ThingML_temp/" + cfg.getName()); compiler.setOutputDirectory(myFileBuf); compiler.compile(cfg); final InputStream input = new FileInputStream(myFileBuf.getAbsolutePath() + "/" + cfg.getName() + "/" + cfg.getName() + ".pde"); //System.out.println("tmp file: " + myFileBuf.getAbsolutePath() + "/" + cfg.getName() + "/" + cfg.getName() + ".pde"); //final InputStream input = new FileInputStream(myFileBuf); String result = null; try { if (input != null) { result = org.apache.commons.io.IOUtils.toString(input); input.close(); transferBuf.setString(result); transferBuf.hasChanged(); transferBuf.notifyObservers(); } else { //System.out.println("WHY"); } } catch (Exception exce) { if (ThingMLApp.debug) System.out.println("OH REALLY?"); } } } catch (Exception ex) { if (ThingMLApp.debug) ex.printStackTrace(); } } }); c = null; } } menubar.add(newCompilersMenu); } codeEditor.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { lastUpdate.set(System.currentTimeMillis()); checkNeeded.set(true); } public void insertUpdate(DocumentEvent e) { lastUpdate.set(System.currentTimeMillis()); checkNeeded.set(true); } public void changedUpdate(DocumentEvent e) { lastUpdate.set(System.currentTimeMillis()); checkNeeded.set(true); } }); java.util.Timer timer = new Timer(); timer.scheduleAtFixedRate(new SeamlessNotification(), 250, 250); } catch (Exception e) { if (ThingMLApp.debug) e.printStackTrace(); } }
From source file:org.springframework.richclient.factory.DefaultComponentFactory.java
/** * {@inheritDoc}/*from w ww . j av a 2 s .com*/ */ public JComponent createToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); return toolBar; }
From source file:org.terentich.pram.GUIPRAM.java
private void setContent() { FrameView mainview = getMainView();/*from w w w .j a v a 2 s. c om*/ Action openFileAction = mainview.getContext().getActionMap().get(ResourceNames.OPEN_FILE_ACTION_NAME); Action aboutDialogAction = mainview.getContext().getActionMap().get(ResourceNames.ABOUT_DIALOG_ACTION_NAME); JMenuBar bar = new JMenuBar(); JMenu menuFile = new JMenu(getContext().getResourceMap().getString(ResourceNames.MENU_FILE_NAME)); JMenu menuHelp = new JMenu(getContext().getResourceMap().getString(ResourceNames.MENU_HELP_NAME)); menuFile.add(openFileAction); menuHelp.add(aboutDialogAction); bar.add(menuFile); bar.add(menuHelp); mainview.setMenuBar(bar); // Container panel = mainview.getRootPane().getContentPane(); // panel.setLayout(new MigLayout()); // panel.add(new JButton(mainview.getContext().getActionMap() // .get(OPEN_FILE_ACTION_NAME))); mainview.getFrame().setTitle(MessageFormat.format(APPLICATION_TITLE_FORMAT, metaReader.getApplicationName(), metaReader.getApplicationVersion())); Container content = mainview.getRootPane().getContentPane(); tabPane = new JTabbedPane(); content.add(tabPane); JToolBar toolbar = new JToolBar(); toolbar.add(getContext().getActionMap().get(ResourceNames.OPEN_FILE_ACTION_NAME)); toolbar.add(getContext().getActionMap().get(ResourceNames.ABOUT_DIALOG_ACTION_NAME)); content.add(toolbar, BorderLayout.NORTH); initCLIOptions(); }
From source file:org.tinymediamanager.ui.movies.MoviePanel.java
/** * Create the panel.//from w w w . j a va 2 s .com */ public MoviePanel() { super(); // load movielist LOGGER.debug("loading MovieList"); movieList = MovieList.getInstance(); sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()), new MovieComparator()); sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS); // build menu menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$ JFrame mainFrame = MainWindow.getFrame(); JMenuBar menuBar = mainFrame.getJMenuBar(); menuBar.add(menu); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), })); splitPaneHorizontal = new JSplitPane(); splitPaneHorizontal.setContinuousLayout(true); add(splitPaneHorizontal, "2, 2, fill, fill"); JPanel panelMovieList = new JPanel(); splitPaneHorizontal.setLeftComponent(panelMovieList); panelMovieList.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); toolBar.setOpaque(false); panelMovieList.add(toolBar, "2, 1, left, fill"); // udpate datasource // toolBar.add(actionUpdateDataSources); final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH); // temp fix for size of the button buttonUpdateDatasource.setText(" "); buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonUpdateDatasource.setSplitWidth(18); buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionUpdateDataSources.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { // build the popupmenu on the fly buttonUpdateDatasource.getPopupMenu().removeAll(); JMenuItem item = new JMenuItem(actionUpdateDataSources2); buttonUpdateDatasource.getPopupMenu().add(item); buttonUpdateDatasource.getPopupMenu().addSeparator(); for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) { buttonUpdateDatasource.getPopupMenu() .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds))); } buttonUpdateDatasource.getPopupMenu().pack(); } }); JPopupMenu popup = new JPopupMenu("popup"); buttonUpdateDatasource.setPopupMenu(popup); toolBar.add(buttonUpdateDatasource); JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH); // temp fix for size of the button buttonScrape.setText(" "); buttonScrape.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonScrape.setSplitWidth(18); buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$ // register for listener buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionScrape.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { } }); popup = new JPopupMenu("popup"); JMenuItem item = new JMenuItem(actionScrape2); popup.add(item); item = new JMenuItem(actionScrapeUnscraped); popup.add(item); item = new JMenuItem(actionScrapeSelected); popup.add(item); buttonScrape.setPopupMenu(popup); toolBar.add(buttonScrape); toolBar.add(actionEditMovie); btnRen = new JButton("REN"); btnRen.setAction(actionRename); toolBar.add(btnRen); btnMediaInformation = new JButton("MI"); btnMediaInformation.setAction(actionMediaInformation); toolBar.add(btnMediaInformation); JButton btnCreateOflline = new JButton(); btnCreateOflline.setAction(new MovieCreateOfflineAction(false)); toolBar.add(btnCreateOflline); textField = EnhancedTextField.createSearchTextField(); panelMovieList.add(textField, "3, 1, right, bottom"); textField.setColumns(13); // table = new JTable(); // build JTable MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator()); MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor(); FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor); textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor); movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor); movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies), new MovieTableFormat()); table = new ZebraJTable(movieTableModel); movieTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount())); // select first movie if nothing is selected ListSelectionModel selectionModel = table.getSelectionModel(); if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) { selectionModel.setSelectionInterval(0, 0); } if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) { movieSelectionModel.setSelectedMovie(null); } } }); // install and save the comparator on the Table movieSelectionModel.setTableComparatorChooser( TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN)); // table = new MyTable(); table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916))); // scrollPane.setViewportView(table); // JScrollPane scrollPane = new JScrollPane(table); JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table); panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill"); { final JToggleButton filterButton = new JToggleButton(IconManager.FILTER); filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ panelMovieList.add(filterButton, "5, 1, right, bottom"); // add a propertychangelistener which reacts on setting a filter movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("filterChanged".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { filterButton.setIcon(IconManager.FILTER_ACTIVE); filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$ } else { filterButton.setIcon(IconManager.FILTER); filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ } } } }); panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel); panelExtendedSearch.setVisible(false); // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill"); filterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (panelExtendedSearch.isVisible() == true) { panelExtendedSearch.setVisible(false); } else { panelExtendedSearch.setVisible(true); } } }); } JPanel panelStatus = new JPanel(); panelMovieList.add(panelStatus, "2, 6, 2, 1"); panelStatus.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"), ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("fill:default:grow"), })); panelMovieCount = new JPanel(); panelStatus.add(panelMovieCount, "3, 1, left, fill"); lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$ panelMovieCount.add(lblMovieCount); lblMovieCountFiltered = new JLabel(""); panelMovieCount.add(lblMovieCountFiltered); lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$ panelMovieCount.add(lblMovieCountOf); lblMovieCountTotal = new JLabel(""); panelMovieCount.add(lblMovieCountTotal); JLayeredPane layeredPaneRight = new JLayeredPane(); layeredPaneRight.setLayout( new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") }, new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") })); panelRight = new MovieInformationPanel(movieSelectionModel); layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill"); layeredPaneRight.setLayer(panelRight, 0); // glass pane layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill"); layeredPaneRight.setLayer(panelExtendedSearch, 1); splitPaneHorizontal.setRightComponent(layeredPaneRight); splitPaneHorizontal.setContinuousLayout(true); // beansbinding init initDataBindings(); addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { menu.setVisible(false); super.componentHidden(e); } @Override public void componentShown(ComponentEvent e) { menu.setVisible(true); super.componentHidden(e); } }); // further initializations init(); // filter if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) { movieList.searchDuplicates(); movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters()); } }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Instantiates a new tv show panel./*www . ja v a 2 s.com*/ */ public TvShowPanel() { super(); treeModel = new TvShowTreeModel(tvShowList.getTvShows()); tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel(); tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel(); // build menu menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$ JFrame mainFrame = MainWindow.getFrame(); JMenuBar menuBar = mainFrame.getJMenuBar(); menuBar.add(menu); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JSplitPane splitPane = new JSplitPane(); splitPane.setContinuousLayout(true); add(splitPane, "2, 2, fill, fill"); JPanel panelTvShowTree = new JPanel(); splitPane.setLeftComponent(panelTvShowTree); panelTvShowTree.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); textField = EnhancedTextField.createSearchTextField(); panelTvShowTree.add(textField, "4, 1, right, bottom"); textField.setColumns(12); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { applyFilter(); } @Override public void removeUpdate(final DocumentEvent e) { applyFilter(); } @Override public void changedUpdate(final DocumentEvent e) { applyFilter(); } public void applyFilter() { TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel(); if (StringUtils.isNotBlank(textField.getText())) { filteredModel.setFilter(SearchOptions.TEXT, textField.getText()); } else { filteredModel.removeFilter(SearchOptions.TEXT); } filteredModel.filter(tree); } }); final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ panelTvShowTree.add(btnFilter, "6, 1, default, bottom"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill"); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); toolBar.setOpaque(false); panelTvShowTree.add(toolBar, "2, 1"); // toolBar.add(actionUpdateDatasources); final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH); // temp fix for size of the button buttonUpdateDatasource.setText(" "); buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonUpdateDatasource.setSplitWidth(18); buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionUpdateDatasources.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { // build the popupmenu on the fly buttonUpdateDatasource.getPopupMenu().removeAll(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2)); buttonUpdateDatasource.getPopupMenu().addSeparator(); for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) { buttonUpdateDatasource.getPopupMenu() .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds))); } buttonUpdateDatasource.getPopupMenu().addSeparator(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow)); buttonUpdateDatasource.getPopupMenu().pack(); } }); JPopupMenu popup = new JPopupMenu("popup"); buttonUpdateDatasource.setPopupMenu(popup); toolBar.add(buttonUpdateDatasource); JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH); // temp fix for size of the button buttonScrape.setText(" "); buttonScrape.setHorizontalAlignment(JButton.LEFT); buttonScrape.setSplitWidth(18); buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$ // register for listener buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() { @Override public void buttonClicked(ActionEvent e) { actionScrape.actionPerformed(e); } @Override public void splitButtonClicked(ActionEvent e) { } }); popup = new JPopupMenu("popup"); JMenuItem item = new JMenuItem(actionScrape2); popup.add(item); // item = new JMenuItem(actionScrapeUnscraped); // popup.add(item); item = new JMenuItem(actionScrapeSelected); popup.add(item); item = new JMenuItem(actionScrapeNewItems); popup.add(item); buttonScrape.setPopupMenu(popup); toolBar.add(buttonScrape); toolBar.add(actionEdit); JButton btnMediaInformation = new JButton(); btnMediaInformation.setAction(actionMediaInformation); toolBar.add(btnMediaInformation); // install drawing of full with tree = new ZebraJTree(treeModel) { private static final long serialVersionUID = 2422163883324014637L; @Override public void paintComponent(Graphics g) { width = this.getWidth(); super.paintComponent(g); } }; tvShowSelectionModel = new TvShowSelectionModel(tree); TreeUI ui = new TreeUI() { @Override protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { bounds.width = width - bounds.x; super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } }; tree.setUI(ui); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setCellRenderer(new TvShowTreeCellRenderer()); tree.setRowHeight(0); scrollPane.setViewportView(tree); JPanel panelHeader = new JPanel() { private static final long serialVersionUID = -6914183798172482157L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, getWidth(), getHeight()); } }; scrollPane.setColumnHeaderView(panelHeader); panelHeader.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$ lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER); panelHeader.add(lblTvShowsColumn, "2, 1"); JLabel lblNfoColumn = new JLabel(""); lblNfoColumn.setHorizontalAlignment(JLabel.CENTER); lblNfoColumn.setIcon(IconManager.INFO); lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$ panelHeader.add(lblNfoColumn, "4, 1"); JLabel lblImageColumn = new JLabel(""); lblImageColumn.setHorizontalAlignment(JLabel.CENTER); lblImageColumn.setIcon(IconManager.IMAGE); lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$ panelHeader.add(lblImageColumn, "5, 1"); JLabel lblSubtitleColumn = new JLabel(""); lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER); lblSubtitleColumn.setIcon(IconManager.SUBTITLE); lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$ panelHeader.add(lblSubtitleColumn, "6, 1"); JPanel panel = new JPanel(); panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$ panel.add(lblTvShowsT, "1, 2, fill, fill"); lblTvShows = new JLabel(""); panel.add(lblTvShows, "3, 2"); JLabel labelSlash = new JLabel("/"); panel.add(labelSlash, "5, 2"); JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$ panel.add(lblEpisodesT, "7, 2"); lblEpisodes = new JLabel(""); panel.add(lblEpisodes, "9, 2"); JLayeredPane layeredPaneRight = new JLayeredPane(); layeredPaneRight.setLayout( new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") }, new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") })); panelRight = new JPanel(); layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill"); layeredPaneRight.setLayer(panelRight, 0); // glass pane final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree); panelExtendedSearch.setVisible(false); // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill"); btnFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (panelExtendedSearch.isVisible() == true) { panelExtendedSearch.setVisible(false); } else { panelExtendedSearch.setVisible(true); } } }); // add a propertychangelistener which reacts on setting a filter tree.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("filterChanged".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { btnFilter.setIcon(IconManager.FILTER_ACTIVE); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$ } else { btnFilter.setIcon(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ } } } }); layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill"); layeredPaneRight.setLayer(panelExtendedSearch, 1); splitPane.setRightComponent(layeredPaneRight); panelRight.setLayout(new CardLayout(0, 0)); JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel); panelRight.add(panelTvShow, "tvShow"); JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel); panelRight.add(panelTvShowSeason, "tvShowSeason"); JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel); panelRight.add(panelTvShowEpisode, "tvShowEpisode"); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { // click on a tv show if (node.getUserObject() instanceof TvShow) { TvShow tvShow = (TvShow) node.getUserObject(); tvShowSelectionModel.setSelectedTvShow(tvShow); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShow"); } // click on a season if (node.getUserObject() instanceof TvShowSeason) { TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject(); tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowSeason"); } // click on an episode if (node.getUserObject() instanceof TvShowEpisode) { TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject(); tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowEpisode"); } } else { // check if there is at least one tv show in the model TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot(); if (root.getChildCount() == 0) { // sets an inital show tvShowSelectionModel.setSelectedTvShow(null); } } } }); addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { menu.setVisible(false); super.componentHidden(e); } @Override public void componentShown(ComponentEvent e) { menu.setVisible(true); super.componentHidden(e); } }); // further initializations init(); initDataBindings(); // selecting first TV show at startup if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) { DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel() .getRoot()).getFirstChild(); tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath())); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); } }
From source file:org.zaproxy.zap.extension.browserView.ResponseBrowserView.java
private JToolBar createToolbar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);// ww w . ja v a2 s.co m toolBar.setMinimumSize(new Dimension(50, 50)); JButton button = createAdjustHeightButton(); toolBar.add(button); return toolBar; }
From source file:org.zaproxy.zap.extension.fuzz.httpfuzzer.ui.HttpFuzzResultsContentPanel.java
public HttpFuzzResultsContentPanel() { super(new BorderLayout()); tabbedPane = new JTabbedPane(); toolbar = new JToolBar(); toolbar.setFloatable(false);// w ww . ja va 2s.c o m toolbar.setRollover(true); messageCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.messagesSent")); messageCountValueLabel = new JLabel("0"); errorCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.errors")); errorCountValueLabel = new JLabel("0"); showErrorsToggleButton = new ZapToggleButton( Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.label")); showErrorsToggleButton.setEnabled(false); showErrorsToggleButton.setToolTipText( Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip")); showErrorsToggleButton.setSelectedToolTipText( Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.selected")); showErrorsToggleButton.setDisabledToolTipText( Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.disabled")); showErrorsToggleButton .setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/050.png"))); showErrorsToggleButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (ItemEvent.SELECTED == e.getStateChange()) { showTabs(); } else { hideErrorsTab(); } } }); toolbar.add(Box.createHorizontalStrut(4)); toolbar.add(messageCountLabel); toolbar.add(Box.createHorizontalStrut(4)); toolbar.add(messageCountValueLabel); toolbar.add(Box.createHorizontalStrut(32)); toolbar.add(errorCountLabel); toolbar.add(Box.createHorizontalStrut(4)); toolbar.add(errorCountValueLabel); toolbar.add(Box.createHorizontalStrut(16)); toolbar.add(showErrorsToggleButton); JButton button = new JButton(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export")); button.setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/115.png"))); button.addActionListener((new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { WritableFileChooser chooser = new WritableFileChooser( Model.getSingleton().getOptionsParam().getUserDirectory()) { private static final long serialVersionUID = -1660943014924270012L; @Override public void approveSelection() { File file = getSelectedFile(); if (file != null) { String filePath = file.getAbsolutePath(); if (!filePath.toLowerCase(Locale.ROOT).endsWith(CSV_EXTENSION)) { setSelectedFile(new File(filePath + CSV_EXTENSION)); } } super.approveSelection(); } }; chooser.setSelectedFile(new File( Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export.defaultName"))); if (chooser .showSaveDialog(View.getSingleton().getMainFrame()) == WritableFileChooser.APPROVE_OPTION) { boolean success = true; try (CSVPrinter pw = new CSVPrinter( Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8), CSVFormat.DEFAULT)) { pw.printRecord(currentFuzzer.getMessagesModel().getHeaders()); int count = currentFuzzer.getMessagesModel().getRowCount(); for (int i = 0; i < count; i++) { List<Object> valueOfRow = currentFuzzer.getMessagesModel().getEntry(i) .getValuesOfHeaders(); String customStateValue = fuzzResultTable.getCustomStateValue( currentFuzzer.getMessagesModel().getEntry(i).getCustomStates()); valueOfRow.add(13, customStateValue); pw.printRecord(valueOfRow); } } catch (Exception ex) { success = false; JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(), Constant.messages .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageError") + "\n" + ex.getLocalizedMessage()); logger.error("Export Failed: " + ex); } // Delay the presentation of success message, to ensure all the data was // already flushed. if (success) { JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(), Constant.messages .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageSuccessful")); } } } })); toolbar.add(Box.createHorizontalGlue()); toolbar.add(button); mainPanel = new JPanel(new BorderLayout()); fuzzResultTable = new HttpFuzzerResultsTable(RESULTS_PANEL_NAME, EMPTY_RESULTS_MODEL); errorsTable = new HttpFuzzerErrorsTable(ERRORS_PANEL_NAME, EMPTY_ERRORS_MODEL); fuzzResultTableScrollPane = new JScrollPane(); fuzzResultTableScrollPane.setViewportView(fuzzResultTable); errorsTableScrollPane = new JScrollPane(); errorsTableScrollPane.setViewportView(errorsTable); mainPanel.add(fuzzResultTableScrollPane); add(toolbar, BorderLayout.PAGE_START); add(mainPanel, BorderLayout.CENTER); }
From source file:org.zaproxy.zap.extension.httppanel.HttpPanel.java
private void initUi() { allOptions = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); componentOptions = new JPanel(new BorderLayout(0, 0)); moreOptionsComponent = new JPanel(new BorderLayout(0, 0)); toolBarComponents = new JToolBar(); toolBarComponents.setFloatable(false); toolBarComponents.setBorder(BorderFactory.createEmptyBorder()); toolBarComponents.setRollover(true); toolBarMoreOptions = new JToolBar(); toolBarMoreOptions.setFloatable(false); toolBarMoreOptions.setBorder(BorderFactory.createEmptyBorder()); toolBarMoreOptions.setRollover(true); endAllOptions = new JPanel(); JPanel panel1 = new JPanel(new BorderLayout(0, 0)); JPanel panelFlow = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); panelFlow.add(allOptions);/* www . j a v a2s .com*/ panelFlow.add(componentOptions); panelFlow.add(toolBarComponents); panelFlow.add(moreOptionsComponent); panelFlow.add(toolBarMoreOptions); panel1.add(panelFlow, BorderLayout.WEST); panelFlow = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); panelFlow.add(endAllOptions); panel1.add(panelFlow, BorderLayout.EAST); panelHeader.add(panel1, BorderLayout.NORTH); //getPanelContent().add(new EmptyComponent(), ""); initComponents(); setMessage(null); }