private void resetFromFile(@NotNull VirtualFile file, @NotNull Project project) { final Module moduleForFile = ModuleUtilCore.findModuleForFile(file, project); if (moduleForFile == null) { return; } final VirtualFile parent = file.getParent(); if (parent == null) { return; } if (myModule == null) { final Object prev = myModuleCombo.getSelectedItem(); myModuleCombo.setSelectedItem(moduleForFile); if (!moduleForFile.equals(myModuleCombo.getSelectedItem())) { myModuleCombo.setSelectedItem(prev); return; } } else if (!myModule.equals(moduleForFile)) { return; } final JCheckBox checkBox = myCheckBoxes.get(parent.getName()); if (checkBox == null) { return; } for (JCheckBox checkBox1 : myCheckBoxes.values()) { checkBox1.setSelected(false); } checkBox.setSelected(true); myFileNameCombo.getEditor().setItem(file.getName()); }
protected void load() { nameField.setText(data.name); costField.setValue(data.cost); colorBox.setSelectedItem(data.color); charField.setValue(data.text); weightField.setValue(data.weight); spellBox.setSelectedItem(data.spell); }
/** * Set calendar to this week's Monday; set year and week combo boxes to the currently set date; * set the date labels appropriately; and, refresh the review table. */ private void updateYearWeekDates() { yearWeekCalendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); yearWeekCalendar.set(Calendar.HOUR_OF_DAY, 0); yearWeekCalendar.set(Calendar.MINUTE, 0); yearWeekCalendar.set(Calendar.SECOND, 0); yearWeekCalendar.set(Calendar.MILLISECOND, 0); yearCB.setSelectedItem(yearWeekCalendar.get(Calendar.YEAR)); weekCB.setSelectedItem(yearWeekCalendar.get(Calendar.WEEK_OF_YEAR)); fromDate.setDate(yearWeekCalendar); yearWeekCalendar.add(Calendar.DAY_OF_MONTH, 7); toDate.setDate(yearWeekCalendar); yearWeekCalendar.add(Calendar.DAY_OF_MONTH, -7); refreshReviewTable(); }
private void setupAttributes() { Color frameColor = (Color) AttributeFigure.getDefaultAttribute(FigureAttributeConstant.FRAME_COLOR); Color fillColor = (Color) AttributeFigure.getDefaultAttribute(FigureAttributeConstant.FILL_COLOR); Integer arrowMode = (Integer) AttributeFigure.getDefaultAttribute(FigureAttributeConstant.ARROW_MODE); String fontName = (String) AttributeFigure.getDefaultAttribute(FigureAttributeConstant.FONT_NAME); FigureEnumeration fe = view().selection(); while (fe.hasNextFigure()) { Figure f = fe.nextFigure(); frameColor = (Color) f.getAttribute(FigureAttributeConstant.FRAME_COLOR); fillColor = (Color) f.getAttribute(FigureAttributeConstant.FILL_COLOR); arrowMode = (Integer) f.getAttribute(FigureAttributeConstant.ARROW_MODE); fontName = (String) f.getAttribute(FigureAttributeConstant.FONT_NAME); } fFrameColor.setSelectedIndex(ColorMap.colorIndex(frameColor)); fFillColor.setSelectedIndex(ColorMap.colorIndex(fillColor)); if (arrowMode != null) { fArrowChoice.setSelectedIndex(arrowMode.intValue()); } if (fontName != null) { fFontChoice.setSelectedItem(fontName); } }
private void setupAttributes() { Color frameColor = (Color) AttributeFigure.getDefaultAttribute("FrameColor"); Color fillColor = (Color) AttributeFigure.getDefaultAttribute("FillColor"); Color textColor = (Color) AttributeFigure.getDefaultAttribute("TextColor"); Integer arrowMode = (Integer) AttributeFigure.getDefaultAttribute("ArrowMode"); String fontName = (String) AttributeFigure.getDefaultAttribute("FontName"); FigureEnumeration k = view().selectionElements(); while (k.hasMoreElements()) { Figure f = k.nextFigure(); frameColor = (Color) f.getAttribute("FrameColor"); fillColor = (Color) f.getAttribute("FillColor"); textColor = (Color) f.getAttribute("TextColor"); arrowMode = (Integer) f.getAttribute("ArrowMode"); fontName = (String) f.getAttribute("FontName"); } fFrameColor.setSelectedIndex(ColorMap.colorIndex(frameColor)); fFillColor.setSelectedIndex(ColorMap.colorIndex(fillColor)); // fTextColor.select(ColorMap.colorIndex(textColor)); if (arrowMode != null) { fArrowChoice.setSelectedIndex(arrowMode.intValue()); } if (fontName != null) { fFontChoice.setSelectedItem(fontName); } }
public void setIndexer(LibrariesIndexer indexer) { this.indexer = indexer; DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem(); DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem(); categoryChooser.removeActionListener(categoryChooserActionListener); typeChooser.removeActionListener(typeChooserActionListener); // TODO: Remove setIndexer and make getContribModel // return a FilteredAbstractTableModel getContribModel().setIndexer(indexer); categoryFilter = null; categoryChooser.removeAllItems(); // Load categories categoryChooser.addItem(new DropdownAllItem()); Collection<String> categories = indexer.getIndex().getCategories(); for (String category : categories) { categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category)); } categoryChooser.setEnabled(categoryChooser.getItemCount() > 1); categoryChooser.addActionListener(categoryChooserActionListener); if (previouslySelectedCategory != null) { categoryChooser.setSelectedItem(previouslySelectedCategory); } else { categoryChooser.setSelectedIndex(0); } typeFilter = null; typeChooser.removeAllItems(); typeChooser.addItem(new DropdownAllItem()); typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex())); java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes()); Collections.sort(types, new LibraryTypeComparator()); for (String type : types) { typeChooser.addItem(new DropdownLibraryOfTypeItem(type)); } typeChooser.setEnabled(typeChooser.getItemCount() > 1); typeChooser.addActionListener(typeChooserActionListener); if (previouslySelectedType != null) { typeChooser.setSelectedItem(previouslySelectedType); } else { typeChooser.setSelectedIndex(0); } filterField.setEnabled(contribModel.getRowCount() > 0); // Create LibrariesInstaller tied with the provided index installer = new LibraryInstaller(indexer, platform) { @Override public void onProgress(Progress progress) { setProgress(progress); } }; }
protected JComboBox createCombo(String strText, JPanel pnlDisplay) { JComboBox cmbMode = new JComboBox(m_aStrMode); if (!strText.equalsIgnoreCase(m_aStrMode[0]) && !strText.equalsIgnoreCase(m_aStrMode[1])) strText = m_aStrMode[0]; cmbMode.setSelectedItem(strText); pnlDisplay.add(cmbMode); return cmbMode; }
private void extraInit() { addSynapses(); jTextFieldDelay.setText(mySynProps.getDelayGenerator().toShortString()); jTextFieldWeights.setText(mySynProps.getWeightsGenerator().toShortString()); jTextFieldThreshold.setText(mySynProps.getThreshold() + ""); jComboBoxSynapseType.setSelectedItem(mySynProps.getSynapseType()); }
public void selectRemote(@NotNull String remoteName) { for (GitRemote remote : myRemotes) { if (remote.getName().equals(remoteName)) { myRemoteCombobox.setSelectedItem(remote); return; } } myRemoteCombobox.setSelectedIndex(0); }
/** {@inheritDoc} */ public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { BranchDescriptor d = myBranches.get(row); myComboBox.removeAllItems(); for (String s : d.referencesToSelect) { myComboBox.addItem(s); } myComboBox.setSelectedItem(d.referenceToCheckout); return myPanel; }
private void setValue(final JComponent component) { final String primitiveFormName = _primitiveForm.getName(); if (_dotDefinitionDialogFrame.isPropertyStatic(primitiveFormName, _property)) { Object object = _dotDefinitionDialogFrame.getValueOfStaticProperty(primitiveFormName, _property); if (component instanceof JComboBox) { final String currentValue; if (object instanceof Color) { currentValue = ColorManager.getInstance().getColorName((Color) object); } else if (object instanceof Integer) { Integer i = (Integer) object; if (i.equals(Font.PLAIN)) { currentValue = STANDARD_FONT; } else if (i.equals(Font.BOLD)) { currentValue = BOLD_FONT; } else if (i.equals(Font.ITALIC)) { currentValue = ITALIC_FONT; } else { currentValue = "Unbekannter Font"; } } else { currentValue = (String) object; } JComboBox comboBox = (JComboBox) component; comboBox.setSelectedItem(currentValue); } else if (component instanceof JSpinner) { JSpinner spinner = (JSpinner) component; if (object instanceof Integer) { spinner.setValue((Integer) object); } else { spinner.setValue((Double) object); } } } else { if (component instanceof JComboBox) { JComboBox comboBox = (JComboBox) component; comboBox.setSelectedItem(DOTPoint.getDefaultValue(_property)); } else if (component instanceof JSpinner) { JSpinner spinner = (JSpinner) component; spinner.setValue(DOTPoint.getDefaultValue(_property)); } } }
// Вид формы при изменении сотрудника public void sotrDiaUpdate(Sotrudnik s) { label_id_hidden.setText(Integer.toString(s.getId_sotrudnika())); textField_familiya.setText(s.getFamiliya()); textField_imya.setText(s.getImya()); textField_otchestvo.setText(s.getOtchestvo()); textField_phone.setText(s.getPhone()); textField_date.setText(s.getData_priema().toString()); comboBox_doljnost.removeAllItems(); comboBox_kvalification.removeAllItems(); try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); DBClass db2 = new DBClass(); Doljnost dd = db2.doljnostFromDB(s); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); Doljnost ddd = (Doljnost) comboBox_doljnost.getItemAt(i); if (dd.getNazvanie_doljnosti().equals(ddd.getNazvanie_doljnosti())) dd = ddd; } comboBox_doljnost.setSelectedItem(dd); DBClass db3 = new DBClass(); ArrayList<Kvalification> k = db3.kvalificationFromDB(); DBClass db4 = new DBClass(); Kvalification kk = db4.kvalificationFromDB(s); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); Kvalification kkk = (Kvalification) comboBox_kvalification.getItemAt(i); if (kk.getNazvanie_kvalification().equals(kkk.getNazvanie_kvalification())) kk = kkk; } comboBox_kvalification.setSelectedItem(kk); } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } }
public static void refreshCalendar(int month, int year) { // instantiation String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; int numoday, startom; // Number Of Days, Start Of Month // Allow/disallow buttons prev.setEnabled(true); next.setEnabled(true); if (month == 0 && year <= ryear) { prev.setEnabled(false); } // Cannot set an appointment back in time if (month == 11 && year >= ryear + 50) { next.setEnabled(false); } // Too early to set an appointment lmonth.setText(months[month]); // Refresh the month label (at the top) lmonth.setBounds( 160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box // deletes current table for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { mcal.setValueAt(null, i, j); } } // Get first day of month and number of days GregorianCalendar cal = new GregorianCalendar(year, month, 1); numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); startom = cal.get(GregorianCalendar.DAY_OF_WEEK); // Create calendar for (int i = 1; i <= numoday; i++) { int row = new Integer((i + startom - 2) / 7); int column = (i + startom - 2) % 7; mcal.setValueAt(i, row, column); } // Apply renderers Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer()); }
public void updateLists(List<? extends ChangeList> lists) { //noinspection unchecked myChooser.setModel(new DefaultComboBoxModel(lists.toArray())); myChooser.setEnabled(lists.size() > 1); if (lists.contains(mySelectedChangeList)) { myChooser.setSelectedItem(mySelectedChangeList); } else { if (myChooser.getItemCount() > 0) { myChooser.setSelectedIndex(0); } } mySelectedChangeList = (ChangeList) myChooser.getSelectedItem(); }
private void lookupViewComboAction(ActionEvent e) { ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView(); ObjEntityView selectedLookupView = (ObjEntityView) lookupViewCombo.getSelectedItem(); if (selectedLookupView != fieldLookupView) { objEntityViewField.getLookup().setLookupObjEntityView(selectedLookupView); dataViewTreeModel.fieldChanged(objEntityViewField); dataMapTreeModel.fieldChanged(objEntityViewField); fieldsTableModel.fireTableCellUpdated( objEntityViewField.getObjEntityView().getIndexOfObjEntityViewField(objEntityViewField), 4); } if (selectedLookupView != null) { ObjEntityViewField nullField = null; java.util.List lookupFields = new ArrayList(); lookupFields.add(nullField); lookupFields.addAll(selectedLookupView.getObjEntityViewFields()); DefaultComboBoxModel lookupFieldsDefaultModel = new DefaultComboBoxModel(lookupFields.toArray()); lookupFieldCombo.setModel(lookupFieldsDefaultModel); ObjEntityViewField fieldLookupField = objEntityViewField.getLookup().getLookupField(); if (fieldLookupField != null) { boolean flagSetSelectedItem = false; for (Iterator itr = lookupFields.iterator(); itr.hasNext(); ) { ObjEntityViewField field = (ObjEntityViewField) itr.next(); if ((field != null) && (fieldLookupField.getName().equals(field.getName()))) { lookupFieldCombo.setSelectedItem(fieldLookupField); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { lookupFieldCombo.setSelectedIndex(0); } } else { lookupFieldCombo.setSelectedIndex(0); } } else { ObjEntityViewField nullField = null; ObjEntityViewField[] fields = new ObjEntityViewField[] {nullField}; DefaultComboBoxModel fieldsModel = new DefaultComboBoxModel(fields); lookupFieldCombo.setModel(fieldsModel); lookupFieldCombo.setSelectedIndex(0); } }
public void setDefaultSelection(final ChangeList defaultSelection) { if (defaultSelection == null) { myExistingListsCombo.setSelectedIndex(0); } else { myExistingListsCombo.setSelectedItem(defaultSelection); } // if defaultSelection was predefined as null then it means we could not use existing is this // context if (defaultSelection != null && VcsConfiguration.getInstance(myProject).PRESELECT_EXISTING_CHANGELIST) { myRbExisting.setSelected(true); } else { myRbNew.setSelected(true); } updateEnabledItems(); }
public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return; int pos = m_editor.getCaretPosition(); String str = m_editor.getText(); if (str.length() == 0) return; for (int k = 0; k < m_comboBox.getItemCount(); k++) { String item = m_comboBox.getItemAt(k).toString(); if (item.startsWith(str)) { m_editor.setText(item); m_editor.setCaretPosition(item.length()); m_editor.moveCaretPosition(pos); m_comboBox.setSelectedItem(item); break; } } }
private void objRelationshipComboAction(ActionEvent e) { ObjRelationship selectedObjRelationship = (ObjRelationship) objRelationshipCombo.getSelectedItem(); ObjRelationship fieldObjRelationship = objEntityViewField.getObjRelationship(); if (selectedObjRelationship != fieldObjRelationship) { objEntityViewField.setObjRelationship(selectedObjRelationship); } if (selectedObjRelationship != null) { ObjEntity targetObjEntity = selectedObjRelationship.getTargetObjEntity(); ObjEntityView nullView = null; java.util.List lookupViews = new ArrayList(); lookupViews.add(nullView); lookupViews.addAll(targetObjEntity.getObjEntityViews()); DefaultComboBoxModel lookupViewModel = new DefaultComboBoxModel(lookupViews.toArray()); lookupViewCombo.setModel(lookupViewModel); ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView(); if (fieldLookupView != null) { boolean flagSetSelectedItem = false; for (Iterator itr = lookupViews.iterator(); itr.hasNext(); ) { ObjEntityView view = (ObjEntityView) itr.next(); if (fieldLookupView == view) { lookupViewCombo.setSelectedItem(fieldLookupView); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { lookupViewCombo.setSelectedIndex(0); } } else { lookupViewCombo.setSelectedIndex(0); } } else { ObjEntityView nullView = null; ObjEntityView[] views = new ObjEntityView[] {nullView}; DefaultComboBoxModel viewsModel = new DefaultComboBoxModel(views); lookupViewCombo.setModel(viewsModel); lookupViewCombo.setSelectedIndex(0); } }
public void setValue(T value, ObjectMeta target) { init(m_widgetContext); m_parentObject = target; valueMap = m_parentObject.getAll(getClassModel().getContainedClass()); byName = new HashMap<String, ObjectMeta<T>>(); for (ObjectMeta<T> objectMeta : valueMap.values()) { byName.put(objectMeta.getKey(), objectMeta); } setComboValues(new ArrayList(valueMap.keySet())); m_comboBox.setRenderer( new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof String) { T obj = getObj((String) value); setToolTipText(getTooltip(obj)); String t = getLabelText(obj); value = t != null ? t : value; } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); /*if (getClassModel().isTreeType()) { m_root = new Tree(); Tree root = getClassModel().getTreeRoot(); m_root.setPathSeparator(root.pathSeparator()); m_root.getChildren().add(root); m_comboBox.setEditable(true); } else { m_comboBox.setEditable(false); }*/ m_comboBox.setSelectedItem(getKeyByValue(value)); }
private boolean addSynapses() { // ModFile[] inbuiltSynapses = ModFileHelper.getSynapseModFilesInDir(new // File(GeneralProperties.getModTemplateDirectory())); Vector synapticTypes = project.cellMechanismInfo.getAllChemElecSynMechNames(); for (int i = 0; i < synapticTypes.size(); i++) { jComboBoxSynapseType.addItem(synapticTypes.elementAt(i)); if (this.mySynProps.getSynapseType().equals(synapticTypes.elementAt(i))) { jComboBoxSynapseType.setSelectedItem(synapticTypes.elementAt(i)); } } /* ModFile[] mods = null; File neuronCodeDir = new File(project.getProjectFile() + System.getProperty("file.separator") + GeneralProperties.getDirForNeuronCode()); mods = ModFileHelper.getSynapseModFilesInDir(neuronCodeDir); for (int i = 0; i < mods.length; i++) { jComboBoxSynapseType.addItem(mods[i]); if (this.mySynProps.synapseType.equals(mods[i].myNeuronElement.getProcessName())) { jComboBoxSynapseType.setSelectedItem(mods[i]); } } */ return true; }
public CreateXmlResourceDialog( @NotNull Module module, @NotNull ResourceType resourceType, @Nullable String predefinedName, @Nullable String predefinedValue, boolean chooseName, @Nullable VirtualFile defaultFile) { super(module.getProject()); myResourceType = resourceType; if (predefinedName != null && predefinedName.length() > 0) { if (!chooseName) { myNameLabel.setVisible(false); myNameField.setVisible(false); } myNameField.setText(predefinedName); } if (predefinedValue != null && predefinedValue.length() > 0) { myValueLabel.setVisible(false); myValueField.setVisible(false); myValueField.setText(predefinedValue); } final Set<Module> modulesSet = new HashSet<Module>(); modulesSet.add(module); for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) { modulesSet.add(depFacet.getModule()); } assert modulesSet.size() > 0; if (modulesSet.size() == 1) { myModule = module; myModuleLabel.setVisible(false); myModuleCombo.setVisible(false); } else { myModule = null; final Module[] modules = modulesSet.toArray(new Module[modulesSet.size()]); Arrays.sort( modules, new Comparator<Module>() { @Override public int compare(Module m1, Module m2) { return m1.getName().compareTo(m2.getName()); } }); myModuleCombo.setModel(new DefaultComboBoxModel(modules)); myModuleCombo.setSelectedItem(module); myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer())); } if (defaultFile == null) { final String defaultFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType); if (defaultFileName != null) { myFileNameCombo.getEditor().setItem(defaultFileName); } } myDirectoriesList = new CheckBoxList(); myDirectoriesLabel.setLabelFor(myDirectoriesList); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList); decorator.setEditAction(null); decorator.disableUpDownActions(); decorator.setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { doAddNewDirectory(); } }); decorator.setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { doDeleteDirectory(); } }); final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) { @Override public void actionPerformed(AnActionEvent e) { doSelectAllDirs(); } }; decorator.addExtraAction(selectAll); final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) { @Override public void actionPerformed(AnActionEvent e) { doUnselectAllDirs(); } }; decorator.addExtraAction(unselectAll); myDirectoriesPanel.add(decorator.createPanel()); updateDirectories(true); myModuleCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateDirectories(true); } }); final JCheckBox valuesCheckBox = myCheckBoxes.get(SdkConstants.FD_RES_VALUES); if (valuesCheckBox != null) { valuesCheckBox.setSelected(true); } if (defaultFile != null) { resetFromFile(defaultFile, module.getProject()); } init(); }
public JComponent createComponent() { final JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(IdeBorderFactory.createTitledBorder("File Context", false)); myCombo = new ComboBox(); myCombo.putClientProperty(CONTEXTS_COMBO_KEY, Boolean.TRUE); panel.add( new JLabel("Included into:"), new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 0), 0, 0)); panel.add( myCombo, new GridBagConstraints( 1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); final PsiManager psiManager = PsiManager.getInstance(myProject); final FileBasedIndex fbi = FileBasedIndex.getInstance(); final Collection<VirtualFile> antFiles = fbi.getContainingFiles( AntImportsIndex.INDEX_NAME, AntImportsIndex.ANT_FILES_WITH_IMPORTS_KEY, myFileFilter); for (VirtualFile file : antFiles) { final PsiFile psiFile = psiManager.findFile(file); if (!(psiFile instanceof XmlFile)) { continue; } final XmlFile xmlFile = (XmlFile) psiFile; if (!xmlFile.equals(myFile) && AntDomFileDescription.isAntFile(xmlFile)) { final String path = PathUtil.getLocalPath(file); final XmlFile previous = myPathToFileMap.put(path, xmlFile); assert previous == null; } } final List<String> paths = new ArrayList<String>(myPathToFileMap.keySet()); Collections.sort( paths, new Comparator<String>() { public int compare(final String o1, final String o2) { return o1.compareTo(o2); } }); myCombo.addItem(NONE); for (String path : paths) { myCombo.addItem(path); } final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(myProject); final XmlFile currentContext = antConfig.getContextFile(myFile); if (currentContext != null) { final VirtualFile vFile = currentContext.getVirtualFile(); assert vFile != null; final String path = PathUtil.getLocalPath(vFile); if (!FileUtil.pathsEqual(path, myLocalPath)) { myOriginalContext = path; } } myCombo.setSelectedItem(myOriginalContext); return panel; }
private void calcTypeComboAction(ActionEvent e) { String comboCalcType = (String) calcTypeCombo.getSelectedItem(); ObjEntity objEntity = objEntityViewField.getObjEntityView().getObjEntity(); if (comboCalcType.equals("No Calculation")) { objEntityViewField.setCalcType("nocalc"); objRelationshipCombo.setEnabled(false); lookupViewCombo.setEnabled(false); lookupFieldCombo.setEnabled(false); ObjAttribute nullAttribute = null; java.util.List attributes = new ArrayList(); attributes.add(nullAttribute); if (objEntity != null) { attributes.addAll(objEntity.getObjAttributes()); } DefaultComboBoxModel attributesDefaultModel = new DefaultComboBoxModel(attributes.toArray()); objAttributeCombo.setModel(attributesDefaultModel); objAttributeCombo.setEnabled(true); if (objEntity != null) { if (objEntityViewField.getObjAttribute() != null) { objAttributeCombo.setSelectedItem(objEntityViewField.getObjAttribute()); } else { objAttributeCombo.setSelectedIndex(0); } } else { objAttributeCombo.setSelectedIndex(0); } } if (comboCalcType.equals("Lookup")) { objEntityViewField.setCalcType("lookup"); objAttributeCombo.setEnabled(false); objRelationshipCombo.setEnabled(true); lookupViewCombo.setEnabled(true); lookupFieldCombo.setEnabled(true); ObjRelationship nullRelationship = null; java.util.List relationships = new ArrayList(); relationships.add(nullRelationship); if (objEntity != null) { relationships.addAll(objEntity.getDataMap().getObjRelationshipsBySourceToOne(objEntity)); } DefaultComboBoxModel relationshipsDefaultModel = new DefaultComboBoxModel(relationships.toArray()); objRelationshipCombo.setModel(relationshipsDefaultModel); ObjRelationship fieldRelationship = objEntityViewField.getObjRelationship(); if (fieldRelationship != null) { boolean flagSetSelectedItem = false; for (Iterator itr = relationships.iterator(); itr.hasNext(); ) { ObjRelationship relationship = (ObjRelationship) itr.next(); if ((relationship != null) && (fieldRelationship.getName().equals(relationship.getName()))) { objRelationshipCombo.setSelectedItem(fieldRelationship); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { objRelationshipCombo.setSelectedIndex(0); } } else { objRelationshipCombo.setSelectedIndex(0); } } }
DOTItemDialog() { super(); _primitiveForm = primitiveForm; _property = property; _dynamicDefinitionComponent = new DynamicDefinitionComponent(_configuration, new DOTPointPlugin()); final Object propertyValue = initDynamicDefinitionComponent(); final JPanel panel = new JPanel(); panel.setLayout(new SpringLayout()); JLabel aLabel = null; if (_property == DOTProperty.DURCHMESSER) { aLabel = new JLabel("Durchmesser: "); if (propertyValue != null) { _diameterSpinner.setValue(propertyValue); } _component = _diameterSpinner; } else if (_property == DOTProperty.FARBE || _property == DOTProperty.FUELLUNG) { aLabel = new JLabel("Farbe: "); if (propertyValue != null) { _colorComboBox.setSelectedItem(propertyValue); } _component = _colorComboBox; } else if (_property == DOTProperty.GROESSE) { aLabel = new JLabel("Schriftgröße: "); if (propertyValue != null) { _textSizeSpinner.setValue(propertyValue); } _component = _textSizeSpinner; } else if (_property == DOTProperty.STRICHBREITE) { aLabel = new JLabel("Strichbreite: "); if (propertyValue != null) { _strokeWidthSpinner.setValue(propertyValue); } _component = _strokeWidthSpinner; } else if (_property == DOTProperty.TEXT) { aLabel = new JLabel("Text: "); prepareTextComboBox(propertyValue); _component = _textComboBox; } else if (_property == DOTProperty.TEXTSTIL) { aLabel = new JLabel("Textstil: "); if (propertyValue != null) { _textStyleComboBox.setSelectedItem(propertyValue); } _component = _textStyleComboBox; } else if (_property == DOTProperty.TRANSPARENZ) { aLabel = new JLabel("Tranzparenz: "); if (propertyValue != null) { _transparencySpinner.setValue(propertyValue); } _component = _transparencySpinner; } panel.add(aLabel); panel.add(_component); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); SpringUtilities.makeCompactGrid(panel, 2, 20, 5); final JButton saveButton = new JButton("Speichern"); saveButton.setEnabled(_dotDefinitionDialogFrame.isEditable()); final JButton cancelButton = new JButton("Dialog schließen"); final JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new SpringLayout()); buttonsPanel.add(saveButton); buttonsPanel.add(cancelButton); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); SpringUtilities.makeCompactGrid(buttonsPanel, 2, 20, 5); addButtonListeners(saveButton, cancelButton); setTitle("GND: Darstellungsfestlegung für Punkte"); setLayout(new BorderLayout()); add(new JScrollPane(panel), BorderLayout.NORTH); add(new JScrollPane(_dynamicDefinitionComponent), BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); pack(); setSize(700, 550); final Rectangle bounds = getBounds(); setLocation( new Point((int) (bounds.getHeight() / 1.5 + 300), (int) (bounds.getWidth() / 1.5))); }
public SyntaxTab() { super(new BorderLayout(), "Syntax highlighting"); /* * upper checkboxes */ JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0)); upper.setOpaque(false); upper.add(MyPanel.wrap(highlightSyntax)); upper.add(MyPanel.wrap(matchBracket)); highlightSyntax.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { SyntaxTab.this.updateComponentStatus(); } }); this.add(upper, BorderLayout.PAGE_START); /* * upper panel (painters) */ painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance()); painterComboBox.setFont(f13); if (isMetal) painterComboBox.setBackground(Color.WHITE); painterComboBox.addItemListener(this.painterChangeListener); JButton addPainter = new MyButton("+") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { String name; do { name = JOptionPane.showInputDialog( SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE); } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this)); if ((name != null) && (!name.isEmpty())) { // name is valid, neither cancelled nor pressed enter directly myjava.gui.syntax.Painter newPainter = ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem())) .newInstance(name); addPainter(newPainter); System.out.println("now set, should call listener"); painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s) } } }; JButton removePainter = new MyButton("-") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { myjava.gui.syntax.Painter painter = (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()); if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) { JOptionPane.showMessageDialog( SyntaxTab.this, "The default painter cannot be removed.", "Error", JOptionPane.ERROR_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( SyntaxTab.this, "Remove painter \"" + painter.getName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { // remove "painter" removedPainters.add(painter); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance()); painterComboBox.removeItem(painter); for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) { EntryListPanel panel = it.next(); if (panel.getPainter().getName().equals(painter.getName())) { System.out.println("removing, then break"); it.remove(); centerPanel.remove(panel); break; } } painterComboBox.addItemListener(painterChangeListener); cardLayout.show( centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName()); } } } }; // lower part JPanel center = new JPanel(new BorderLayout()); JLabel selectLabel = new MyLabel("Selected painter:"); center.add( MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter), BorderLayout.PAGE_START); componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter)); center.add(centerPanel, BorderLayout.CENTER); this.add(center, BorderLayout.CENTER); cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName()); }
/** Loads the configuration form obtained from the chat room. */ protected void loadConfigurationForm() { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); Iterator<?> values = formField.getValues(); Iterator<String> options = formField.getOptions(); JComponent field; JLabel label = new JLabel("", JLabel.RIGHT); if (formField.getLabel() != null) label.setText(formField.getLabel() + ": "); String fieldType = formField.getType(); if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) { // Create a check box when the field is of type boolean. field = new SIPCommCheckBox(formField.getLabel()); label.setText(""); if (values.hasNext()) { ((JCheckBox) field).setSelected((Boolean) values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { field = new JLabel(); if (values.hasNext()) { String value = values.next().toString(); ((JLabel) field).setText(value); field.setFont(new Font(null, Font.ITALIC, 10)); field.setForeground(Color.GRAY); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) { field = new TransparentPanel(new GridLayout(0, 1)); field.setBorder(BorderFactory.createLineBorder(Color.GRAY)); Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>(); while (options.hasNext()) { Object option = options.next(); JCheckBox checkBox = new SIPCommCheckBox(option.toString()); field.add(checkBox); optionCheckBoxes.put(option, checkBox); } while (values.hasNext()) { Object value = values.next(); (optionCheckBoxes.get(value)).setSelected(true); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) { field = new JComboBox(); while (options.hasNext()) { ((JComboBox) field).addItem(options.next()); } if (values.hasNext()) { ((JComboBox) field).setSelectedItem(values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) { field = new JEditorPane(); if (values.hasNext()) { String value = values.next().toString(); ((JEditorPane) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE) || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) { field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) { field = new JPasswordField(); if (values.hasNext()) { String value = values.next().toString(); ((JPasswordField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { StringBuffer buff = new StringBuffer(); while (values.hasNext()) { String value = values.next().toString(); buff.append(value); if (values.hasNext()) buff.append(System.getProperty("line.separator")); } field = new JTextArea(buff.toString()); } else { if (label.getText() == null) continue; field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } // If the field is not fixed (i.e. could be changed) we would like // to save it in a list in order to use it later when user saves // the configuration data. if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { uiFieldsTable.put(formField.getName(), field); } JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2)); fieldPanel.setOpaque(false); if (!(field instanceof JLabel)) fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); fieldPanel.add(label); fieldPanel.add(field); this.mainPanel.add(fieldPanel); } }