List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:org.openconcerto.erp.core.finance.accounting.ui.PlanComptableGPanel.java
private void uiInit() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.setOpaque(false); this.panelCompte.setOpaque(false); this.panelInfosCompte.setOpaque(false); this.panelDetails.setOpaque(false); this.panelCompte.setLayout(new GridBagLayout()); this.panelInfosCompte.setLayout(new GridBagLayout()); this.panelDetails.setLayout(new GridBagLayout()); /******************************************************************************************* * * RadioButton Selection du mode d'affichage du PCG abrege, base ou developp Panel * Details/*from www. j ava2 s. com*/ ******************************************************************************************/ this.panelDetails.add(this.radioCompteBase, c); this.radioCompteBase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCompteTable(); } }); c.gridy++; this.panelDetails.add(this.radioCompteAbrege, c); this.radioCompteAbrege.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCompteTable(); } }); c.gridy++; this.panelDetails.add(this.radioCompteDeveloppe, c); this.radioCompteDeveloppe.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCompteTable(); } }); ButtonGroup grp1 = new ButtonGroup(); grp1.add(this.radioCompteBase); grp1.add(this.radioCompteAbrege); grp1.add(this.radioCompteDeveloppe); this.radioCompteBase.setSelected(true); /******************************************************************************************* * ** Panel Compte ******************************************************************************************/ c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0; c.weighty = 0; this.panelDetails.setBorder(BorderFactory.createTitledBorder("Dtails")); this.panelCompte.add(this.panelDetails, c); /******************************************************************************************* * * Affichage du plan comptable ******************************************************************************************/ SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); SQLTable classeCompteTable = base.getTable("CLASSE_COMPTE"); SQLSelect selClasse = new SQLSelect(base); selClasse.addSelect(classeCompteTable.getField("ID")); selClasse.addSelect(classeCompteTable.getField("NOM")); selClasse.addSelect(classeCompteTable.getField("TYPE_NUMERO_COMPTE")); selClasse.addRawOrder("\"CLASSE_COMPTE\".\"TYPE_NUMERO_COMPTE\""); String reqClasse = selClasse.asString(); Object obClasse = base.getDataSource().execute(reqClasse, new ArrayListHandler()); List myListClasse = (List) obClasse; if (myListClasse.size() != 0) { for (int k = 0; k < myListClasse.size(); k++) { Object[] objTmp = (Object[]) myListClasse.get(k); ClasseCompte ccTmp = new ClasseCompte(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString(), objTmp[2].toString()); this.classeComptes.add(ccTmp); JTable tab = creerJTable(ccTmp); this.tables.add(tab); this.tabbedClasse.add(ccTmp.getNom(), new JScrollPane(tab)); } } c.gridwidth = 4; c.gridheight = 6; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.gridx++; c.gridy = 0; this.panelCompte.add(this.tabbedClasse, c); /******************************************************************************************* * * Informations sur le compte selectionn Panel Infos Compte ******************************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; c.gridy = 0; c.gridx = 0; TitledSeparator sep = new TitledSeparator("Informations sur le compte"); this.panelInfosCompte.add(sep, c); GridBagConstraints cInfos = new GridBagConstraints(); cInfos.insets = new Insets(0, 0, 0, 0); cInfos.fill = GridBagConstraints.BOTH; cInfos.anchor = GridBagConstraints.NORTHWEST; cInfos.gridx = 0; cInfos.gridy = 0; cInfos.gridwidth = 1; cInfos.gridheight = 1; cInfos.weightx = 1; cInfos.weighty = 1; this.textInfos.setFont(this.getFont()); this.textInfos.setEditable(false); JPanel infos = new JPanel(new GridBagLayout()); infos.add(this.textInfos, cInfos); JScrollPane scrollInfos = new JScrollPane(infos); c.insets = new Insets(0, 0, 0, 0); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = GridBagConstraints.REMAINDER; this.panelInfosCompte.add(scrollInfos, c); this.panelInfosCompte.setMinimumSize(new Dimension(100, 80)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.panelCompte, this.panelInfosCompte); split.setBorder(null); this.add(split, c); }
From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private ValidState validVarName; private JRadioButton radioVal = new JRadioButton("Valeur"); private JRadioButton radioFormule = new JRadioButton("Formule"); private final JTextField textValeur = new JTextField(); // private final ITextArea textFormule = new ITextArea(); private final VariableTree treeVariable = new VariableTree(); private final JTextField textNom = new JTextField(); private final JLabel labelWarningBadVar = new JLabelWarning(); private ElementComboBox comboSelSal; private EditFrame edit = null; private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree()); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.validVarName = null; this.textFormule.setEditable(false); // Arbre des variables JScrollPane sc = new JScrollPane(this.treeVariable); sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height)); this.treeVariable.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent mE) { if (mE.getButton() == MouseEvent.BUTTON3) { JPopupMenu menuDroit = new JPopupMenu(); TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); final Object obj = path.getLastPathComponent(); if ((obj == null) || !(obj instanceof VariableRowTreeNode)) { return; }// w ww.j av a2s . c o m menuDroit.add(new AbstractAction("Editer") { public void actionPerformed(ActionEvent e) { if (edit == null) { edit = new EditFrame(getElement(), EditFrame.MODIFICATION); } System.err.println("Action performed"); if (obj != null) { System.err.println("Object not null --> " + obj.toString()); if (obj instanceof VariableRowTreeNode) { System.err.println("Object VariableRowTreeNode"); VariableRowTreeNode varNode = (VariableRowTreeNode) obj; edit.selectionId(varNode.getID(), 1); edit.setVisible(true); } } } }); menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y); } else { if (mE.getClickCount() == 2) { TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); Object obj = path.getLastPathComponent(); if (obj != null) { if (obj instanceof FormuleTreeNode) { final FormuleTreeNode n = (FormuleTreeNode) obj; int start = textFormule.getSelectionStart(); String tmp = textFormule.getText(); textFormule.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length())); } } } } } }); JPanel panelDroite = new JPanel(); panelDroite.setLayout(new GridBagLayout()); // Categorie JTextField textCategorie = new JTextField(); c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy = 0; JLabel labelCategorie = new JLabel("Catgorie"); panelDroite.add(labelCategorie, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(textCategorie, c); c.gridwidth = 1; // Nom c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy++; JLabel labelNom = new JLabel("Nom"); panelDroite.add(labelNom, c); c.gridx++; c.weightx = 1; panelDroite.add(this.textNom, c); this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateValidVarName(); } }); c.gridx++; c.weightx = 0; panelDroite.add(this.labelWarningBadVar, c); // Description JLabel labelInfos = new JLabel(getLabelFor("INFOS")); ITextArea textInfos = new ITextArea(); c.gridy++; c.gridx = 1; c.gridwidth = 1; c.weightx = 0; panelDroite.add(labelInfos, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; panelDroite.add(textInfos, c); // Valeur c.gridx = 1; c.gridy++; c.gridwidth = 1; c.weightx = 0; panelDroite.add(this.radioVal, c); c.gridx++; c.weightx = 1; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textValeur, c); c.gridwidth = 1; c.gridx = 1; c.gridy++; panelDroite.add(this.radioFormule, c); c.gridx++; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textFormule, c); c.gridwidth = 1; ButtonGroup group = new ButtonGroup(); group.add(this.radioVal); group.add(this.radioFormule); this.radioVal.setSelected(true); setFormuleEnabled(false); this.radioVal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(false); } }); this.radioFormule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(true); } }); c.gridy++; c.gridx = 1; c.weighty = 0; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.comboSelSal = new ElementComboBox(false); this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class)); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; panelDroite.add(this.comboSelSal, c); c.gridwidth = 1; JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; this.add(split, c); this.addRequiredSQLObject(this.textNom, "NOM"); this.addSQLObject(this.textValeur, "VALEUR"); this.addSQLObject(this.textFormule, "FORMULE"); this.addSQLObject(textCategorie, "CATEGORIE"); this.addSQLObject(textInfos, "INFOS"); this.comboSelSal.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // TODO Auto-generated method stub textFormule.setSalarieID(comboSelSal.getSelectedId()); } }); } @Override public synchronized ValidState getValidState() { return super.getValidState().and(this.validVarName); } private void setFormuleEnabled(boolean b) { if (b) { this.textValeur.setText(""); } else { this.textFormule.setText(""); } this.textValeur.setEditable(!b); this.textValeur.setEnabled(!b); this.textFormule.setEditable(b); this.textFormule.setEnabled(b); this.treeVariable.setEnabled(b); this.treeVariable.setEditable(b); } private void setValidVarName(ValidState s) { if (!s.equals(this.validVarName)) { this.validVarName = s; final boolean warningVisible = !s.isValid(); if (warningVisible) this.labelWarningBadVar.setText(s.getValidationText()); this.labelWarningBadVar.setVisible(warningVisible); this.fireValidChange(); } } private void updateValidVarName() { this.setValidVarName(this.computeValidVarName()); } private ValidState computeValidVarName() { // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _) final String varName = this.textNom.getText().trim(); System.err.println("Verification de la validit du nom de la variable."); if (varName.length() == 0) { return VAR_NO_NAME; } // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre if (!isJavaVar(varName)) { return VAR_NAME_NOT_CORRECT; } // on vrifie que la variable n'existe pas dja SQLSelect selAllVarName = new SQLSelect(getTable().getBase()); selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID")); Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName); w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID())); selAllVarName.setWhere(w); String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "' // REGEXP VARIABLE_PAYE.NOM"; Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName, new ArrayListHandler())).toArray(); if (objKeysRowName.length > 0) { return VAR_ALREADY_EXIST; } else { // Impossible de crer une variable du meme nom qu'un champ du salarie if (isForbidden(varName)) return VAR_ALREADY_EXIST; this.textFormule.setVarAssign(varName); return ValidState.getTrueInstance(); } } private boolean isJavaVar(String s) { if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) { System.err.println("Erreur la variable commence par un chiffre!!"); return false; } else { for (int i = 0; i < s.length(); i++) { if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z') || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) { System.err.println("Erreur la variable contient un caractere incorrect!!"); return false; } } return (!CTokenMarker.getKeywords().isExisting(s)); } } @Override public void select(SQLRowAccessor r) { super.select(r); // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " + // this.hashCode()); if (r != null) { if (r.getString("FORMULE").trim().length() == 0) { this.radioVal.setSelected(true); setFormuleEnabled(false); } else { this.radioFormule.setSelected(true); setFormuleEnabled(true); } this.textFormule.setVarAssign(r.getString("NOM")); } this.updateValidVarName(); } }; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Initializes the components composing the display. * //from www .j ava2 s. c o m * @param filters The filters to handle. * @param importerAction The cancel-all-imports action. */ private void initComponents(FileFilter[] filters, ImporterAction importerAction) { canvas = new QuotaCanvas(); sizeImportLabel = new JLabel(); diskSpacePane = new JPanel(); diskSpacePane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); diskSpacePane.add(UIUtilities.setTextFont(TEXT_FREE_SPACE)); diskSpacePane.add(canvas); showThumbnails = new JCheckBox(TEXT_SHOW_THUMBNAILS); showThumbnails.setVisible(false); Registry registry = ImporterAgent.getRegistry(); Boolean loadThumbnails = (Boolean) registry.lookup(LOAD_THUMBNAIL); if (loadThumbnails != null) { if (loadThumbnails.booleanValue()) { showThumbnails.setVisible(true); showThumbnails.setSelected(loadThumbnails.booleanValue()); } } if (!isFastConnection()) // slow connection showThumbnails.setSelected(false); long groupId = -1; if (model.getSelectedGroup() != null) groupId = model.getSelectedGroup().getGroupId(); if (groupId < 0) groupId = ImporterAgent.getUserDetails().getGroupId(); locationDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, true); locationDialog.addPropertyChangeListener(this); int plugin = ImporterAgent.runAsPlugin(); if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) { detachedDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, false); detachedDialog.addPropertyChangeListener(this); } tagSelectionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src instanceof JButton) { TagAnnotationData tag = tagsMap.get(src); if (tag != null) { tagsMap.remove(src); handleTagsSelection(tagsMap.values()); } } } }; tabbedPane = new JTabbedPane(); numberOfFolders = new NumericalTextField(); numberOfFolders.setMinimum(0); numberOfFolders.setText("0"); numberOfFolders.setColumns(3); numberOfFolders.addPropertyChangeListener(this); tagsMap = new LinkedHashMap<JButton, TagAnnotationData>(); IconManager icons = IconManager.getInstance(); refreshFilesButton = new JButton(TEXT_REFRESH_FILES); refreshFilesButton.setBackground(UIUtilities.BACKGROUND); refreshFilesButton.setToolTipText(TOOLTIP_REFRESH_FILES); refreshFilesButton.setActionCommand("" + CMD_REFRESH_FILES); refreshFilesButton.addActionListener(this); tagButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(tagButton); tagButton.addActionListener(this); tagButton.setActionCommand("" + CMD_TAG); tagButton.setToolTipText(TOOLTIP_ADD_TAGS); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); overrideName = new JCheckBox(TEXT_OVERRIDE_FILE_NAMING); overrideName.setToolTipText(UIUtilities.formatToolTipText(WARNING)); overrideName.setSelected(true); ButtonGroup group = new ButtonGroup(); fullName = new JRadioButton(TEXT_NAMING_FULL_PATH); group.add(fullName); partialName = new JRadioButton(); partialName.setText(TEXT_NAMING_PARTIAL_PATH); partialName.setSelected(true); group.add(partialName); table = new FileSelectionTable(this); table.addPropertyChangeListener(this); chooser = new GenericFileChooser(); JList list = (JList) UIUtilities.findComponent(chooser, JList.class); KeyAdapter ka = new KeyAdapter() { /** * Adds the files to the import queue. * * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { handleEnterKeyPressed(e.getSource()); } } }; if (list != null) list.addKeyListener(ka); if (list == null) { JTable t = (JTable) UIUtilities.findComponent(chooser, JTable.class); if (t != null) t.addKeyListener(ka); } try { File f = UIUtilities.getDefaultFolder(); if (f != null) chooser.setCurrentDirectory(f); } catch (Exception e) { // Ignore: could not set the default container } chooser.addPropertyChangeListener(this); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setControlButtonsAreShown(false); chooser.setApproveButtonText(TEXT_IMPORT); chooser.setApproveButtonToolTipText(TOOLTIP_IMPORT); bioFormatsFileFilters = new ArrayList<FileFilter>(); if (filters != null) { chooser.setAcceptAllFileFilterUsed(false); for (FileFilter fileFilter : filters) { if (fileFilter instanceof ComboFileFilter) { bioFormatsFileFiltersCombined = fileFilter; ComboFileFilter comboFilter = (ComboFileFilter) fileFilter; FileFilter[] extensionFilters = comboFilter.getFilters(); for (FileFilter combinedFilter : extensionFilters) { bioFormatsFileFilters.add(combinedFilter); } break; } } chooser.addChoosableFileFilter(bioFormatsFileFiltersCombined); for (FileFilter fileFilter : bioFormatsFileFilters) { chooser.addChoosableFileFilter(fileFilter); } chooser.setFileFilter(bioFormatsFileFiltersCombined); } else { chooser.setAcceptAllFileFilterUsed(true); } closeButton = new JButton(TEXT_CLOSE); closeButton.setToolTipText(TOOLTIP_CLOSE); closeButton.setActionCommand("" + CMD_CLOSE); closeButton.addActionListener(this); cancelImportButton = new JButton(importerAction); importerAction.setEnabled(false); importButton = new JButton(TEXT_IMPORT); importButton.setToolTipText(TOOLTIP_IMPORT); importButton.setActionCommand("" + CMD_IMPORT); importButton.addActionListener(this); importButton.setEnabled(false); pixelsSize = new ArrayList<NumericalTextField>(); NumericalTextField field; for (int i = 0; i < 3; i++) { field = new NumericalTextField(); field.setNumberType(Double.class); field.setColumns(2); pixelsSize.add(field); } List<Component> boxes = UIUtilities.findComponents(chooser, JComboBox.class); if (boxes != null) { JComboBox box; JComboBox filterBox = null; Iterator<Component> i = boxes.iterator(); while (i.hasNext()) { box = (JComboBox) i.next(); Object o = box.getItemAt(0); if (o instanceof FileFilter) { filterBox = box; break; } } if (filterBox != null) { filterBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { String value = KeyEvent.getKeyText(e.getKeyCode()); JComboBox box = (JComboBox) e.getSource(); int n = box.getItemCount(); FileFilter filter; FileFilter selectedFilter = null; String d; for (int j = 0; j < n; j++) { filter = (FileFilter) box.getItemAt(j); d = filter.getDescription(); if (d.startsWith(value)) { selectedFilter = filter; break; } } if (selectedFilter != null) box.setSelectedItem(selectedFilter); } }); } } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** * Brings up the <code>ManagePopupMenu</code>on top of the specified * component at the specified location.//from ww w . ja va2s . c om * * @param c The component that requested the po-pup menu. * @param p The point at which to display the menu, relative to the * <code>component</code>'s coordinates. */ private void showPersonalMenu(Component c, Point p) { if (p == null) return; if (c == null) throw new IllegalArgumentException("No component."); personalMenu = new JPopupMenu(); personalMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); List<GroupSelectionAction> l = controller.getUserGroupAction(); Iterator<GroupSelectionAction> i = l.iterator(); GroupSelectionAction a; JCheckBoxMenuItem item; ButtonGroup buttonGroup = new ButtonGroup(); long id = model.getGroupId(); while (i.hasNext()) { a = i.next(); item = new JCheckBoxMenuItem(a); item.setEnabled(true); item.setSelected(a.isSameGroup(id)); initMenuItem(item); buttonGroup.add(item); personalMenu.add(item); } personalMenu.show(c, p.x, p.y); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Creates the menu bar./*from www. j av a2s . com*/ * * @param pref The user preferences. * @return The menu bar. */ private JMenuBar createMenuBar(ViewerPreferences pref) { zoomMenu = new JMenu("Zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomingGroup = new ButtonGroup(); //Create zoom grid menu zoomGridMenu = new JMenu("Zoom"); zoomingGridGroup = new ButtonGroup(); JMenuBar menuBar = new JMenuBar(); menuBar.add(createControlsMenu(pref)); menuBar.add(createViewMenu(pref)); if (!model.isBigImage()) menuBar.add(createZoomMenu(pref, true)); menuBar.add(createShowViewMenu()); TaskBar tb = ImViewerAgent.getRegistry().getTaskBar(); //menuBar.add(tb.getWindowsMenu()); menuBar.add(tb.getMenu(TaskBar.WINDOW_MENU)); menuBar.add(tb.getMenu(TaskBar.HELP_MENU)); return menuBar; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Helper method to create the background color sub-menu. * // w w w . j a va 2 s.c o m * @param pref The user preferences. * @return See above. */ private JMenuItem createBackgroundColorSubMenu(ViewerPreferences pref) { JMenu menu = new JMenu("Background color"); bgColorGroup = new ButtonGroup(); Iterator<Entry<Color, String>> i = backgrounds.entrySet().iterator(); ColorCheckBoxMenuItem item; Color c; Color refColor = ImagePaintingFactory.DEFAULT_BACKGROUND; if (pref != null) refColor = pref.getBackgroundColor(); if (refColor == null) refColor = ImagePaintingFactory.DEFAULT_BACKGROUND; Entry<Color, String> entry; while (i.hasNext()) { entry = i.next(); c = entry.getKey(); item = new ColorCheckBoxMenuItem(c); item.setText(entry.getValue()); item.setSelected(c.equals(refColor)); bgColorGroup.add(item); menu.add(item); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ColorCheckBoxMenuItem src = (ColorCheckBoxMenuItem) e.getSource(); if (src.isSelected()) { controller.setPreferences(); if (lens != null) lens.setBackgroundColor(src.getColor()); model.getBrowser().setBackgroundColor(src.getColor()); } } }); } return menu; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Helper method to create the unit bar color sub-menu. * //from ww w .ja v a 2 s . c o m * @param pref The user preferences. * @return See above. */ private JMenuItem createScaleBarColorSubMenu(ViewerPreferences pref) { JMenu menu = new JMenu("Scale bar/Text color"); ButtonGroup group = new ButtonGroup(); Iterator<Entry<Color, String>> i = EditorUtil.COLORS_BAR.entrySet().iterator(); ColorCheckBoxMenuItem item; Color c; Color refColor = ImagePaintingFactory.UNIT_BAR_COLOR; if (pref != null) refColor = pref.getScaleBarColor(); if (refColor == null) refColor = ImagePaintingFactory.UNIT_BAR_COLOR; Entry<Color, String> entry; while (i.hasNext()) { entry = i.next(); c = entry.getKey(); item = new ColorCheckBoxMenuItem(c); item.setText(entry.getValue()); item.setSelected(c.equals(refColor)); group.add(item); menu.add(item); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ColorCheckBoxMenuItem source = (ColorCheckBoxMenuItem) e.getSource(); if (source.isSelected()) model.getBrowser().setUnitBarColor(source.getColor()); } }); } return menu; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Helper method to create the unit bar sub-menu. * /*from w w w . j a v a 2s . c om*/ * @param pref The user preferences. * @return See above. */ private JMenu createScaleBarLengthSubMenu(ViewerPreferences pref) { scaleBarMenu = new JMenu(SCALE_BAR_TEXT + model.getUnits() + ")"); scaleBarGroup = new ButtonGroup(); if (pref != null && pref.getScaleBarIndex() > 0) defaultIndex = pref.getScaleBarIndex(); UnitBarSizeAction a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_ONE); JCheckBoxMenuItem item = new JCheckBoxMenuItem(a); item.setSelected(a.getIndex() == defaultIndex); scaleBarGroup.add(item); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TWO); item = new JCheckBoxMenuItem(a); item.setSelected(a.getIndex() == defaultIndex); scaleBarGroup.add(item); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_FIVE); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_FIVE)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TEN); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_TEN)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TWENTY); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_TWENTY)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_FIFTY); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_FIFTY)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_HUNDRED); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_HUNDRED)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_CUSTOM); item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_CUSTOM)); scaleBarGroup.add(item); item.setSelected(a.getIndex() == defaultIndex); scaleBarMenu.add(item); return scaleBarMenu; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Helper method to create the controls menu. * /*from www .j a va 2s.c o m*/ * @param pref The user preferences. * @return The controls sub-menu. */ private JMenu createControlsMenu(ViewerPreferences pref) { JMenu menu = new JMenu("Controls"); menu.setMnemonic(KeyEvent.VK_C); ViewerAction action = controller.getAction(ImViewerControl.RENDERER); rndItem = new JCheckBoxMenuItem(); rndItem.setSelected(isRendererShown()); rndItem.setAction(action); rndItem.setText(action.getName()); if (pref != null) rndItem.setSelected(pref.isRenderer()); //menu.add(rndItem); action = controller.getAction(ImViewerControl.METADATA); metadataItem = new JCheckBoxMenuItem(); metadataItem.setSelected(isRendererShown()); metadataItem.setAction(action); metadataItem.setText(action.getName()); if (pref != null) metadataItem.setSelected(pref.isRenderer()); //menu.add(metadataItem); action = controller.getAction(ImViewerControl.HISTORY); historyItem = new JCheckBoxMenuItem(); historyItem.setSelected(isHistoryShown()); historyItem.setAction(action); historyItem.setText(action.getName()); if (pref != null) historyItem.setSelected(pref.isHistory()); //menu.add(historyItem); action = controller.getAction(ImViewerControl.MOVIE); JMenuItem item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); action = controller.getAction(ImViewerControl.LENS); item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); action = controller.getAction(ImViewerControl.MEASUREMENT_TOOL); item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); menu.add(new JSeparator(JSeparator.HORIZONTAL)); //Color model colorModelGroup = new ButtonGroup(); action = controller.getAction(ImViewerControl.GREY_SCALE_MODEL); item = new JCheckBoxMenuItem(); String cm = model.getColorModel(); item.setSelected(cm.equals(ImViewer.GREY_SCALE_MODEL)); item.setAction(action); colorModelGroup.add(item); menu.add(item); action = controller.getAction(ImViewerControl.RGB_MODEL); item = new JCheckBoxMenuItem(); item.setAction(action); item.setSelected(cm.equals(ImViewer.RGB_MODEL)); colorModelGroup.add(item); menu.add(item); menu.add(new JSeparator()); action = controller.getAction(ImViewerControl.CHANNELS_ON); item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); action = controller.getAction(ImViewerControl.CHANNELS_OFF); item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); menu.add(new JSeparator()); action = controller.getAction(ImViewerControl.SAVE); item = new JMenuItem(action); item.setText(action.getName()); menu.add(item); action = controller.getAction(ImViewerControl.PREFERENCES); item = new JMenuItem(action); item.setText(action.getName()); //menu.add(item); return menu; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates and displays the menu // w w w .j a v a 2 s.c om * @param src The invoker. * @param p The location where to show the menu. */ private void displayMenu(Component src, Point p) { JPopupMenu menu = new JPopupMenu(); ButtonGroup group = new ButtonGroup(); JCheckBoxMenuItem item = createMenuItem(SHOW_ALL); group.add(item); menu.add(item); item = createMenuItem(ADDED_BY_ME); group.add(item); menu.add(item); item = createMenuItem(ADDED_BY_OTHERS); group.add(item); menu.add(item); menu.show(src, p.x, p.y); }