List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:DialogDemo.java
private JPanel createIconDialogBox() { JButton showItButton = null;/*from ww w. j a v a 2 s .c om*/ final int numButtons = 6; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); final String plainCommand = "plain"; final String infoCommand = "info"; final String questionCommand = "question"; final String errorCommand = "error"; final String warningCommand = "warning"; final String customCommand = "custom"; radioButtons[0] = new JRadioButton("Plain (no icon)"); radioButtons[0].setActionCommand(plainCommand); radioButtons[1] = new JRadioButton("Information icon"); radioButtons[1].setActionCommand(infoCommand); radioButtons[2] = new JRadioButton("Question icon"); radioButtons[2].setActionCommand(questionCommand); radioButtons[3] = new JRadioButton("Error icon"); radioButtons[3].setActionCommand(errorCommand); radioButtons[4] = new JRadioButton("Warning icon"); radioButtons[4].setActionCommand(warningCommand); radioButtons[5] = new JRadioButton("Custom icon"); radioButtons[5].setActionCommand(customCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); // no icon if (command == plainCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message", JOptionPane.PLAIN_MESSAGE); // information icon } else if (command == infoCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE); // XXX: It doesn't make sense to make a question with // XXX: only one button. // XXX: See "Yes/No (but not in those words)" for a better solution. // question icon } else if (command == questionCommand) { JOptionPane.showMessageDialog(frame, "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?", "Inane question", JOptionPane.QUESTION_MESSAGE); // error icon } else if (command == errorCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE); // warning icon } else if (command == warningCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning", JOptionPane.WARNING_MESSAGE); // custom icon } else if (command == customCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog", JOptionPane.INFORMATION_MESSAGE, icon); } } }); return create2ColPane(iconDesc + ":", radioButtons, showItButton); }
From source file:org.pentaho.support.standalone.SDSupportUtility.java
/** * initializing UI//from ww w. j ava2 s . com * * @throws Exception */ public SDSupportUtility() throws Exception { prop = loadProperty(); setResizable(false); setTitle(SDConstant.PENT_SUP_WIZARD); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 665, 516); contentPane = new JPanel(); contentPane.setBackground(UIManager.getColor("Button.background")); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblLastAttached = new JLabel("Last Attached"); lblLastAttached.setOpaque(false); lblLastAttached.setHorizontalAlignment(SwingConstants.LEFT); lblLastAttached.setBounds(322, 335, 127, 23); contentPane.add(lblLastAttached); JLabel lblPentahoCustomerSupport = new JLabel("Pentaho Customer Support Wizard"); lblPentahoCustomerSupport.setForeground(new Color(51, 51, 51)); lblPentahoCustomerSupport.setVerticalAlignment(SwingConstants.TOP); lblPentahoCustomerSupport.setHorizontalAlignment(SwingConstants.RIGHT); lblPentahoCustomerSupport.setFont(new Font("Tahoma", Font.BOLD, 23)); lblPentahoCustomerSupport.setBounds(130, 109, 506, 37); contentPane.add(lblPentahoCustomerSupport); JLabel lbllogo = new JLabel(); lbllogo.setIcon(new ImageIcon( SDSupportUtility.class.getResource("/org/pentaho/support/standalone/puc-login-logo.png"))); lbllogo.setBounds(10, 11, 409, 93); contentPane.add(lbllogo); chckbxNewCheckBoxEnvironment = new JCheckBox("Environment"); chckbxNewCheckBoxEnvironment.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.ENVIRONMENT); } else { ArgList.remove(SDConstant.ENVIRONMENT); } } }); chckbxNewCheckBoxEnvironment.setBounds(109, 268, 243, 23); contentPane.add(chckbxNewCheckBoxEnvironment); chckbxNewCheckBoxEnvironment.setOpaque(false); chckbxNewCheckBoxStructure = new JCheckBox("Structure Details"); chckbxNewCheckBoxStructure.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.STRUCT); } else { ArgList.remove(SDConstant.STRUCT); } } }); chckbxNewCheckBoxStructure.setBounds(377, 190, 248, 23); contentPane.add(chckbxNewCheckBoxStructure); chckbxNewCheckBoxStructure.setOpaque(false); chckbxLogs = new JCheckBox("Logs"); chckbxLogs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.LOGS); } else { ArgList.remove(SDConstant.LOGS); } } }); chckbxLogs.setBounds(377, 164, 248, 23); contentPane.add(chckbxLogs); chckbxLogs.setOpaque(false); chckbxGetSecureFiles = new JCheckBox("Secure Files"); chckbxGetSecureFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.SECURITY); } else { ArgList.remove(SDConstant.SECURITY); } } }); chckbxGetSecureFiles.setBounds(109, 190, 243, 23); contentPane.add(chckbxGetSecureFiles); chckbxGetSecureFiles.setOpaque(false); chckbxMd5 = new JCheckBox("MD5 Hash Value"); chckbxMd5.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.MD5); } else { ArgList.remove(SDConstant.MD5); } } }); chckbxMd5.setBounds(109, 216, 243, 23); contentPane.add(chckbxMd5); chckbxMd5.setOpaque(false); chckbxDbdetails = new JCheckBox("Datasource Details"); chckbxDbdetails.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.DATASOURCE); } else { ArgList.remove(SDConstant.DATASOURCE); } } }); chckbxDbdetails.setBounds(109, 294, 243, 23); contentPane.add(chckbxDbdetails); chckbxDbdetails.setOpaque(false); chckbxLicense = new JCheckBox("License File"); chckbxLicense.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.LICENSE); } else { ArgList.remove(SDConstant.LICENSE); } } }); chckbxLicense.setBounds(109, 164, 243, 23); contentPane.add(chckbxLicense); chckbxLicense.setOpaque(false); chckbxProcesslist = new JCheckBox("Running Process"); chckbxProcesslist.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.RUNNING_TASK); } else { ArgList.remove(SDConstant.RUNNING_TASK); } } }); chckbxProcesslist.setBounds(109, 242, 243, 23); contentPane.add(chckbxProcesslist); chckbxProcesslist.setOpaque(false); chckbxTomcatxml = new JCheckBox("XML files from Tomcat"); chckbxTomcatxml.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); tomcatXml = true; } else { ArgList.remove(SDConstant.FILE); tomcatXml = false; } } }); chckbxTomcatxml.setBounds(377, 242, 248, 23); contentPane.add(chckbxTomcatxml); chckbxTomcatxml.setOpaque(false); chckbxServerXml = new JCheckBox("XML files from Server"); chckbxServerXml.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverXml = true; } else { ArgList.remove(SDConstant.FILE); serverXml = false; } } }); chckbxServerXml.setBounds(377, 216, 248, 23); contentPane.add(chckbxServerXml); chckbxServerXml.setOpaque(false); chckbxGetBatfiles = new JCheckBox("Start up files from server"); chckbxGetBatfiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverBatFile = true; } else { ArgList.remove(SDConstant.FILE); serverBatFile = false; } } }); chckbxGetBatfiles.setBounds(377, 268, 248, 23); contentPane.add(chckbxGetBatfiles); chckbxGetBatfiles.setOpaque(false); chckbxServerproperties = new JCheckBox("Properites files from server"); chckbxServerproperties.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverProrperties = true; } else { ArgList.remove(SDConstant.FILE); serverProrperties = false; } } }); chckbxServerproperties.setBounds(377, 294, 248, 23); contentPane.add(chckbxServerproperties); chckbxServerproperties.setOpaque(false); btnNewButton = new JButton("Package"); btnNewButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { if (installType.equalsIgnoreCase("Manual")) { if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error", JOptionPane.ERROR_MESSAGE); } else { WEB_XML = new StringBuilder(); WEB_XML.append(prop.getProperty(SDConstant.BI_TOM_PATH)).append(File.separator) .append(SDConstant.WEB_APP).append(File.separator).append(SDConstant.PENTAHO) .append(File.separator).append(SDConstant.WEB_INF).append(File.separator) .append(SDConstant.WEB_XML); PENTAHO_SOLU_PATH = getSolutionPath("biserver", WEB_XML.toString()); prop.put(SDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH); prop.put(SDConstant.BI_PATH, PENTAHO_SOLU_PATH); } } if (prop.getProperty(SDConstant.BI_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_1, "Inane error", JOptionPane.ERROR_MESSAGE); } if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error", JOptionPane.ERROR_MESSAGE); } disableAll(); setBIServerPath(prop); final String data = textFieldBrowser.getText(); if (!data.equalsIgnoreCase(null)) { ArgList.add(SDConstant.BROWSER); } String[] array = new String[ArgList.size()]; int count = 0; for (int i = 0; i < ArgList.size(); i++) { String retName = ArgList.get(i); if (retName.equals("file")) { if (count == 0) { array[i] = retName; count++; } } else { array[i] = retName; } } ApplicationContext context = new ClassPathXmlApplicationContext(SDConstant.SPRNG_FILE_NAME); factory = (CofingRetrieverFactory) context.getBean("cofingRetrieverFactory"); ConfigRetreiver[] config = factory.getConfigRetrevier(array); ExecutorService service = Executors.newFixedThreadPool(10); for (final ConfigRetreiver configobj : config) { if (null != configobj) { configobj.setBISeverPath(prop); configobj.setServerName("biserver"); if (installType.equalsIgnoreCase("Installer")) { configobj.setInstallType("Installer"); } else if (installType.equalsIgnoreCase("Archive")) { configobj.setInstallType("Archive"); } else if (installType.equalsIgnoreCase("Manual")) { configobj.setInstallType("Manual"); } if (configobj instanceof FileRetriever) { configobj.setBidiXml(serverXml); configobj.setBidiBatFile(serverBatFile); configobj.setBidiProrperties(serverProrperties); configobj.setTomcatXml(tomcatXml); } if (configobj instanceof BrowserInfoRetriever) { configobj.setBrowserInfo(data); } service.execute(new Runnable() { public void run() { if (null != configobj) configobj.readAndSaveConfiguration(prop); } }); } } btnNewButton.setVisible(false); progressBar.setVisible(true); ProgressThread thread = new ProgressThread(); thread.setSupport(getSupport()); thread.setProp(prop); new Thread(thread).start(); service.shutdown(); } catch (Exception e1) { e1.printStackTrace(); } } }); chckbxSelectAll = new JCheckBox("Select/ De-select"); chckbxSelectAll.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { selectAll(); } else { deSelectAll(); } } }); chckbxSelectAll.setBounds(46, 138, 201, 23); chckbxSelectAll.setOpaque(false); contentPane.add(chckbxSelectAll); btnNewButton.setForeground(SystemColor.infoText); btnNewButton.setBounds(10, 430, 639, 37); contentPane.add(btnNewButton); chckbxServerproperties.setOpaque(false); JLabel lblAttach = new JLabel("Attach Artifact"); lblAttach.setHorizontalAlignment(SwingConstants.LEFT); lblAttach.setBounds(32, 335, 177, 23); contentPane.add(lblAttach); lblAttach.setOpaque(false); JButton btnNewButtonBrowse = new JButton("Browse"); btnNewButtonBrowse.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { saveSelectedFile(prop); JFrame parentFrame = new JFrame(); JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Specify a file to save"); fileChooser.setMultiSelectionEnabled(true); int userSelection = fileChooser.showSaveDialog(parentFrame); if (userSelection == JFileChooser.APPROVE_OPTION) { fileToSave = fileChooser.getSelectedFiles(); for (int i = 0; i < fileToSave.length; i++) { File file = fileToSave[i]; String artifactpath = file.getAbsolutePath(); File f = new File(artifactpath); String absolutefilename = f.getName(); String filename = ArtifactsDirectory.concat(absolutefilename); CopyFile artifactcopy = new CopyFile(artifactpath, filename); try { artifactcopy.copy(); } catch (Exception e1) { e1.printStackTrace(); } } uploadedFiles(); rowList = new JList(model); listScrollPane.setViewportView(rowList); panel.add(listScrollPane); } rowList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lblDelete.setVisible(true); } }); } }); btnNewButtonBrowse.setBounds(208, 335, 104, 23); contentPane.add(btnNewButtonBrowse); btnNewButtonBrowse.setOpaque(false); textFieldBrowser = new JTextField(); textFieldBrowser.setBounds(208, 364, 441, 23); contentPane.add(textFieldBrowser); textFieldBrowser.setColumns(10); progressBar = new JProgressBar(0, 100); progressBar.setBounds(8, 437, 639, 24); progressBar.setVisible(false); progressBar.setStringPainted(true); contentPane.add(progressBar); JLabel lblBrowserInformation = new JLabel("Browser Information"); lblBrowserInformation.setHorizontalAlignment(SwingConstants.LEFT); lblBrowserInformation.setLabelFor(textFieldBrowser); lblBrowserInformation.setBounds(32, 368, 174, 14); contentPane.add(lblBrowserInformation); panel = new JPanel(); panel.setBounds(423, 325, 127, 33); contentPane.add(panel); panel.setLayout(null); listScrollPane = new JScrollPane(); listScrollPane.setBounds(0, 0, 127, 33); panel.add(listScrollPane); lblDelete = new JLabel(""); lblDelete.setBounds(552, 325, 22, 23); lblDelete.setVisible(false); lblDelete.setIcon( new ImageIcon(SDSupportUtility.class.getResource("/org/pentaho/support/standalone/remove.png"))); contentPane.add(lblDelete); lblDelete.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this file ?"); if (option == JOptionPane.YES_OPTION) { String sel = rowList.getSelectedValue().toString(); String selected = dir + "/" + sel; File fileExists = new File(selected); fileExists.delete(); model.remove(sel.indexOf(sel)); lblDelete.setVisible(false); } } }); JLabel instalType = new JLabel("Installation Type : "); instalType.setBounds(32, 395, 177, 23); instalType.setVisible(true); contentPane.add(instalType); ButtonGroup btnGrp = new ButtonGroup(); rdbtnInstaller = new JRadioButton("Installer"); rdbtnInstaller.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Installer"; } }); rdbtnInstaller.setBounds(208, 395, 104, 23); rdbtnInstaller.setSelected(true); contentPane.add(rdbtnInstaller); btnGrp.add(rdbtnInstaller); rdbtnArchive = new JRadioButton("Archive"); rdbtnArchive.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Archive"; } }); rdbtnArchive.setBounds(333, 395, 104, 23); contentPane.add(rdbtnArchive); btnGrp.add(rdbtnArchive); rdbtnManual = new JRadioButton("Manual"); rdbtnManual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Manual"; } }); rdbtnManual.setBounds(460, 395, 127, 27); contentPane.add(rdbtnManual); btnGrp.add(rdbtnManual); JLabel lblBackground = new JLabel(); lblBackground.setIcon(new ImageIcon( SDSupportUtility.class.getResource("/org/pentaho/support/standalone/login-crystal-bg.jpg"))); lblBackground.setBackground(SystemColor.controlHighlight); lblBackground.setHorizontalAlignment(SwingConstants.CENTER); lblBackground.setBounds(0, 0, 659, 488); contentPane.add(lblBackground); }
From source file:edu.uci.ics.jung.samples.PerspectiveTransformerDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom and perspective features. * /*from w ww. j a v a2 s . c om*/ */ @SuppressWarnings("serial") public PerspectiveTransformerDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout<String, Number>) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv.getRenderContext().setVertexShapeTransformer(new Transformer<String, Shape>() { public Shape transform(String v) { return new Rectangle2D.Float(-10, -10, 20, 20); } }); vv.setBackground(Color.white); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); viewSupport = new PerspectiveViewTransformSupport<String, Number>(vv); layoutSupport = new PerspectiveLayoutTransformSupport<String, Number>(vv); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); final JSlider horizontalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(80, super.getPreferredSize().height); } }; final JSlider verticalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 80); } }; verticalSlider.setOrientation(JSlider.VERTICAL); final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { int vval = -verticalSlider.getValue(); int hval = horizontalSlider.getValue(); Dimension d = vv.getSize(); PerspectiveTransform pt = null; pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval, d.height + hval, -vval, d.height - hval, 0, 0, d.width, 0, d.width, d.height, 0, d.height); viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); vv.repaint(); } }; horizontalSlider.addChangeListener(changeListener); verticalSlider.addChangeListener(changeListener); JPanel perspectivePanel = new JPanel(new BorderLayout()); JPanel perspectiveCenterPanel = new JPanel(new BorderLayout()); perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls")); final JButton center = new JButton("Center"); center.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { horizontalSlider.setValue(0); verticalSlider.setValue(0); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; if (selected) { if (viewSupport != null) { viewSupport.deactivate(); } if (layoutSupport != null) { layoutSupport.deactivate(); } } center.setEnabled(!selected); horizontalSlider.setEnabled(!selected); verticalSlider.setEnabled(!selected); } }); final JRadioButton perspectiveView = new JRadioButton("In View"); perspectiveView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton perspectiveModel = new JRadioButton("In Layout"); perspectiveModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(normal); radio.add(perspectiveModel); radio.add(perspectiveView); normal.setSelected(true); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Container controls = new JPanel(new BorderLayout()); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel perspectiveControls = new JPanel(new GridLayout(3, 1)); zoomControls.add(plus); zoomControls.add(minus); perspectiveControls.add(normal); perspectiveControls.add(perspectiveModel); perspectiveControls.add(perspectiveView); controls.add(zoomControls, BorderLayout.WEST); controls.add(modePanel); perspectivePanel.add(perspectiveControls, BorderLayout.WEST); perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH); perspectivePanel.add(verticalSlider, BorderLayout.EAST); perspectiveCenterPanel.add(center); perspectivePanel.add(perspectiveCenterPanel); controls.add(perspectivePanel, BorderLayout.EAST); content.add(controls, BorderLayout.SOUTH); }
From source file:net.sf.jabref.groups.GroupSelector.java
/** * The first element for each group defines which field to use for the quicksearch. The next two define the name and * regexp for the group./* ww w . ja va 2s . c o m*/ */ public GroupSelector(JabRefFrame frame, SidePaneManager manager) { super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups")); this.groupsRoot = new GroupTreeNode(new AllEntriesGroup()); this.frame = frame; hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"), !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"), Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); ButtonGroup nonHits = new ButtonGroup(); nonHits.add(hideNonHits); nonHits.add(grayOut); floatCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()); } }); andCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, andCb.isSelected()); } }); invCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()); } }); showOverlappingGroups.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING, showOverlappingGroups.isSelected()); if (!showOverlappingGroups.isSelected()) { groupsTree.setHighlight2Cells(null); } } }); select.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SELECT_MATCHES, select.isSelected()); } }); grayOut.addChangeListener( event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected())); JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) { floatCb.setSelected(true); highlCb.setSelected(false); } else { highlCb.setSelected(true); floatCb.setSelected(false); } JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) { andCb.setSelected(true); orCb.setSelected(false); } else { orCb.setSelected(true); andCb.setSelected(false); } showNumberOfElements.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS, showNumberOfElements.isSelected()); if (groupsTree != null) { groupsTree.invalidate(); groupsTree.validate(); groupsTree.repaint(); } } }); autoAssignGroup.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroup.isSelected()); } }); invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS)); showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING)); select.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SELECT_MATCHES)); editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE); editModeCb.setSelected(editModeIndicator); showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); openset.setMargin(new Insets(0, 0, 0, 0)); settings.add(andCb); settings.add(orCb); settings.addSeparator(); settings.add(invCb); settings.addSeparator(); settings.add(select); settings.addSeparator(); settings.add(editModeCb); settings.addSeparator(); settings.add(grayOut); settings.add(hideNonHits); settings.addSeparator(); settings.add(showOverlappingGroups); settings.addSeparator(); settings.add(showNumberOfElements); settings.add(autoAssignGroup); // settings.add(moreRow); // settings.add(lessRow); openset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!settings.isVisible()) { JButton src = (JButton) e.getSource(); showNumberOfElements .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); settings.show(src, 0, openset.getHeight()); } } }); JButton expand = new JButton(IconTheme.JabRefIcon.ADD_ROW.getSmallIcon()); expand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) + 1; groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); LOGGER.info("Height: " + GroupSelector.this.getHeight() + "; Preferred height: " + GroupSelector.this.getPreferredSize().getHeight()); } }); JButton reduce = new JButton(IconTheme.JabRefIcon.REMOVE_ROW.getSmallIcon()); reduce.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) - 1; if (i < 1) { i = 1; } groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); // _panel.sidePaneManager.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); } }); editModeCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editModeIndicator = editModeCb.getState(); updateBorder(editModeIndicator); Globals.prefs.putBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, editModeIndicator); } }); int butSize = newButton.getIcon().getIconHeight() + 5; Dimension butDim = new Dimension(butSize, butSize); //Dimension butDimSmall = new Dimension(20, 20); newButton.setPreferredSize(butDim); newButton.setMinimumSize(butDim); refresh.setPreferredSize(butDim); refresh.setMinimumSize(butDim); JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFiles.groupsHelp) .getHelpButton(); helpButton.setPreferredSize(butDim); helpButton.setMinimumSize(butDim); autoGroup.setPreferredSize(butDim); autoGroup.setMinimumSize(butDim); openset.setPreferredSize(butDim); openset.setMinimumSize(butDim); expand.setPreferredSize(butDim); expand.setMinimumSize(butDim); reduce.setPreferredSize(butDim); reduce.setMinimumSize(butDim); Insets butIns = new Insets(0, 0, 0, 0); helpButton.setMargin(butIns); reduce.setMargin(butIns); expand.setMargin(butIns); openset.setMargin(butIns); newButton.addActionListener(this); refresh.addActionListener(this); andCb.addActionListener(this); orCb.addActionListener(this); invCb.addActionListener(this); showOverlappingGroups.addActionListener(this); autoGroup.addActionListener(this); floatCb.addActionListener(this); highlCb.addActionListener(this); select.addActionListener(this); hideNonHits.addActionListener(this); grayOut.addActionListener(this); newButton.setToolTipText(Localization.lang("New group")); refresh.setToolTipText(Localization.lang("Refresh view")); andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups.")); orCb.setToolTipText( Localization.lang("Display all entries belonging to one or more of the selected groups.")); autoGroup.setToolTipText(Localization.lang("Automatically create groups for database.")); invCb.setToolTipText(Localization.lang("Show entries *not* in group selection")); showOverlappingGroups.setToolTipText(Localization .lang("Highlight groups that contain entries contained in any currently selected group")); floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top")); highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection")); select.setToolTipText(Localization.lang("Select entries in group selection")); expand.setToolTipText(Localization.lang("Show one more row")); reduce.setToolTipText(Localization.lang("Show one less rows")); editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries")); ButtonGroup bgr = new ButtonGroup(); bgr.add(andCb); bgr.add(orCb); ButtonGroup visMode = new ButtonGroup(); visMode.add(floatCb); visMode.add(highlCb); JPanel main = new JPanel(); GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.BOTH; //con.insets = new Insets(0, 0, 2, 0); con.weightx = 1; con.gridwidth = 1; con.gridx = 0; con.gridy = 0; //con.insets = new Insets(1, 1, 1, 1); gbl.setConstraints(newButton, con); main.add(newButton); con.gridx = 1; gbl.setConstraints(refresh, con); main.add(refresh); con.gridx = 2; gbl.setConstraints(autoGroup, con); main.add(autoGroup); con.gridx = 3; con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(helpButton, con); main.add(helpButton); // header.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); // helpButton.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); groupsTree = new GroupsTree(this); groupsTree.addTreeSelectionListener(this); groupsTree.setModel(groupsTreeModel = new DefaultTreeModel(groupsRoot)); JScrollPane sp = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); revalidateGroups(); con.gridwidth = GridBagConstraints.REMAINDER; con.weighty = 1; con.gridx = 0; con.gridwidth = 4; con.gridy = 1; gbl.setConstraints(sp, con); main.add(sp); JPanel pan = new JPanel(); GridBagLayout gb = new GridBagLayout(); con.weighty = 0; gbl.setConstraints(pan, con); pan.setLayout(gb); con.insets = new Insets(0, 0, 0, 0); con.gridx = 0; con.gridy = 0; con.weightx = 1; con.gridwidth = 4; con.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(openset, con); pan.add(openset); con.gridwidth = 1; con.gridx = 4; con.gridy = 0; gb.setConstraints(expand, con); pan.add(expand); con.gridx = 5; gb.setConstraints(reduce, con); pan.add(reduce); con.gridwidth = 6; con.gridy = 1; con.gridx = 0; con.fill = GridBagConstraints.HORIZONTAL; con.gridy = 2; con.gridx = 0; con.gridwidth = 4; gbl.setConstraints(pan, con); main.add(pan); main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); add(main, BorderLayout.CENTER); updateBorder(editModeIndicator); definePopup(); NodeAction moveNodeUpAction = new MoveNodeUpAction(); moveNodeUpAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK)); NodeAction moveNodeDownAction = new MoveNodeDownAction(); moveNodeDownAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK)); NodeAction moveNodeLeftAction = new MoveNodeLeftAction(); moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK)); NodeAction moveNodeRightAction = new MoveNodeRightAction(); moveNodeRightAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK)); }
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private void addEspDevice(JMenu menu, RawEspConnection connection, ButtonGroup bg) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(connection.getName()); bg.add(item); menu.add(item);/*from w w w . java 2 s. c o m*/ item.addActionListener(e -> setConnection(connection)); }
From source file:DialogDemo.java
/** Creates the panel shown by the second tab. */ private JPanel createFeatureDialogBox() { final int numButtons = 5; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;/*w ww. ja va 2s . c o m*/ final String pickOneCommand = "pickone"; final String textEnteredCommand = "textfield"; final String nonAutoCommand = "nonautooption"; final String customOptionCommand = "customoption"; final String nonModalCommand = "nonmodal"; radioButtons[0] = new JRadioButton("Pick one of several choices"); radioButtons[0].setActionCommand(pickOneCommand); radioButtons[1] = new JRadioButton("Enter some text"); radioButtons[1].setActionCommand(textEnteredCommand); radioButtons[2] = new JRadioButton("Non-auto-closing dialog"); radioButtons[2].setActionCommand(nonAutoCommand); radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)"); radioButtons[3].setActionCommand(customOptionCommand); radioButtons[4] = new JRadioButton("Non-modal dialog"); radioButtons[4].setActionCommand(nonModalCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); // pick one of many if (command == pickOneCommand) { Object[] possibilities = { "ham", "spam", "yam" }; String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham"); // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); // text input } else if (command == textEnteredCommand) { String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, null, "ham"); // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); // non-auto-closing dialog } else if (command == nonAutoCommand) { final JOptionPane optionPane = new JOptionPane( "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); // You can't use pane.createDialog() because that // method sets up the JDialog with a property change // listener that automatically closes the window // when a button is clicked. final JDialog dialog = new JDialog(frame, "Click a button", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setLabel("Thwarted user attempt to close window."); } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { setLabel("Good."); } else if (value == JOptionPane.NO_OPTION) { setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. " + "You can't!"); } else { setLabel("Window unavoidably closed (ESC?)."); } // non-auto-closing dialog with custom message area // NOTE: if you don't intend to check the input, // then just use showInputDialog instead. } else if (command == customOptionCommand) { customDialog.setLocationRelativeTo(frame); customDialog.setVisible(true); String s = customDialog.getValidatedText(); if (s != null) { // The text is valid. setLabel("Congratulations! " + "You entered \"" + s + "\"."); } // non-modal dialog } else if (command == nonModalCommand) { // Create the dialog. final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog"); // Add contents to it. It must have a close button, // since some L&Fs (notably Java/Metal) don't provide one // in the window decorations for dialogs. JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>" + "You can have one or more of these up<br>" + "and still use the main window."); label.setHorizontalAlignment(JLabel.CENTER); Font font = label.getFont(); label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f)); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); JPanel closePanel = new JPanel(); closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS)); closePanel.add(Box.createHorizontalGlue()); closePanel.add(closeButton); closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(label, BorderLayout.CENTER); contentPane.add(closePanel, BorderLayout.PAGE_END); contentPane.setOpaque(true); dialog.setContentPane(contentPane); // Show it. dialog.setSize(new Dimension(300, 150)); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); } } }); return createPane(moreDialogDesc + ":", radioButtons, showItButton); }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
private void initComponents() { splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); splitPane.setOneTouchExpandable(true); topPanel = new JPanel(); topPanel.setBackground(UIConstants.BACKGROUND_COLOR); dashboardTable = null;//from w ww .j av a 2 s .co m dashboardTableScrollPane = new JScrollPane(); dashboardTableScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); dashboardTableScrollPane.setViewportView(dashboardTable); dashboardTableScrollPane.setDoubleBuffered(true); controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(164, 164, 164))); controlPanel.setPreferredSize(new Dimension(100, 20)); tagFilterButton = new IconButton(); tagFilterButton .setIcon(new ImageIcon(getClass().getResource("/com/mirth/connect/client/ui/images/wrench.png"))); // NOI18N tagFilterButton.setToolTipText("Show Channel Filter"); tagFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { tagFilterButtonActionPerformed(); } }); tagsLabel = new JLabel(); ButtonGroup showStatsButtonGroup = new ButtonGroup(); showCurrentStatsButton = new JRadioButton("Current Statistics"); showCurrentStatsButton.setSelected(true); showCurrentStatsButton .setToolTipText("Show the statistics accumulated since the last time the statistics were reset"); showCurrentStatsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { showCurrentStatsButtonActionPerformed(); } }); showStatsButtonGroup.add(showCurrentStatsButton); showLifetimeStatsButton = new JRadioButton("Lifetime Statistics"); showLifetimeStatsButton .setToolTipText("Show the statistics accumulated over the entire lifetime of the channel"); showLifetimeStatsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { showLifetimeStatsButtonActionPerformed(); } }); showStatsButtonGroup.add(showLifetimeStatsButton); pluginContainerPanel = new JPanel(); controlSeparator = new JSeparator(SwingConstants.VERTICAL); ButtonGroup tableModeButtonGroup = new ButtonGroup(); tableModeGroupsButton = new IconToggleButton(UIConstants.ICON_GROUP); tableModeGroupsButton.setToolTipText("Groups"); tableModeGroupsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { switchTableMode(true); } }); tableModeButtonGroup.add(tableModeGroupsButton); tableModeChannelsButton = new IconToggleButton(UIConstants.ICON_CHANNEL); tableModeChannelsButton.setToolTipText("Channels"); tableModeChannelsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { switchTableMode(false); } }); tableModeButtonGroup.add(tableModeChannelsButton); tabPane = new JTabbedPane(); splitPane.setTopComponent(topPanel); splitPane.setBottomComponent(tabPane); }
From source file:com.mirth.connect.plugins.httpauth.HttpAuthConnectorPropertiesPanel.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); typeLabel = new JLabel("Authentication Type:"); typeLabel.setHorizontalAlignment(SwingConstants.RIGHT); typeComboBox = new MirthComboBox(); typeComboBox.setModel(new DefaultComboBoxModel<AuthType>(AuthType.values())); typeComboBox.addActionListener(new ActionListener() { @Override//from w w w .j ava 2 s . c om public void actionPerformed(ActionEvent evt) { authTypeChanged(); } }); typeComboBox.setToolTipText("Select the type of HTTP authentication to perform for incoming requests."); basicRealmLabel = new JLabel("Realm:"); basicRealmField = new MirthTextField(); basicRealmField.setToolTipText("The protection space for this server."); basicCredentialsLabel = new JLabel("Credentials:"); basicCredentialsPanel = new JPanel(); basicCredentialsPanel.setBackground(getBackground()); basicCredentialsTable = new MirthTable(); basicCredentialsTable.setModel(new RefreshTableModel(new String[] { "Username", "Password" }, 0)); basicCredentialsTable.setCustomEditorControls(true); basicCredentialsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); basicCredentialsTable.setRowSelectionAllowed(true); basicCredentialsTable.setRowHeight(UIConstants.ROW_HEIGHT); basicCredentialsTable.setDragEnabled(false); basicCredentialsTable.setOpaque(true); basicCredentialsTable.setSortable(false); basicCredentialsTable.getTableHeader().setReorderingAllowed(false); basicCredentialsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); basicCredentialsTable.setToolTipText( "<html>Username and password pairs to authenticate<br/>users with. At least one pair is required.</html>"); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); basicCredentialsTable.setHighlighters(highlighter); } CredentialsTableCellEditor basicCredentialsTableCellEditor = new CredentialsTableCellEditor( basicCredentialsTable); basicCredentialsTable.getColumnExt(0).setCellEditor(basicCredentialsTableCellEditor); basicCredentialsTable.getColumnExt(0).setToolTipText("The username to authenticate with."); basicCredentialsTable.getColumnExt(1).setCellRenderer(new PasswordCellRenderer()); basicCredentialsTable.getColumnExt(1).setCellEditor(new DefaultCellEditor(new JPasswordField())); basicCredentialsTable.getColumnExt(1).setToolTipText("The password to authenticate with."); basicCredentialsTableScrollPane = new JScrollPane(basicCredentialsTable); basicCredentialsNewButton = new MirthButton("New"); basicCredentialsNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String username; boolean found; do { num++; username = "user" + num; found = false; for (int row = 0; row < basicCredentialsTable.getModel().getRowCount(); row++) { if (StringUtils.equals(username, (String) basicCredentialsTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) basicCredentialsTable.getModel()).addRow(new String[] { username, "" }); basicCredentialsTable.setRowSelectionInterval(basicCredentialsTable.getRowCount() - 1, basicCredentialsTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); basicCredentialsDeleteButton = new MirthButton("Delete"); basicCredentialsDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(basicCredentialsTable); if (selectedRow >= 0) { if (basicCredentialsTable.isEditing()) { basicCredentialsTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) basicCredentialsTable.getModel()).removeRow(selectedRow); int rowCount = basicCredentialsTable.getRowCount(); if (selectedRow < rowCount) { basicCredentialsTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { basicCredentialsTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); basicCredentialsTableCellEditor.setDeleteButton(basicCredentialsDeleteButton); digestRealmLabel = new JLabel("Realm:"); digestRealmField = new MirthTextField(); digestRealmField.setToolTipText("The protection space for this server."); digestAlgorithmLabel = new JLabel("Algorithms:"); ButtonGroup digestAlgorithmButtonGroup = new ButtonGroup(); String toolTipText = "<html>Specifies the digest algorithms supported by this server.<br/><b> - MD5:</b> The security data A1 will contain the username, realm, and password.<br/><b> - MD5-sess:</b> The security data A1 will also contain the server and client nonces.</html>"; digestAlgorithmMD5Radio = new MirthRadioButton(Algorithm.MD5.toString()); digestAlgorithmMD5Radio.setBackground(getBackground()); digestAlgorithmMD5Radio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmMD5Radio); digestAlgorithmMD5SessRadio = new MirthRadioButton(Algorithm.MD5_SESS.toString()); digestAlgorithmMD5SessRadio.setBackground(getBackground()); digestAlgorithmMD5SessRadio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmMD5SessRadio); digestAlgorithmBothRadio = new MirthRadioButton("Both"); digestAlgorithmBothRadio.setBackground(getBackground()); digestAlgorithmBothRadio.setToolTipText(toolTipText); digestAlgorithmButtonGroup.add(digestAlgorithmBothRadio); digestQOPLabel = new JLabel("QOP Modes:"); toolTipText = "<html>The quality of protection modes to support.<br/><b> - auth:</b> Regular auth with client nonce and count in the digest.<br/><b> - auth-int:</b> Same as auth, but also with message integrity protection enabled.</html>"; digestQOPAuthCheckBox = new MirthCheckBox(QOPMode.AUTH.toString()); digestQOPAuthCheckBox.setBackground(getBackground()); digestQOPAuthCheckBox.setToolTipText(toolTipText); digestQOPAuthIntCheckBox = new MirthCheckBox(QOPMode.AUTH_INT.toString()); digestQOPAuthIntCheckBox.setBackground(getBackground()); digestQOPAuthIntCheckBox.setToolTipText(toolTipText); digestOpaqueLabel = new JLabel("Opaque:"); digestOpaqueField = new MirthTextField(); digestOpaqueField.setToolTipText("A string of data that should be returned by the client unchanged."); digestCredentialsLabel = new JLabel("Credentials:"); digestCredentialsPanel = new JPanel(); digestCredentialsPanel.setBackground(getBackground()); digestCredentialsTable = new MirthTable(); digestCredentialsTable.setModel(new RefreshTableModel(new String[] { "Username", "Password" }, 0)); digestCredentialsTable.setCustomEditorControls(true); digestCredentialsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); digestCredentialsTable.setRowSelectionAllowed(true); digestCredentialsTable.setRowHeight(UIConstants.ROW_HEIGHT); digestCredentialsTable.setDragEnabled(false); digestCredentialsTable.setOpaque(true); digestCredentialsTable.setSortable(false); digestCredentialsTable.getTableHeader().setReorderingAllowed(false); digestCredentialsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); digestCredentialsTable.setToolTipText( "<html>Username and password pairs to authenticate<br/>users with. At least one pair is required.</html>"); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); digestCredentialsTable.setHighlighters(highlighter); } CredentialsTableCellEditor digestCredentialsTableCellEditor = new CredentialsTableCellEditor( digestCredentialsTable); digestCredentialsTable.getColumnExt(0).setCellEditor(digestCredentialsTableCellEditor); digestCredentialsTable.getColumnExt(0).setToolTipText("The username to authenticate with."); digestCredentialsTable.getColumnExt(1).setCellRenderer(new PasswordCellRenderer()); digestCredentialsTable.getColumnExt(1).setCellEditor(new DefaultCellEditor(new JPasswordField())); digestCredentialsTable.getColumnExt(1).setToolTipText("The password to authenticate with."); digestCredentialsTableScrollPane = new JScrollPane(digestCredentialsTable); digestCredentialsNewButton = new MirthButton("New"); digestCredentialsNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String username; boolean found; do { num++; username = "user" + num; found = false; for (int row = 0; row < digestCredentialsTable.getModel().getRowCount(); row++) { if (StringUtils.equals(username, (String) digestCredentialsTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) digestCredentialsTable.getModel()).addRow(new String[] { username, "" }); digestCredentialsTable.setRowSelectionInterval(digestCredentialsTable.getRowCount() - 1, digestCredentialsTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); digestCredentialsDeleteButton = new MirthButton("Delete"); digestCredentialsDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(digestCredentialsTable); if (selectedRow >= 0) { if (digestCredentialsTable.isEditing()) { digestCredentialsTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) digestCredentialsTable.getModel()).removeRow(selectedRow); int rowCount = digestCredentialsTable.getRowCount(); if (selectedRow < rowCount) { digestCredentialsTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { digestCredentialsTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); digestCredentialsTableCellEditor.setDeleteButton(digestCredentialsDeleteButton); jsScriptLabel = new JLabel("Script:"); jsScriptField = new JTextField(); jsScriptField.setEditable(false); jsScriptField.setBackground(getBackground()); jsScriptField.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); jsScriptField.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { JavaScriptHttpAuthDialog dialog = new JavaScriptHttpAuthDialog(PlatformUI.MIRTH_FRAME, jsScript); if (dialog.wasSaved()) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); jsScript = dialog.getScript(); updateJSScriptField(); } } }); jsScriptField.setToolTipText( "<html>Click here to open the JavaScript editor dialog.<br/>The return value of this script is used to accept or reject requests.</html>"); customClassNameLabel = new JLabel("Class Name:"); customClassNameField = new MirthTextField(); customClassNameField .setToolTipText("The fully-qualified Java class name of the Authenticator class to use."); customPropertiesLabel = new JLabel("Properties:"); customPropertiesPanel = new JPanel(); customPropertiesPanel.setBackground(getBackground()); customPropertiesTable = new MirthTable(); customPropertiesTable.setModel(new RefreshTableModel(new String[] { "Name", "Value" }, 0)); customPropertiesTable.setCustomEditorControls(true); customPropertiesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customPropertiesTable.setRowSelectionAllowed(true); customPropertiesTable.setRowHeight(UIConstants.ROW_HEIGHT); customPropertiesTable.setDragEnabled(false); customPropertiesTable.setOpaque(true); customPropertiesTable.setSortable(false); customPropertiesTable.getTableHeader().setReorderingAllowed(false); customPropertiesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); customPropertiesTable.setToolTipText( "Optional properties to pass into the Authenticator class when it is instantiated."); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); customPropertiesTable.setHighlighters(highlighter); } CredentialsTableCellEditor customPropertiesTableCellEditor = new CredentialsTableCellEditor( customPropertiesTable); customPropertiesTable.getColumnExt(0).setCellEditor(customPropertiesTableCellEditor); customPropertiesTable.getColumnExt(0).setToolTipText("The name of the property to include."); customPropertiesTable.getColumnExt(1).setToolTipText("The value of the property to include."); customPropertiesTableScrollPane = new JScrollPane(customPropertiesTable); customPropertiesNewButton = new MirthButton("New"); customPropertiesNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int num = 0; String name; boolean found; do { num++; name = "Property " + num; found = false; for (int row = 0; row < customPropertiesTable.getModel().getRowCount(); row++) { if (StringUtils.equals(name, (String) customPropertiesTable.getModel().getValueAt(row, 0))) { found = true; } } } while (found); ((DefaultTableModel) customPropertiesTable.getModel()).addRow(new String[] { name, "" }); customPropertiesTable.setRowSelectionInterval(customPropertiesTable.getRowCount() - 1, customPropertiesTable.getRowCount() - 1); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); customPropertiesDeleteButton = new MirthButton("Delete"); customPropertiesDeleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int selectedRow = getSelectedRow(customPropertiesTable); if (selectedRow >= 0) { if (customPropertiesTable.isEditing()) { customPropertiesTable.getCellEditor().cancelCellEditing(); } ((DefaultTableModel) customPropertiesTable.getModel()).removeRow(selectedRow); int rowCount = customPropertiesTable.getRowCount(); if (selectedRow < rowCount) { customPropertiesTable.setRowSelectionInterval(selectedRow, selectedRow); } else if (rowCount > 0) { customPropertiesTable.setRowSelectionInterval(rowCount - 1, rowCount - 1); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); customPropertiesTableCellEditor.setDeleteButton(customPropertiesDeleteButton); oauth2TokenLabel = new JLabel("Access Token Location:"); oauth2TokenLocationComboBox = new MirthComboBox(); oauth2TokenLocationComboBox.setModel(new DefaultComboBoxModel<TokenLocation>(TokenLocation.values())); oauth2TokenLocationComboBox .setToolTipText("Determines where the access token is located in client requests."); oauth2TokenField = new MirthTextField(); oauth2TokenField .setToolTipText("The header or query parameter to pass along with the verification request."); oauth2VerificationURLLabel = new JLabel("Verification URL:"); oauth2VerificationURLField = new MirthTextField(); oauth2VerificationURLField.setToolTipText( "<html>The HTTP URL to perform a GET request to for access<br/>token verification. If the response code is >= 400,<br/>the authentication attempt is rejected by the server.</html>"); for (ConnectorPropertiesPlugin connectorPropertiesPlugin : LoadedExtensions.getInstance() .getConnectorPropertiesPlugins().values()) { if (connectorPropertiesPlugin .isConnectorPropertiesPluginSupported(HttpAuthConnectorPluginProperties.PLUGIN_POINT)) { connectorPropertiesPanel = connectorPropertiesPlugin.getConnectorPropertiesPanel(); } } }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void makeDefaultXslMenuItems() { ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem jRadioButtonMenuItem; for (File xsltFile : Utilities.getXsltFiles()) { jRadioButtonMenuItem = new JRadioButtonMenuItem(xsltFile.getName()); if (xsltFile.getName().equals(retrieveFromDb.retrieveDefaultXsl())) { jRadioButtonMenuItem.setSelected(true); }/*from ww w.ja va2s .c o m*/ jRadioButtonMenuItem.addActionListener(new XslSelectActionListener()); group.add(jRadioButtonMenuItem); defaultXslSelectionSubmenu.add(jRadioButtonMenuItem); } }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void createLanguageMenu() { Locale currentLocale = Locale.getDefault(); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem("English"); rbMenuItem.setActionCommand("en"); if (!Arrays.asList(LANGUAGES_OF_TOOL).contains(currentLocale.getLanguage()) || currentLocale.getLanguage().equals("en")) { rbMenuItem.setSelected(true);// w w w .ja v a 2s .c om } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Franais"); rbMenuItem.setActionCommand("fr"); if (currentLocale.getLanguage().equals("fr")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Deutsch"); rbMenuItem.setActionCommand("de"); if (currentLocale.getLanguage().equals("de")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem(""); rbMenuItem.setActionCommand("el"); if (currentLocale.getLanguage().equals("el")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Nederlands"); rbMenuItem.setActionCommand("nl"); if (currentLocale.getLanguage().equals("nl")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Magyar"); rbMenuItem.setActionCommand("hu"); if (currentLocale.getLanguage().equals("hu")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); if (Utilities.isDev) { languageMenu.addSeparator(); rbMenuItem = new JRadioButtonMenuItem("XXXXXX"); rbMenuItem.setActionCommand("xx"); if (currentLocale.getLanguage().equals("xx")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); } }