/** * The keyReleased event ensures that the caret-position is updated for both peers, when the * user moves the caret with the arrow-keys. */ public void keyReleased(KeyEvent e) { int left = e.VK_LEFT; int right = e.VK_RIGHT; int up = e.VK_UP; int down = e.VK_DOWN; int home = e.VK_HOME; int end = e.VK_END; int A = e.VK_A; int kc = e.getKeyCode(); if (kc == left || kc == right || kc == up || kc == down || kc == home || kc == end || (kc == A && e.isControlDown())) { if (dec == null) return; lc.increment(); TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp()); dec.sendObjectToAllPeers(cu); er.getEventHistoryLock().lock(); er.getEventHistory().add(cu); er.getEventHistoryLock().unlock(); } }
public void mouseReleased(MouseEvent e) { if (e.getButton() == e.BUTTON1 && connected) { if (dec == null) return; lc.increment(); TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp()); dec.sendObjectToAllPeers(cu); er.getEventHistoryLock().lock(); er.getEventHistory().add(cu); er.getEventHistoryLock().unlock(); } }
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()); } } }