List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
public ResPlanPanel(ResPlanController cntrl, CollectableResPlanModel model, DateTimeModel timeModel) { final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance(); this.controller = cntrl; this.timeModel = timeModel; this.resPlanModel = model; setLayout(new BorderLayout()); JToolBar tb = UIUtils.createNonFloatableToolBar(); tb.setFloatable(false);//from ww w . ja v a 2s.com tb.add(new AbstractAction(localeDelegate.getText("nuclos.resplan.action.refresh"), Icons.getInstance().getIconRefresh16()) { @Override public void actionPerformed(ActionEvent e) { controller.refresh(); } }); tb.add(exportAction); tb.addSeparator(); this.timeHorizon = new Interval<Date>(model.getDefaultViewFrom(), model.getDefaultViewUntil()); final LabeledComponentSupport support = new LabeledComponentSupport(); startDateChooser = new DateChooser(support, timeHorizon.getStart()); startDateChooser.setMinimumSize(startDateChooser.getPreferredSize()); startDateChooser.setMaximumSize(startDateChooser.getPreferredSize()); endDateChooser = new DateChooser(support, timeHorizon.getEnd()); endDateChooser.setMinimumSize(endDateChooser.getPreferredSize()); endDateChooser.setMaximumSize(endDateChooser.getPreferredSize()); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.from"))); tb.add(startDateChooser); tb.add(Box.createHorizontalStrut(5)); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.until"))); tb.add(endDateChooser); timeGranularityModel = new ListComboBoxModel<ResPlanController.TimeGranularity>( controller.getTimeGranularityOptions()); tb.addSeparator(); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.granularity"))); timeGranularityComboBox = new JComboBox(timeGranularityModel); tb.add(timeGranularityComboBox); timeGranularityComboBox .setMaximumSize(Orientation.VERTICAL.updateExtent(timeGranularityComboBox.getPreferredSize(), 20)); tb.addSeparator(); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.resourceFilter"))); searchFilterComboBox = new JComboBox(); searchFilterComboBox.setRenderer(new SearchFilterListCellRenderer()); refreshSearchFilter(); tb.add(searchFilterComboBox); searchFilterComboBox .setMaximumSize(Orientation.VERTICAL.updateExtent(searchFilterComboBox.getPreferredSize(), 20)); tb.add(Box.createGlue()); infoButton = new JButton(infoAction); infoButton.setVisible(false); tb.add(infoButton); tb.add(Box.createHorizontalStrut(3)); initJResPlan(); ActionListener dateChooserListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { timeHorzionChanged(); } }; startDateChooser.addActionListener(dateChooserListener); endDateChooser.addActionListener(dateChooserListener); timeGranularityComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Runnable runnable = createScrollToCurrentAreaRunnable(); ResPlanController.TimeGranularity granularity = timeGranularityModel.getSelectedItem(); resPlan.setTimeModel(granularity.getTimeModel()); resPlan.getTimelineHeader().setCategoryModel(granularity.getHeaderCategories()); SwingUtilities.invokeLater(runnable); } } }); searchFilterComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { EntitySearchFilter filter = (EntitySearchFilter) searchFilterComboBox.getSelectedItem(); if (filter instanceof NewCustomSearchFilter) { runCustomSearch(); return; } setSearchCondition(filter.getSearchCondition()); } } }); scrollPane = new JScrollPane(resPlan); JButton corner = new JButton(switchOrientationAction); corner.setBorderPainted(false); scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, corner); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(tb, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); resPlan.setTimeHorizon(this.timeHorizon); resPlan.invalidate(); setFocusable(true); setFocusCycleRoot(true); getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("DELETE"), "delete"); //getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control F"), "find"); getActionMap().put("delete", removeAction); //getActionMap().put("find", findAction); KeyBindingProvider.bindActionToComponent(KeyBindingProvider.ACTIVATE_SEARCH_PANEL_2, findAction, this); }
From source file:org.nuclos.client.main.mainframe.workspace.WorkspaceEditor.java
public WorkspaceEditor(WorkspaceVO wovo) { final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance(); this.wovo = wovo; this.backup = new WorkspaceVO(); this.backup.importHeader(wovo.getWoDesc()); boolean showAlwaysReset = wovo.isAssigned() && SecurityCache.getInstance().isActionAllowed(Actions.ACTION_WORKSPACE_ASSIGN); contentPanel = new JPanel(); initJPanel(contentPanel,//from w w w .ja v a 2 s . c om new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, 20, 20, 20, showAlwaysReset ? 20 : 0, 10, 20, TableLayout.FILL, TableLayout.PREFERRED }); contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel lbName = new JLabel(localeDelegate.getMessage("WorkspaceEditor.2", "Name"), JLabel.TRAILING); contentPanel.add(lbName, "0, 0"); tfName = new JTextField(15); lbName.setLabelFor(tfName); contentPanel.add(tfName, "1, 0"); chckHideName = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.3", "Name ausblenden")); contentPanel.add(chckHideName, "2, 0, 3, 0"); chckHide = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.8", "Auswahl Button ausblenden")); if (wovo.isAssigned() && SecurityCache.getInstance().isActionAllowed(Actions.ACTION_WORKSPACE_ASSIGN)) { contentPanel.add(chckHide, "4, 0"); } chckAlwaysOpenAtLogin = new JCheckBox( localeDelegate.getMessage("WorkspaceEditor.11", "Immer bei Anmeldung ffnen")); contentPanel.add(chckAlwaysOpenAtLogin, "1, 1"); JLabel lbMainFrame = new JLabel(localeDelegate.getMessage("WorkspaceEditor.9", "Hauptfenster"), JLabel.TRAILING); contentPanel.add(lbMainFrame, "0, 2"); chckHideMenuBar = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.10", "Nur Standard Menuleiste")); contentPanel.add(chckHideMenuBar, "1, 2"); chckUseLastFrameSettings = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.12", "Letzte Fenster Einstellungen bernehmen (Gre und Position)")); contentPanel.add(chckUseLastFrameSettings, "1, 3, 5, 3"); chckAlwaysReset = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.alwaysreset", "Zuletzt geffnete Tabs immer zurcksetzen")); if (showAlwaysReset) { contentPanel.add(chckAlwaysReset, "1, 4, 5, 4"); } JTabbedPane tbbdPane = new JTabbedPane(); nuclosIconChooser = new ResourceIconChooser(WorkspaceChooserController.ICON_SIZE, NuclosResourceCategory.ENTITY_ICON); nuclosIconChooser.removeBorder(); tbbdPane.addTab(localeDelegate.getMessage("WorkspaceEditor.4", "Icon"), nuclosIconChooser); JPanel parameterPanel = new JPanel(new BorderLayout()); parameterModel = new ParameterModel(); jtbParameter = new JTable(parameterModel); JScrollPane parameterScroller = new JScrollPane(jtbParameter); jtbParameter.setFillsViewportHeight(true); jtbParameter.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jtbParameter.getColumnModel().getColumn(0).setPreferredWidth(100); jtbParameter.getColumnModel().getColumn(1).setPreferredWidth(400); parameterPanel.add(parameterScroller, BorderLayout.CENTER); JToolBar parameterTools = UIUtils.createNonFloatableToolBar(JToolBar.VERTICAL); parameterTools.add(new ParameterAddButton()); btRemoveParameter = new ParameterRemoveButton(); btRemoveParameter.setEnabled(false); parameterTools.add(btRemoveParameter); parameterPanel.add(parameterTools, BorderLayout.WEST); tbbdPane.addTab(localeDelegate.getMessage("WorkspaceEditor.13", "Parameter"), parameterPanel); contentPanel.add(tbbdPane, "1, 6, 5, 7"); JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 2)); btSave = new JButton(localeDelegate.getMessage("WorkspaceEditor.5", "Speichern")); btCancel = new JButton(localeDelegate.getMessage("WorkspaceEditor.6", "Abbrechen")); actionsPanel.add(btSave); actionsPanel.add(btCancel); contentPanel.add(actionsPanel, "0, 8, 5, 8"); tfName.setText(wovo.getWoDesc().getName()); chckHide.setSelected(wovo.getWoDesc().isHide()); chckHideName.setSelected(wovo.getWoDesc().isHideName()); chckHideMenuBar.setSelected(wovo.getWoDesc().isHideMenuBar()); chckAlwaysOpenAtLogin.setSelected(wovo.getWoDesc().isAlwaysOpenAtLogin()); chckUseLastFrameSettings.setSelected(wovo.getWoDesc().isUseLastFrameSettings()); chckAlwaysReset.setSelected(wovo.getWoDesc().isAlwaysReset()); nuclosIconChooser.setSelected(wovo.getWoDesc().getNuclosResource()); parameterModel.setParamters(wovo.getWoDesc().getParameters()); dialog = new JDialog(Main.getInstance().getMainFrame(), localeDelegate.getMessage("WorkspaceEditor.1", "Arbeitsumgebung Eigenschaften"), true); dialog.setContentPane(contentPanel); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.getRootPane().setDefaultButton(btSave); Rectangle mfBounds = Main.getInstance().getMainFrame().getBounds(); dialog.setBounds(mfBounds.x + (mfBounds.width / 2) - 300, mfBounds.y + (mfBounds.height / 2) - 200, 600, 400); dialog.setResizable(false); initListener(); dialog.setVisible(true); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates a tool bar and adds the passed buttons to it. * //from w ww. ja v a2 s.co m * @param addButton The button to add. * @param removeButton The button to add. * @return See above. */ private JToolBar createBar(JButton addButton, JButton removeButton) { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.setBorder(null); bar.setBackground(UIUtilities.BACKGROUND_COLOR); if (addButton != null) bar.add(addButton); if (removeButton != null) bar.add(removeButton); return bar; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java
/** Builds and lays out the UI. */ private void buildGUI() { setBackground(UIUtilities.BACKGROUND_COLOR); setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); add(label);//from w ww.j ava2 s . c o m JToolBar bar = new JToolBar(); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.setOpaque(true); boolean b = setControlsEnabled(data != null); int count = 0; if (editButton != null) count++; if (unlinkButton != null) count++; if (downloadButton != null) count++; if (infoButton != null) count++; if (openButton != null) count++; if (count > 0 && data != null) { menuButton.setEnabled(true); if (model.isAcrossGroups()) menuButton.setEnabled(false); bar.add(menuButton); if (!b) bar.add(Box.createHorizontalStrut(8)); add(bar); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java
/** * Builds the tool bar.//from w ww . j a va2 s . c o m * * @return See above. */ private JComponent buildToolBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.add(downloadButton); return bar; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Lays out the components using a <code>FlowLayout</code>. * // w ww . j a v a 2s .c o m * @param button The component to lay out. * @param component The component to lay out. * @param sizeRow The size of the row. * @return See above. */ private JPanel layoutEditablefield(Component button, JComponent component, int sizeRow) { JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; if (button != null) { JToolBar bar = new JToolBar(); bar.setBorder(null); bar.setFloatable(false); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.add(button); p.add(bar, c); c.gridx++; } if (sizeRow > 0) { c.ipady = sizeRow; c.gridheight = 2; } p.add(component, c); JPanel content = UIUtilities.buildComponentPanel(p, 0, 0); content.setBackground(UIUtilities.BACKGROUND_COLOR); return content; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** * Builds the general bar.//from www. ja va 2 s .c o m * * @return See above. */ private JComponent buildGeneralBar() { JToolBar bar = new JToolBar(); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.add(saveButton); bar.add(Box.createHorizontalStrut(5)); bar.add(refreshButton); bar.add(Box.createHorizontalStrut(5)); bar.add(viewButton); bar.add(Box.createHorizontalStrut(5)); bar.add(linkButton); bar.add(Box.createHorizontalStrut(5)); bar.add(saveAsButton); bar.add(Box.createHorizontalStrut(5)); bar.add(publishingButton); /* if (MetadataViewerAgent.isAdministrator()) { bar.add(Box.createHorizontalStrut(5)); bar.add(uploadScriptButton); } bar.add(Box.createHorizontalStrut(5)); bar.add(scriptsButton); */ //bar.add(scriptsButton); return bar; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Helper method to create the tool bar hosting the edit items. * /*from ww w . j a va2 s . c om*/ * @return See above. */ private JToolBar createSearchBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.add(new JSeparator(JSeparator.VERTICAL)); bar.add(new JToggleButton(controller.getAction(TreeViewerControl.SEARCH))); return bar; }
From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java
/** * Invokes when the activity end. /* w ww . j a va2s .com*/ * * @param result The result of the activity. */ public void endActivity(Object result) { this.result = result; boolean busy = status.isBusy(); reset(); if (result instanceof Map) { Map<String, Object> m = convertResult((Map<String, Object>) result); int size = m.size(); this.result = m; remove(resultPane); Color c = getBackground(); if (size == 0) { JToolBar row = new JToolBar(); row.setOpaque(false); row.setFloatable(false); row.setBorder(null); row.setBackground(c); JButton button; if (errorObject != null) { button = createButton(ActivityResultRow.ERROR_TEXT, ERROR, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), ERROR, e.getX(), e.getY()); } }); row.add(button); } if (infoObject != null) { button = createButton(ActivityResultRow.INFO_TEXT, INFO, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), INFO, e.getX(), e.getY()); } }); row.add(button); } add(row, paneIndex); } else { Entry<String, Object> entry; Iterator<Entry<String, Object>> i = m.entrySet().iterator(); ActivityResultRow row = null; JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setBackground(c); int index = 0; int max = 2; JButton moreButton = null; while (i.hasNext()) { entry = (Entry<String, Object>) i.next(); this.result = entry.getValue(); row = new ActivityResultRow((String) entry.getKey(), entry.getValue(), this); row.setBackground(c); row.addPropertyChangeListener(listener); resultButtons.add(row); if (index < max) content.add(row); else { if (moreButton == null) { moreButton = createButton("" + (m.size() - max) + " more", ALL_RESULT, this); content.add(moreButton); } } index++; } if (m.size() == 1) add(row, paneIndex); else add(content, paneIndex); resultPane = content; } repaint(); } firePropertyChange(UNREGISTER_ACTIVITY_PROPERTY, null, this); notifyActivityEnd(); //Post an event to //if (busy) { EventBus bus = registry.getEventBus(); bus.post(new ActivityProcessEvent(this, busy)); //} }
From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java
/** * Helper method to create the window's toolbars panel. * This panel contains all the predefined toolbars (file, connect, and * help) as well as those specified by {@link TaskBar}. * * @return The window's toolbars panel./*from ww w .j a va2 s . c o m*/ */ private JPanel createToolBarsPanel() { createButtons(); JToolBar file = createToolBar(), connect = createToolBar(), help = createToolBar(); file.add(buttons[EXIT_BTN]); connect.add(buttons[CONNECT_BTN]); connect.add(buttons[DISCONNECT_BTN]); help.add(buttons[HELP_BTN]); JPanel bars = new JPanel(), outerPanel = new JPanel(); bars.setBorder(null); bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS)); bars.add(file); bars.add(connect); bars.add(help); outerPanel.setBorder(null); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(bars); outerPanel.add(Box.createRigidArea(new Dimension(100, 16))); outerPanel.add(Box.createHorizontalGlue()); return outerPanel; }