Author: scabanovich
Date: 2010-10-26 11:01:22 -0400 (Tue, 26 Oct 2010)
New Revision: 26069
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
Log:
JBIDE-6180
https://jira.jboss.org/browse/JBIDE-6180
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2010-10-26
13:55:56 UTC (rev 26068)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2010-10-26
15:01:22 UTC (rev 26069)
@@ -41,6 +41,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
@@ -128,7 +129,7 @@
this.form = mainContainer;
}
-
+
public void addErrorSelectionListener(ErrorSelectionListener listener) {
errorForm.addErrorSelectionListener(listener);
}
@@ -224,9 +225,20 @@
}
rightFormContainer.addForm(form);
form.setParent(rightFormContainer);
+ if(checkFocus()) {
+ setFocus();
+ }
}
}
+ boolean checkFocus() {
+ Control c = Display.getDefault().getFocusControl();
+ if(c == null) {
+ return true;
+ }
+ return false;
+ }
+
private IFormFactory getFormFactory(XModelObject selected) {
if(selected == null) return null;
XModelObjectFormFactory formFactory = null;
@@ -410,7 +422,11 @@
}
public void setFocus() {
- if(control != null && !control.isDisposed()) control.setFocus();
+ if(treeForm != null && treeForm.getControl() != null &&
!treeForm.getControl().isDisposed()) {
+ treeForm.setFocus();
+ } else {
+ if(control != null && !control.isDisposed()) control.setFocus();
+ }
}
public Object getAdapter(Class adapter) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2010-10-26
13:55:56 UTC (rev 26068)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleTreeForm.java 2010-10-26
15:01:22 UTC (rev 26069)
@@ -53,6 +53,15 @@
createActionMapping();
}
+ public void setFocus() {
+ if(tree != null && tree.getViewer() != null) {
+ Control c = tree.getViewer().getControl();
+ if(c != null && !c.isDisposed()) {
+ c.setFocus();
+ }
+ }
+ }
+
public void dispose() {
super.dispose();
if (tree!=null) tree.dispose();