|
Added
Link Here
|
| 0 |
- |
1 |
/******************************************************************************* |
|
|
2 |
* Copyright (c) 2013 BREDEX GmbH. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* BREDEX GmbH - initial API and implementation and/or initial documentation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.jubula.client.ui.rcp.propertytester; |
| 12 |
|
| 13 |
import org.eclipse.jubula.client.core.model.IEventExecTestCasePO; |
| 14 |
import org.eclipse.jubula.client.core.model.IExecTestCasePO; |
| 15 |
import org.eclipse.jubula.client.core.model.INodePO; |
| 16 |
import org.eclipse.jubula.client.core.model.IProjectPO; |
| 17 |
import org.eclipse.jubula.client.core.model.ISpecTestCasePO; |
| 18 |
import org.eclipse.jubula.client.core.model.ITestJobPO; |
| 19 |
import org.eclipse.jubula.client.core.model.ITestSuitePO; |
| 20 |
import org.eclipse.jubula.client.core.propertytester.AbstractBooleanPropertyTester; |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Property tester for Selections. |
| 25 |
* |
| 26 |
* @author BREDEX GmbH |
| 27 |
* @created Sep 27, 2013 |
| 28 |
*/ |
| 29 |
public class SelectionPropertyTester extends AbstractBooleanPropertyTester { |
| 30 |
/** the id of the "isRoot" property */ |
| 31 |
public static final String IS_NOT_ROOT_IN_EDITOR = "isNotRootInEditor"; //$NON-NLS-1$ |
| 32 |
/** |
| 33 |
* <code>PROPERTIES</code> |
| 34 |
*/ |
| 35 |
private static final String[] PROPERTIES = |
| 36 |
new String[] { IS_NOT_ROOT_IN_EDITOR }; |
| 37 |
|
| 38 |
/** {@inheritDoc} */ |
| 39 |
public boolean testImpl(Object receiver, String property, Object[] args) { |
| 40 |
INodePO node = (INodePO)receiver; |
| 41 |
if (property.equals(IS_NOT_ROOT_IN_EDITOR)) { |
| 42 |
if (node instanceof IExecTestCasePO |
| 43 |
|| node instanceof IEventExecTestCasePO) { |
| 44 |
// an ExecTestCase or an EventExecTestCase is never a root |
| 45 |
return true; |
| 46 |
} else if (node instanceof ISpecTestCasePO) { |
| 47 |
ISpecTestCasePO specTc = (ISpecTestCasePO) node; |
| 48 |
if (!(specTc.getParentNode() instanceof IProjectPO)) { |
| 49 |
return true; |
| 50 |
} |
| 51 |
} else if (node instanceof ITestSuitePO) { |
| 52 |
ITestSuitePO testSuite = (ITestSuitePO) node; |
| 53 |
if (!(testSuite.getParentNode() == null)) { |
| 54 |
return true; |
| 55 |
} |
| 56 |
} else if (node instanceof ITestJobPO) { |
| 57 |
ITestJobPO testJob = (ITestJobPO) node; |
| 58 |
if (!(testJob.getParentNode() == null)) { |
| 59 |
return true; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
return false; |
| 64 |
} |
| 65 |
|
| 66 |
/** {@inheritDoc} */ |
| 67 |
public Class<? extends Object> getType() { |
| 68 |
return INodePO.class; |
| 69 |
} |
| 70 |
|
| 71 |
/** {@inheritDoc} */ |
| 72 |
public String[] getProperties() { |
| 73 |
return PROPERTIES; |
| 74 |
} |
| 75 |
} |