diff -r 8bf4fddd49f6 api.visual/src/org/netbeans/api/visual/action/InplaceEditorProvider.java
--- a/api.visual/src/org/netbeans/api/visual/action/InplaceEditorProvider.java Fri Aug 15 18:28:57 2008 +0200
+++ b/api.visual/src/org/netbeans/api/visual/action/InplaceEditorProvider.java Mon Aug 18 10:59:54 2008 +0200
@@ -83,7 +83,7 @@
/**
* This is an interface of editor action supplied to the methods in the provider.
*/
- interface EditorController {
+ public interface EditorController {
/**
* Returns whether an in-place editor is visible.
@@ -108,6 +108,47 @@
* Notify the boundary of an editor component is changed and auto-expansion should be recalculated.
*/
void notifyEditorComponentBoundsChanged ();
+
+ }
+
+ /**
+ * This is an interface that extends EditorController for ability to query for invocation type.
+ * @since
+ */
+ interface TypedEditorController extends EditorController {
+
+ /**
+ * Returns a type of editor invocation
+ * @return invocation type
+ * @since
+ */
+ EditorInvocationType getEditorInvocationType ();
+
+ }
+
+ /**
+ * Represents a type of in-place editor action invocation.
+ * @since
+ */
+ public enum EditorInvocationType {
+
+ /**
+ * Invoked by mouse.
+ * @since
+ */
+ MOUSE,
+
+ /**
+ * Invoked by keyboard.
+ * @since
+ */
+ KEY,
+
+ /**
+ * Invoked by ActionFactory.getInplaceEditorController (inplaceEditorAction).openEditor(widget)
method.
+ * @since
+ */
+ CODE,
}
diff -r 8bf4fddd49f6 api.visual/src/org/netbeans/modules/visual/action/InplaceEditorAction.java
--- a/api.visual/src/org/netbeans/modules/visual/action/InplaceEditorAction.java Fri Aug 15 18:28:57 2008 +0200
+++ b/api.visual/src/org/netbeans/modules/visual/action/InplaceEditorAction.java Mon Aug 18 10:59:54 2008 +0200
@@ -55,12 +55,13 @@
/**
* @author David Kaspar
*/
-public final class InplaceEditorAction extends WidgetAction.LockedAdapter implements InplaceEditorProvider.EditorController {
+public final class InplaceEditorAction extends WidgetAction.LockedAdapter implements InplaceEditorProvider.TypedEditorController {
private InplaceEditorProvider provider;
private C editor = null;
private Widget widget = null;
private Rectangle rectangle = null;
+ private InplaceEditorProvider.EditorInvocationType invocationType;
public InplaceEditorAction(InplaceEditorProvider provider) {
this.provider = provider;
@@ -72,7 +73,7 @@
public State mouseClicked(Widget widget, WidgetMouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {
- if (openEditor(widget)) {
+ if (openEditor(widget, InplaceEditorProvider.EditorInvocationType.MOUSE)) {
return State.createLocked(widget, this);
}
}
@@ -111,7 +112,7 @@
public State keyPressed(Widget widget, WidgetKeyEvent event) {
if (event.getKeyChar() == KeyEvent.VK_ENTER) {
- if (openEditor(widget)) {
+ if (openEditor(widget, InplaceEditorProvider.EditorInvocationType.KEY)) {
return State.createLocked(widget, this);
}
}
@@ -123,6 +124,10 @@
}
public final boolean openEditor(Widget widget) {
+ return openEditor (widget, InplaceEditorProvider.EditorInvocationType.CODE);
+ }
+
+ private boolean openEditor (Widget widget, InplaceEditorProvider.EditorInvocationType invocationType) {
if (editor != null) {
return false;
}
@@ -131,8 +136,10 @@
if (component == null) {
return false;
}
+ this.invocationType = invocationType;
editor = provider.createEditorComponent(this, widget);
if (editor == null) {
+ this.invocationType = null;
return false;
}
this.widget = widget;
@@ -204,7 +211,7 @@
editor = null;
widget = null;
rectangle = null;
-
+ invocationType = null;
}
public void notifyEditorComponentBoundsChanged() {
@@ -268,4 +275,9 @@
editor.setBounds(rectangle);
editor.repaint();
}
+
+ public InplaceEditorProvider.EditorInvocationType getEditorInvocationType () {
+ return invocationType;
+ }
+
}