List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:org.jax.bham.test.PhenotypeEffectPlotPanel.java
/** * Constructor/*from w w w . ja va 2 s .c o m*/ * @param phenotypeDataSource * the phenotype data source * @param strainGroups * the strain groupings */ public PhenotypeEffectPlotPanel(PhenotypeDataSource phenotypeDataSource, Map<String, ? extends Collection<String>> strainGroups) { super(new BorderLayout()); this.chartPanel = new ChartPanel(null, true); this.showIndividualStrainEffectsCheckBox = new JCheckBox("Show Individual Strain Effects", false); this.phenotypeDataSource = phenotypeDataSource; this.phenotypeData = phenotypeDataSource.getPhenotypeData(); this.strainGroups = strainGroups; this.updateChart(); JToolBar toolBar = new JToolBar(); toolBar.add(this.showIndividualStrainEffectsCheckBox); this.showIndividualStrainEffectsCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { PhenotypeEffectPlotPanel.this.updateChart(); } }); this.add(toolBar, BorderLayout.PAGE_START); this.add(this.chartPanel, BorderLayout.CENTER); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRInitialController.java
/** * Initialize view./*from w ww.j a v a 2 s . c o m*/ */ @Override protected void initDRInitialPanel() { dRInitialPlotPanel = new DRInitialPlotPanel(); //init chart panel initialChartPanel = new ChartPanel(null); initialChartPanel.setOpaque(false); /** * Action listeners for buttons */ /** * If selected, text field to enter value for parameter constraining * will be taken into account on plotting. */ dRInitialPlotPanel.getBottomCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { bottomConstrainValue = 0.0; } else { bottomConstrainValue = null; } } }); dRInitialPlotPanel.getTopCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { topConstrainValue = 0.0; } else { topConstrainValue = null; } } }); /** * Perform fitting and plot new dose-response graph, taking into account * any choices made by the user. */ dRInitialPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (bottomConstrainValue != null) { bottomConstrainValue = Double.parseDouble(dRInitialPlotPanel.getBottomTextField().getText()); } if (topConstrainValue != null) { topConstrainValue = Double.parseDouble(dRInitialPlotPanel.getTopTextField().getText()); } doseResponseController .performFitting( dataToFit, doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getFittingResults(false), bottomConstrainValue, topConstrainValue); //Plot fitted data in dose-response curve, along with R annotation doseResponseController.plotDoseResponse(initialChartPanel, dRInitialPlotPanel.getDoseResponseChartParentPanel(), dataToFit, doseResponseController.getdRAnalysisGroup(), false); //Calculate new statistics doseResponseController.calculateStatistics(); } }); }
From source file:gdt.jgui.tool.JTextEncrypter.java
/** * The default constructor.//w w w .jav a2 s . c om */ public JTextEncrypter() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Master password", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panel); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); JCheckBox chckbxNewCheckBox = new JCheckBox("Show"); chckbxNewCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); chckbxNewCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() != ItemEvent.SELECTED) { passwordField.setEchoChar('*'); } else { passwordField.setEchoChar((char) 0); } } }); panel.add(chckbxNewCheckBox); panel.setFocusTraversalPolicy( new FocusTraversalOnArray(new Component[] { chckbxNewCheckBox, passwordField })); passwordField = new JPasswordField(); passwordField.setMaximumSize(new Dimension(Integer.MAX_VALUE, passwordField.getPreferredSize().height)); panel.add(passwordField); JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, "Text", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panel_1); panel_1.setLayout(new BorderLayout(0, 0)); textArea = new JTextArea(); textArea.setColumns(1); panel_1.add(textArea); }
From source file:com.diversityarrays.kdxplore.field.CollectionPathSetupDialog.java
public CollectionPathSetupDialog(Window owner, String title, boolean wantPlotsPerGroup) { super(owner, title, ModalityType.APPLICATION_MODAL); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(useAction)); Container cp = getContentPane(); if (wantPlotsPerGroup) { plotsPerGroupChoice.addItemListener(new ItemListener() { @Override/* w ww. j a va2 s . c o m*/ public void itemStateChanged(ItemEvent e) { plotsPerGroup = (PlotsPerGroup) plotsPerGroupChoice.getSelectedItem(); } }); JPanel ppgPanel = new JPanel(); GBH gbh = new GBH(ppgPanel); int y = 0; gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Plots Per Group:"); gbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.WEST, plotsPerGroupChoice); ++y; cp.add(ppgPanel, BorderLayout.NORTH); } cp.add(odtChoicePanel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:ru.goodfil.catalog.ui.forms.FilterWindow.java
public FilterWindow(Filter fitler) { this.filter = fitler; reReadFilterTypes();//from w ww .j av a 2 s.co m initComponents(); filterFormsCombo = new ComboAdapter(cbFilterForm, filterForms); filterTypesCombo = new ComboAdapter(cbFilterType, filterTypes); cbFilterForm.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { adjustButtonsEnabled(); } }); cbFilterType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { adjustButtonsEnabled(); } }); cbFilterStatus.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { adjustButtonsEnabled(); } }); init(filter); adjustButtonsEnabled(); Toolkit.getDefaultToolkit().addAWTEventListener(eventListener, AWTEvent.KEY_EVENT_MASK); }
From source file:com.ibm.bluej.commonutil.visualization.PrintableVisualizationViewer.java
protected void setStandardOptions() { PluggableRenderer r = (PluggableRenderer) this.getRenderer(); r.setVertexStringer(new StringVertexStringer()); r.setEdgeStringer(new StringEdgeStringer()); r.setEdgeShapeFunction(new SpacedCurve()); r.setVertexPaintFunction(new SmartVertexPaintFunction(r, callbacks)); r.setEdgeLabelClosenessFunction(new ConstantEdgeValue(.5)); r.setEdgePaintFunction(new SmartEdgePaintFunction(r, callbacks)); r.setEdgeFontFunction(new FontHandler()); this.setDoubleBuffered(true); DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); this.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); this.getPickedState().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getItem() instanceof LabeledDirectedSparseVertex) { LabeledDirectedSparseVertex v = (LabeledDirectedSparseVertex) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) v.marked); return; }/*from w w w. j a va 2s . com*/ if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) v.marked); return; } System.err.println(e.toString()); System.err.println(e.getItem().toString()); } else { LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } System.out.println("Edge pick"); System.out.println(e.getItem().getClass().getName()); System.out.println(e.getStateChange()); } } }); setToolTipFunction(new DefaultToolTipFunction() { public String getToolTipText(Vertex v) { return callbacks.getToolTip((T) ((LabeledDirectedSparseVertex) v).marked); } /* public String getToolTipText(Edge edge) { edu.uci.ics.jung.utils.Pair accts = edge.getEndpoints(); Vertex v1 = (Vertex) accts.getFirst(); Vertex v2 = (Vertex) accts.getSecond(); return v1 + " -- " + v2; } */ }); Predicate p = new Predicate() { public boolean evaluate(Object arg0) { if (!(arg0 instanceof LabeledDirectedSparseEdge)) { System.err.println("Unexpected: " + arg0); return false; } LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) arg0; return callbacks.shouldShowEdge((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); } }; r.setEdgeIncludePredicate(p); this.setPickSupport(new ShapePickSupport(4)); //System.out.println(getPickSupport().getClass().getName()); }
From source file:net.pms.encoders.AviSynthMEncoder.java
@Override public JComponent config() { FormLayout layout = new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 12dlu, p, 3dlu, 0:grow"); PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.EMPTY);// w w w.j a v a 2s .c o m builder.opaque(false); CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(2, 1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"), configuration.getAvisynthMultiThreading()); multithreading.setContentAreaFilled(false); multithreading.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthMultiThreading((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3)); interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"), configuration.getAvisynthInterFrame()); interframe.setContentAreaFilled(false); interframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setAvisynthInterFrame(interframe.isSelected()); if (configuration.getAvisynthInterFrame()) { JOptionPane.showMessageDialog( SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()), Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } } }); builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5)); interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"), configuration.getAvisynthInterFrameGPU()); interframegpu.setContentAreaFilled(false); interframegpu.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7)); convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"), configuration.getAvisynthConvertFps()); convertfps.setContentAreaFilled(false); convertfps.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9)); String aviSynthScriptInstructions = Messages.getString("AviSynthMEncoder.4") + Messages.getString("AviSynthMEncoder.5") + Messages.getString("AviSynthMEncoder.6") + Messages.getString("AviSynthMEncoder.7") + Messages.getString("AviSynthMEncoder.8"); JTextArea aviSynthScriptInstructionsContainer = new JTextArea(aviSynthScriptInstructions); aviSynthScriptInstructionsContainer.setEditable(false); aviSynthScriptInstructionsContainer.setBorder(BorderFactory.createEtchedBorder()); aviSynthScriptInstructionsContainer.setBackground(new Color(255, 255, 192)); aviSynthScriptInstructionsContainer.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)), BorderFactory.createEmptyBorder(3, 5, 3, 5))); builder.add(aviSynthScriptInstructionsContainer, cc.xy(2, 11)); String clip = configuration.getAvisynthScript(); if (clip == null) { clip = ""; } StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(clip, PMS.AVS_SEPARATOR); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append("\n"); } sb.append(st.nextToken()); i++; } textArea = new JTextArea(sb.toString()); textArea.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(textArea.getText(), "\n"); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append(PMS.AVS_SEPARATOR); } sb.append(st.nextToken()); i++; } configuration.setAvisynthScript(sb.toString()); } }); JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane.setPreferredSize(new Dimension(500, 350)); builder.add(pane, cc.xy(2, 13)); configuration.addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { if (event.getPropertyName() == null) { return; } if ((!event.isBeforeUpdate()) && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) { interframegpu.setEnabled(configuration.isGPUAcceleration()); } } }); return builder.getPanel(); }
From source file:net.pms.newgui.NetworkTab.java
public JComponent build() { FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow", "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.DLU4_BORDER); builder.setOpaque(true);/*from ww w .j av a2 s . c o m*/ CellConstraints cc = new CellConstraints(); smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3")); smcheckBox.setContentAreaFilled(false); smcheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED)); } }); if (PMS.getConfiguration().isMinimized()) { smcheckBox.setSelected(true); } JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7)); final KeyedComboBoxModel kcbm = new KeyedComboBoxModel( new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it", "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" }, new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic", "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" }); langs = new JComboBox(kcbm); langs.setEditable(false); //langs.setSelectedIndex(0); String defaultLang = null; if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) { defaultLang = configuration.getLanguage(); } else { defaultLang = Locale.getDefault().getLanguage(); } if (defaultLang == null) { defaultLang = "en"; } kcbm.setSelectedKey(defaultLang); if (langs.getSelectedIndex() == -1) { langs.setSelectedIndex(0); } langs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setLanguage((String) kcbm.getSelectedKey()); } } }); builder.add(langs, cc.xyw(3, 7, 7)); builder.add(smcheckBox, cc.xyw(1, 9, 9)); JButton service = new JButton(Messages.getString("NetworkTab.4")); service.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (PMS.get().installWin32Service()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"), "Information", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE); } } }); builder.add(service, cc.xy(1, 11)); if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) { service.setEnabled(false); } host = new JTextField(PMS.getConfiguration().getServerHostname()); host.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { configuration.setHostname(host.getText()); PMS.get().getFrame().setReloadable(true); } }); // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ; port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : ""); port.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { try { String p = port.getText(); if (StringUtils.isEmpty(p)) { p = "5001"; } int ab = Integer.parseInt(p); configuration.setServerPort(ab); PMS.get().getFrame().setReloadable(true); } catch (NumberFormatException nfe) { } } }); cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); ArrayList<String> names = new ArrayList<String>(); names.add(""); ArrayList<String> interfaces = new ArrayList<String>(); interfaces.add(""); Enumeration<NetworkInterface> enm; try { enm = NetworkInterface.getNetworkInterfaces(); while (enm.hasMoreElements()) { NetworkInterface ni = enm.nextElement(); // check for interface has at least one ip address. if (ni.getInetAddresses().hasMoreElements()) { names.add(ni.getName()); String displayName = ni.getDisplayName(); if (displayName == null) { displayName = ni.getName(); } interfaces.add(displayName.trim()); } } } catch (SocketException e1) { logger.error(null, e1); } final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray()); networkinterfacesCBX = new JComboBox(networkInterfaces); networkInterfaces.setSelectedKey(configuration.getNetworkInterface()); networkinterfacesCBX.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey()); //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ; PMS.get().getFrame().setReloadable(true); } } }); ip_filter = new JTextField(PMS.getConfiguration().getIpFilter()); ip_filter.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { configuration.setIpFilter(ip_filter.getText()); PMS.get().getFrame().setReloadable(true); } }); builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23)); builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7)); builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25)); builder.add(host, cc.xyw(3, 25, 7)); builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27)); builder.add(port, cc.xyw(3, 27, 7)); builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29)); builder.add(ip_filter, cc.xyw(3, 29, 7)); cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32")); newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2()); newHTTPEngine.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(newHTTPEngine, cc.xyw(1, 33, 9)); preventSleep = new JCheckBox(Messages.getString("NetworkTab.33")); preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep()); preventSleep.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(preventSleep, cc.xyw(1, 35, 9)); cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); JPanel panel = builder.getPanel(); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); return scrollPane; }
From source file:org.codinjutsu.tools.mongo.runner.MongoRunConfigurationEditor.java
public MongoRunConfigurationEditor(Project project) { mongoShellOptionsPanel.setBorder(IdeBorderFactory.createTitledBorder("Mongo shell options", true)); shellParametersField.setDialogCaption("Mongo arguments"); MongoServer[] mongoServers = getAvailableMongoServers(project); if (mongoServers.length == 0) { serverConfigurationCombobox.setEnabled(false); databaseCombobox.setEnabled(false); return;/*from w ww. ja v a2s . c om*/ } serverConfigurationCombobox.setModel(new DefaultComboBoxModel(mongoServers)); serverConfigurationCombobox.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { MongoServer serverConfiguration = (MongoServer) value; append(serverConfiguration.getLabel()); } }); databaseCombobox.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { MongoDatabase mongoDatabase = (MongoDatabase) value; if (value == null) { return; } append(mongoDatabase.getName()); } }); serverConfigurationCombobox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { MongoServer selectedServer = (MongoServer) serverConfigurationCombobox.getSelectedItem(); if (selectedServer == null) { return; } databaseCombobox.removeAllItems(); for (MongoDatabase mongoDatabase : selectedServer.getDatabases()) { databaseCombobox.addItem(mongoDatabase); } } }); serverConfigurationCombobox.setSelectedIndex(-1); serverConfigurationCombobox.setSelectedIndex(0); }
From source file:org.kontalk.view.ThreadDetails.java
ThreadDetails(final Component focusGainer, KonThread thread) { mThread = thread;/*from w ww. ja va2 s . co m*/ GroupPanel groupPanel = new GroupPanel(View.GAP_BIG, false); groupPanel.setMargin(View.MARGIN_BIG); groupPanel.add(new WebLabel(Tr.tr("Edit Chat")).setBoldFont()); groupPanel.add(new WebSeparator(true, true)); // editable fields groupPanel.add(new WebLabel(Tr.tr("Subject:"))); String subj = mThread.getSubject(); mSubjectField = new WebTextField(subj, 22); mSubjectField.setInputPrompt(subj); mSubjectField.setHideInputPromptOnFocus(false); groupPanel.add(mSubjectField); groupPanel.add(new WebSeparator(true, true)); final WebSlider colorSlider = new WebSlider(WebSlider.HORIZONTAL); groupPanel.add(new WebLabel(Tr.tr("Custom Background"))); mColorOpt = new WebRadioButton(Tr.tr("Color:") + " "); Optional<Color> optBGColor = mThread.getViewSettings().getBGColor(); mColorOpt.setSelected(optBGColor.isPresent()); mColorOpt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { colorSlider.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mColor = new WebButton(); mColor.setMinimumHeight(25); Color oldColor = optBGColor.orElse(DEFAULT_BG); mColor.setBottomBgColor(oldColor); groupPanel.add(new GroupPanel(GroupingType.fillLast, mColorOpt, mColor)); colorSlider.setMinimum(0); colorSlider.setMaximum(100); colorSlider.setPaintTicks(false); colorSlider.setPaintLabels(false); colorSlider.setEnabled(optBGColor.isPresent()); final GradientData gradientData = GradientData.getDefaultValue(); // TODO set location for color gradientData.getColor(0); colorSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float v = colorSlider.getValue() / (float) 100; Color c = gradientData.getColorForLocation(v); mColor.setBottomBgColor(c); mColor.repaint(); } }); groupPanel.add(colorSlider); mImgOpt = new WebRadioButton(Tr.tr("Image:") + " "); String imgPath = mThread.getViewSettings().getImagePath(); mImgOpt.setSelected(!imgPath.isEmpty()); mImgOpt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { mImgChooser.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mImgChooser.getChooseButton().setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mImgChooser = Utils.createImageChooser(!imgPath.isEmpty(), imgPath); groupPanel.add(new GroupPanel(GroupingType.fillLast, mImgOpt, mImgChooser)); UnselectableButtonGroup.group(mColorOpt, mImgOpt); groupPanel.add(new WebSeparator()); // groupPanel.add(new WebLabel(Tr.tr("Participants:"))); // mParticipantsList = new WebCheckBoxList(); // mParticipantsList.setVisibleRowCount(10); // for (User oneUser : UserList.getInstance().getAll()) { // boolean selected = mThread.getUser().contains(oneUser); // mParticipantsList.getCheckBoxListModel().addCheckBoxElement( // new UserElement(oneUser), // selected); // } final WebButton saveButton = new WebButton(Tr.tr("Save")); // mParticipantsList.getModel().addListDataListener(new ListDataListener() { // @Override // public void intervalAdded(ListDataEvent e) { // } // @Override // public void intervalRemoved(ListDataEvent e) { // } // @Override // public void contentsChanged(ListDataEvent e) { // saveButton.setEnabled(!mParticipantsList.getCheckedValues().isEmpty()); // } // }); // // groupPanel.add(new WebScrollPane(mParticipantsList)); // groupPanel.add(new WebSeparator(true, true)); this.add(groupPanel, BorderLayout.CENTER); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // if (mParticipantsList.getCheckedValues().size() > 1) { // String infoText = Tr.t/r("More than one receiver not supported (yet)."); // WebOptionPane.showMessageDialog(ThreadListView.this, // infoText, // Tr.t/r("Sorry"), // WebOptionPane.INFORMATION_MESSAGE); // return; // } ThreadDetails.this.save(); // close popup focusGainer.requestFocus(); } }); //this.getRootPane().setDefaultButton(saveButton); GroupPanel buttonPanel = new GroupPanel(2, saveButton); buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); this.add(buttonPanel, BorderLayout.SOUTH); }