public void updateCodeHistory() { String code = getCode(); if (code != null) { code = code.trim(); if (!code.equals("")) { addToCodeHistory(code, true); storeCodeHistory(); } } }
public void setCode(String newCode) { setCode(newCode, false, -1); }
public void setBottomAccessory(Component component) { add(component, BorderLayout.SOUTH); }
private void invokeExpressionEditor() { final Window window = SwingUtilities.getWindowAncestor(VisatApp.getApp().getMainFrame()); final ExpressionPane pane = ProductExpressionPane.createBooleanExpressionPane(new Product[]{_product}, _product, VisatApp.getApp().getPreferences()); pane.setCode(_validMaskField.getText()); final int status = pane.showModalDialog(window, "Edit Valid Mask Expression"); /*I18N*/ if (status == ModalDialog.ID_OK) { _validMaskField.setText(pane.getCode()); _validMaskField.setCaretPosition(0); } }
String oldCode = getCode(); append(sb, oldCode.substring(0, selPos1)); if (phPatPos >= 0) { append(sb, pattern.substring(0, phPatPos)); append(sb, selCode.trim()); append(sb, pattern.substring(phPatPos + PLACEHOLDER_LEN)); } else { append(sb, pattern); append(sb, oldCode.substring(selPos2)); } else { append(sb, oldCode.substring(0, phPos)); append(sb, pattern); newCaretPos = sb.length(); append(sb, oldCode.substring(phPos + PLACEHOLDER_LEN)); } else { append(sb, lCode); append(sb, pattern.substring(PLACEHOLDER_LEN, pattern.length() - PLACEHOLDER_LEN)); newCaretPos = sb.length(); append(sb, rCode); } else { append(sb, lCode); append(sb, pattern.substring(PLACEHOLDER_LEN));
actionPane = createActionPane(); actionPane.setName("actionPane"); messageLabel.setFont(getFont().deriveFont(10.0F)); messageLabel.setHorizontalAlignment(JLabel.RIGHT); add(codePane, BorderLayout.CENTER); setCode("");
public void setCode(String newCode, boolean recordUndo, int caretPos) { String oldCode = codeArea.getText(); if (recordUndo) { pushCodeOnUndoStack(oldCode); } codeArea.setText(newCode == null ? "" : newCode); checkCode(newCode); updateUIState(); if (caretPos >= 0) { codeArea.setCaretPosition(caretPos); } codeArea.requestFocus(); firePropertyChange("code", oldCode, newCode); }
final JButton andButton = createInsertButton("@ and @"); final JButton orButton = createInsertButton("@ or @"); final JButton notButton = createInsertButton("not @"); andButton.setName("andButton"); orButton.setName("orButton"); notButton.setName("notButton"); add(patternPane, andButton, gbc); gbc.gridy++; add(patternPane, orButton, gbc); gbc.gridy++; add(patternPane, notButton, gbc); gbc.gridy++; } else { final JButton plusButton = createInsertButton("@ + @"); final JButton minusButton = createInsertButton("@ - @"); final JButton mulButton = createInsertButton("@ * @"); final JButton divButton = createInsertButton("@ / @"); plusButton.setName("plusButton"); minusButton.setName("minusButton"); add(patternPane, plusButton, gbc); gbc.gridy++; add(patternPane, minusButton, gbc); gbc.gridy++; add(patternPane, mulButton, gbc); gbc.gridy++; add(patternPane, divButton, gbc); gbc.gridy++;
public void undoLastEdit() { if (!undoBuffer.isEmpty()) { String code = undoBuffer.pop(); setCode(code); updateUIState(); codeArea.requestFocus(); } }
public void loadCodeHistory() { if (preferences != null) { history.clear(); for (int index = 0; index < CODE_HISTORY_MAX; index++) { final String code = preferences.getPropertyString(CODE_HISTORY_PREFERENCES_PREFIX + index); addToCodeHistory(code, false); } historyIndex = -1; updateUIState(); } }
@Override protected boolean verifyUserInput() { checkCode(); String lastErrorMessage = getLastErrorMessage(); if (lastErrorMessage != null) { JOptionPane.showMessageDialog(getJDialog(), lastErrorMessage, "Error", JOptionPane.ERROR_MESSAGE); return false; } return true; } }
public void changedUpdate(DocumentEvent e) { checkCode(); } });
public void actionPerformed(ActionEvent e) { clearCode(); } });
private String[] getFunctionTemplates() { final Namespace defaultNamespace = parser.getDefaultNamespace(); // collect names String[] functionNames; if (defaultNamespace instanceof NamespaceImpl) { final NamespaceImpl namespace = (NamespaceImpl) defaultNamespace; final Function[] functions = namespace.getAllFunctions(); functionNames = new String[functions.length]; for (int i = 0; i < functions.length; i++) { functionNames[i] = createFunctionTemplate(functions[i]); } } else { functionNames = FUNCTION_NAMES; } // remove double values Set<String> set = new HashSet<String>(); Collections.addAll(set, functionNames); functionNames = set.toArray(new String[set.size()]); Arrays.sort(functionNames); return functionNames; }
private void invokeExpressionEditor(final int colorIndex) { final Window window = SwingUtilities.getWindowAncestor(this); final String title = "Edit " + COLOR_COMP_NAMES[colorIndex] + " Expression"; if (product != null) { final ExpressionPane pane; pane = ProductExpressionPane.createGeneralExpressionPane(new Product[]{product}, product, preferences); pane.setCode(getExpression(colorIndex)); int status = pane.showModalDialog(window, title); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, pane.getCode()); } } else { final JTextArea textArea = new JTextArea(8, 48); textArea.setFont(EXPRESSION_FONT); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setText(getExpression(colorIndex)); final ModalDialog modalDialog = new ModalDialog(window, title, ModalDialog.ID_OK_CANCEL, ""); final JPanel panel = new JPanel(new BorderLayout(2, 2)); panel.add(new JLabel("Expression:"), BorderLayout.NORTH); panel.add(new JScrollPane(textArea), BorderLayout.CENTER); modalDialog.setContent(panel); final int status = modalDialog.show(); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, textArea.getText()); } } }
public void insertUpdate(DocumentEvent e) { checkCode(); }
public void clearCode() { setCode(""); }
public void setLeftAccessory(Component component) { add(component, BorderLayout.WEST); }
public void removeUpdate(DocumentEvent e) { checkCode(); }