Changeset 8005 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-02-03T21:53:19+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java
r7509 r8005 62 62 protected final void createColumns() { 63 63 64 AutoCompletingTextField roleEditor = new AutoCompletingTextField( );64 AutoCompletingTextField roleEditor = new AutoCompletingTextField(0, false); 65 65 RelationMemberConflictDecisionRenderer decisionRenderer = new RelationMemberConflictDecisionRenderer(); 66 66 RelationMemberConflictDecisionEditor decisionEditor = new RelationMemberConflictDecisionEditor(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberRoleCellEditor.java
r7556 r8005 30 30 this.ds = ds; 31 31 this.relation = relation; 32 editor = new AutoCompletingTextField( );32 editor = new AutoCompletingTextField(0, false); 33 33 editor.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); 34 34 autoCompletionList = new AutoCompletionList(); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java
r6084 r8005 33 33 */ 34 34 public TagCellEditor() { 35 editor = new AutoCompletingTextField( );35 editor = new AutoCompletingTextField(0, false); 36 36 editor.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); 37 37 } -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
r7509 r8005 154 154 */ 155 155 public AutoCompletingTextField() { 156 init();156 this(0); 157 157 } 158 158 … … 163 163 */ 164 164 public AutoCompletingTextField(int columns) { 165 super(columns); 165 this(columns, true); 166 } 167 168 /** 169 * Constructs a new {@code AutoCompletingTextField}. 170 * @param columns the number of columns to use to calculate the preferred width; 171 * if columns is set to zero, the preferred width will be whatever naturally results from the component implementation 172 * @param undoRedo Enables or not Undo/Redo feature. Not recommended for table cell editors, unless each cell provides its own editor 173 */ 174 public AutoCompletingTextField(int columns, boolean undoRedo) { 175 super(null, null, columns, undoRedo); 166 176 init(); 167 177 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java
r7937 r8005 181 181 private PopupMenuLauncher launcher; 182 182 183 @Override public void propertyChange(PropertyChangeEvent evt) { 183 @Override 184 public void propertyChange(PropertyChangeEvent evt) { 184 185 if ("editable".equals(evt.getPropertyName())) { 185 186 if (evt.getNewValue().equals(true)) { … … 202 203 component = (JTextComponent) editorComponent; 203 204 component.addMouseListener(this); 204 launcher = TextContextualPopupMenu.enableMenuFor(component );205 launcher = TextContextualPopupMenu.enableMenuFor(component, true); 205 206 } 206 207 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
r7937 r8005 32 32 */ 33 33 public JosmEditorPane() { 34 TextContextualPopupMenu.enableMenuFor(this );34 TextContextualPopupMenu.enableMenuFor(this, true); 35 35 } 36 36 -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java
r7937 r8005 86 86 public JosmTextArea(Document doc, String text, int rows, int columns) { 87 87 super(doc, text, rows, columns); 88 TextContextualPopupMenu.enableMenuFor(this );88 TextContextualPopupMenu.enableMenuFor(this, true); 89 89 addFocusListener(this); 90 90 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r8002 r8005 45 45 */ 46 46 public JosmTextField(Document doc, String text, int columns) { 47 this(doc, text, columns, true); 48 } 49 50 /** 51 * Constructs a new <code>JosmTextField</code> that uses the given text 52 * storage model and the given number of columns. 53 * This is the constructor through which the other constructors feed. 54 * If the document is <code>null</code>, a default model is created. 55 * 56 * @param doc the text storage to use; if this is <code>null</code>, 57 * a default will be provided by calling the 58 * <code>createDefaultModel</code> method 59 * @param text the initial string to display, or <code>null</code> 60 * @param columns the number of columns to use to calculate 61 * the preferred width >= 0; if <code>columns</code> 62 * is set to zero, the preferred width will be whatever 63 * naturally results from the component implementation 64 * @param undoRedo Enables or not Undo/Redo feature. Not recommended for table cell editors, unless each cell provides its own editor 65 * @exception IllegalArgumentException if <code>columns</code> < 0 66 */ 67 public JosmTextField(Document doc, String text, int columns, boolean undoRedo) { 47 68 super(doc, text, columns); 48 TextContextualPopupMenu.enableMenuFor(this );69 TextContextualPopupMenu.enableMenuFor(this, undoRedo); 49 70 // Fix minimum size when columns are specified 50 71 if (columns > 0) { -
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r8002 r8005 46 46 47 47 protected JTextComponent component = null; 48 protected boolean undoRedo; 48 49 protected final UndoAction undoAction = new UndoAction(); 49 50 protected final RedoAction redoAction = new RedoAction(); … … 82 83 * @see #detach() 83 84 */ 84 protected TextContextualPopupMenu attach(JTextComponent component ) {85 protected TextContextualPopupMenu attach(JTextComponent component, boolean undoRedo) { 85 86 if (component != null && !isAttached()) { 86 87 this.component = component; 87 if (component.isEditable()) { 88 this.undoRedo = undoRedo; 89 if (undoRedo && component.isEditable()) { 88 90 component.getDocument().addUndoableEditListener(undoEditListener); 89 91 if (!GraphicsEnvironment.isHeadless()) { … … 102 104 private void addMenuEntries() { 103 105 if (component.isEditable()) { 104 add(new JMenuItem(undoAction)); 105 add(new JMenuItem(redoAction)); 106 addSeparator(); 106 if (undoRedo) { 107 add(new JMenuItem(undoAction)); 108 add(new JMenuItem(redoAction)); 109 addSeparator(); 110 } 107 111 addMenuEntry(component, tr("Cut"), DefaultEditorKit.cutAction, null); 108 112 } … … 125 129 component.removePropertyChangeListener(EDITABLE, propertyChangeListener); 126 130 removeAll(); 127 component.getDocument().removeUndoableEditListener(undoEditListener); 131 if (undoRedo) { 132 component.getDocument().removeUndoableEditListener(undoEditListener); 133 } 128 134 component = null; 129 135 } … … 134 140 * Creates a new {@link TextContextualPopupMenu} and enables it for the given text component. 135 141 * @param component The component that will display the menu and handle its actions. 142 * @param undoRedo Enables or not Undo/Redo feature. Not recommended for table cell editors, unless each cell provides its own editor 136 143 * @return The {@link PopupMenuLauncher} responsible of displaying the popup menu. 137 144 * Call {@link #disableMenuFor} with this object if you want to disable the menu later. 138 * @see #disableMenuFor (JTextComponent, PopupMenuLauncher)139 */ 140 public static PopupMenuLauncher enableMenuFor(JTextComponent component ) {141 PopupMenuLauncher launcher = new PopupMenuLauncher(new TextContextualPopupMenu().attach(component ), true);145 * @see #disableMenuFor 146 */ 147 public static PopupMenuLauncher enableMenuFor(JTextComponent component, boolean undoRedo) { 148 PopupMenuLauncher launcher = new PopupMenuLauncher(new TextContextualPopupMenu().attach(component, undoRedo), true); 142 149 component.addMouseListener(launcher); 143 150 return launcher; … … 148 155 * @param component The component that currently displays the menu and handles its actions. 149 156 * @param launcher The {@link PopupMenuLauncher} obtained via {@link #enableMenuFor}. 150 * @see #enableMenuFor (JTextComponent)157 * @see #enableMenuFor 151 158 */ 152 159 public static void disableMenuFor(JTextComponent component, PopupMenuLauncher launcher) {
Note:
See TracChangeset
for help on using the changeset viewer.