void insertMatchButton_actionPerformed(ActionEvent e) { String key = (String) matchComboBox.getSelectedItem(); String format = (String) matchesKeys.get(key); if (key.equals(STRING_LITERAL)) { format = escapeReservedChars( (String) JOptionPane.showInputDialog( this, "Enter the string you wish to match", "String Literal Input", JOptionPane.OK_CANCEL_OPTION)); if (StringUtil.isNullString(format)) { return; } } if (selectedPane == 0) { insertText(format, PLAIN_ATTR, editorPane.getSelectionStart()); } else { // add the combobox data value to the edit box int pos = formatTextArea.getCaretPosition(); formatTextArea.insert(format, pos); } }
void insertButton_actionPerformed(ActionEvent e) { Object selected = paramComboBox.getSelectedItem(); ConfigParamDescr descr; String key; int type = 0; String format = ""; if (selected instanceof ConfigParamDescr) { descr = (ConfigParamDescr) selected; key = descr.getKey(); type = descr.getType(); switch (type) { case ConfigParamDescr.TYPE_STRING: case ConfigParamDescr.TYPE_URL: case ConfigParamDescr.TYPE_BOOLEAN: format = "%s"; break; case ConfigParamDescr.TYPE_INT: case ConfigParamDescr.TYPE_LONG: case ConfigParamDescr.TYPE_POS_INT: NumericPaddingDialog dialog = new NumericPaddingDialog(); Point pos = this.getLocationOnScreen(); dialog.setLocation(pos.x, pos.y); dialog.pack(); dialog.setVisible(true); StringBuilder fbuf = new StringBuilder("%"); int width = dialog.getPaddingSize(); boolean is_zero = dialog.useZero(); if (width > 0) { fbuf.append("."); if (is_zero) { fbuf.append(0); } fbuf.append(width); } if (type == ConfigParamDescr.TYPE_LONG) { fbuf.append("ld"); } else { fbuf.append("d"); } format = fbuf.toString(); break; case ConfigParamDescr.TYPE_YEAR: if (key.startsWith(DefinableArchivalUnit.PREFIX_AU_SHORT_YEAR)) { format = "%02d"; } else { format = "%d"; } break; case ConfigParamDescr.TYPE_RANGE: case ConfigParamDescr.TYPE_NUM_RANGE: case ConfigParamDescr.TYPE_SET: format = "%s"; break; } if (selectedPane == 0) { insertParameter(descr, format, editorPane.getSelectionStart()); } else if (selectedPane == 1) { // add the combobox data value to the edit box int pos = formatTextArea.getCaretPosition(); formatTextArea.insert(format, pos); pos = parameterTextArea.getCaretPosition(); parameterTextArea.insert(", " + key, pos); } } else { key = selected.toString(); format = escapePrintfChars( (String) JOptionPane.showInputDialog( this, "Enter the string you wish to input", "String Literal Input", JOptionPane.OK_CANCEL_OPTION)); if (StringUtil.isNullString(format)) { return; } if (selectedPane == 0) { insertText(format, PLAIN_ATTR, editorPane.getSelectionStart()); } else if (selectedPane == 1) { // add the combobox data value to the edit box formatTextArea.insert(format, formatTextArea.getCaretPosition()); } } }