This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 144123
Collapse All | Expand All

(-)a/api.visual/src/org/netbeans/api/visual/action/InplaceEditorProvider.java (-1 / +42 lines)
Lines 83-89 Link Here
83
    /**
83
    /**
84
     * This is an interface of editor action supplied to the methods in the provider.
84
     * This is an interface of editor action supplied to the methods in the provider.
85
     */
85
     */
86
    interface EditorController {
86
    public interface EditorController {
87
87
88
        /**
88
        /**
89
         * Returns whether an in-place editor is visible.
89
         * Returns whether an in-place editor is visible.
Lines 108-113 Link Here
108
         * Notify the boundary of an editor component is changed and auto-expansion should be recalculated.
108
         * Notify the boundary of an editor component is changed and auto-expansion should be recalculated.
109
         */
109
         */
110
        void notifyEditorComponentBoundsChanged ();
110
        void notifyEditorComponentBoundsChanged ();
111
112
    }
113
114
    /**
115
     * This is an interface that extends EditorController for ability to query for invocation type.
116
     * @since
117
     */
118
    interface TypedEditorController extends EditorController {
119
120
        /**
121
         * Returns a type of editor invocation
122
         * @return invocation type
123
         * @since
124
         */
125
        EditorInvocationType getEditorInvocationType ();
126
127
    }
128
129
    /**
130
     * Represents a type of in-place editor action invocation.
131
     * @since
132
     */
133
    public enum EditorInvocationType {
134
135
        /**
136
         * Invoked by mouse.
137
         * @since
138
         */
139
        MOUSE,
140
141
        /**
142
         * Invoked by keyboard.
143
         * @since
144
         */
145
        KEY,
146
147
        /**
148
         * Invoked by <code>ActionFactory.getInplaceEditorController (inplaceEditorAction).openEditor(widget)</code> method.
149
         * @since
150
         */
151
        CODE,
111
152
112
    }
153
    }
113
154
(-)a/api.visual/src/org/netbeans/modules/visual/action/InplaceEditorAction.java (-4 / +16 lines)
Lines 55-66 Link Here
55
/**
55
/**
56
 * @author David Kaspar
56
 * @author David Kaspar
57
 */
57
 */
58
public final class InplaceEditorAction<C extends JComponent> extends WidgetAction.LockedAdapter implements InplaceEditorProvider.EditorController {
58
public final class InplaceEditorAction<C extends JComponent> extends WidgetAction.LockedAdapter implements InplaceEditorProvider.TypedEditorController {
59
59
60
    private InplaceEditorProvider<C> provider;
60
    private InplaceEditorProvider<C> provider;
61
    private C editor = null;
61
    private C editor = null;
62
    private Widget widget = null;
62
    private Widget widget = null;
63
    private Rectangle rectangle = null;
63
    private Rectangle rectangle = null;
64
    private InplaceEditorProvider.EditorInvocationType invocationType;
64
65
65
    public InplaceEditorAction(InplaceEditorProvider<C> provider) {
66
    public InplaceEditorAction(InplaceEditorProvider<C> provider) {
66
        this.provider = provider;
67
        this.provider = provider;
Lines 72-78 Link Here
72
73
73
    public State mouseClicked(Widget widget, WidgetMouseEvent event) {
74
    public State mouseClicked(Widget widget, WidgetMouseEvent event) {
74
        if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {
75
        if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {
75
            if (openEditor(widget)) {
76
            if (openEditor(widget, InplaceEditorProvider.EditorInvocationType.MOUSE)) {
76
                return State.createLocked(widget, this);
77
                return State.createLocked(widget, this);
77
            }
78
            }
78
        }
79
        }
Lines 111-117 Link Here
111
112
112
    public State keyPressed(Widget widget, WidgetKeyEvent event) {
113
    public State keyPressed(Widget widget, WidgetKeyEvent event) {
113
        if (event.getKeyChar() == KeyEvent.VK_ENTER) {
114
        if (event.getKeyChar() == KeyEvent.VK_ENTER) {
114
            if (openEditor(widget)) {
115
            if (openEditor(widget, InplaceEditorProvider.EditorInvocationType.KEY)) {
115
                return State.createLocked(widget, this);
116
                return State.createLocked(widget, this);
116
            }
117
            }
117
        }
118
        }
Lines 123-128 Link Here
123
    }
124
    }
124
125
125
    public final boolean openEditor(Widget widget) {
126
    public final boolean openEditor(Widget widget) {
127
        return openEditor (widget, InplaceEditorProvider.EditorInvocationType.CODE);
128
    }
129
130
    private boolean openEditor (Widget widget, InplaceEditorProvider.EditorInvocationType invocationType) {
126
        if (editor != null) {
131
        if (editor != null) {
127
            return false;
132
            return false;
128
        }
133
        }
Lines 131-138 Link Here
131
        if (component == null) {
136
        if (component == null) {
132
            return false;
137
            return false;
133
        }
138
        }
139
        this.invocationType = invocationType;
134
        editor = provider.createEditorComponent(this, widget);
140
        editor = provider.createEditorComponent(this, widget);
135
        if (editor == null) {
141
        if (editor == null) {
142
            this.invocationType = null;
136
            return false;
143
            return false;
137
        }
144
        }
138
        this.widget = widget;
145
        this.widget = widget;
Lines 204-210 Link Here
204
        editor = null;
211
        editor = null;
205
        widget = null;
212
        widget = null;
206
        rectangle = null;
213
        rectangle = null;
207
214
        invocationType = null;
208
    }
215
    }
209
216
210
    public void notifyEditorComponentBoundsChanged() {
217
    public void notifyEditorComponentBoundsChanged() {
Lines 268-271 Link Here
268
        editor.setBounds(rectangle);
275
        editor.setBounds(rectangle);
269
        editor.repaint();
276
        editor.repaint();
270
    }
277
    }
278
279
    public InplaceEditorProvider.EditorInvocationType getEditorInvocationType () {
280
        return invocationType;
281
    }
282
271
}
283
}

Return to bug 144123