private void populate(GeneralSubtree generalSubtree) { if (generalSubtree != null) { jgnBase.setGeneralName(generalSubtree.getBase()); if (generalSubtree.getMinimum() != null) { jtfMinimum.setText("" + generalSubtree.getMinimum().intValue()); jtfMinimum.setCaretPosition(0); } if (generalSubtree.getMaximum() != null) { jtfMaximum.setText("" + generalSubtree.getMaximum().intValue()); jtfMaximum.setCaretPosition(0); } } }
/** * Updates the suggestions every time the input field changes * * @param e A DocumentEvent representing the change in the input field */ public void updateSuggestions(String text) { // if (!text.equals("")) { // this.removeAllItems(); // this.addItem(text); // _textField.setCaretPosition(_cursor); // this.hidePopup(); // _gui.send("AUTOCORRECT\t" + _comboBoxID + "\t" + text); // } else { // this.hidePopup(); // } if (!text.equals("")) { List<String> results = _gui.autocorrect(text); int numResults = results.size() < Autocorrect.NUM_RESULTS ? results.size() : Autocorrect.NUM_RESULTS; this.removeAllItems(); this.addItem(text); _textField.setCaretPosition(_cursor); this.hidePopup(); // display up to NUM_RESULTS results for (String result : results) { if (numResults == 0) break; this.addItem(result); numResults--; } this.showPopup(); } else { this.hidePopup(); } }
private JTextField createField(final String text) { final JTextField field = new JTextField(text) { public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); return new Dimension(preferredSize.width, myTextHeight); } }; field.setBackground(UIUtil.getPanelBackground()); field.setEditable(false); final Border lineBorder = BorderFactory.createLineBorder(UIUtil.getPanelBackground()); final DottedBorder dotted = new DottedBorder(UIUtil.getActiveTextColor()); field.setBorder(lineBorder); // field.setFocusable(false); field.setHorizontalAlignment(JTextField.RIGHT); field.setCaretPosition(0); field.addFocusListener( new FocusAdapter() { public void focusGained(FocusEvent e) { field.setBorder(dotted); } public void focusLost(FocusEvent e) { field.setBorder(lineBorder); } }); return field; }
public void actionPerformed(ActionEvent e) { // Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(ElectorFicheros.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); fseleccionado = file; log.setText(" " + file.getName()); // Coge el nombre del fichero para abrir. logruta.setText("" + file.getAbsolutePath()); // Coge la ruta del fichero para abrir. } else { log.setText(""); logruta.setText(""); } log.setCaretPosition(log.getDocument().getLength()); logruta.setCaretPosition(logruta.getDocument().getLength()); } }
/** * Constructs a {@code GUITextField}. * * @param field the field */ public GUITextField(TextField field) { super(field); text = new JTextField(field.getInitialValue(), field.getSize()); text.setName(field.getVariable()); text.setCaretPosition(0); text.getDocument().addDocumentListener(this); text.addFocusListener(this); addField(text); }
private int selectCompletionRemoveText( final CompletionResult result, boolean selectReplacedText) { int pos = myPathTextField.getCaretPosition(); if (result.myToComplete.size() > 0 && selectReplacedText) { myPathTextField.setCaretPosition(myPathTextField.getText().length()); myPathTextField.moveCaretPosition(pos); } return pos; }
/** Observer method to update the editPanel and it's contents */ public void updateEditPanel() { InsuranceCompany insuranceCompany = model.getCurrentInsuranceCompany(); if (insuranceCompany != null) { // If no currentInsuranceCompany is set (if the db is empty) // Update all text fields String id = (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0); companyIdTextField.setText(id); companyNameTextField.setText(insuranceCompany.getCompanyName()); urlTextField.setText(insuranceCompany.getUrl()); urlTextField.setCaretPosition(0); generalDescriptionTextField.setText(insuranceCompany.getGeneralDescription()); generalDescriptionTextField.setCaretPosition(0); insuranceTypesTextField.setText(insuranceCompany.getInsuranceTypes()); insuranceTypesTextField.setCaretPosition(0); telephoneTextField.setText(insuranceCompany.getTelephone()); percentageTextField.setText(Float.toString(insuranceCompany.getPercentage())); } }
/** * Methode, um die ausgewählten Attributgruppen zu übergeben. * * @param attributeGroups ausgewählte Attributgruppen */ private void setAttributeGroups(List<AttributeGroup> attributeGroups) { _attributeGroups.clear(); if (attributeGroups != null && attributeGroups.size() >= 1) { _attributeGroups.addAll(attributeGroups); AttributeGroup atg = (AttributeGroup) _attributeGroups.get(0); _atgTextField.setText(atg.getNameOrPidOrId()); _atgTextField.setCaretPosition(0); } else { remove(_atgLabel); remove(_atgTextField); _numberOfSelectedAttributeGroups = 0; } }
/** * Replace the path component under the caret with the file selected from the completion list. * * @param file the selected file. * @param caretPos * @param start the start offset of the path component under the caret. * @param end the end offset of the path component under the caret. * @throws BadLocationException */ private void replacePathComponent(LookupFile file, int caretPos, int start, int end) throws BadLocationException { final Document doc = myPathTextField.getDocument(); myPathTextField.setSelectionStart(0); myPathTextField.setSelectionEnd(0); final String name = file.getName(); boolean toRemoveExistingName; String prefix = ""; if (caretPos >= start) { prefix = doc.getText(start, caretPos - start); if (prefix.length() == 0) { prefix = doc.getText(start, end - start); } if (SystemInfo.isFileSystemCaseSensitive) { toRemoveExistingName = name.startsWith(prefix) && prefix.length() > 0; } else { toRemoveExistingName = name.toUpperCase().startsWith(prefix.toUpperCase()) && prefix.length() > 0; } } else { toRemoveExistingName = true; } int newPos; if (toRemoveExistingName) { doc.remove(start, end - start); doc.insertString(start, name, doc.getDefaultRootElement().getAttributes()); newPos = start + name.length(); } else { doc.insertString(caretPos, name, doc.getDefaultRootElement().getAttributes()); newPos = caretPos + name.length(); } if (file.isDirectory()) { if (!myFinder.getSeparator().equals(doc.getText(newPos, 1))) { doc.insertString( newPos, myFinder.getSeparator(), doc.getDefaultRootElement().getAttributes()); newPos++; } } if (newPos < doc.getLength()) { if (myFinder.getSeparator().equals(doc.getText(newPos, 1))) { newPos++; } } myPathTextField.setCaretPosition(newPos); }
/** * Methode, um die ausgewählten Aspekte zu übergeben. * * @param aspects die ausgewählten Aspekte */ private void setAspects(List<Aspect> aspects) { _aspects.clear(); if (aspects != null && aspects.size() == 1) { _aspects.addAll(aspects); Aspect aspect = (Aspect) _aspects.get(0); _aspTextField.setText(aspect.getNameOrPidOrId()); _aspTextField.setCaretPosition(0); _numberOfSelectedAspects = 1; } else { remove(_aspLabel); remove(_aspTextField); _numberOfSelectedAspects = 0; } }
/** @see com.royalstone.pos.gui.MainUI#setInputField(java.lang.String) */ public void setInputField(String value) { switch (step) { case 0: MoneyDuom.setEditable(true); MoneyDuom.setText(value); MoneyDuom.setCaretPosition(value.length()); break; case 1: StringBuffer strb = new StringBuffer(); for (int i = 0; i < value.length(); i++) { strb.append("*"); } MoneyDuom.setEditable(false); break; } }
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; } } }
@Override public void setRegistry(DDbRegistry registry) throws Exception { moRegistry = (DDbDps) registry; mnFormResult = DLibConsts.UNDEFINED; mbFirstActivation = true; // Set registry: removeAllListeners(); reloadCatalogues(); if (moRegistry.isRegistryNew()) { throw new Exception(DGuiConsts.ERR_MSG_FORM_EXIST_REG); } else { jtfRegistryKey.setText(""); } setFormEditable(true); // enable all controls before setting form values mtOriginalDate = moRegistry.getDate(); mnOriginalYear = DLibTimeUtils.digestYear(mtOriginalDate)[0]; moTextSeries.setValue(moRegistry.getSeries()); moIntNumber.setValue(moRegistry.getNumber()); moDateDate.setValue(mtOriginalDate); moKeyEmissionType.setValue(new int[] {moRegistry.getFkEmissionTypeId()}); jtfDocType.setText( (String) miClient .getSession() .readField( DModConsts.TS_DPS_TP, moRegistry.getDpsTypeKey(), DDbRegistry.FIELD_NAME)); jtfDocType.setCaretPosition(0); moPanelDps.setValue(DModSysConsts.PARAM_YEAR, mnOriginalYear); moPanelDps.setRegistry(moRegistry); moTextSeries.setEditable(false); moDateDate.setEditable(false); addAllListeners(); }
/** * Sets list index based on editor's text. * * @return true if matching item was found on the list */ private boolean setSelectedByEditor() { String editorText = editorField.getText().toUpperCase(); if (editorText.length() == 0) { return false; } int pos = editorField.getCaretPosition(); boolean found = false; for (int i = 0; i < getItemCount() && !found; i++) { String item = getItemAt(i).toString(); if (item.toUpperCase().startsWith(editorText)) { editorField.setText(item); editorField.setCaretPosition(item.length()); editorField.moveCaretPosition(pos); moveCaretInSelection = false; setSelectedIndex(i); moveCaretInSelection = true; found = true; } } return found; }
/** * Sets the query service URL. * * @param url service access URL */ public void setServiceUrl(String url) { urlField_.setText(url); urlField_.setCaretPosition(0); updateServiceCoverage(); }
private void fireRegexpOptionsChanged() { boolean multiline = cbMultiline.isSelected(); boolean caseInsensitive = cbCaseInsensitive.isSelected(); boolean dotall = cbDotall.isSelected(); boolean unicodeCase = cbUnicodeCase.isSelected(); String pattern = regexpTextField.getText(); String flags = getFlags(pattern); if (flags.contains("m")) { if (!multiline) { flags = flags.replace("m", ""); } } else { if (multiline) { flags += "m"; } } if (flags.contains("i")) { if (!caseInsensitive) { flags = flags.replace("i", ""); } } else { if (caseInsensitive) { flags += "i"; } } if (flags.contains("u")) { if (!unicodeCase) { flags = flags.replace("u", ""); } } else { if (unicodeCase) { flags += "u"; } } if (flags.contains("s")) { if (!dotall) { flags = flags.replace("s", ""); } } else { if (dotall) { flags += "s"; } } if (!flags.equals("") || pattern.startsWith("(?") && getFlags(pattern).equals("")) { flags = "(?" + flags + ")"; } if (pattern.startsWith("(?") && !pattern.startsWith("(?-")) { int oldFlagsEnd = pattern.indexOf(")"); if (oldFlagsEnd == -1) { oldFlagsEnd = 1; } oldFlagsEnd++; pattern = flags + pattern.substring(oldFlagsEnd); } else { pattern = flags + pattern; } int caretPosition = regexpTextField.getCaretPosition(); regexpTextField.setText(pattern); if (caretPosition < pattern.length()) { regexpTextField.setCaretPosition(caretPosition); } else { regexpTextField.setCaretPosition(pattern.length()); } fireRegularExpressionUpdated(); }
/** * Constructs a new modal {@code FileCrypter}. * * @param encrypt Whether to encrypt or decrypt the files * @param files The files to encrypt or decrypt * @see #init() */ private FileCrypter(boolean encrypt, @Nullable VFSFile... files) { super( jEdit.getActiveView(), jEdit.getProperty(encrypt ? "cipher.file-encrypter.title" : "cipher.file-decrypter.title"), true); this.encrypt = encrypt; this.files = files; cipherOptionPane = new CipherOptionPane(false, false); newFileHandlingLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.new-file-handling.label")); Dimension dim = new Dimension(20, 0); firstColumnFiller = new Filler(dim, dim, dim); directoryFiller = new Filler(dim, dim, dim); suffixFiller = new Filler(dim, dim, dim); overwriteRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.overwrite.label"), false); dim = overwriteRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; overwriteRadioButton.setMaximumSize(dim); newFileHandlingLabel.setLabelFor(overwriteRadioButton); otherDirectoryRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.other-directory.label"), false); dim = otherDirectoryRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; otherDirectoryRadioButton.setMaximumSize(dim); directoryLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.directory.label")); directoryTextField = new JTextField(jEdit.getProperty("options.cipher.file-crypter.directory")); directoryTextField.setEditable(false); directoryTextField.setColumns(25); directoryTextField.setCaretPosition(0); directoryLabel.setLabelFor(directoryTextField); chooseDirectoryButton = new JButton(jEdit.getProperty("cipher.file-crypter.choose-button.label")); dim = chooseDirectoryButton.getMaximumSize(); dim.height = Integer.MAX_VALUE; chooseDirectoryButton.setMaximumSize(dim); suffixRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.suffix-radio-button.label"), false); dim = suffixRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; suffixRadioButton.setMaximumSize(dim); suffixLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.suffix.label")); suffixTextField = new JTextField(jEdit.getProperty("options.cipher.file-crypter.suffix")); suffixTextField.setColumns(25); suffixTextField.setCaretPosition(0); suffixLabel.setLabelFor(suffixTextField); cryptButton = new JButton( jEdit.getProperty( encrypt ? "cipher.file-crypter.encrypt-button.label" : "cipher.file-crypter.decrypt-button.label")); dim = cryptButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; cryptButton.setMaximumSize(dim); getRootPane().setDefaultButton(cryptButton); NewFileHandling newFileHandling = Enum.valueOf( NewFileHandling.class, jEdit.getProperty("options.cipher.file-crypter.new-file-handling", "OVERWRITE")); switch (newFileHandling) { case OVERWRITE: overwriteRadioButton.setSelected(true); break; case OTHER_DIRECTORY: otherDirectoryRadioButton.setSelected(true); break; case SUFFIX: suffixRadioButton.setSelected(true); break; default: throw new InternalError("missing case branch for NewFileHandling: " + newFileHandling); } ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(overwriteRadioButton); buttonGroup.add(otherDirectoryRadioButton); buttonGroup.add(suffixRadioButton); setLayout(new ExtendedGridLayout(5, 5, new Insets(5, 5, 5, 5))); add(cipherOptionPane, new ExtendedGridLayoutConstraints(0, 5, 1, cipherOptionPane)); add(newFileHandlingLabel, new ExtendedGridLayoutConstraints(1, 5, 1, newFileHandlingLabel)); add(firstColumnFiller, new ExtendedGridLayoutConstraints(2, 1, 5, firstColumnFiller)); add(overwriteRadioButton, new ExtendedGridLayoutConstraints(2, 4, 1, overwriteRadioButton)); add( otherDirectoryRadioButton, new ExtendedGridLayoutConstraints(3, 4, 1, otherDirectoryRadioButton)); add(directoryFiller, new ExtendedGridLayoutConstraints(4, directoryFiller)); add(directoryLabel, new ExtendedGridLayoutConstraints(4, directoryLabel)); add(directoryTextField, new ExtendedGridLayoutConstraints(4, directoryTextField)); add(chooseDirectoryButton, new ExtendedGridLayoutConstraints(4, chooseDirectoryButton)); add(suffixRadioButton, new ExtendedGridLayoutConstraints(5, 4, 1, suffixRadioButton)); add(suffixFiller, new ExtendedGridLayoutConstraints(6, suffixFiller)); add(suffixLabel, new ExtendedGridLayoutConstraints(6, suffixLabel)); add(suffixTextField, new ExtendedGridLayoutConstraints(6, 2, 1, suffixTextField)); add(cryptButton, new ExtendedGridLayoutConstraints(7, 5, 1, cryptButton)); }
/** Creates UI on JPanel */ void jbInit() throws Exception { minxLabel.setText(PirolPlugInMessages.getString("minx")); // $NON-NLS-1$ maxxLabel.setText(PirolPlugInMessages.getString("maxx")); // $NON-NLS-1$ minyLabel.setText(PirolPlugInMessages.getString("miny")); // $NON-NLS-1$ maxyLabel.setText(PirolPlugInMessages.getString("maxy")); // $NON-NLS-1$ this.setLayout(gridBagLayout1); minxTextField.setPreferredSize(new Dimension(270, 21)); minxTextField.setCaretPosition(minxTextField.getText().length()); maxxTextField.setPreferredSize(new Dimension(270, 21)); maxxTextField.setCaretPosition(maxxTextField.getText().length()); minyTextField.setPreferredSize(new Dimension(270, 21)); minyTextField.setCaretPosition(minyTextField.getText().length()); maxyTextField.setPreferredSize(new Dimension(270, 21)); maxyTextField.setCaretPosition(maxyTextField.getText().length()); this.add( minxLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0)); this.add( minxTextField, new GridBagConstraints( 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 4), 0, 0)); this.add( maxxLabel, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0)); this.add( maxxTextField, new GridBagConstraints( 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 4), 0, 0)); this.add( minyLabel, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0)); this.add( minyTextField, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 4), 0, 0)); this.add( maxyLabel, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0)); this.add( maxyTextField, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 4), 0, 0)); this.add( fillerPanel, new GridBagConstraints( 2, 10, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
private void alignSnSki() { final ServiceDigitalIdentityMultivalueAdapter serviceDigitalIdentityMultivalueAdapter = (ServiceDigitalIdentityMultivalueAdapter) certificateButton.getMultivaluePanel().getMultivalueModel(); final List<DigitalIdentityType> digitalId = serviceDigitalIdentityMultivalueAdapter.getDigitalIdentityList().getDigitalId(); boolean useSn = boxSN.isSelected(); boolean useSki = boxSKI.isSelected(); serviceDigitalIdentityMultivalueAdapter.setSn(useSn); serviceDigitalIdentityMultivalueAdapter.setSki(useSki); boolean snAdded = false; boolean skiAdded = false; // cleanup existing SN & SKI (might not be aligned with the certificates chosen for (Iterator<DigitalIdentityType> iterator = digitalId.iterator(); iterator.hasNext(); ) { DigitalIdentityType digitalIdentityType = iterator.next(); if (digitalIdentityType.getX509SubjectName() != null) { iterator.remove(); } if (digitalIdentityType.getX509SKI() != null) { iterator.remove(); } } // cleanup SubjetName display distinguishedName.setText(""); distinguishedName.setCaretPosition(0); // search new values for (final String key : serviceDigitalIdentityMultivalueAdapter.getKeys()) { final DigitalIdentityModel digitalIdentityModel = serviceDigitalIdentityMultivalueAdapter.getValue(key); if (digitalIdentityModel != null) { final X509Certificate certificate = digitalIdentityModel.getCertificate(); if (certificate != null) { final DigitalIdentityType digitalIdentitySN = new DigitalIdentityType(); final String x509SubjectName = certificate.getSubjectX500Principal().getName(X500Principal.RFC2253); digitalIdentitySN.setX509SubjectName(x509SubjectName); // updateUI too // TODO: might be interesting to display all different subjectName (with error message) if // use has chosen different certificitates distinguishedName.setText(x509SubjectName); distinguishedName.setCaretPosition(0); if (!snAdded && useSn) { digitalId.add(digitalIdentitySN); snAdded = true; } if (!skiAdded && useSki) { final byte[] skiValue = DSSUtils.getSki(certificate); if (skiValue != null && skiValue.length > 0) { final DigitalIdentityType digitalIdentitySKI = new DigitalIdentityType(); digitalIdentitySKI.setX509SKI(skiValue); digitalId.add(digitalIdentitySKI); skiAdded = true; } } } } } }
@Override protected void init() { GridBagLayout layout = new GridBagLayout(); setLayout(layout); setPreferredSize(new Dimension(275, 275)); String[] months = { "September", "October", "November", "December", "January", "February", "March", "April", "May", "June" }; JComboBox<String> courseSelectorinit; if (AllCourses.getInstance().getNames().length == 0) { String[] defaultOption = {"No Course"}; courseSelectorinit = new JComboBox<>(defaultOption); } else { courseSelectorinit = new JComboBox<>(AllCourses.getInstance().getNames()); } final JComboBox<String> courseSelector = courseSelectorinit; JLabel name = new JLabel("Name"), units = new JLabel("Units"); final JTextField nameField = new JTextField(), unitsField = new JTextField(); final JTextField orderField = new JTextField(); JLabel orderLabel = new JLabel("Order"); final JTextField weightField = new JTextField(); JLabel weightLabel = new JLabel("Weight"); final JCheckBox finished = new JCheckBox("Finished"); JLabel monthLabel = new JLabel("Month completed"); final JComboBox<String> month = new JComboBox<>(months); done = new JButton("Done"); cancel = new JButton("Cancel"); name.setHorizontalAlignment(SwingConstants.CENTER); units.setHorizontalAlignment(SwingConstants.CENTER); orderLabel.setHorizontalAlignment(SwingConstants.CENTER); weightLabel.setHorizontalAlignment(SwingConstants.CENTER); monthLabel.setHorizontalAlignment(SwingConstants.CENTER); courseSelector.setSelectedItem(currentWork.getCourseName()); nameField.setText(currentWork.getName()); nameField.setCaretPosition(0); unitsField.setText(String.valueOf(currentWork.getUnits())); orderField.setText(String.valueOf(currentWork.getOrder())); weightField.setText(String.valueOf(currentWork.getWeight())); finished.setSelected(currentWork.isComplete()); if (currentWork.isComplete()) { month.setSelectedIndex(currentWork.getMonthComplete()); } else { month.setSelectedIndex(Workload.convertMonth(DateTime.now().getMonthOfYear())); } courseSelector.addKeyListener(doneListener); nameField.addKeyListener(doneListener); unitsField.addKeyListener(doneListener); orderField.addKeyListener(doneListener); weightField.addKeyListener(doneListener); finished.addKeyListener(doneListener); month.addKeyListener(doneListener); done.addKeyListener(doneListener); cancel.addKeyListener(doneListener); done.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { editWork( courseSelector.getSelectedItem().toString(), nameField.getText(), Integer.parseInt(unitsField.getText()), Integer.parseInt(orderField.getText()), finished.isSelected(), month.getSelectedIndex(), Integer.parseInt(weightField.getText())); dispose(); } catch (NumberFormatException ex) { new ErrorMessage(ex, "Please input real numbers").createAndViewGUI(); } } }); cancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(5, 8, 5, 8); constraints.weightx = 1; constraints.weighty = 1; constraints.gridwidth = 2; layout.addLayoutComponent(courseSelector, constraints); constraints.gridy = 1; constraints.gridx = 0; constraints.gridwidth = 1; layout.addLayoutComponent(name, constraints); constraints.gridx = 1; layout.addLayoutComponent(nameField, constraints); constraints.gridy = 2; constraints.gridx = 0; layout.addLayoutComponent(units, constraints); constraints.gridx = 1; layout.addLayoutComponent(unitsField, constraints); constraints.gridy = 3; constraints.gridx = 0; layout.addLayoutComponent(orderLabel, constraints); constraints.gridx = 1; layout.addLayoutComponent(orderField, constraints); constraints.gridx = 0; constraints.gridy = 4; layout.addLayoutComponent(weightLabel, constraints); constraints.gridx = 1; layout.addLayoutComponent(weightField, constraints); constraints.gridwidth = 2; constraints.gridy = 5; constraints.gridx = 1; constraints.insets = new Insets(0, 0, 0, 0); layout.addLayoutComponent(monthLabel, constraints); constraints.gridy = 6; constraints.gridx = 0; constraints.gridwidth = 1; constraints.insets = new Insets(5, 8, 5, 8); layout.addLayoutComponent(finished, constraints); constraints.gridx = 1; layout.addLayoutComponent(month, constraints); constraints.gridy = 7; constraints.gridx = 0; layout.addLayoutComponent(done, constraints); constraints.gridx = 1; layout.addLayoutComponent(cancel, constraints); add(courseSelector); add(name); add(nameField); add(units); add(unitsField); add(orderField); add(orderLabel); add(weightLabel); add(weightField); add(monthLabel); add(finished); add(month); add(done); add(cancel); }
private void showResult(QUERY_TYPE type, String result) { if (result == null || result.length() == 0) { JOptionPane.showMessageDialog(null, "There is no information"); return; } if (type == QUERY_TYPE.OVERLAY || type == QUERY_TYPE.OVERLAY_BAYESIAN || type == QUERY_TYPE.DYN_OVERLAY_BAYESIAN) { knowledge.setText(result); knowledge.setCaretPosition(0); } else if (type == QUERY_TYPE.LEARNING_STYLE) { ls.setText(result); ls.setCaretPosition(0); } else if (type == QUERY_TYPE.RECOMMENDED_PRE_CONCEPT) { prerec.setText(result); prerec.setCaretPosition(0); } else if (type == QUERY_TYPE.RECOMMENDED_POST_CONCEPT) { postrec.setText(result); postrec.setCaretPosition(0); } else if (type == QUERY_TYPE.LEARNING_PATH) { lp.setText(result); lp.setCaretPosition(0); } else if (type == QUERY_TYPE.COMMUNITY) { community.setText(result); community.setCaretPosition(0); } else if (type == QUERY_TYPE.PERSONAL_INFO || type == QUERY_TYPE.CONCEPT_INFO) { String[] items = result.split(","); String[][] data = new String[items.length][2]; for (int i = 0; i < items.length; i++) { String[] attr = items[i].split("="); if (attr.length != 2) continue; String key = attr[0].trim(); data[i][0] = key; if (key.toLowerCase().equals("password")) data[i][1] = "***"; else data[i][1] = attr[1]; } TableModel tableModel = new DefaultTableModel(data, new String[] {"Attribute", "Value"}) { private static final long serialVersionUID = 1L; @Override public boolean isCellEditable(int row, int column) { return false; } }; infoTable.setModel(tableModel); } else if (type == QUERY_TYPE.STUDY_TIME) { studytime.setText(result); } else if (type == QUERY_TYPE.DOCCLASS) { docclass.setText(result); } else if (type == QUERY_TYPE.USERREPORT || type == QUERY_TYPE.FEEDBACKREPORT || type == QUERY_TYPE.TOTALREPORT) { new UserReportDlg(null, result); } else if (type == QUERY_TYPE.MAILINGLIST_REG || type == QUERY_TYPE.MAILINGLIST_UNREG) { String str = type == QUERY_TYPE.MAILINGLIST_REG ? "Registering" : "Unregistering"; if (result.toLowerCase().equals("true")) JOptionPane.showMessageDialog( this, str + " Mailing List success!", "Result of " + str + " Mailing List", JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog( this, str + " Mailing List fail!", "Result of " + str + " Unregistering Mailing List", JOptionPane.INFORMATION_MESSAGE); } }
/** Refreshes the GUI including locale-based resource strings. */ protected void refreshGUI() { setTitle(ToolsRes.getString("LibraryManager.Title")); // $NON-NLS-1$ okButton.setText(ToolsRes.getString("Tool.Button.Close")); // $NON-NLS-1$ addButton.setText(ToolsRes.getString("LibraryManager.Button.Add")); // $NON-NLS-1$ removeButton.setText(ToolsRes.getString("LibraryManager.Button.Remove")); // $NON-NLS-1$ moveUpButton.setText(ToolsRes.getString("LibraryTreePanel.Button.Up")); // $NON-NLS-1$ moveDownButton.setText(ToolsRes.getString("LibraryTreePanel.Button.Down")); // $NON-NLS-1$ allButton.setText(ToolsRes.getString("LibraryManager.Button.All")); // $NON-NLS-1$ noneButton.setText(ToolsRes.getString("LibraryManager.Button.None")); // $NON-NLS-1$ clearCacheButton.setText(ToolsRes.getString("LibraryManager.Button.ClearCache")); // $NON-NLS-1$ setCacheButton.setText(ToolsRes.getString("LibraryManager.Button.SetCache")); // $NON-NLS-1$ addButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.Add.Tooltip")); // $NON-NLS-1$ removeButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.Remove.Tooltip")); // $NON-NLS-1$ moveUpButton.setToolTipText( ToolsRes.getString("LibraryTreePanel.Button.Up.Tooltip")); // $NON-NLS-1$ moveDownButton.setToolTipText( ToolsRes.getString("LibraryTreePanel.Button.Down.Tooltip")); // $NON-NLS-1$ allButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.All.Tooltip")); // $NON-NLS-1$ noneButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.None.Tooltip")); // $NON-NLS-1$ clearCacheButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.ClearCache.Tooltip")); // $NON-NLS-1$ setCacheButton.setToolTipText( ToolsRes.getString("LibraryManager.Button.SetCache.Tooltip")); // $NON-NLS-1$ nameLabel.setText( ToolsRes.getString("LibraryManager.Label.Name") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ pathLabel.setText( ToolsRes.getString("LibraryManager.Label.Path") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ collectionsTitleBorder.setTitle( ToolsRes.getString("LibraryManager.Title.MenuItems") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ importsTitleBorder.setTitle( ToolsRes.getString("LibraryManager.Title.Import") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ searchTitleBorder.setTitle( ToolsRes.getString("LibraryManager.Title.Search") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ cacheTitleBorder.setTitle( ToolsRes.getString("LibraryManager.Title.Cache") + ":"); // $NON-NLS-1$ //$NON-NLS-2$ int k = tabbedPane.indexOfComponent(collectionsPanel); if (k > -1) { tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.MyLibrary")); // $NON-NLS-1$ tabbedPane.setToolTipTextAt( k, ToolsRes.getString("LibraryManager.Tab.MyLibrary.Tooltip")); // $NON-NLS-1$ } k = tabbedPane.indexOfComponent(importsPanel); if (k > -1) { tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Import")); // $NON-NLS-1$ tabbedPane.setToolTipTextAt( k, ToolsRes.getString("LibraryManager.Tab.Import.Tooltip")); // $NON-NLS-1$ } k = tabbedPane.indexOfComponent(searchPanel); if (k > -1) { tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Search")); // $NON-NLS-1$ tabbedPane.setToolTipTextAt( k, ToolsRes.getString("LibraryManager.Tab.Search.Tooltip")); // $NON-NLS-1$ } k = tabbedPane.indexOfComponent(cachePanel); if (k > -1) { tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Cache")); // $NON-NLS-1$ tabbedPane.setToolTipTextAt( k, ToolsRes.getString("LibraryManager.Tab.Cache.Tooltip")); // $NON-NLS-1$ } resizeLabels(); pathField.setForeground(LibraryTreePanel.defaultForeground); if (tabbedPane.getSelectedComponent() == collectionsPanel) { nameField.setEditable(true); int i = collectionList.getSelectedIndex(); moveDownButton.setEnabled(i < library.pathList.size() - 1); moveUpButton.setEnabled(i > 0); if (i > -1 && library.pathList.size() > i) { removeButton.setEnabled(true); String path = library.pathList.get(i); pathField.setText(path); pathField.setCaretPosition(0); String name = library.pathToNameMap.get(path); nameField.setText(name); boolean unavailable = path.startsWith("http:") && !LibraryBrowser.webConnected; // $NON-NLS-1$ Resource res = unavailable ? null : ResourceLoader.getResourceZipURLsOK(path); if (res == null) { pathField.setForeground(LibraryTreePanel.darkRed); } } else { removeButton.setEnabled(false); nameField.setEditable(false); nameField.setText(null); nameField.setBackground(Color.white); pathField.setText(null); pathField.setBackground(Color.white); } } else if (tabbedPane.getSelectedComponent() == importsPanel) { nameField.setEditable(false); int i = guestList.getSelectedIndex(); moveDownButton.setEnabled(i < library.importedPathList.size() - 1); moveUpButton.setEnabled(i > 0); if (i > -1 && library.importedPathList.size() > i) { removeButton.setEnabled(true); String path = library.importedPathList.get(i); pathField.setText(path); pathField.setCaretPosition(0); String name = library.importedPathToLibraryMap.get(path).getName(); nameField.setText(name); boolean unavailable = path.startsWith("http:") && !LibraryBrowser.webConnected; // $NON-NLS-1$ Resource res = unavailable ? null : ResourceLoader.getResourceZipURLsOK(path); if (res == null) { pathField.setForeground(LibraryTreePanel.darkRed); } } else { removeButton.setEnabled(false); nameField.setText(null); nameField.setBackground(Color.white); pathField.setText(null); pathField.setBackground(Color.white); } } nameField.setBackground(Color.white); pathField.setBackground(Color.white); }
/** * Parses the XML reply from BioGeomancer Classic, creating a {@link * BioGeomancerQuerySummaryStruct} holding the corresponding data. The data is then displayed in * the appropriate UI widgets. * * @param bgXmlResponse * @throws Exception */ public void setBioGeomancerResultsData(String bgXmlResponse) throws Exception { mapLabel.setIcon(null); mapLabel.setText(getResourceString("BioGeomancerResultsDisplay.LOADING_MAP")); // $NON-NLS-1$ summary = BioGeomancer.parseBioGeomancerResponse(bgXmlResponse); idField.setText(summary.id); idField.setCaretPosition(0); countryField.setText(summary.country); countryField.setCaretPosition(0); adm1Field.setText(summary.adm1); adm1Field.setCaretPosition(0); adm2Field.setText(summary.adm2); adm2Field.setCaretPosition(0); localityField.setText(summary.localityStr); localityField.setCaretPosition(0); countryBoundingBoxField.setText(summary.countryBoundingBox); countryBoundingBoxField.setCaretPosition(0); matchedCountField.setText(summary.matchedRecordCount); matchedCountField.setCaretPosition(0); boundingBoxField.setText(summary.boundingBox); boundingBoxField.setCaretPosition(0); boundingBoxCentroidField.setText(summary.boundingBoxCentroid); boundingBoxCentroidField.setCaretPosition(0); centroidErrorRadiusField.setText(summary.boundingBoxCentroidErrorRadius); centroidErrorRadiusField.setCaretPosition(0); centroidErrorRadiusUnitsField.setText(summary.boundingBoxCentroidErrorRadiusUnits); centroidErrorRadiusUnitsField.setCaretPosition(0); multiPointMatchField.setText(summary.multiPointMatch); multiPointMatchField.setCaretPosition(0); weightedCentroidField.setText(summary.weightedCentroid); weightedCentroidField.setCaretPosition(0); bgResultsTable.setModel(new BioGeomancerResultsTableModel(summary.results)); UIHelper.calcColumnWidths(bgResultsTable); BioGeomancer.getMapOfQuerySummary(summary, this); repaint(); }
/** Update the text field based on the model. */ private void updateTextField() { _textField.setText(_pim.getMask()); _textField.setCaretPosition(_pim.getMask().length()); }