summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-09-07 02:42:24 (EDT)
committerSteffen Kriese2011-09-07 02:42:24 (EDT)
commit949748f26e19fc8a10e02fc176dd10e855883dce (patch)
treedc72f888ba08bd52cb89e55fc7c3890c28888b6e
parent6341972c576aa212dddf775aadb8ca92d5f5deb0 (diff)
downloadorg.eclipse.riena-949748f26e19fc8a10e02fc176dd10e855883dce.zip
org.eclipse.riena-949748f26e19fc8a10e02fc176dd10e855883dce.tar.gz
org.eclipse.riena-949748f26e19fc8a10e02fc176dd10e855883dce.tar.bz2
masterDetails.suggestNewEntry() sets the focus to the first ridget in the details area
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java1
-rw-r--r--org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java4
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractMasterDetailsRidget.java31
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java32
4 files changed, 53 insertions, 15 deletions
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
index d13af7a..788796c 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/views/SubModuleView.java
@@ -426,6 +426,7 @@ public abstract class SubModuleView extends ViewPart implements INavigationNodeV
((IMarkableRidget) ridget).updateMarkers();
}
}
+ getController().restoreFocusRequestFromRidget(getController().getRidgets());
}
}
diff --git a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
index c75915f..efbba4f 100644
--- a/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
+++ b/org.eclipse.riena.navigation.ui/src/org/eclipse/riena/navigation/ui/controllers/SubModuleController.java
@@ -174,7 +174,7 @@ public class SubModuleController extends NavigationNodeController<ISubModuleNode
* <p>
* If the value is null or if the ridget cannot receive the focus (because
* it is not enabled / not visible / not focusable) then the first
- * ridget/widget that can receive the focus will ge the focus (i.e. same
+ * ridget/widget that can receive the focus will get the focus (i.e. same
* behavior as in standard RCP).
*
* @param ridget
@@ -203,7 +203,7 @@ public class SubModuleController extends NavigationNodeController<ISubModuleNode
* @param collection
* the collection to check
*/
- private void restoreFocusRequestFromRidget(final Collection<? extends IRidget> collection) {
+ public void restoreFocusRequestFromRidget(final Collection<? extends IRidget> collection) {
for (final IRidget ridget : collection) {
if (ridget instanceof IComplexRidget) {
restoreFocusRequestFromRidget(((IComplexRidget) ridget).getRidgets());
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractMasterDetailsRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractMasterDetailsRidget.java
index 3c29e60..e234889 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractMasterDetailsRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/AbstractMasterDetailsRidget.java
@@ -425,11 +425,9 @@ public abstract class AbstractMasterDetailsRidget extends AbstractCompositeRidge
updateDetails(editable);
}
- // set focus to first ridget in detailsarea
- final Collection<? extends IRidget> ridgets = detailRidgets.getRidgets();
- if (!ridgets.isEmpty()) {
- final IRidget[] array = ridgets.toArray(new IRidget[ridgets.size()]);
- array[ridgets.size() - 1].requestFocus();
+ // set focus to first focusable ridget in detailsarea
+ if (!setFocusToFirstDetailsRidget()) {
+ getApplyButtonRidget().requestFocus();
}
} finally {
@@ -437,6 +435,29 @@ public abstract class AbstractMasterDetailsRidget extends AbstractCompositeRidge
}
}
+ /**
+ *
+ */
+ private boolean setFocusToFirstDetailsRidget() {
+ final Collection<? extends IRidget> ridgets = detailRidgets.getRidgets();
+ final IRidget[] ridgetArray = ridgets.toArray(new IRidget[ridgets.size()]);
+
+ if (!ridgets.isEmpty()) {
+ for (int i = ridgetArray.length - 1; i >= 0; i--) {
+ final IRidget current = ridgetArray[i];
+ if (current.isEnabled() && current.isFocusable()) {
+ if (current instanceof IMarkableRidget && ((IMarkableRidget) current).isOutputOnly()) {
+ continue;
+ }
+
+ current.requestFocus();
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public final void updateApplyButton() {
if (!hasApplyButton()) {
return;
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
index 2607958..d226547 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/AbstractCompositeRidget.java
@@ -146,12 +146,7 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
}
public boolean isFocusable() {
- for (final IRidget ridget : getRidgets()) {
- if (ridget.isFocusable()) {
- return true;
- }
- }
- return false;
+ return null != getFirstFocusableRidget();
}
public boolean isVisible() {
@@ -169,9 +164,30 @@ public abstract class AbstractCompositeRidget extends AbstractRidget implements
}
public void requestFocus() {
- if (!getRidgets().isEmpty()) {
- getRidgets().iterator().next().requestFocus();
+ final IRidget firstFocusableRidget = getFirstFocusableRidget();
+ if (null != firstFocusableRidget) {
+ firstFocusableRidget.requestFocus();
+ }
+ }
+
+ private IRidget getFirstFocusableRidget() {
+ for (final IRidget ridget : getRidgets()) {
+ if (ridget.isFocusable() && ridget.isEnabled()) {
+ if (ridget instanceof IMarkableRidget && ((IMarkableRidget) ridget).isOutputOnly()) {
+ continue;
+ }
+
+ if (ridget instanceof ILabelRidget) {
+ continue;
+ }
+
+ if (ridget instanceof IStatusMeterRidget) {
+ continue;
+ }
+ return ridget;
+ }
}
+ return null;
}
public void setEnabled(final boolean enabled) {