summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-10-15 14:43:35 +0200
committerNoel Grandin <noel@peralex.com>2014-10-16 08:15:48 +0200
commit973eb2f6db60c0939299a968a3121e3310e6d1f5 (patch)
tree9eece355c20bc4d930e7e58943fc2d33bedfcfd0 /toolkit
parentfa652cdd2314f485359119a8ff081a7afd1c01b0 (diff)
java: reduce the depth of some deeply nested if blocks
Change-Id: I3c0c7f08d4d8ea594e72fc0d9b93d085d4ab4bf5
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/test/accessibility/AccessibilityTree.java86
-rw-r--r--toolkit/test/accessibility/AccessibleCellHandler.java21
-rw-r--r--toolkit/test/accessibility/AccessibleSelectionHandler.java97
3 files changed, 101 insertions, 103 deletions
diff --git a/toolkit/test/accessibility/AccessibilityTree.java b/toolkit/test/accessibility/AccessibilityTree.java
index 6f9484762e00..72944e30e1ab 100644
--- a/toolkit/test/accessibility/AccessibilityTree.java
+++ b/toolkit/test/accessibility/AccessibilityTree.java
@@ -243,53 +243,53 @@ public class AccessibilityTree
public boolean popupTrigger( MouseEvent e )
{
boolean bIsPopup = e.isPopupTrigger();
- if( bIsPopup )
+ if( !bIsPopup )
+ return false;
+
+ int selRow = maTree.getComponent().getRowForLocation(e.getX(), e.getY());
+ if (selRow == -1)
+ return bIsPopup;
+
+ TreePath aPath = maTree.getComponent().getPathForLocation(e.getX(), e.getY());
+
+ // check for actions
+ Object aObject = aPath.getLastPathComponent();
+ JPopupMenu aMenu = new JPopupMenu();
+ if( aObject instanceof AccTreeNode )
+ {
+ AccTreeNode aNode = (AccTreeNode)aObject;
+
+ ArrayList<String> aActions = new ArrayList<String>();
+ aMenu.add (new AccessibilityTree.ShapeExpandAction(maTree, aNode));
+ aMenu.add (new AccessibilityTree.SubtreeExpandAction(maTree, aNode));
+
+ aNode.getActions(aActions);
+ for( int i = 0; i < aActions.size(); i++ )
+ {
+ aMenu.add( new NodeAction(
+ aActions.get(i),
+ aNode, i ) );
+ }
+ }
+ else if (aObject instanceof AccessibleTreeNode)
{
- int selRow = maTree.getComponent().getRowForLocation(e.getX(), e.getY());
- if (selRow != -1)
+ AccessibleTreeNode aNode = (AccessibleTreeNode)aObject;
+ String[] aActionNames = aNode.getActions();
+ int nCount=aActionNames.length;
+ if (nCount > 0)
{
- TreePath aPath = maTree.getComponent().getPathForLocation(e.getX(), e.getY());
-
- // check for actions
- Object aObject = aPath.getLastPathComponent();
- JPopupMenu aMenu = new JPopupMenu();
- if( aObject instanceof AccTreeNode )
- {
- AccTreeNode aNode = (AccTreeNode)aObject;
-
- ArrayList<String> aActions = new ArrayList<String>();
- aMenu.add (new AccessibilityTree.ShapeExpandAction(maTree, aNode));
- aMenu.add (new AccessibilityTree.SubtreeExpandAction(maTree, aNode));
-
- aNode.getActions(aActions);
- for( int i = 0; i < aActions.size(); i++ )
- {
- aMenu.add( new NodeAction(
- aActions.get(i),
- aNode, i ) );
- }
- }
- else if (aObject instanceof AccessibleTreeNode)
- {
- AccessibleTreeNode aNode = (AccessibleTreeNode)aObject;
- String[] aActionNames = aNode.getActions();
- int nCount=aActionNames.length;
- if (nCount > 0)
- {
- for (int i=0; i<nCount; i++)
- aMenu.add( new NodeAction(
- aActionNames[i],
- aNode,
- i));
- }
- else
- aMenu = null;
- }
- if (aMenu != null)
- aMenu.show (maTree.getComponent(),
- e.getX(), e.getY());
+ for (int i=0; i<nCount; i++)
+ aMenu.add( new NodeAction(
+ aActionNames[i],
+ aNode,
+ i));
}
+ else
+ aMenu = null;
}
+ if (aMenu != null)
+ aMenu.show (maTree.getComponent(),
+ e.getX(), e.getY());
return bIsPopup;
}
diff --git a/toolkit/test/accessibility/AccessibleCellHandler.java b/toolkit/test/accessibility/AccessibleCellHandler.java
index 6ba28a1411b9..d99fdbfe4cb4 100644
--- a/toolkit/test/accessibility/AccessibleCellHandler.java
+++ b/toolkit/test/accessibility/AccessibleCellHandler.java
@@ -27,21 +27,20 @@ class AccessibleCellHandler extends NodeHandler
@Override
public NodeHandler createHandler (XAccessibleContext xContext)
{
+ if (xContext == null)
+ return null;
+
AccessibleCellHandler aCellHandler = null;
- if (xContext != null)
+ XAccessible xParent = xContext.getAccessibleParent();
+ if (xParent != null)
{
- XAccessible xParent = xContext.getAccessibleParent();
- if (xParent != null)
- {
- XAccessibleTable xTable =
- UnoRuntime.queryInterface (
- XAccessibleTable.class, xParent.getAccessibleContext());
- if (xTable != null)
- aCellHandler = new AccessibleCellHandler (xTable);
- }
+ XAccessibleTable xTable =
+ UnoRuntime.queryInterface (
+ XAccessibleTable.class, xParent.getAccessibleContext());
+ if (xTable != null)
+ aCellHandler = new AccessibleCellHandler (xTable);
}
return aCellHandler;
-
}
public AccessibleCellHandler ()
diff --git a/toolkit/test/accessibility/AccessibleSelectionHandler.java b/toolkit/test/accessibility/AccessibleSelectionHandler.java
index 2d4f64f5d44d..ece8153b67e5 100644
--- a/toolkit/test/accessibility/AccessibleSelectionHandler.java
+++ b/toolkit/test/accessibility/AccessibleSelectionHandler.java
@@ -51,71 +51,70 @@ class AccessibleSelectionHandler
public AccessibleTreeNode createChild( AccessibleTreeNode aParent,
int nIndex )
{
+ if( !(aParent instanceof AccTreeNode) )
+ return null;
+
+ XAccessibleSelection xSelection = ((AccTreeNode)aParent).getSelection();
+ if( xSelection == null )
+ return null;
+
AccessibleTreeNode aChild = null;
- if( aParent instanceof AccTreeNode )
+ switch( nIndex )
{
- XAccessibleSelection xSelection =
- ((AccTreeNode)aParent).getSelection();
- if( xSelection != null )
+ case 0:
+ aChild = new StringNode(
+ "getSelectedAccessibleChildCount: " +
+ xSelection.getSelectedAccessibleChildCount(),
+ aParent );
+ break;
+ case 1:
{
- switch( nIndex )
+ VectorNode aVNode =
+ new VectorNode( "Selected Children", aParent);
+ int nSelected = 0;
+ int nCount = ((AccTreeNode)aParent).getContext().
+ getAccessibleChildCount();
+ try
{
- case 0:
- aChild = new StringNode(
- "getSelectedAccessibleChildCount: " +
- xSelection.getSelectedAccessibleChildCount(),
- aParent );
- break;
- case 1:
+ for( int i = 0; i < nCount; i++ )
{
- VectorNode aVNode =
- new VectorNode( "Selected Children", aParent);
- int nSelected = 0;
- int nCount = ((AccTreeNode)aParent).getContext().
- getAccessibleChildCount();
try
{
- for( int i = 0; i < nCount; i++ )
+ if( xSelection.isAccessibleChildSelected( i ) )
{
- try
- {
- if( xSelection.isAccessibleChildSelected( i ) )
- {
- XAccessible xSelChild = xSelection.
- getSelectedAccessibleChild(nSelected);
- XAccessible xNChild =
- ((AccTreeNode)aParent).
- getContext().getAccessibleChild( i );
- aVNode.addChild( new StringNode(
- i + ": " +
- xNChild.getAccessibleContext().
- getAccessibleDescription() + " (" +
- (xSelChild.equals(xNChild) ? "OK" : "XXX") +
- ")", aParent ) );
- }
- }
- catch (com.sun.star.lang.DisposedException e)
- {
- aVNode.addChild( new StringNode(
- i + ": caught DisposedException while creating",
- aParent ));
- }
+ XAccessible xSelChild = xSelection.
+ getSelectedAccessibleChild(nSelected);
+ XAccessible xNChild =
+ ((AccTreeNode)aParent).
+ getContext().getAccessibleChild( i );
+ aVNode.addChild( new StringNode(
+ i + ": " +
+ xNChild.getAccessibleContext().
+ getAccessibleDescription() + " (" +
+ (xSelChild.equals(xNChild) ? "OK" : "XXX") +
+ ")", aParent ) );
}
- aChild = aVNode;
}
- catch( IndexOutOfBoundsException e )
+ catch (com.sun.star.lang.DisposedException e)
{
- aChild = new StringNode( "IndexOutOfBounds",
- aParent );
+ aVNode.addChild( new StringNode(
+ i + ": caught DisposedException while creating",
+ aParent ));
}
}
- break;
- default:
- aChild = new StringNode( "ERROR", aParent );
- break;
+ aChild = aVNode;
+ }
+ catch( IndexOutOfBoundsException e )
+ {
+ aChild = new StringNode( "IndexOutOfBounds",
+ aParent );
}
}
+ break;
+ default:
+ aChild = new StringNode( "ERROR", aParent );
+ break;
}
return aChild;