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 syncPanel() { panelPat.syncPanel(); regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A); regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B); regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C); elevBox.setText(dlg.panelMain.mark.getElevation()); heightBox.setText(dlg.panelMain.mark.getObjectHeight()); sourceBox.setText(dlg.panelMain.mark.getSource()); infoBox.setText(dlg.panelMain.mark.getInfo()); for (Sts sts : statuses.keySet()) { int item = statuses.get(sts); if (dlg.panelMain.mark.getStatus() == sts) statusBox.setSelectedIndex(item); } for (Cns cns : constructions.keySet()) { int item = constructions.get(cns); if (dlg.panelMain.mark.getConstr() == cns) constrBox.setSelectedIndex(item); } for (Con con : conspicuities.keySet()) { int item = conspicuities.get(con); if (dlg.panelMain.mark.getConsp() == con) conBox.setSelectedIndex(item); } for (Con con : reflectivities.keySet()) { int item = reflectivities.get(con); if (dlg.panelMain.mark.getRefl() == con) reflBox.setSelectedIndex(item); } }
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); }
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 SwingThreadFrame() { setTitle("SwingThreadTest"); final JComboBox combo = new JComboBox(); combo.insertItemAt(new Integer(Integer.MAX_VALUE), 0); combo.setPrototypeDisplayValue(combo.getItemAt(0)); combo.setSelectedIndex(0); JPanel panel = new JPanel(); JButton goodButton = new JButton("Good"); goodButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { new Thread(new GoodWorkerRunnable(combo)).start(); } }); panel.add(goodButton); JButton badButton = new JButton("Bad"); badButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { new Thread(new BadWorkerRunnable(combo)).start(); } }); panel.add(badButton); panel.add(combo); add(panel); pack(); }
public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
private void fillGUI() { Object[] attributes; boolean enabled; if (context != null) { attributes = this.context.getAttributes().toArray(); enabled = true; } else { attributes = new Object[] {"No context available"}; enabled = false; } sequenceColumnChooser.setModel(new DefaultComboBoxModel(attributes)); sequenceColumnChooser.setEnabled(enabled); timelineColumnChooser.setModel(new DefaultComboBoxModel(attributes)); timelineColumnChooser.setEnabled(enabled); if (context != null) { timelineColumnChooser.setSelectedIndex(Math.min(attributes.length - 1, 1)); } calculateValueLists(); fillSequenceChooser(); setButtonStates(!enabled); }
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); } }; }
public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source.equals(root)) { root.setSelectedIndex(directoryPane.changeRoot(root.getSelectedIndex())); } else if (source.equals(refresh)) { directoryPane.reloadTree(); } }
public void syncPanel() { if (SeaMark.EntMAP.get(dlg.panelMain.mark.getObject()) == Ent.MOORING) { mooringButton.setBorderPainted(true); categoryBox.setVisible(false); mooringBox.setVisible(true); pillarButton.setEnabled(false); sparButton.setEnabled(false); beaconButton.setEnabled(false); towerButton.setEnabled(false); stakeButton.setEnabled(false); cairnButton.setEnabled(false); noticeButton.setEnabled(false); topmarkButton.setVisible(false); for (Cat cat : moorings.keySet()) { int item = moorings.get(cat); if (dlg.panelMain.mark.getCategory() == cat) mooringBox.setSelectedIndex(item); } } else { mooringButton.setBorderPainted(false); mooringBox.setVisible(false); categoryBox.setVisible(true); pillarButton.setEnabled(true); sparButton.setEnabled(true); beaconButton.setEnabled(true); towerButton.setEnabled(true); stakeButton.setEnabled(true); cairnButton.setEnabled(true); noticeButton.setEnabled(true); topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP); topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP); topmarkButton.setVisible(dlg.panelMain.mark.testValid()); for (Cat cat : categories.keySet()) { int item = categories.get(cat); if (dlg.panelMain.mark.getCategory() == cat) categoryBox.setSelectedIndex(item); } } for (Shp shp : shapes.keySet()) { JRadioButton button = shapes.get(shp); if (dlg.panelMain.mark.getShape() == shp) { button.setBorderPainted(true); } else button.setBorderPainted(false); } noticeButton.setBorderPainted(false); dlg.panelMain.mark.testValid(); }
public void selectRemote(@NotNull String remoteName) { for (GitRemote remote : myRemotes) { if (remote.getName().equals(remoteName)) { myRemoteCombobox.setSelectedItem(remote); return; } } myRemoteCombobox.setSelectedIndex(0); }
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); } }
/** * 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; } } }
/** Create the tabbed panels for the GUI */ private void createTabs() { // Create the tabbed pane mainPanel = new JTabbedPane(JTabbedPane.BOTTOM); // Create the various panels workspacePanel = new JPanel(new BorderLayout()); userListPanel = new JPanel(new BorderLayout()); searchPanel = new JPanel(new GridLayout(0, 2)); // Create the pieces of the workspace panel workspaceList.setLayoutOrientation(JList.VERTICAL_WRAP); workspacePanel.add(new JScrollPane(workspaceList)); workspacePanel.add(new JLabel("Local File Listing"), BorderLayout.NORTH); // Create the UserList tab JPanel labelPanel = new JPanel(new GridLayout(0, 2)); labelPanel.add(new JLabel("Users Connected:")); labelPanel.add(new JLabel("Selected User's Files:")); JPanel listPanel = new JPanel(new GridLayout(0, 2)); listPanel.add(new JScrollPane(userList)); listPanel.add(new JScrollPane(fileList)); userList.addMouseListener(mouseHandler); fileList.addMouseListener(mouseHandler); userListPanel.add(labelPanel, BorderLayout.NORTH); userListPanel.add(listPanel, BorderLayout.CENTER); // Create Search Panel searchPanel = new JPanel(new BorderLayout()); JPanel searchOpsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); searchName = new JTextField(20); searchInit = new JButton("Search"); searchInit.addMouseListener(mouseHandler); String types[] = {"Image", "Video", "Audio", "Any"}; searchType = new JComboBox(types); searchType.setSelectedIndex(3); searchOpsPanel.add(new JLabel("Search String")); searchOpsPanel.add(searchName); searchOpsPanel.add(new JLabel("File Type")); searchOpsPanel.add(searchType); searchOpsPanel.add(searchInit); searchPanel.add(new JScrollPane(searchList)); searchPanel.add(searchOpsPanel, BorderLayout.NORTH); // Add panels to the tab pane mainPanel.addTab("Home", workspacePanel); mainPanel.addTab("Server", userListPanel); mainPanel.addTab("Search", searchPanel); }
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 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; } } } }
private void completePanel() { if (criterion != null) { jtfCode.setText(criterion.getCode()); jtfCode.setEditable(false); jtfLibelle.setText(criterion.getLibelle()); jcbSortOrder.setSelectedIndex((criterion.getSortOrder() > 0) ? 0 : 1); jcbPlacementCriterion.setSelected(criterion.isPlacement()); jcbClassementCriterion.setSelected(criterion.isClassement()); jcbSortOrder.setEnabled(!parent.getWorkConfiguration().isOfficialProfile()); jcbPlacementCriterion.setEnabled(!parent.getWorkConfiguration().isOfficialProfile()); jcbClassementCriterion.setEnabled(!parent.getWorkConfiguration().isOfficialProfile()); } }
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 secureMove() { int rw = tblItems.getSelectedRow(); if (rw == -1) { JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE); return; } int idx = tblItems.convertRowIndexToModel(rw); String[] opts = new String[storeLocs.size()]; for (int i = 0; i < opts.length; i++) opts[i] = storeLocs.get(i).getAbsolutePath(); JComboBox cmbMove = new JComboBox(opts); cmbMove.setSelectedIndex(store.curStore(idx)); if (JOptionPane.showConfirmDialog(frm, cmbMove, "Move item", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) return; File newLoc = store.move(idx, cmbMove.getSelectedIndex()); if (newLoc == null) System.err.println("move " + store.plainName(idx) + " unsuccessful"); else needsSave = true; }
private void updateParams(EDPCellData data) { paramComboBox.removeAllItems(); paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor); if (!m_isCrawlRuleEditor) { paramComboBox.addItem(STRING_LITERAL); } for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) { ConfigParamDescr descr = (ConfigParamDescr) it.next(); int type = descr.getType(); if (!m_isCrawlRuleEditor && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue; paramComboBox.addItem(descr); } paramComboBox.setEnabled(true); paramComboBox.setSelectedIndex(0); paramComboBox.setToolTipText("Select a parameter to insert into the format string"); insertButton.setEnabled(true); }
/** * Loads the account with the given identifier. * * @param accountID the account identifier */ public void loadAccount(AccountID accountID) { enableDefaultEncryption.setSelected( accountID.getAccountPropertyBoolean(ProtocolProviderFactory.DEFAULT_ENCRYPTION, true)); Map<String, Integer> encryptionProtocols = accountID.getIntegerPropertiesByPrefix(ProtocolProviderFactory.ENCRYPTION_PROTOCOL, true); Map<String, Boolean> encryptionProtocolStatus = accountID.getBooleanPropertiesByPrefix( ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS, true, false); this.loadEncryptionProtocols(encryptionProtocols, encryptionProtocolStatus); enableSipZrtpAttribute.setSelected( accountID.getAccountPropertyBoolean( ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE, true)); cboSavpOption.setSelectedIndex( accountID.getAccountPropertyInt( ProtocolProviderFactory.SAVP_OPTION, ProtocolProviderFactory.SAVP_OFF)); cipherModel.loadData( accountID.getAccountPropertyString(ProtocolProviderFactory.SDES_CIPHER_SUITES)); loadStates(); }
public void setJob(Job job) { jobNameTextField.setEnabled(false); enabledCheckBox.setEnabled(true); saveButton.setEnabled(true); id = job.getId(); jobNameTextField.setText(job.getName()); enabledCheckBox.setSelected(job.isEnabled()); if (job.getIntervalUnit() == null) { onDemandRadioButton.setSelected(true); } else { scheduledRadioButton.setSelected(true); intervalFormattedTextField.setText(String.valueOf(job.getIntervalPeriod())); int index = 0; String[] units = Job.getUnits(); for (int i = 0; i < units.length; i++) if (job.getIntervalUnit().equals(units[i])) index = i; intervalUnitComboBox.setSelectedIndex(index); } }
public MySimpleCal(JFrame owner, JTextField text, int t) { super(owner, true); this.plane_scheduler = t; System.out.println(plane_scheduler + "班期"); this.owner = owner; this.text = text; cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); panel = new JPanel(); initCalPanel(); JPanel southPanel = new JPanel(); btn = new JButton("确定"); southPanel.add(btn); SpinnerNumberModel snm = new SpinnerNumberModel(year, year - 10, year + 10, 1); yearSpi = new JSpinner(snm); // yearSpi.getEditor().setEnabled(false); String[] str = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}; monthBox = new JComboBox(str); JPanel northPanel = new JPanel(); northPanel.add(yearSpi); northPanel.add(monthBox); monthBox.setSelectedIndex(month); this.setLayout(new BorderLayout()); this.add(northPanel, BorderLayout.NORTH); this.add(panel, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setResizable(false); this.setSize(310, 350); this.setMiddle(); this.addEventListener(); }
public ChoiceField(ChoiceOption option) { super(option); this.choices = option.getChoices().toArray(new Choice[0]); comboBox = new JComboBox(); for (int i = 0; i < choices.length; i++) { comboBox.addItem(makeEntry(choices[i].getDisplayName())); if (i == 0 || choices[i].isDefault()) { comboBox.setSelectedIndex(i); } } comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireChangeEvent(); } }); configureEnableToggle( option.isInitiallyEnabled(), option.getDisabledValue(), Arrays.asList((JComponent) comboBox)); }
@Analyzer( name = "Event Data Attribute Visualizer", names = {"Log"}) public JComponent analyze(LogReader log) { /* * this plugin takes a log, shows a list of available data-attributes * and a list of cases After selecting a data-attribute (and possibly a * case) a graph is made of the value of the data-attribute against * either time or against the sequence of events. * * input: log with data attributes gui-input: select a data-attribute, * choose time or event-sequence, and possibly a case * * internally : if not caseselected -> scatterplot of values against * time/event-number else show graph for value against time/event-number * * createGraph : check number / string */ mylog = log; mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); chartPanel = new JPanel(); chartPanel.setLayout(new BoxLayout(chartPanel, BoxLayout.PAGE_AXIS)); optionsPanel = new JPanel(); optionsPanel.setLayout(new SpringLayout()); JLabel attributelabel = new JLabel("Select attributes to use"); attributeslist = new JList(getAttributes()); attributeslist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); attributeslist.setLayoutOrientation(JList.VERTICAL); optionsPanel.add(attributelabel); optionsPanel.add(attributeslist); JLabel xlabel = new JLabel("Chart type"); String[] xvalues = new String[4]; xvalues[0] = " Attribute values against event sequence"; xvalues[1] = "Attribute values against timestamps"; xvalues[2] = "Average attribute values against event sequence"; xvalues[3] = "Average attribute values against timestamps"; xbox = new JComboBox(xvalues); xbox.setMaximumSize(xbox.preferredSize()); xbox.setSelectedIndex(1); xbox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getSelectedIndex() == 3) { BSpinner.setVisible(true); } else { BSpinner.setVisible(false); } }; }); optionsPanel.add(xlabel); optionsPanel.add(xbox); JLabel timelabel = new JLabel("show time by "); String[] timevalues = new String[4]; timevalues[0] = "second"; timevalues[1] = "minute"; timevalues[2] = "hour"; timevalues[3] = "day"; timebox = new JComboBox(timevalues); timebox.setMaximumSize(timebox.preferredSize()); timebox.setSelectedIndex(1); optionsPanel.add(timelabel); optionsPanel.add(timebox); SpinnerModel Bmodel = new SpinnerNumberModel(10, 2, 1000000, 1); BSpinner = new JSpinner(Bmodel); JLabel BLabel = new JLabel("Select histogram barsize"); JLabel B2Label = new JLabel("used for average against timestamps"); BSpinner.setMaximumSize(BSpinner.preferredSize()); BSpinner.setVisible(false); optionsPanel.add(BLabel); optionsPanel.add(B2Label); optionsPanel.add(BSpinner); JButton updatebutton = new JButton("update"); updatebutton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] sels = attributeslist.getSelectedValues(); String[] els = new String[sels.length]; for (int i = 0; i < sels.length; i++) { els[i] = sels[i].toString(); } long timesize = 1000; switch (timebox.getSelectedIndex()) { case 0: timesize = 1000; break; case 1: timesize = 1000 * 60; break; case 2: timesize = 1000 * 60 * 60; break; case 3: timesize = 1000 * 60 * 60 * 24; break; } String xname = null; JFreeChart mychart = null; if (xbox.getSelectedIndex() == 0) { data = getDataAttributes(els, false, timesize); xname = "Event sequence"; mychart = ChartFactory.createScatterPlot( "Scatterplot of all values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); } else if (xbox.getSelectedIndex() == 1) { data = getDataAttributes(els, true, timesize); xname = "Time(" + timebox.getSelectedItem() + ") since beginning of the process"; mychart = ChartFactory.createScatterPlot( "Scatterplot of all values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); } else if (xbox.getSelectedIndex() == 2) { xname = "Event sequence"; data = getHistrogrammedDataAttributes(els, 1, 1); mychart = ChartFactory.createXYLineChart( "Average values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); mychart.setBackgroundPaint(Color.white); XYPlot plot = mychart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); DeviationRenderer renderer = new DeviationRenderer(true, true); renderer.setSeriesStroke( 0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); renderer.setSeriesStroke(3, new BasicStroke(2.0f)); renderer.setSeriesFillPaint(0, Color.red); renderer.setSeriesFillPaint(1, Color.blue); renderer.setSeriesFillPaint(2, Color.green); renderer.setSeriesFillPaint(3, Color.orange); plot.setRenderer(renderer); // change the auto tick unit selection to integer units // only... NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); // yAxis.setAutoRangeIncludesZero(false); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } else { xname = "Time(" + timebox.getSelectedItem() + "s) since beginning of the process"; data = getHistrogrammedDataAttributes( els, ((Integer) BSpinner.getValue()) * timesize, timesize); mychart = ChartFactory.createXYLineChart( "Average values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); mychart.setBackgroundPaint(Color.white); XYPlot plot = mychart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); DeviationRenderer renderer = new DeviationRenderer(true, true); renderer.setSeriesStroke( 0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); renderer.setSeriesStroke(3, new BasicStroke(2.0f)); renderer.setSeriesFillPaint(0, Color.red); renderer.setSeriesFillPaint(1, Color.blue); renderer.setSeriesFillPaint(2, Color.green); renderer.setSeriesFillPaint(3, Color.orange); plot.setRenderer(renderer); // change the auto tick unit selection to integer units // only... NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); // yAxis.setAutoRangeIncludesZero(false); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } ChartPanel mychartpanel = new ChartPanel(mychart); mychartpanel.setBackground(Color.white); chartPanel.removeAll(); chartPanel.add(mychartpanel); chartPanel.updateUI(); }; }); optionsPanel.add(updatebutton); JSplitPane splitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, optionsPanel, chartPanel); SpringUtils.makeCompactGrid( optionsPanel, 10, 1, // rows, cols 6, 2, // initX, initY 6, 2); // xPad, yPad mainPanel.add(splitPanel, BorderLayout.CENTER); return mainPanel; }
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); } } }
/** Set both year and week combo boxes to field "Custom". */ private void resetYearWeekComboBoxes() { yearCB.setSelectedIndex(0); weekCB.setSelectedIndex(0); }
private void refresh(int index) { GridBagConstraints c = new GridBagConstraints(); // No connector ................ if (acs.size() == 0) { add(new JLabel(bundle.getString("CTL_No_Connector")), c); return; } // Connector switch ................ if (acs.size() > 1) { c.insets = new Insets(0, 0, 3, 3); add(new JLabel(bundle.getString("CTL_Connector")), c); cbConnectors = new JComboBox(); int i, k = acs.size(); for (i = 0; i < k; i++) { AttachingConnector ac = (AttachingConnector) acs.get(i); int jj = ac.name().lastIndexOf('.'); String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1); cbConnectors.addItem(s + " (" + ac.description() + ")"); } c = new GridBagConstraints(); c.insets = new Insets(0, 3, 3, 0); c.weightx = 1.0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.gridwidth = 0; cbConnectors.setSelectedIndex(index); cbConnectors.setActionCommand("SwitchMe!"); cbConnectors.addActionListener(this); add(cbConnectors, c); } ac = (AttachingConnector) acs.get(index); // Transport ................ c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); add(new JLabel(bundle.getString("CTL_Transport")), c); JTextField tfTransport = new JTextField(ac.transport().name()); tfTransport.setEnabled(false); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(3, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfTransport, c); // Other params ................ args = ac.defaultArguments(); tfParams = new JTextField[args.size()]; Iterator it = args.keySet().iterator(); int i = 0; while (it.hasNext()) { String name = (String) it.next(); Argument a = (Argument) args.get(name); c = new GridBagConstraints(); c.insets = new Insets(6, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(a.label() + ": "), c); JTextField tfParam = new JTextField(a.value()); tfParams[i++] = tfParam; tfParam.setName(name); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(6, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfParam, c); } c = new GridBagConstraints(); c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = {"one", "two", "three", "four", "five", "six", "seven"}; String[] columnNames = {"French", "Spanish", "Italian"}; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane( output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }