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; }
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 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(); }
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); }
/** * 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; } } }
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(); }
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); }
/** initialises a parmeter to the default component */ private void initParam(String param) { params.put(param, comptype.getModel().getElementAt(0)); }