Repository: cayenne Updated Branches: refs/heads/master 3eb9affcb -> 055cb4130
CAY-2318 Query. Exception after Undo clicking Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/584ed289 Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/584ed289 Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/584ed289 Branch: refs/heads/master Commit: 584ed2892558b91ac300cd78bbe820db6f7fedf8 Parents: d8ffcdf Author: Anton Dreka <drek...@gmail.com> Authored: Thu Jun 15 13:55:52 2017 +0300 Committer: Anton Dreka <drek...@gmail.com> Committed: Thu Jun 15 13:55:52 2017 +0300 ---------------------------------------------------------------------- .../modeler/osx/OSXCayenneModelerModule.java | 1 - .../cayenne/modeler/osx/OSXWidgetFactory.java | 103 -------- modeler/cayenne-modeler/pom.xml | 5 - .../modeler/editor/EjbqlQueryScriptsTab.java | 18 +- .../modeler/editor/SQLTemplateScriptsTab.java | 239 +++++++++---------- .../modeler/undo/JTextFieldUndoListener.java | 19 +- .../modeler/util/DefaultWidgetFactory.java | 8 - .../modeler/util/JEditTextAreaUndoable.java | 119 --------- .../cayenne/modeler/util/WidgetFactory.java | 7 - pom.xml | 5 - 10 files changed, 143 insertions(+), 381 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXCayenneModelerModule.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXCayenneModelerModule.java b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXCayenneModelerModule.java index 78d00aa..7a66f7c 100644 --- a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXCayenneModelerModule.java +++ b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXCayenneModelerModule.java @@ -27,6 +27,5 @@ public class OSXCayenneModelerModule implements Module { public void configure(Binder binder) { binder.bind(PlatformInitializer.class).to(OSXPlatformInitializer.class); - binder.bind(WidgetFactory.class).to(OSXWidgetFactory.class); } } http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXWidgetFactory.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXWidgetFactory.java b/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXWidgetFactory.java deleted file mode 100644 index 5713f0a..0000000 --- a/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/osx/OSXWidgetFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.modeler.osx; - -import java.awt.event.KeyEvent; - -import org.apache.cayenne.modeler.util.DefaultWidgetFactory; -import org.syntax.jedit.DefaultInputHandler; -import org.syntax.jedit.JEditTextArea; - -public class OSXWidgetFactory extends DefaultWidgetFactory { - - @Override - public JEditTextArea createJEditTextArea() { - JEditTextArea area = super.createJEditTextArea(); - area.setInputHandler(new MacInputHandler()); - return area; - } - - /** - * Class for enabling Mac OS X keys - */ - private static class MacInputHandler extends DefaultInputHandler { - - MacInputHandler() { - addDefaultKeyBindings(); - } - - public void addDefaultKeyBindings() { - addKeyBinding("BACK_SPACE", BACKSPACE); - addKeyBinding("M+BACK_SPACE", BACKSPACE_WORD); - addKeyBinding("DELETE", DELETE); - addKeyBinding("M+DELETE", DELETE_WORD); - - addKeyBinding("ENTER", INSERT_BREAK); - addKeyBinding("TAB", INSERT_TAB); - - addKeyBinding("INSERT", OVERWRITE); - addKeyBinding("M+\\", TOGGLE_RECT); - - addKeyBinding("HOME", HOME); - addKeyBinding("END", END); - addKeyBinding("M+A", SELECT_ALL); - addKeyBinding("S+HOME", SELECT_HOME); - addKeyBinding("S+END", SELECT_END); - addKeyBinding("M+HOME", DOCUMENT_HOME); - addKeyBinding("M+END", DOCUMENT_END); - addKeyBinding("MS+HOME", SELECT_DOC_HOME); - addKeyBinding("MS+END", SELECT_DOC_END); - - addKeyBinding("PAGE_UP", PREV_PAGE); - addKeyBinding("PAGE_DOWN", NEXT_PAGE); - addKeyBinding("S+PAGE_UP", SELECT_PREV_PAGE); - addKeyBinding("S+PAGE_DOWN", SELECT_NEXT_PAGE); - - addKeyBinding("LEFT", PREV_CHAR); - addKeyBinding("S+LEFT", SELECT_PREV_CHAR); - addKeyBinding("A+LEFT", PREV_WORD); // option + left - addKeyBinding("AS+LEFT", SELECT_PREV_WORD); // option + shift + left - addKeyBinding("RIGHT", NEXT_CHAR); - addKeyBinding("S+RIGHT", SELECT_NEXT_CHAR); - addKeyBinding("A+RIGHT", NEXT_WORD); // option + right - addKeyBinding("AS+RIGHT", SELECT_NEXT_WORD); // option + shift + right - addKeyBinding("UP", PREV_LINE); - addKeyBinding("S+UP", SELECT_PREV_LINE); - addKeyBinding("DOWN", NEXT_LINE); - addKeyBinding("S+DOWN", SELECT_NEXT_LINE); - - addKeyBinding("M+ENTER", REPEAT); - - // Clipboard - addKeyBinding("M+C", CLIP_COPY); // command + c - addKeyBinding("M+V", CLIP_PASTE); // command + v - addKeyBinding("M+X", CLIP_CUT); // command + x - } - - @Override - public void keyTyped(KeyEvent evt) { - - // keys pressed with command key shouldn't generate text - int modifiers = evt.getModifiers(); - if ((modifiers & KeyEvent.META_MASK) == 0) { - super.keyTyped(evt); - } - } - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/pom.xml ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/pom.xml b/modeler/cayenne-modeler/pom.xml index 586a9f4..107340d 100644 --- a/modeler/cayenne-modeler/pom.xml +++ b/modeler/cayenne-modeler/pom.xml @@ -98,11 +98,6 @@ </dependency> <dependency> - <groupId>net.sf.jedit-syntax</groupId> - <artifactId>jedit-syntax</artifactId> - </dependency> - - <dependency> <groupId>jgraph</groupId> <artifactId>jgraph</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java index 404fb81..25c6094 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java @@ -56,7 +56,16 @@ public class EjbqlQueryScriptsTab extends JPanel implements DocumentListener { void displayScript() { EJBQLQueryDescriptor query = getQuery(); - scriptArea.setText(query.getEjbql()); + Document document = scriptArea.getDocument();; + String text = query.getEjbql(); + try { + if(!document.getText(0, document.getLength()).equals(query.getEjbql())) { + document.remove(0, document.getLength()); + document.insertString(0, text, null); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } updateDisabled = false; } @@ -82,7 +91,12 @@ public class EjbqlQueryScriptsTab extends JPanel implements DocumentListener { } public void removeUpdate(DocumentEvent e) { - getQuery().setEjbql(scriptArea.getText()); + try { + String text = scriptArea.getDocument().getText(0,scriptArea.getDocument().getLength()); + getQuery().setEjbql(text); + } catch (BadLocationException e1) { + e1.printStackTrace(); + } validateEJBQL(); } }); http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateScriptsTab.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateScriptsTab.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateScriptsTab.java index 2276fb1..dc41c57 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateScriptsTab.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateScriptsTab.java @@ -23,18 +23,14 @@ import com.jgoodies.forms.builder.PanelBuilder; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; import org.apache.cayenne.configuration.event.QueryEvent; -import org.apache.cayenne.modeler.Application; import org.apache.cayenne.modeler.ProjectController; import org.apache.cayenne.modeler.util.DbAdapterInfo; import org.apache.cayenne.map.QueryDescriptor; import org.apache.cayenne.map.SQLTemplateDescriptor; +import org.apache.cayenne.modeler.util.JUndoableCayenneTextPane; +import org.apache.cayenne.swing.components.textpane.JCayenneTextPane; +import org.apache.cayenne.swing.components.textpane.syntax.SQLSyntaxConstants; import org.apache.cayenne.util.Util; -import org.syntax.jedit.JEditTextArea; -import org.syntax.jedit.KeywordMap; -import org.syntax.jedit.tokenmarker.PLSQLTokenMarker; -import org.syntax.jedit.tokenmarker.SQLTokenMarker; -import org.syntax.jedit.tokenmarker.Token; -import org.syntax.jedit.tokenmarker.TokenMarker; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; @@ -51,7 +47,6 @@ import javax.swing.text.Document; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Font; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -60,53 +55,20 @@ import java.util.Map; /** * A panel for configuring SQL scripts of a SQL template. - * + * */ -public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { +public class SQLTemplateScriptsTab extends JPanel { private static final String DEFAULT_LABEL = "Default"; - - /** - * JEdit marker for SQL Template - */ - static final TokenMarker SQL_TEMPLATE_MARKER; - static { - KeywordMap map = PLSQLTokenMarker.getKeywordMap(); - - //adding more keywords - map.add("FIRST", Token.KEYWORD1); - map.add("LIMIT", Token.KEYWORD1); - map.add("OFFSET", Token.KEYWORD1); - map.add("TOP", Token.KEYWORD1); - - //adding velocity template highlighing - map.add("#bind", Token.KEYWORD2); - map.add("#bindEqual", Token.KEYWORD2); - map.add("#bindNotEqual", Token.KEYWORD2); - map.add("#bindObjectEqual", Token.KEYWORD2); - map.add("#bindObjectNotEqual", Token.KEYWORD2); - map.add("#chain", Token.KEYWORD2); - map.add("#chunk", Token.KEYWORD2); - map.add("#end", Token.KEYWORD2); - map.add("#result", Token.KEYWORD2); - - SQL_TEMPLATE_MARKER = new SQLTokenMarker(map); - } protected ProjectController mediator; protected JList scripts; - - /** - * JEdit text component for highlighing SQL syntax (see CAY-892) - */ - protected JEditTextArea scriptArea; - - /** - * Indication that no update should be fired - */ - private boolean updateDisabled; - + protected List keys; + protected PanelBuilder builder; + protected CellConstraints cc; + protected JCayenneTextPane textPane; + protected List<JCayenneTextPane> panes; protected ListSelectionListener scriptRefreshHandler; public SQLTemplateScriptsTab(ProjectController mediator) { @@ -122,31 +84,32 @@ public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { - displayScript(); + displayScript(); } } }; scripts = new JList(); scripts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - scripts.setCellRenderer(new DbAdapterListRenderer(DbAdapterInfo - .getStandardAdapterLabels())); + scripts.setCellRenderer(new DbAdapterListRenderer(DbAdapterInfo.getStandardAdapterLabels())); - List keys = new ArrayList(DbAdapterInfo.getStandardAdapters().length + 1); + keys = new ArrayList(DbAdapterInfo.getStandardAdapters().length + 1); keys.addAll(Arrays.asList(DbAdapterInfo.getStandardAdapters())); Collections.sort(keys); keys.add(0, DEFAULT_LABEL); scripts.setModel(new DefaultComboBoxModel(keys.toArray())); - - scriptArea = Application.getWidgetFactory().createJEditTextArea(); - - scriptArea.setTokenMarker(SQL_TEMPLATE_MARKER); - scriptArea.getDocument().addDocumentListener(this); - scriptArea.getPainter().setFont(new Font("Verdana", Font.PLAIN, 12)); // assemble - CellConstraints cc = new CellConstraints(); - PanelBuilder builder = new PanelBuilder(new FormLayout( + cc = new CellConstraints(); + + textPane = new JUndoableCayenneTextPane(new SQLSyntaxConstants()); + textPane.setName(DEFAULT_LABEL); + textPane.getDocument().addDocumentListener(new CustomListener(textPane.getName())); + + panes = new ArrayList<>(); + panes.add(textPane); + + builder = new PanelBuilder(new FormLayout( "fill:100dlu, 3dlu, fill:100dlu:grow", "3dlu, fill:p:grow")); @@ -155,7 +118,7 @@ public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { scripts, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), cc.xy(1, 2)); - builder.add(scriptArea, cc.xy(3, 2)); + builder.add(textPane.getPane(), cc.xy(3, 2)); setLayout(new BorderLayout()); add(builder.getPanel(), BorderLayout.CENTER); @@ -174,8 +137,7 @@ public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { scripts.setSelectedIndex(0); displayScript(); scripts.addListSelectionListener(scriptRefreshHandler); - - scriptArea.setEnabled(true); + setVisible(true); } @@ -209,99 +171,118 @@ public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { SQLTemplateDescriptor query = getQuery(); if (query == null) { - disableEditor(); return; } String key = (String) scripts.getSelectedValue(); if (key == null) { - disableEditor(); return; } - enableEditor(); - - String text = (key.equals(DEFAULT_LABEL)) ? query.getSql() : query - .getAdapterSql().get(key); + boolean exist = true; + for (JCayenneTextPane textPane: panes) { + if (textPane.getName().equals(key)) { + exist = true; + break; + } else { + exist = false; + } + } - updateDisabled = true; - scriptArea.setText(text); - updateDisabled = false; - } + if (!exist) { + JCayenneTextPane textPane = new JUndoableCayenneTextPane(new SQLSyntaxConstants()); + textPane.setName(key); + textPane.getDocument().addDocumentListener(new CustomListener(textPane.getName())); + builder.add(textPane.getPane(), cc.xy(3, 2)); + panes.add(textPane); + } - void disableEditor() { - scriptArea.setText(null); - scriptArea.setEnabled(false); - scriptArea.setEditable(false); - scriptArea.setBackground(getBackground()); - } + final String text = (key.equals(DEFAULT_LABEL)) ? query.getSql() : query + .getAdapterSql().get(key); - void enableEditor() { - scriptArea.setEnabled(true); - scriptArea.setEditable(true); - scriptArea.setBackground(Color.WHITE); + for (final JCayenneTextPane textPane: panes) { + if (key.equals(textPane.getName())) { + Document document = textPane.getDocument(); + try { + if(!document.getText(0, document.getLength()).equals(text)) { + document.remove(0, document.getLength()); + document.insertString(0, text, null); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } + textPane.getPane().setVisible(true); + textPane.getPane().setEditable(true); + } else { + textPane.getPane().setVisible(false); + textPane.getPane().setEditable(false); + } + } } - void setSQL(DocumentEvent e) { + void setSQL(DocumentEvent e, String key) { Document doc = e.getDocument(); try { - setSQL(doc.getText(0, doc.getLength())); + String text = doc.getText(0, doc.getLength()); + + SQLTemplateDescriptor query = getQuery(); + + if (query == null) { + return; + } + + if (key == null) { + return; + } + + if (text != null) { + text = text.trim(); + if (text.length() == 0) { + text = null; + } + } + + // Compare the value before modifying the query - text pane + // will call "verify" even if no changes have occured.... + if (key.equals(DEFAULT_LABEL)) { + if (!Util.nullSafeEquals(text, query.getSql())) { + query.setSql(text); + mediator.fireQueryEvent(new QueryEvent(this, query)); + } + } else { + if (!Util.nullSafeEquals(text, query.getAdapterSql().get(key))) { + query.getAdapterSql().put(key, text); + mediator.fireQueryEvent(new QueryEvent(this, query)); + } + } } catch (BadLocationException e1) { e1.printStackTrace(); } - } - /** - * Sets the value of SQL template for the currently selected script. - */ - void setSQL(String text) { - SQLTemplateDescriptor query = getQuery(); - if (query == null) { - return; - } + final class CustomListener implements DocumentListener{ - String key = (String) scripts.getSelectedValue(); - if (key == null) { - return; - } + private String key; - if (text != null) { - text = text.trim(); - if (text.length() == 0) { - text = null; - } + public CustomListener(String key) { + this.key = key; } - // Compare the value before modifying the query - text area - // will call "verify" even if no changes have occured.... - if (key.equals(DEFAULT_LABEL)) { - if (!Util.nullSafeEquals(text, query.getSql())) { - query.setSql(text); - mediator.fireQueryEvent(new QueryEvent(this, query)); - } + @Override + public void insertUpdate(DocumentEvent e) { + changedUpdate(e); } - else { - if (!Util.nullSafeEquals(text, query.getAdapterSql().get(key))) { - query.getAdapterSql().put(key, text); - mediator.fireQueryEvent(new QueryEvent(this, query)); - } + + @Override + public void removeUpdate(DocumentEvent e) { + changedUpdate(e); } - } - - public void insertUpdate(DocumentEvent e) { - changedUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - changedUpdate(e); - } - - public void changedUpdate(DocumentEvent e) { - if (!updateDisabled) { - setSQL(e); + @Override + public void changedUpdate(DocumentEvent e) { + setSQL(e, key); } } @@ -346,11 +327,11 @@ public class SQLTemplateScriptsTab extends JPanel implements DocumentListener { return c; } } - + public int getSelectedIndex() { return scripts.getSelectedIndex(); } - + public void setSelectedIndex(int index) { scripts.setSelectedIndex(index); } http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java index 5bbf431..b830493 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java @@ -20,6 +20,8 @@ package org.apache.cayenne.modeler.undo; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import javax.swing.event.DocumentEvent; import javax.swing.event.UndoableEditEvent; @@ -42,6 +44,8 @@ public class JTextFieldUndoListener implements UndoableEditListener { private int lastOffset; private int lastLength; + private boolean isKeyEdit; + public JTextFieldUndoListener(TextAdapter adapter) { this(adapter.getComponent()); this.adapter = adapter; @@ -57,6 +61,13 @@ public class JTextFieldUndoListener implements UndoableEditListener { finishCurrentEdit(); } }); + + this.editor.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + isKeyEdit = true; + } + }); } public void undoableEditHappened(UndoableEditEvent e) { @@ -98,10 +109,13 @@ public class JTextFieldUndoListener implements UndoableEditListener { ? new TextCompoundEdit(adapter, this) : new TextCompoundEdit(editor, this); - compoundEdit.addEdit(anEdit); + if (isKeyEdit) { + compoundEdit.addEdit(anEdit); + } else { + return null; + } Application.getInstance().getUndoManager().addEdit(compoundEdit); - return compoundEdit; } @@ -109,6 +123,7 @@ public class JTextFieldUndoListener implements UndoableEditListener { if (compoundEdit != null) { compoundEdit.end(); compoundEdit = null; + isKeyEdit = false; } } } http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DefaultWidgetFactory.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DefaultWidgetFactory.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DefaultWidgetFactory.java index 36fb249..e54952a 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DefaultWidgetFactory.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DefaultWidgetFactory.java @@ -22,7 +22,6 @@ import org.apache.cayenne.modeler.ModelerPreferences; import org.apache.cayenne.modeler.undo.JComboBoxUndoListener; import org.apache.cayenne.modeler.util.combo.AutoCompletion; import org.apache.cayenne.modeler.util.combo.ComboBoxCellEditor; -import org.syntax.jedit.JEditTextArea; import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; @@ -32,7 +31,6 @@ import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.table.TableCellEditor; import java.awt.Color; -import java.awt.Font; import java.util.Arrays; import java.util.Collection; @@ -108,10 +106,4 @@ public class DefaultWidgetFactory implements WidgetFactory { return editor; } - /** - * Creates and returns a JEdit text component with syntax highlighing - */ - public JEditTextArea createJEditTextArea() { - return new JEditTextAreaUndoable(); - } } http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JEditTextAreaUndoable.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JEditTextAreaUndoable.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JEditTextAreaUndoable.java deleted file mode 100644 index f81b1d2..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JEditTextAreaUndoable.java +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.modeler.util; - -import java.awt.event.FocusListener; - -import javax.swing.JTextField; -import javax.swing.event.UndoableEditListener; -import javax.swing.text.Document; - -import org.apache.cayenne.modeler.undo.JTextFieldUndoListener; -import org.syntax.jedit.JEditTextArea; - -class JEditTextAreaUndoable extends JEditTextArea { - - private UndoableEditListener undoListener; - - JEditTextAreaUndoable() { - this.undoListener = new JTextFieldUndoListener(new JEditTextAreaUndoableAdapter(this)); - - this.getDocument().addUndoableEditListener(this.undoListener); - } - - @Override - public void setText(String t) { - this.getDocument().removeUndoableEditListener(this.undoListener); - try { - super.setText(t); - } finally { - this.getDocument().addUndoableEditListener(this.undoListener); - } - } - - private static class JEditTextAreaUndoableAdapter extends JTextField { - - @Override - public void addFocusListener(FocusListener l) { - if (textArea != null) { - textArea.addFocusListener(l); - } - } - - private JEditTextArea textArea; - - public JEditTextAreaUndoableAdapter(JEditTextArea scriptArea) { - this.textArea = scriptArea; - } - - public int getCaretPosition() { - if (textArea == null) { - return 0; - } - - return textArea.getCaretPosition(); - } - - public Document getDocument() { - if (textArea == null) { - return null; - } - - return textArea.getDocument(); - } - - public boolean requestFocusInWindow() { - if (textArea == null) { - return false; - } - - return textArea.requestFocusInWindow(); - } - - public void selectAll() { - if (textArea == null) { - return; - } - - textArea.selectAll(); - } - - @Override - public void setText(String t) { - if (textArea == null) { - return; - } - - textArea.setText(t); - } - - public void setCaretPosition(int position) { - if (textArea == null) { - return; - } - - textArea.setCaretPosition(position); - } - - @Override - public void updateUI() { - - } - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/WidgetFactory.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/WidgetFactory.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/WidgetFactory.java index 7cae4d8..ff4061e 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/WidgetFactory.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/WidgetFactory.java @@ -26,8 +26,6 @@ import javax.swing.JComboBox; import javax.swing.JTextField; import javax.swing.table.TableCellEditor; -import org.syntax.jedit.JEditTextArea; - /** * Utility class to create standard Swing widgets following default look-and-feel of * CayenneModeler. @@ -67,9 +65,4 @@ public interface WidgetFactory { */ TableCellEditor createCellEditor(JComboBox<?> combo); - /** - * Creates and returns a JEdit text component with syntax highlighing - */ - JEditTextArea createJEditTextArea(); - } http://git-wip-us.apache.org/repos/asf/cayenne/blob/584ed289/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 19943a3..ab061e0 100644 --- a/pom.xml +++ b/pom.xml @@ -407,11 +407,6 @@ <version>2.2.1</version> </dependency> <dependency> - <groupId>net.sf.jedit-syntax</groupId> - <artifactId>jedit-syntax</artifactId> - <version>2.2.2</version> - </dependency> - <dependency> <groupId>jgraph</groupId> <artifactId>jgraph</artifactId> <version>5.13.0.0</version>