private static int getComboBoxBaselineResizeBehavior(JComboBox cb) { if (cb.isEditable()) { return getBaselineResizeBehavior(cb.getEditor().getEditorComponent()); } ListCellRenderer renderer = cb.getRenderer(); if (renderer == null) { if (brbListCellRenderer == null) { brbListCellRenderer = new DefaultListCellRenderer(); } renderer = brbListCellRenderer; } Object value = null; Object prototypeValue = cb.getPrototypeDisplayValue(); if (prototypeValue != null) { value = prototypeValue; } else if (cb.getModel().getSize() > 0) { value = cb.getModel().getElementAt(0); } if (value != null) { if (brbList == null) { brbList = new JList(); } Component component = renderer.getListCellRendererComponent(brbList, value, -1, false, false); return getBaselineResizeBehavior(component); } return BRB_OTHER; }
void move(int direction) { int index = -1; int size = 0; if (myCombo != null) { index = myCombo.getSelectedIndex(); size = myCombo.getModel().getSize(); } else if (myList != null) { index = myList.getSelectedIndex(); size = myList.getModel().getSize(); } if (index == -1 || size == 0) return; index += direction; if (index == size) { if (!UISettings.getInstance().CYCLE_SCROLLING) return; index = 0; } else if (index == -1) { if (!UISettings.getInstance().CYCLE_SCROLLING) return; index = size - 1; } if (myCombo != null) { myCombo.setSelectedIndex(index); } else if (myList != null) { myList.setSelectedIndex(index); } }
public void testModulesSelector() throws ConfigurationException { if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; Module module1 = getModule1(); Module module2 = getModule2(); JUnitConfigurable editor = new JUnitConfigurable(myProject); try { JUnitConfiguration configuration = createConfiguration(findTestA(module2)); editor.getComponent(); // To get all the watchers installed. Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration); JComboBox comboBox = editor.getModulesComponent(); configurable.reset(); assertFalse(configurable.isModified()); assertEquals(module2.getName(), ((Module) comboBox.getSelectedItem()).getName()); assertEquals( ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); // no module comboBox.setSelectedItem(module1); assertTrue(configurable.isModified()); configurable.apply(); assertFalse(configurable.isModified()); assertEquals( Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules())); } finally { Disposer.dispose(editor); } }
@Nullable private DownloadableFileSetDescription getSelectedVersion() { final Object version = versionComboBox.getModel().getSelectedItem(); return version instanceof DownloadableFileSetDescription ? (DownloadableFileSetDescription) version : null; }
private void stateChanged(ActionEvent event) { // debug("state changed: " + (agents.getSelectedIndex() + 1) + ". item selected"); if (agents.getSelectedIndex() + 1 == agents.getModel().getSize()) { // debug("a new agent shall be created!"); model.createNewAgent(); } else model.reReadAgents(); }
public Element createXML() { if (agents.getSelectedIndex() + 1 < agents.getModel().getSize()) { Element e = (Element) AgentComboBoxModel.getAgents().get(agents.getSelectedIndex()); Vector settings = new Vector(); // Eigenschaften ab 7 werden als Settings fürs Tool ausgelesen (EXIF-Tags) :) // ist keines gesetzt, so wird der Vector wieder auf null gesetzt :) boolean atLeastOneSettingDefined = false; Iterator itVals = ctm.getValues().iterator(); int tempCount = 0; for (Object o : ctm.getKeys()) { String tempKey = (String) o; String tempVal = (String) itVals.next(); if (tempVal.length() > 0 && tempCount > 5) { // Wenn Wert da und wenns keiner der ersten 6 std werte is settings.add(tempKey + "=" + tempVal); atLeastOneSettingDefined = true; } tempCount++; } if (!atLeastOneSettingDefined) settings = null; String time = null; if (datatable.getValueAt(0, 1).toString().length() > 0) time = datatable.getValueAt(0, 1).toString(); String tool = null; int count = 0; for (Object o1 : ctm.getKeys()) { String s = (String) o1; if (s.equals("Make")) { if (tool == null) tool = new String(); tool = ctm.getValues().get(count) + " " + tool; } if (s.equals("Model")) { if (tool == null) tool = new String(); tool = tool + ctm.getValues().get(count); } count++; } Mpeg7CreationInformation m7ci = new Mpeg7CreationInformation(e, tool, settings, time); // Getting data .... String bits = null, fformat = null, fsize = null, ih = null, iw = null; if (datatable.getValueAt(1, 1).toString().length() > 0) fformat = datatable.getValueAt(1, 1).toString(); if (datatable.getValueAt(2, 1).toString().length() > 0) fsize = datatable.getValueAt(2, 1).toString(); if (datatable.getValueAt(4, 1).toString().length() > 0) ih = datatable.getValueAt(4, 1).toString(); if (datatable.getValueAt(3, 1).toString().length() > 0) iw = datatable.getValueAt(3, 1).toString(); if (datatable.getValueAt(5, 1).toString().length() > 0) bits = datatable.getValueAt(5, 1).toString(); Mpeg7MediaFormat m7mf = new Mpeg7MediaFormat(bits, fformat, fsize, ih, iw); Element mediaFormat = m7mf.createDocument(); Element ret = new Element("return", mediaFormat.getNamespace()).addContent(mediaFormat); ret.addContent(m7ci.createDocument().detach()); return ret; } else { return null; } }
private void selectTestType(TestType testType) { TestTypeListItem testTypeListItem = myListItemByTestTypeMap.get(testType); ComboBoxModel comboBoxModel = myTestTypeComboBox.getModel(); if (comboBoxModel.getSelectedItem() != testTypeListItem) { comboBoxModel.setSelectedItem(testTypeListItem); } myTestTypeContentRunSettingsSection.select(testTypeListItem); }
/** populates the comptype combo box with the COMPONENT_TYPES */ private void populateCompType() { DefaultComboBoxModel model = (DefaultComboBoxModel) comptype.getModel(); for (int count = 0; count < COMPONENT_TYPES.length; count++) { model.addElement(COMPONENT_TYPES[count]); } comptype.addItemListener(this); }
@Override public void adoptElement(SceneElement elem) { if (!(elem instanceof NenyaImageSceneElement || elem instanceof NenyaTileSceneElement || elem instanceof NenyaComponentSceneElement)) { enableEditor(false); return; } DefaultComboBoxModel dcm = (DefaultComboBoxModel) itemList.getModel(); // Important: Work on a copy, not on the original. Otherwise we mess up the undomanager sceneElement = elem.copy(); if ((sceneElement instanceof NenyaImageSceneElement) && !locked) { dcm.removeAllElements(); String[] tmp = ((NenyaImageSceneElement) sceneElement).getPath(); dcm.addElement(tmp[tmp.length - 1]); } if ((sceneElement instanceof NenyaTileSceneElement) && !locked) { dcm.removeAllElements(); dcm.addElement(((NenyaTileSceneElement) sceneElement).getTileName()); } if ((sceneElement instanceof NenyaComponentSceneElement) && !locked) { dcm.removeAllElements(); NenyaComponentItem[] ni = ((NenyaComponentSceneElement) sceneElement).getComponents(); for (NenyaComponentItem element : ni) { dcm.addElement(element); } } try { ClassedItem[] cols = null; if (elem instanceof NenyaTileSceneElement) cols = ((NenyaTileSceneElement) elem).getColorList(); if (elem instanceof NenyaImageSceneElement) cols = ((NenyaImageSceneElement) elem).getColorList(); if (elem instanceof NenyaComponentSceneElement) { NenyaComponentItem nci = (NenyaComponentItem) dcm.getSelectedItem(); cols = nci.getColorList(); } Vector<TreePath> collect = new Vector<TreePath>(); TreeNode root = (TreeNode) colors.getModel().getRoot(); for (ClassedItem col : cols) { String[] tmp = {root.toString(), col.getClassName(), col.getItemName()}; collect.add(TreeUtil.findPath(root, tmp)); } TreePath[] path = collect.toArray(new TreePath[0]); colors.getSelectionModel().setSelectionPaths(path); } catch (Exception e) { // Either the tree is filtered away or the selected item is not colorized. } enableEditor(true); itemList.setEnabled(elem instanceof NenyaComponentSceneElement); }
/** * Sets the log level combo box to the specified log level. * * @param logLevel the log level in question. */ private void setLogLevelComboBoxSetting(LogLevel logLevel) { DefaultComboBoxModel model = (DefaultComboBoxModel) logLevelComboBox.getModel(); for (int index = 0; index < model.getSize(); index++) { LogLevelWrapper wrapper = (LogLevelWrapper) model.getElementAt(index); if (wrapper.logLevel == logLevel) { logLevelComboBox.setSelectedIndex(index); return; } } }
public LibraryDescriptor findLibraryDescriptorFor(LibraryId id) { DefaultComboBoxModel model = (DefaultComboBoxModel) myCompilerLibrary.getModel(); for (int i = 0; i < model.getSize(); i++) { LibraryDescriptor entry = (LibraryDescriptor) model.getElementAt(i); if (entry != null && entry.id().equals(id)) { return entry; } } return null; }
private void prepareTextComboBox(final Object propertyValue) { // _textComboBox wird in der letzten Zeile editierbar gemacht, und es wird // der übergebene Wert in diese Zeile eingetragen und selektiert, wenn er nicht // einem der anderen Einträge entspricht. if (propertyValue != null) { String propertyValueAsString = (String) propertyValue; final int size = _textComboBox.getModel().getSize(); boolean propertyValueFound = false; for (int i = 0; i < size - 1; i++) { if (propertyValueAsString.equals((String) _textComboBox.getItemAt(i))) { propertyValueFound = true; _textComboBox.setSelectedIndex(i); break; } } if (!propertyValueFound) { _textComboBox.removeItemAt(size - 1); _textComboBox.addItem(propertyValueAsString); _textComboBox.setSelectedIndex(size - 1); } } ItemListener textComboBoxItemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (_textComboBox.getSelectedIndex() == DOTPointPainter.DYNAMIC_TEXT_ITEMS.length - 1) { _textComboBox.setEditable(true); } else { _textComboBox.setEditable(false); } } } }; _textComboBox.addItemListener(textComboBoxItemListener); ActionListener editorActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { final int length = DOTPointPainter.DYNAMIC_TEXT_ITEMS.length; final int index = length - 1; final ComboBoxEditor editor = _textComboBox.getEditor(); String editedItem = (String) editor.getItem(); _textComboBox.insertItemAt(editedItem, index); final DefaultComboBoxModel model = (DefaultComboBoxModel) _textComboBox.getModel(); if (model.getSize() > length) { // Sieht komisch aus, aber der direkte Weg ging nicht. model.removeElementAt(length); } } }; _textComboBox.getEditor().addActionListener(editorActionListener); }
public boolean isModified() { Sdk sdk = myCompilationServerSdk.getSelectedJdk(); String sdkName = sdk == null ? null : sdk.getName(); if (showTypeInfoOnCheckBox.isSelected() != mySettings.SHOW_TYPE_TOOLTIP_ON_MOUSE_HOVER) return true; if (!delaySpinner.getValue().equals(mySettings.SHOW_TYPE_TOOLTIP_DELAY)) return true; return !(myEnableCompileServer.isSelected() == mySettings.COMPILE_SERVER_ENABLED && myCompilationServerPort.getText().equals(mySettings.COMPILE_SERVER_PORT) && ComparatorUtil.equalsNullable(sdkName, mySettings.COMPILE_SERVER_SDK) && myCompilationServerMaximumHeapSize .getText() .equals(mySettings.COMPILE_SERVER_MAXIMUM_HEAP_SIZE) && myCompilationServerJvmParameters .getText() .equals(mySettings.COMPILE_SERVER_JVM_PARAMETERS) && myIncrementalTypeCmb.getModel().getSelectedItem().equals(mySettings.INCREMENTAL_TYPE) && myCompileOrderCmb.getModel().getSelectedItem().equals(mySettings.COMPILE_ORDER)); }
/** * Find the class for the projection * * @param proj projection * @return corresponding ProjectionClass (or null if not found) */ private ProjectionClass findProjectionClass(Projection proj) { Class want = proj.getClass(); ComboBoxModel projClassList = projClassCB.getModel(); for (int i = 0; i < projClassList.getSize(); i++) { ProjectionClass pc = (ProjectionClass) projClassList.getElementAt(i); if (want.equals(pc.projClass)) { return pc; } } return null; }
private void selectScope(String preselect) { if (preselect != null) { final JComboBox combo = getComboBox(); DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel(); for (int i = 0; i < model.getSize(); i++) { ScopeDescriptor descriptor = (ScopeDescriptor) model.getElementAt(i); if (preselect.equals(descriptor.getDisplay())) { combo.setSelectedIndex(i); break; } } } }
public void apply() throws ConfigurationException { mySettings.INCREMENTAL_TYPE = (String) myIncrementalTypeCmb.getModel().getSelectedItem(); mySettings.COMPILE_ORDER = (String) myCompileOrderCmb.getModel().getSelectedItem(); mySettings.COMPILE_SERVER_ENABLED = myEnableCompileServer.isSelected(); mySettings.COMPILE_SERVER_PORT = myCompilationServerPort.getText(); Sdk sdk = myCompilationServerSdk.getSelectedJdk(); mySettings.COMPILE_SERVER_SDK = sdk == null ? null : sdk.getName(); mySettings.COMPILE_SERVER_MAXIMUM_HEAP_SIZE = myCompilationServerMaximumHeapSize.getText(); mySettings.COMPILE_SERVER_JVM_PARAMETERS = myCompilationServerJvmParameters.getText(); mySettings.SHOW_TYPE_TOOLTIP_ON_MOUSE_HOVER = showTypeInfoOnCheckBox.isSelected(); mySettings.SHOW_TYPE_TOOLTIP_DELAY = (Integer) delaySpinner.getValue(); // TODO // boolean externalCompiler = // CompilerWorkspaceConfiguration.getInstance(myProject).USE_COMPILE_SERVER; // // if (!externalCompiler || !myEnableCompileServer.isSelected()) { // myProject.getComponent(CompileServerLauncher.class).stop(); // } // myProject.getComponent(CompileServerManager.class).configureWidget(); }
public FeaturesConfigurationTab( final OfbizFacetConfiguration originalConfiguration, final FacetEditorContext editorContext) { this.originalConfiguration = originalConfiguration; disablePropertiesKeys.setSelected(originalConfiguration.isPropertiesKeysDisabled()); final Module module = editorContext.getModule(); // final String version = OfbizVersionDetector.detectStrutsVersion(module); final String version = "11.04"; if (version != null) { versionComboBox.setModel(new DefaultComboBoxModel(new String[] {version})); versionComboBox.getModel().setSelectedItem(version); versionComboBox.setEnabled(false); return; } }
public FeaturesConfigurationTab( final StrutsFacetConfiguration originalConfiguration, final FacetEditorContext editorContext, final FacetLibrariesValidator validator) { this.originalConfiguration = originalConfiguration; this.validator = validator; disablePropertiesKeys.setSelected(originalConfiguration.isPropertiesKeysDisabled()); final Module module = editorContext.getModule(); final String version = StrutsVersionDetector.detectStrutsVersion(module); if (version != null) { versionComboBox.setModel(new DefaultComboBoxModel(new String[] {version})); versionComboBox.getModel().setSelectedItem(version); versionComboBox.setEnabled(false); return; } setupVersionComboBox(); }
private void initUI() { SortedMap<String, SourceIdentifier> stats = mainFrame.getAvailableStatistics(); List<WrappedSourceIdentifier> wrappedSources = new ArrayList<WrappedSourceIdentifier>(stats.size() + 1); wrappedSources.add(new WrappedSourceIdentifier("Global", new SourceIdentifier("global"))); for (Map.Entry<String, SourceIdentifier> current : stats.entrySet()) { WrappedSourceIdentifier wrapped = new WrappedSourceIdentifier(current.getKey(), current.getValue()); wrappedSources.add(wrapped); } Object[] newSourcesArray = wrappedSources.toArray(); if (!Arrays.equals(previousSourcesArray, newSourcesArray)) { previousSourcesArray = newSourcesArray; DefaultComboBoxModel model = new DefaultComboBoxModel(newSourcesArray); sourcesComboBox.setModel(model); } int index = 0; if (sourceIdentifier != null) { ComboBoxModel model = sourcesComboBox.getModel(); for (int i = 0; i < model.getSize(); i++) { Object current = model.getElementAt(i); if (current instanceof WrappedSourceIdentifier) { WrappedSourceIdentifier wrapped = (WrappedSourceIdentifier) current; if (sourceIdentifier.getIdentifier().equals(wrapped.sourceIdentifier.getIdentifier())) { if (logger.isDebugEnabled()) logger.debug("Equal"); index = i; break; } else { if (logger.isDebugEnabled()) { logger.debug("Not equal: {} != {}", sourceIdentifier, wrapped.sourceIdentifier); } } } else { if (logger.isWarnEnabled()) logger.warn("Not instanceof WrappedSourceIdentifier"); } } } sourcesComboBox.setSelectedIndex(index); }
public FileTypePatternDialog( @Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) { myPatternField.setText(initialPatterns); if (fileType instanceof TemplateLanguageFileType) { final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel(); model.addElement(null); final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages(); Collections.sort( languages, new Comparator<Language>() { @Override public int compare(final Language o1, final Language o2) { return o1.getID().compareTo(o2.getID()); } }); for (Language language : languages) { model.addElement(language); } myLanguageCombo.setRenderer( new ListCellRendererWrapper() { @Override public void customize( JList list, Object value, int index, boolean selected, boolean hasFocus) { setText(value == null ? "" : ((Language) value).getDisplayName()); if (value != null) { final FileType type = ((Language) value).getAssociatedFileType(); if (type != null) { setIcon(type.getIcon()); } } } }); myLanguageCombo.setSelectedItem(templateDataLanguage); } else { myLanguageCombo.setVisible(false); myTemplateDataLanguageButton.setVisible(false); } }
@Override protected void resetEditorFrom(GoTestConfiguration s) { switch (s.executeWhat) { case Test: test.setSelected(true); break; case Benchmark: benchmark.setSelected(true); break; } if (s.filter == null || s.filter.isEmpty()) { updateTestsFilterField(); } else { filter.setSelected(true); testsFilter.setText(s.filter); updateTestsFilterField(); } packages.getModel().setSelectedItem(s.packageName); useShort.setSelected(s.useShortRun); moduleSelector.reset(s); }
/** initialises a parmeter to the default component */ private void initParam(String param) { params.put(param, comptype.getModel().getElementAt(0)); }
@Nullable private Artifact getSelectedVersion() { final Object version = versionComboBox.getModel().getSelectedItem(); return version instanceof Artifact ? (Artifact) version : null; }
public AutoCompletion(final JComboBox comboBox) { this.comboBox = comboBox; model = comboBox.getModel(); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!selecting) { highlightCompletedText(0); } } }); comboBox.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("editor")) { configureEditor((ComboBoxEditor) e.getNewValue()); } if (e.getPropertyName().equals("model")) { model = (ComboBoxModel) e.getNewValue(); } } }); editorKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent e) { if (comboBox.isDisplayable()) { comboBox.setPopupVisible(true); } hitBackspace = false; switch (e.getKeyCode()) { // determine if the pressed key is backspace (needed by the remove method) case KeyEvent.VK_BACK_SPACE: hitBackspace = true; hitBackspaceOnSelection = editor.getSelectionStart() != editor.getSelectionEnd(); break; // ignore delete key case KeyEvent.VK_DELETE: e.consume(); comboBox.getToolkit().beep(); break; } } }; // Bug 5100422 on Java 1.5: Editable JComboBox won't hide popup when tabbing out hidePopupOnFocusLoss = System.getProperty("java.version").startsWith("1.5"); // Highlight whole text when gaining focus editorFocusListener = new FocusAdapter() { public void focusGained(FocusEvent e) { highlightCompletedText(0); } public void focusLost(FocusEvent e) { // Workaround for Bug 5100422 - Hide Popup on focus loss if (hidePopupOnFocusLoss) { comboBox.setPopupVisible(false); } } }; configureEditor(comboBox.getEditor()); // Handle initially selected object Object selected = comboBox.getSelectedItem(); if (selected != null) { setText(selected.toString()); } highlightCompletedText(0); }
private void setComboboxModel( final JComboBox comboBox, final VirtualFile initialTargetDirectorySourceRoot, final VirtualFile oldSelection, final ProjectFileIndex fileIndex, final VirtualFile[] sourceRoots, final Project project, final boolean forceIncludeAll, final Pass<String> updateErrorMessage) { final LinkedHashSet<PsiDirectory> targetDirectories = new LinkedHashSet<PsiDirectory>(); final HashMap<PsiDirectory, String> pathsToCreate = new HashMap<PsiDirectory, String>(); MoveClassesOrPackagesUtil.buildDirectoryList( new PackageWrapper(PsiManager.getInstance(project), getTargetPackage()), sourceRoots, targetDirectories, pathsToCreate); if (!forceIncludeAll && targetDirectories.size() > pathsToCreate.size()) { targetDirectories.removeAll(pathsToCreate.keySet()); } final ArrayList<DirectoryChooser.ItemWrapper> items = new ArrayList<DirectoryChooser.ItemWrapper>(); DirectoryChooser.ItemWrapper initial = null; DirectoryChooser.ItemWrapper oldOne = null; for (PsiDirectory targetDirectory : targetDirectories) { DirectoryChooser.ItemWrapper itemWrapper = new DirectoryChooser.ItemWrapper(targetDirectory, pathsToCreate.get(targetDirectory)); items.add(itemWrapper); final VirtualFile sourceRootForFile = fileIndex.getSourceRootForFile(targetDirectory.getVirtualFile()); if (sourceRootForFile == initialTargetDirectorySourceRoot) { initial = itemWrapper; } else if (sourceRootForFile == oldSelection) { oldOne = itemWrapper; } } items.add(NULL_WRAPPER); final DirectoryChooser.ItemWrapper selection = chooseSelection(initialTargetDirectorySourceRoot, fileIndex, items, initial, oldOne); final ComboBoxModel model = comboBox.getModel(); if (model instanceof CollectionComboBoxModel) { boolean sameModel = model.getSize() == items.size(); if (sameModel) { for (int i = 0; i < items.size(); i++) { final DirectoryChooser.ItemWrapper oldItem = (DirectoryChooser.ItemWrapper) model.getElementAt(i); final DirectoryChooser.ItemWrapper itemWrapper = items.get(i); if (!areItemsEquivalent(oldItem, itemWrapper)) { sameModel = false; break; } } } if (sameModel) { if (areItemsEquivalent( (DirectoryChooser.ItemWrapper) comboBox.getSelectedItem(), selection)) { return; } } } updateErrorMessage(updateErrorMessage, fileIndex, selection); Collections.sort( items, new Comparator<DirectoryChooser.ItemWrapper>() { @Override public int compare(DirectoryChooser.ItemWrapper o1, DirectoryChooser.ItemWrapper o2) { if (o1 == NULL_WRAPPER) return -1; if (o2 == NULL_WRAPPER) return 1; return o1.getRelativeToProjectPath().compareToIgnoreCase(o2.getRelativeToProjectPath()); } }); comboBox.setModel(new CollectionComboBoxModel(items, selection)); }