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 |
} |