public KMeanScatterPanelChoose(WorkloadAnalysisSession m) { super(new BorderLayout()); setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Scatter Clustering")); model = (ModelWorkloadAnalysis) m.getDataModel(); this.session = m; varXCombo = new JComboBox(model.getMatrix().getVariableNames()); varYCombo = new JComboBox(model.getMatrix().getVariableNames()); varXCombo.setSelectedIndex(0); varYCombo.setSelectedIndex(1); JButton vis = new JButton(VIS_SCATTER); JPanel combos = new JPanel(new GridLayout(1, 2, 5, 0)); combos.add(varXCombo); combos.add(varYCombo); add(combos, BorderLayout.NORTH); add(vis, BorderLayout.SOUTH); }
/** * Returns path relative to the root of the SFS. May return * <code>null</code> for empty String or user's custom non-string items. * Also see {@link Util#isValidSFSPath(String)}. */ public static String getSFSPath(final JComboBox lpCombo, final String supposedRoot) { Object editorItem = lpCombo.getEditor().getItem(); String path = null; if (editorItem instanceof LayerItemPresenter) { path = ((LayerItemPresenter) editorItem).getFullPath(); } else if (editorItem instanceof String) { String editorItemS = ((String) editorItem).trim(); if (editorItemS.length() > 0) { path = searchLIPCategoryCombo(lpCombo, editorItemS); if (path == null) { // entered by user - absolute and relative are supported... path = editorItemS.startsWith(supposedRoot) ? editorItemS : supposedRoot + '/' + editorItemS; } } } return path; }
public AnonActionProfileListener(JComboBox<Object> anonProfiles, JLabel profileLabel, JRadioButton radioBodyCharac1, JRadioButton radioBodyCharac2, JRadioButton radioDates1, JRadioButton radioDates2, JRadioButton radioBd2, JRadioButton radioBd1, JRadioButton radioPt1, JRadioButton radioPt2, JRadioButton radioSc1, JRadioButton radioSc2, JRadioButton radioDesc1, JRadioButton radioDesc2){ this.profileLabel = profileLabel; this.anonProfiles = anonProfiles; this.radioBodyCharac1 = radioBodyCharac1; this.radioBodyCharac2 = radioBodyCharac2; this.radioDates1 = radioDates1; this.radioDates2 = radioDates2; this.radioBd2 = radioBd2; this.radioBd1 = radioBd1; this.radioPt1 = radioPt1; this.radioPt2 = radioPt2; this.radioSc1 = radioSc1; this.radioSc2 = radioSc2; this.radioDesc1 = radioDesc1; this.radioDesc2 = radioDesc2; }
public void setUpSportColumn(JTable table, TableColumn sportColumn) { // Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); }
private void createPositionModel(final JComboBox positionsCombo, final FileObject[] files, final LayerItemPresenter parent) { DefaultComboBoxModel newModel = new DefaultComboBoxModel(); LayerItemPresenter previous = null; for (FileObject file : files) { if (file.getNameExt().endsWith(LayerUtil.HIDDEN)) { continue; } LayerItemPresenter current = new LayerItemPresenter( file, parent.getFileObject()); newModel.addElement(createPosition(previous, current)); previous = current; } newModel.addElement(createPosition(previous, null)); positionsCombo.setModel(newModel); checkValidity(); }
private static void setup(final Point tmp) { comboBox = new JComboBox<>(); for (int i = 1; i < 7; i++) { comboBox.addItem("Long-long-long-long-long text in the item-" + i); } String property = System.getProperty(PROPERTY_NAME); comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property)); frame = new JFrame(); frame.setAlwaysOnTop(true); frame.setLayout(new FlowLayout()); frame.add(comboBox); frame.pack(); frame.setSize(frame.getWidth(), SIZE); frame.setVisible(true); frame.setLocation(tmp.x, tmp.y); }
@Test public void testMatchTypeComboBoxWithUnsupportedTypes() { JComboBox cb = new JComboBox(); SearchPatternController controller = ComponentUtils.adjustComboForSearchPattern(cb); JComboBox matchTypeCb = new JComboBox( new Object[]{MatchType.LITERAL, MatchType.REGEXP}); controller.bindMatchTypeComboBox(matchTypeCb); assertEquals(MatchType.LITERAL, matchTypeCb.getSelectedItem()); controller.setSearchPattern(SearchPattern.create("test", false, false, MatchType.BASIC)); assertEquals(MatchType.LITERAL, controller.getSearchPattern().getMatchType()); controller.setSearchPattern(SearchPattern.create("test", false, false, MatchType.REGEXP)); assertEquals(MatchType.REGEXP, controller.getSearchPattern().getMatchType()); controller.setSearchPattern(SearchPattern.create("test", false, false, MatchType.BASIC)); assertEquals(MatchType.REGEXP, controller.getSearchPattern().getMatchType()); }
public void assertContentDuplicates() throws InterruptedException { siw(new Runnable() { @Override public void run() { combo = (JComboBox) ComponentUtils.findComponent(JComboBox.class, frame); } }); final RComboBox rCombo = new RComboBox(combo, null, null, new LoggingRecorder()); final Object[] content = new Object[] { null }; siw(new Runnable() { @Override public void run() { content[0] = rCombo.getContent(); } }); JSONArray a = new JSONArray(content[0]); AssertJUnit.assertEquals("[[\"Phillip\",\"Larry\",\"Lisa\",\"James\",\"Larry(1)\"]]", a.toString()); }
private void initializeComboBoxes() throws Exception { List<LocalidadeVO> localidades = this.cadastroRota.recuperarLocalidades(); this.cboxOrigem = new JComboBox<LocalidadeVO>(); this.startComboBoxValues(this.cboxOrigem, localidades); GridBagConstraints gbc_comboBox = new GridBagConstraints(); gbc_comboBox.insets = new Insets(0, 0, 5, 5); gbc_comboBox.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox.gridx = 3; gbc_comboBox.gridy = 3; this.panel.add(this.cboxOrigem, gbc_comboBox); this.cboxDestino = new JComboBox<LocalidadeVO>(); this.startComboBoxValues(this.cboxDestino, localidades); GridBagConstraints gbc_comboBox_1 = new GridBagConstraints(); gbc_comboBox_1.insets = new Insets(0, 0, 5, 5); gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_1.gridx = 3; gbc_comboBox_1.gridy = 8; this.panel.add(this.cboxDestino, gbc_comboBox_1); }
private void setRepository(Repository repository, HookPanel panel) throws IllegalArgumentException, IllegalAccessException { Field[] fs = panel.qs.getClass().getDeclaredFields(); for (Field f : fs) { if(f.getType() == QuickSearchPanel.class) { f.setAccessible(true); QuickSearchPanel qsp = (QuickSearchPanel) f.get(panel.qs); fs = qsp.getClass().getDeclaredFields(); for (Field f2 : fs) { if(f2.getType() == JComboBox.class) { f2.setAccessible(true); JComboBox cmb = (JComboBox) f2.get(qsp); DefaultComboBoxModel model = new DefaultComboBoxModel(new Repository[] {repository}); cmb.setModel(model); cmb.setSelectedItem(repository); return; } } } } }
/** * Checks if is memory selection error. The initial memory should * always be larger than the maximum memory of the JVM. * @return true, if is memory selection error */ private boolean isMemorySelectionError(JComboBox<String> combo) { boolean error = false; String initialMemory = (String) getJComboBoxJVMMemoryInitial().getSelectedItem(); String maximumMemory = (String) getJComboBoxJVMMemoryMaximum().getSelectedItem(); int initMem = Integer.parseInt(initialMemory.replaceAll("[a-zA-Z]", "")); int maxiMem = Integer.parseInt(maximumMemory.replaceAll("[a-zA-Z]", "")); if(initialMemory.contains("g")){ initMem = initMem*1024; } if(maximumMemory.contains("g")){ maxiMem = maxiMem*1024; } if (initMem>=maxiMem) { combo.hidePopup(); String head = Language.translate("Initialer Arbeitsspeicher >= Maximaler Arbeitsspeicher !"); String msg = Language.translate("Der maximale Arbeitsspeicher muss größer als der initiale Arbeitsspeicher sein."); JOptionPane.showMessageDialog(Application.getMainWindow(), msg, head, JOptionPane.ERROR_MESSAGE); error = true; } return error; }
private void confirm(EventObject fe) { JTextField tf = (JTextField) fe.getSource(); JComboBox combo = (JComboBox) tf.getParent(); if (combo==null) return; if (fe instanceof FocusEvent) { combo.getEditor().getEditorComponent().removeFocusListener(this); } else { combo.getEditor().getEditorComponent().removeKeyListener(this); } Configuration config = configName==null ? ConfigurationsManager.getDefault().duplicate(lastSelected, tf.getText(), tf.getText()): ConfigurationsManager.getDefault().create(tf.getText(), tf.getText()); combo.setSelectedItem(config); combo.setEditable(false); }
/** * Check if the element is editable or not * * @return if the element is editable or not */ @PublicAtsApi public boolean isElementEditable() { try { Component component = SwingElementLocator.findFixture(element).component(); if (component instanceof JTextComponent) { return ((JTextComponent) component).isEditable(); } else if (component instanceof JComboBox) { return ((JComboBox) component).isEditable(); } else if (component instanceof JTree) { return ((JTree) component).isEditable(); } throw new NotSupportedOperationException("Component of type \"" + component.getClass().getName() + "\" doesn't have 'editable' state!"); } catch (ElementNotFoundException nsee) { lastNotFoundException = nsee; return false; } }
public FontInterpolator(Font selectedFont, GetSet gs, ChangeListener... listeners) { super(gs, listeners); Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); String[] fontNames = new String[fonts.length]; for(int i = 0; i < fonts.length; i++) fontNames[i] = fonts[i].getFontName(); box = new JComboBox<String>(fontNames) { private static final long serialVersionUID = 2454221612986775298L; @Override public Dimension getPreferredSize() { Dimension ps = super.getPreferredSize(); return new Dimension(Math.min(ps.width, 120), ps.height); } }; box.setSelectedItem(selectedFont.getFontName()); box.addActionListener(ae -> { fireChangeEvent(); }); }
@Override public void actionPerformed(ActionEvent ae) { if (ConfigurationsManager.getDefault().size() == 1) { setSelectedItem(getElementAt(0)); return; } JComboBox combo = (JComboBox) ae.getSource(); combo.setSelectedItem(lastSelected); combo.hidePopup(); if (JOptionPane.showConfirmDialog(combo, Bundle.MSG_ReallyDeleteConfig(lastSelected), Bundle.DeleteConfigTitle(), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { ConfigurationsManager.getDefault().remove(lastSelected); setSelectedItem(getElementAt(0)); } }
private static JComboBox findComboBox(Component comp) { if (comp instanceof JLabel) { JLabel label = (JLabel) comp; if (LABEL_TEXT.equals(label.getText())) { return (JComboBox) label.getLabelFor(); } } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { JComboBox result = findComboBox(cont.getComponent(i)); if (result != null) { return result; } } } return null; }
public Component getControls() { if (panel == null) { panel = Box.createHorizontalBox(); panel.add(new JLabel(name)); box = new JComboBox(validValues); box.setMaximumSize(new Dimension(box.getMaximumSize().width,box.getPreferredSize().height)); if (isValidValue(getValue())) { box.setSelectedItem(getValue()); } else if (validValues.length > 0) { box.setSelectedIndex(0); } box.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { noUpdate = true; setValue(box.getSelectedItem()); noUpdate = false; } }); panel.add(box); } return panel; }
public void testProcessRecentFolders_BranchInHistory () throws Exception { JComboBox combo = new JComboBox(); JTextComponent comp = (JTextComponent) combo.getEditor().getEditorComponent(); Map<String, String> items; // combo items should be sorted by name // file on branch, branches and tags in history items = CopyDialog.setupModel(combo, new RepositoryFile(new SVNUrl("file:///home"), "branches/SOMEBRANCH/subfolder/folder", SVNRevision.HEAD), recentUrlsWithBranches, false); assertModel(items, combo, Arrays.asList(new String[] { "trunk/subfolder/folder", null, "----------", null, "branches/branch1/subfolder/folder", "<html>branches/<strong>branch1</strong>/subfolder/folder</html>", "tags/tag1/subfolder/folder", "<html>tags/<strong>tag1</strong>/subfolder/folder</html>", MORE_BRANCHES, null, "----------", null, "branches/branch1/Project/src/folder", null, "Project/src/folder", null, "Project2/src/folder", null, "tags/tag1/Project/src/folder", null, "trunk/Project/src/folder", null })); // least recently used branch is preselected assertEquals("branches/branch1/subfolder/folder", comp.getText()); // no branch - no selection assertEquals("branch1", comp.getSelectedText()); }
private void initMappings(List<FreeformProjectGenerator.TargetMapping> list, String antScript) { for (FreeformProjectGenerator.TargetMapping tm : list) { Iterator<JComboBox> combosIt = combos.iterator(); for (TargetDescriptor desc : targetDescs) { JComboBox combo = combosIt.next(); if (tm.name.equals(desc.getIDEActionName())) { selectItem(combo, Collections.singletonList(getListAsString(tm.targets)), true); checkAntScript(combo, antScript, tm.script); } } } targetMappings = list; }
@Override public void popupMenuCanceled(PopupMenuEvent e) { // without the check the previous non-special item would be displayed // while calling DataComboBoxModel.newItemActionPerformed() // instead of NEW_ITEM, but this is unwanted. Same for // popupMenuWillBecomeImvisible(). if (!performingNewItemAction) { setPreviousNonSpecialItem((JComboBox)e.getSource()); } }
static JComboBox makeAlphabetizedComboBox(Map<Procedure, MarkovGraph> grafs) { List<Procedure> ls = new LinkedList<Procedure>(); List<String> names = new LinkedList<String>(); ls.addAll(grafs.keySet()); for (Procedure p : ls) { names.add(p.getName().toLowerCase()); } Collections.sort(names); JComboBox jcb = new JComboBox(names.toArray()); ActionListener l = null; // FIXME(svelagap) new MyActionListener(grafs); jcb.addActionListener(l); return jcb; }
/** * Maps {@code JComboBox.removeItemAt(int)} through queue */ public void removeItemAt(final int i) { runMapping(new MapVoidAction("removeItemAt") { @Override public void map() { ((JComboBox) getSource()).removeItemAt(i); } }); }
/** Asks the user to choose a font; returns "" if the user cancels the request. */ public synchronized static String askFont() { if (allFonts == null) allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); JComboBox jcombo = new OurCombobox(allFonts); Object ans = show("Font", JOptionPane.INFORMATION_MESSAGE, new Object[] {"Please choose the new font:", jcombo}, new Object[] {"Ok", "Cancel"}, "Cancel" ); Object value = jcombo.getSelectedItem(); if (ans=="Ok" && (value instanceof String)) return (String)value; else return ""; }
Box createGeneralPanel() { chkDwnldPrg = new JCheckBox(getString("SHOW_DWNLD_PRG")); chkDwnldPrg.setContentAreaFilled(false); chkDwnldPrg.setFocusPainted(false); chkDwnldNotify = new JCheckBox(getString("SHOW_DWNLD_PRG_NOTIFY")); chkDwnldPrg.setContentAreaFilled(false); chkDwnldPrg.setFocusPainted(false); chkFinishedDlg = new JCheckBox(getString("SHOW_DWNLD_DLG")); chkFinishedDlg.setContentAreaFilled(false); chkFinishedDlg.setFocusPainted(false); chkFinishedNotify = new JCheckBox(getString("SHOW_DWNLD_NOTIFY")); chkFinishedNotify.setContentAreaFilled(false); chkFinishedNotify.setFocusPainted(false); // chkAllowBrowser = new JCheckBox(getString("ALLOW_BROWSER")); // chkAllowBrowser.setContentAreaFilled(false); // chkAllowBrowser.setFocusPainted(false); cmbDupAction = new JComboBox(new String[] { StringResource.getString("DUP__OP1"), StringResource.getString("DUP__OP2"), StringResource.getString("DUP__OP3"), StringResource.getString("DUP__OP4") }); cmbDupAction.setBorder(null); cmbDupAction.setMaximumSize(new Dimension(chkDwnldPrg .getPreferredSize().width, cmbDupAction.getPreferredSize().height)); Box box = Box.createVerticalBox(); box.setOpaque(false); box.setBorder(new EmptyBorder(10, 0, 0, 10)); Box b0 = Box.createHorizontalBox(); b0.add(chkDwnldPrg); b0.add(Box.createHorizontalGlue()); box.add(b0); Box b1 = Box.createHorizontalBox(); b1.add(chkFinishedDlg); b1.add(Box.createHorizontalGlue()); box.add(b1); Box b31 = Box.createHorizontalBox(); b31.add(chkDwnldNotify); b31.add(Box.createHorizontalGlue()); box.add(b31); Box b3 = Box.createHorizontalBox(); b3.add(chkFinishedNotify); b3.add(Box.createHorizontalGlue()); box.add(b3); // Box b2 = Box.createHorizontalBox(); // b2.add(chkAllowBrowser); // b2.add(Box.createHorizontalGlue()); // box.add(b2); Box b4 = Box.createHorizontalBox(); b4.add(new JLabel(getString("SHOW_DUP_ACTION"))); b4.add(Box.createHorizontalGlue()); b4.add(cmbDupAction); box.add(Box.createVerticalStrut(10)); box.add(b4); return box; }
private void populateRecordSchema(JComboBox<NameValue> schemaCombo) { for( RecordFormat format : RecordFormat.values() ) { String uri = format.getUri(); String name = format.getName() + " - " + uri; //$NON-NLS-1$ schemaCombo.addItem(new NameValue(name, uri)); } }
/** * Maps {@code JComboBox.getUI()} through queue */ public ComboBoxUI getUI() { return (runMapping(new MapAction<ComboBoxUI>("getUI") { @Override public ComboBoxUI map() { return ((JComboBox) getSource()).getUI(); } })); }
private <E> JComboBox<E> createCombo(String name) { JComboBox<E> combo = new JComboBox<E>(); combo.setActionCommand(name); combo.addActionListener(this); return combo; }
private void createComboTransf() { transfs = new JComboBox(); transfs.setToolTipText(TRANSF_COMBO); transfs.addItem("Logarithmic"); transfs.addItem("Mix - Max"); transfs.addItem("z-score (Standard Deviation)"); }
/** Creates a new instance of TextComponentUpdater */ @SuppressWarnings("LeakingThisInConstructor") public ComboBoxUpdater(JComboBox comp, JLabel label) { component = comp; component.addAncestorListener(this); this.label = label; }
public EnumControl(final Class<? extends Enum> c, final Object f, PropertyDescriptor p) { super(); final String name = p.getName(); final Method r = p.getReadMethod(), w = p.getWriteMethod(); setterMap.put(name, this); clazz = f; write = w; read = r; setLayout(new GridLayout(1, 0)); // setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setAlignmentX(ALIGNMENT); final JLabel label = new JLabel(name); label.setAlignmentX(ALIGNMENT); label.setFont(label.getFont().deriveFont(fontSize)); addTip(p, label); add(label); control = new JComboBox(c.getEnumConstants()); control.setFont(control.getFont().deriveFont(fontSize)); // control.setHorizontalAlignment(SwingConstants.LEADING); add(label); add(control); refresh(); control.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { w.invoke(clazz, control.getSelectedItem()); } catch (Exception e2) { e2.printStackTrace(); } } }); }
@Override public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) { final JComboBox box = new JComboBox(); box.setRenderer(comboBoxRenderer); for (Stroke stroke : LineStyleChooser.getStrokes()) { box.addItem(stroke); } return new DefaultCellEditor(box) { private Pin pin; @Override public boolean stopCellEditing() { if (box.getSelectedItem() instanceof Stroke) { ((Journaled) engine).startUserTransaction(); apply((BasicStroke) box.getSelectedItem(), pin); return super.stopCellEditing(); } return false; } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { pin = (Pin) ((MetadataGetter) table).getMetadata(); return super.getTableCellEditorComponent(table, value, isSelected, row, column); } }; }
public void testComboParameters() { JComboBox combo = new JComboBox(); ComboParameter cp = new QueryParameter.ComboParameter(combo, PARAMETER, "UTF-8"); assertEquals(PARAMETER, cp.getParameter()); assertNull(combo.getSelectedItem()); assertEquals(cp.get(false).toString(), "&" + PARAMETER + "="); assertFalse(cp.isChanged()); cp.setParameterValues(VALUES); cp.setValues(new ParameterValue[] {PV2}); Object item = combo.getSelectedItem(); assertNotNull(item); assertEquals(PV2, item); ParameterValue[] v = cp.getValues(); assertEquals(1, v.length); assertEquals(PV2, v[0]); assertEquals(cp.get(false).toString(), "&" + PARAMETER + "=" + PV2.getValue()); combo.setSelectedItem(PV3); assertEquals(cp.get(false).toString(), "&" + PARAMETER + "=" + PV3.getValue()); assertTrue(cp.isChanged()); cp.reset(); assertFalse(cp.isChanged()); }
@Override public void actionPerformed(ActionEvent e) { JComboBox<Integer> cb = (JComboBox<Integer>) e.getSource(); Integer selectedYear = (Integer) cb.getSelectedItem(); setYearData(selectedYear); }
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // GMA 1.4.8: Now check which combo box event is coming from if ( e.getSource() == box ) { // ***** Changed by A.K.M. 6/23/06 ***** // setPrototypeDisplayValue restricts the size of the box to a fixed // length of eight characters box.setPrototypeDisplayValue("WWWWWWWW"); // The popup listener adjusts the size of the popup to match the size // of the text being displayed JComboBox tempBox = (JComboBox) e.getSource(); Object comp = tempBox.getUI().getAccessibleChild(tempBox, 0); if (!(comp instanceof JPopupMenu)) { return; } JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0); Dimension size = scrollPane.getPreferredSize(); UnknownDataSet tester1 = (UnknownDataSet)tempBox.getSelectedItem(); CustomBRGTable.setReverseYAxis(false); CustomBRGTable.setIgnoreZeros(false); // 6.5 is a hardcoded value that approximates the size of a // character in pixels // TODO: Find exact size of text in pixels and adjust // size.width accordingly if (tester1 != null) { if (maxDBNameLength < tester1.desc.name.length()) { maxDBNameLength = tester1.desc.name.length(); } size.width = (int)(maxDBNameLength * 6.5); scrollPane.setPreferredSize(size); } // ***** Changed by A.K.M. 6/23/06 ***** } }
protected void updateAnnotationSetsList() { String corpusName = (corpusToSearchIn.getSelectedItem() .equals(Constants.ENTIRE_DATASTORE)) ? null : (String)corpusIds .get(corpusToSearchIn.getSelectedIndex() - 1); TreeSet<String> ts = new TreeSet<String>(stringCollator); ts.addAll(getAnnotationSetNames(corpusName)); DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()])); dcbm.insertElementAt(Constants.ALL_SETS, 0); annotationSetsToSearchIn.setModel(dcbm); annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS); // used in the ConfigureStackViewFrame as Annotation type column // cell editor TreeSet<String> types = new TreeSet<String>(stringCollator); types.addAll(getTypesAndFeatures(null, null).keySet()); // put all annotation types from the datastore // combobox used as cell editor JComboBox<String> annotTypesBox = new JComboBox<String>(); annotTypesBox.setMaximumRowCount(10); annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()]))); DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox); cellEditor.setClickCountToStart(0); configureStackViewFrame.getTable().getColumnModel() .getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor); }
private void initCombo(JComboBox providerCombo) { DefaultComboBoxModel providers = new DefaultComboBoxModel(); for(Provider each : providerSupplier.getSupportedProviders()){ providers.addElement(each); } if (providers.getSize() == 0 && providerSupplier.supportsDefaultProvider()){ providers.addElement(ProviderUtil.DEFAULT_PROVIDER); } if (providers.getSize() == 0){ providers.addElement(EMPTY); } providerCombo.setModel(providers); providerCombo.addItem(SEPARATOR); providerCombo.addItem(new NewPersistenceLibraryItem()); providerCombo.addItem(new ManageLibrariesItem()); providerCombo.setRenderer(new PersistenceProviderCellRenderer(getDefaultProvider(providers))); //select either default or first or preferred provider depending on project details int selectIndex = 0; if(providers.getSize()>1 && providers.getElementAt(0) instanceof Provider){ String defProviderVersion = ProviderUtil.getVersion((Provider) providers.getElementAt(0)); boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider if(specialCase){ for (int i = 1; i<providers.getSize() ; i++){ if(preferredProvider.equals(providers.getElementAt(i))){ selectIndex = i; break; } } } } providerCombo.setSelectedIndex(selectIndex); }
@Override public Class<?> getColumnClass(int column) { switch (column) { case 0: return String.class; default: return JComboBox.class; } }
/** * Tests that the routine for determination if initial repository selection * is performed (not skipped) if there is only one repository available * and method {@code setup()} was passed {@code false} as its third * argument. It also tests that the routine correctly determines no * repository should be preselected if there is no node selected that * would refer to the repository. */ @Test(timeout=10000) public void testSingleRepoNoMatchingNodeFalse() throws InterruptedException { printTestName("testSingleRepoNoMatchingNodeFalse"); runRepositoryComboTest(new SingleRepoComboTezt() { @Override protected void setUpEnvironment() { selectNodes(node1); } @Override RepositoryComboSupport setupComboSupport(JComboBox comboBox) { return RepositoryComboSupport.setup(null, comboBox, false); } @Override protected void scheduleTests(ProgressTester progressTester) { super.scheduleTests(progressTester); progressTester.scheduleResumingTest (Progress.DISPLAYED_REPOS, AWT, new ComboBoxItemsTezt( SELECT_REPOSITORY, repository1), new SelectedItemtezt( SELECT_REPOSITORY)); progressTester.scheduleTest (Progress.WILL_DETERMINE_DEFAULT_REPO, NON_AWT); progressTester.scheduleTest (Progress.DETERMINED_DEFAULT_REPO, NON_AWT); } }); }
/** * This method initializes jComboBoxInterval. * @return javax.swing.JComboBox */ public JComboBox<TimeSelection> getJComboBoxInterval() { if (jComboBoxInterval == null) { jComboBoxInterval = new JComboBox<TimeSelection>(this.getComboBoxModelRecordingInterval()); jComboBoxInterval.setMaximumRowCount(comboBoxModelInterval.getSize()); jComboBoxInterval.setModel(comboBoxModelInterval); jComboBoxInterval.setToolTipText(Language.translate("Abtastintervall")); jComboBoxInterval.addActionListener(this); } return jComboBoxInterval; }
private static List populate(List<String> types, boolean creationSupported, final JComboBox combo, final String selectedType, boolean selectItemLater) { List<Object> items = (types == null ? new LinkedList<Object>() : new LinkedList<Object>(types)); if (items.size() > 0) { items.add(SEPARATOR_ITEM); } if (creationSupported) { items.add(NEW_ITEM); } ReturnTypeComboBoxModel model = new ReturnTypeComboBoxModel(types, items); combo.setModel(model); if (selectedType != null) { // Ensure that the correct item is selected before listeners like FocusListener are called. // ActionListener.actionPerformed() is not called if this method is already called from // actionPerformed(), in that case selectItemLater should be set to true and setSelectedItem() // below is called asynchronously so that the actionPerformed() is called setSelectedItem(combo, selectedType); if (selectItemLater) { SwingUtilities.invokeLater(new Runnable() { // postpone item selection to enable event firing from JCombobox.setSelectedItem() public void run() { setSelectedItem(combo, selectedType); // populate(LVALUE_TYPES, true, combo, "Object", false); } }); } } return types; }