diff options
Diffstat (limited to 'org.eclipse.osee.ote.ui.test.manager')
137 files changed, 10386 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.ui.test.manager/.classpath b/org.eclipse.osee.ote.ui.test.manager/.classpath new file mode 100644 index 000000000..1fa3e6803 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.osee.ote.ui.test.manager/.pmd b/org.eclipse.osee.ote.ui.test.manager/.pmd new file mode 100644 index 000000000..c7b0a9fb3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/.pmd @@ -0,0 +1,925 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pmd> + <useProjectRuleSet>false</useProjectRuleSet> + <ruleSetFile>.ruleset</ruleSetFile> + <rules> + <rule> + <name>LooseCoupling</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>CloneMethodMustImplementCloneable</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>UnusedImports</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>SignatureDeclareThrowsException</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>IfStmtsMustUseBraces</name> + <ruleset>Braces Rules</ruleset> + </rule> + <rule> + <name>WhileLoopsMustUseBraces</name> + <ruleset>Braces Rules</ruleset> + </rule> + <rule> + <name>IfElseStmtsMustUseBraces</name> + <ruleset>Braces Rules</ruleset> + </rule> + <rule> + <name>ForLoopsMustUseBraces</name> + <ruleset>Braces Rules</ruleset> + </rule> + <rule> + <name>UseSingleton</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SimplifyBooleanReturns</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SimplifyBooleanExpressions</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SwitchStmtsShouldHaveDefault</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidDeeplyNestedIfStmts</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidReassigningParameters</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SwitchDensity</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>ConstructorCallsOverridableMethod</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AccessorClassGeneration</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>FinalFieldCouldBeStatic</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>CloseResource</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>NonStaticInitializer</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>DefaultLabelNotLastInSwitchStmt</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>NonCaseLabelInSwitchStatement</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>OptimizableToArrayCall</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>BadComparison</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>EqualsNull</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>ConfusingTernary</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>InstantiationToGetClass</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>IdempotentOperations</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SimpleDateFormatNeedsLocale</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>ImmutableField</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UseLocaleWithCaseConversions</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidProtectedFieldInFinalClass</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AssignmentToNonFinalStatic</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>MissingStaticMethodInNonInstantiatableClass</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidSynchronizedAtMethodLevel</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>MissingBreakInSwitch</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UseNotifyAllInsteadOfNotify</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidInstanceofChecksInCatchClause</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AbstractClassWithoutAbstractMethod</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SimplifyConditional</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>CompareObjectsWithEquals</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>PositionLiteralsFirstInComparisons</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryLocalBeforeReturn</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>NonThreadSafeSingleton</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UncommentedEmptyMethod</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UncommentedEmptyConstructor</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidConstantsInterface</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UnsynchronizedStaticDateFormatter</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>PreserveStackTrace</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>UseCollectionIsEmpty</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>ClassWithOnlyPrivateConstructorsShouldBeFinal</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>EmptyMethodInAbstractClassShouldBeAbstract</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>SingularField</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>ReturnEmptyArrayRatherThanNull</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AbstractClassWithoutAnyMethod</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>TooFewBranchesForASwitchStatement</name> + <ruleset>Design Rules</ruleset> + </rule> + <rule> + <name>AvoidCatchingThrowable</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>SignatureDeclareThrowsException</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>ExceptionAsFlowControl</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>AvoidCatchingNPE</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>AvoidThrowingRawExceptionTypes</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>AvoidThrowingNullPointerException</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>AvoidRethrowingException</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>DoNotExtendJavaLangError</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>DoNotThrowExceptionInFinally</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>AvoidThrowingNewInstanceOfSameException</name> + <ruleset>Strict Exception Rules</ruleset> + </rule> + <rule> + <name>UnusedPrivateField</name> + <ruleset>Unused Code Rules</ruleset> + </rule> + <rule> + <name>UnusedLocalVariable</name> + <ruleset>Unused Code Rules</ruleset> + </rule> + <rule> + <name>UnusedPrivateMethod</name> + <ruleset>Unused Code Rules</ruleset> + </rule> + <rule> + <name>UnusedFormalParameter</name> + <ruleset>Unused Code Rules</ruleset> + </rule> + <rule> + <name>MoreThanOneLogger</name> + <ruleset>Java Logging Rules</ruleset> + </rule> + <rule> + <name>LoggerIsNotStaticFinal</name> + <ruleset>Java Logging Rules</ruleset> + </rule> + <rule> + <name>SystemPrintln</name> + <ruleset>Java Logging Rules</ruleset> + </rule> + <rule> + <name>AvoidPrintStackTrace</name> + <ruleset>Java Logging Rules</ruleset> + </rule> + <rule> + <name>AvoidDuplicateLiterals</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>StringInstantiation</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>StringToString</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>InefficientStringBuffering</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryCaseChange</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>UseStringBufferLength</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>AppendCharacterWithChar</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>ConsecutiveLiteralAppends</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>UseIndexOfChar</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>InefficientEmptyStringCheck</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>InsufficientStringBufferDeclaration</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>UselessStringValueOf</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>StringBufferInstantiationWithChar</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>UseEqualsToCompareStrings</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>AvoidStringBufferField</name> + <ruleset>String and StringBuffer Rules</ruleset> + </rule> + <rule> + <name>ReplaceVectorWithList</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>ReplaceHashtableWithMap</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>ReplaceEnumerationWithIterator</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>AvoidEnumAsIdentifier</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>AvoidAssertAsIdentifier</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>IntegerInstantiation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>ByteInstantiation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>ShortInstantiation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>LongInstantiation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>JUnit4TestShouldUseBeforeAnnotation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>JUnit4TestShouldUseAfterAnnotation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>JUnit4TestShouldUseTestAnnotation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>JUnit4SuitesShouldUseSuiteAnnotation</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>JUnitUseExpected</name> + <ruleset>Migration Rules</ruleset> + </rule> + <rule> + <name>UseProperClassLoader</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>MDBAndSessionBeanNamingConvention</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>RemoteSessionInterfaceNamingConvention</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>LocalInterfaceSessionNamingConvention</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>LocalHomeNamingConvention</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>RemoteInterfaceNamingConvention</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>DoNotCallSystemExit</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>StaticEJBFieldShouldBeFinal</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>DoNotUseThreads</name> + <ruleset>J2EE Rules</ruleset> + </rule> + <rule> + <name>AvoidInstantiatingObjectsInLoops</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>UseArrayListInsteadOfVector</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>SimplifyStartsWith</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>UseStringBufferForStringAppends</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>UseArraysAsList</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>AvoidArrayLoops</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryWrapperObjectCreation</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>AddEmptyString</name> + <ruleset>Optimization Rules</ruleset> + </rule> + <rule> + <name>EmptyCatchBlock</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyIfStmt</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyWhileStmt</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyTryBlock</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyFinallyBlock</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptySwitchStatements</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>JumbledIncrementer</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>ForLoopShouldBeWhileLoop</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryConversionTemporary</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>OverrideBothEqualsAndHashcode</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>DoubleCheckedLocking</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>ReturnFromFinallyBlock</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptySynchronizedBlock</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryReturn</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyStaticInitializer</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UnconditionalIfStatement</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyStatementNotInLoop</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>BooleanInstantiation</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryFinalModifier</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>CollapsibleIfStatements</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UselessOverridingMethod</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>ClassCastExceptionWithToArray</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>AvoidDecimalLiteralsInBigDecimalConstructor</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UselessOperationOnImmutable</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>MisplacedNullCheck</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>UnusedNullCheckInEquals</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>AvoidThreadGroup</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>BrokenNullCheck</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>BigIntegerInstantiation</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>AvoidUsingOctalValues</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>AvoidUsingHardCodedIP</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>CheckResultSet</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>AvoidMultipleUnaryOperators</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>EmptyInitializer</name> + <ruleset>Basic Rules</ruleset> + </rule> + <rule> + <name>MethodReturnsInternalArray</name> + <ruleset>Security Code Guidelines</ruleset> + </rule> + <rule> + <name>ArrayIsStoredDirectly</name> + <ruleset>Security Code Guidelines</ruleset> + </rule> + <rule> + <name>CouplingBetweenObjects</name> + <ruleset>Coupling Rules</ruleset> + </rule> + <rule> + <name>ExcessiveImports</name> + <ruleset>Coupling Rules</ruleset> + </rule> + <rule> + <name>LooseCoupling</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>DuplicateImports</name> + <ruleset>Import Statement Rules</ruleset> + </rule> + <rule> + <name>DontImportJavaLang</name> + <ruleset>Import Statement Rules</ruleset> + </rule> + <rule> + <name>UnusedImports</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + <rule> + <name>ImportFromSamePackage</name> + <ruleset>Import Statement Rules</ruleset> + </rule> + <rule> + <name>TooManyStaticImports</name> + <ruleset>Import Statement Rules</ruleset> + </rule> + <rule> + <name>JUnitStaticSuite</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>JUnitSpelling</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>JUnitAssertionsShouldIncludeMessage</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>JUnitTestsShouldIncludeAssert</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>TestClassWithoutTestCases</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryBooleanAssertion</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>UseAssertEqualsInsteadOfAssertTrue</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>UseAssertSameInsteadOfAssertTrue</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>UseAssertNullInsteadOfAssertTrue</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>SimplifyBooleanAssertion</name> + <ruleset>JUnit Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryConstructor</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>NullAssignment</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>UnusedModifier</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AssignmentInOperand</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AtLeastOneConstructor</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>DontImportSun</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>SuspiciousOctalEscape</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>CallSuperInConstructor</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>UnnecessaryParentheses</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>DefaultPackage</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>BooleanInversion</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>DataflowAnomalyAnalysis</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AvoidFinalLocalVariable</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AvoidUsingShortType</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AvoidUsingVolatile</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AvoidUsingNativeCode</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>AvoidAccessibilityAlteration</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>DoNotCallGarbageCollectionExplicitly</name> + <ruleset>Controversial Rules</ruleset> + </rule> + <rule> + <name>MethodNamingConventions</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>ClassNamingConventions</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>AbstractNaming</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>AvoidDollarSigns</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>MethodWithSameNameAsEnclosingClass</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>SuspiciousHashcodeMethodName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>SuspiciousConstantFieldName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>SuspiciousEqualsMethodName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>AvoidFieldNameMatchingTypeName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>AvoidFieldNameMatchingMethodName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>NoPackage</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>PackageCase</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>MisleadingVariableName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>BooleanGetMethodName</name> + <ruleset>Naming Rules</ruleset> + </rule> + <rule> + <name>NPathComplexity</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>ExcessiveMethodLength</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>ExcessiveParameterList</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>ExcessiveClassLength</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>CyclomaticComplexity</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>ExcessivePublicCount</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>TooManyFields</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>NcssMethodCount</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>NcssTypeCount</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>NcssConstructorCount</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>TooManyMethods</name> + <ruleset>Code Size Rules</ruleset> + </rule> + <rule> + <name>EmptyFinalizer</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>FinalizeOnlyCallsSuperFinalize</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>FinalizeOverloaded</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>FinalizeDoesNotCallSuperFinalize</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>FinalizeShouldBeProtected</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>AvoidCallingFinalize</name> + <ruleset>Finalizer Rules</ruleset> + </rule> + <rule> + <name>UseCorrectExceptionLogging</name> + <ruleset>Jakarta Commons Logging Rules</ruleset> + </rule> + <rule> + <name>ProperLogger</name> + <ruleset>Jakarta Commons Logging Rules</ruleset> + </rule> + <rule> + <name>MissingSerialVersionUID</name> + <ruleset>JavaBean Rules</ruleset> + </rule> + <rule> + <name>ProperCloneImplementation</name> + <ruleset>Clone Implementation Rules</ruleset> + </rule> + <rule> + <name>CloneThrowsCloneNotSupportedException</name> + <ruleset>Clone Implementation Rules</ruleset> + </rule> + <rule> + <name>CloneMethodMustImplementCloneable</name> + <ruleset>Type Resolution Rules</ruleset> + </rule> + </rules> + <includeDerivedFiles>false</includeDerivedFiles> + <violationsAsErrors>true</violationsAsErrors> +</pmd> diff --git a/org.eclipse.osee.ote.ui.test.manager/.project b/org.eclipse.osee.ote.ui.test.manager/.project new file mode 100644 index 000000000..a069d1a04 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.ote.ui.test.manager</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ds.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.osee.ote.ui.test.manager/META-INF/MANIFEST.MF b/org.eclipse.osee.ote.ui.test.manager/META-INF/MANIFEST.MF new file mode 100644 index 000000000..6f0d22aa4 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/META-INF/MANIFEST.MF @@ -0,0 +1,55 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE Test Manager Plug-in (Incubation) +Bundle-SymbolicName: org.eclipse.osee.ote.ui.test.manager;singleton:=true +Bundle-Version: 0.25.3.qualifier +Bundle-Activator: org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin +Bundle-Vendor: Eclipse Open System Engineering Environment +Export-Package: org.eclipse.osee.ote.ui.test.manager, + org.eclipse.osee.ote.ui.test.manager.actions, + org.eclipse.osee.ote.ui.test.manager.configuration, + org.eclipse.osee.ote.ui.test.manager.configuration.pages, + org.eclipse.osee.ote.ui.test.manager.connection, + org.eclipse.osee.ote.ui.test.manager.core, + org.eclipse.osee.ote.ui.test.manager.jobs, + org.eclipse.osee.ote.ui.test.manager.models, + org.eclipse.osee.ote.ui.test.manager.operations, + org.eclipse.osee.ote.ui.test.manager.pages, + org.eclipse.osee.ote.ui.test.manager.pages.contributions, + org.eclipse.osee.ote.ui.test.manager.pages.scriptTable, + org.eclipse.osee.ote.ui.test.manager.panels, + org.eclipse.osee.ote.ui.test.manager.preferences, + org.eclipse.osee.ote.ui.test.manager.preferences.environment, + org.eclipse.osee.ote.ui.test.manager.util, + org.eclipse.osee.ote.ui.test.manager.wizards +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.osee.ote.client, + org.eclipse.osee.ote.core, + org.eclipse.core.resources, + org.eclipse.ui.editors, + org.eclipse.ui.ide, + org.eclipse.ui.workbench.texteditor, + org.eclipse.osee.framework.jdk.core, + org.eclipse.osee.framework.plugin.core, + org.eclipse.osee.framework.ui.plugin, + org.eclipse.osee.framework.ui.swt, + org.eclipse.osee.ote.ui.markers, + org.eclipse.jface.text, + org.eclipse.osee.ote.ui, + org.eclipse.osee.ote.connection.service, + org.eclipse.osee.framework.logging, + org.eclipse.nebula.widgets.xviewer, + org.eclipse.osee.framework.ui.ws, + org.eclipse.osee.ote.runtimeManager, + net.jini;bundle-version="2.1.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.apache.xml.serialize, + org.eclipse.core.filesystem, + org.eclipse.jdt.core, + org.eclipse.nebula.widgets.xviewer.core.model, + org.eclipse.osee.framework.core.exception, + org.eclipse.osee.ote.ui.builder, + org.eclipse.osee.ote.version, + org.osgi.service.event;version="1.3.0" diff --git a/org.eclipse.osee.ote.ui.test.manager/build.properties b/org.eclipse.osee.ote.ui.test.manager/build.properties new file mode 100644 index 000000000..274a831ad --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/build.properties @@ -0,0 +1,7 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + images/,\ + META-INF/,\ + support/,\ + . +source.. = src/ diff --git a/org.eclipse.osee.ote.ui.test.manager/images/add.gif b/org.eclipse.osee.ote.ui.test.manager/images/add.gif Binary files differnew file mode 100644 index 000000000..6cf3b5f1c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/add.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/alert_obj.gif b/org.eclipse.osee.ote.ui.test.manager/images/alert_obj.gif Binary files differnew file mode 100644 index 000000000..7a49f6d45 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/alert_obj.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/binoculars.gif b/org.eclipse.osee.ote.ui.test.manager/images/binoculars.gif Binary files differnew file mode 100644 index 000000000..b04deb3c2 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/binoculars.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/check.gif b/org.eclipse.osee.ote.ui.test.manager/images/check.gif Binary files differnew file mode 100644 index 000000000..6b3078b35 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/check.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/chkbox_disabled.gif b/org.eclipse.osee.ote.ui.test.manager/images/chkbox_disabled.gif Binary files differnew file mode 100644 index 000000000..7aa131aed --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/chkbox_disabled.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/chkbox_enabled.gif b/org.eclipse.osee.ote.ui.test.manager/images/chkbox_enabled.gif Binary files differnew file mode 100644 index 000000000..9cacb96dc --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/chkbox_enabled.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/connected.gif b/org.eclipse.osee.ote.ui.test.manager/images/connected.gif Binary files differnew file mode 100644 index 000000000..8290462e3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/connected.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/connected_plug.gif b/org.eclipse.osee.ote.ui.test.manager/images/connected_plug.gif Binary files differnew file mode 100644 index 000000000..8493df40d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/connected_plug.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/connected_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/connected_sm.gif Binary files differnew file mode 100644 index 000000000..b397d8b2c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/connected_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/debugOutput.gif b/org.eclipse.osee.ote.ui.test.manager/images/debugOutput.gif Binary files differnew file mode 100644 index 000000000..d18ebcb64 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/debugOutput.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/debugOutput_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/debugOutput_sm.gif Binary files differnew file mode 100644 index 000000000..2e74d0afb --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/debugOutput_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/delete.gif b/org.eclipse.osee.ote.ui.test.manager/images/delete.gif Binary files differnew file mode 100644 index 000000000..2cd9c5444 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/delete.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/disconnected_plug.gif b/org.eclipse.osee.ote.ui.test.manager/images/disconnected_plug.gif Binary files differnew file mode 100644 index 000000000..61648a3d1 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/disconnected_plug.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/environment.gif b/org.eclipse.osee.ote.ui.test.manager/images/environment.gif Binary files differnew file mode 100644 index 000000000..f3377f38f --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/environment.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/error.gif b/org.eclipse.osee.ote.ui.test.manager/images/error.gif Binary files differnew file mode 100644 index 000000000..8612eaff5 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/error.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/error_stack.gif b/org.eclipse.osee.ote.ui.test.manager/images/error_stack.gif Binary files differnew file mode 100644 index 000000000..e61fc24f9 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/error_stack.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/file.gif b/org.eclipse.osee.ote.ui.test.manager/images/file.gif Binary files differnew file mode 100644 index 000000000..7ccc6a703 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/file.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/file_delete.gif b/org.eclipse.osee.ote.ui.test.manager/images/file_delete.gif Binary files differnew file mode 100644 index 000000000..45699b57d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/file_delete.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/flatOutput.gif b/org.eclipse.osee.ote.ui.test.manager/images/flatOutput.gif Binary files differnew file mode 100644 index 000000000..bbfa55fe5 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/flatOutput.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/flatOutput_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/flatOutput_sm.gif Binary files differnew file mode 100644 index 000000000..64b499c97 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/flatOutput_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/fldr_obj.gif b/org.eclipse.osee.ote.ui.test.manager/images/fldr_obj.gif Binary files differnew file mode 100644 index 000000000..b6858690c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/fldr_obj.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/glasses.gif b/org.eclipse.osee.ote.ui.test.manager/images/glasses.gif Binary files differnew file mode 100644 index 000000000..9bdbc128f --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/glasses.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/green_bug.gif b/org.eclipse.osee.ote.ui.test.manager/images/green_bug.gif Binary files differnew file mode 100644 index 000000000..1c36fc1a9 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/green_bug.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/import_wiz.gif b/org.eclipse.osee.ote.ui.test.manager/images/import_wiz.gif Binary files differnew file mode 100644 index 000000000..d38085ad9 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/import_wiz.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/light_bolt.gif b/org.eclipse.osee.ote.ui.test.manager/images/light_bolt.gif Binary files differnew file mode 100644 index 000000000..4bc7dd493 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/light_bolt.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/loadConfig.gif b/org.eclipse.osee.ote.ui.test.manager/images/loadConfig.gif Binary files differnew file mode 100644 index 000000000..f92b0e803 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/loadConfig.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/normalOutput.gif b/org.eclipse.osee.ote.ui.test.manager/images/normalOutput.gif Binary files differnew file mode 100644 index 000000000..eea297366 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/normalOutput.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/normalOutput_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/normalOutput_sm.gif Binary files differnew file mode 100644 index 000000000..12c790201 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/normalOutput_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/ofp.gif b/org.eclipse.osee.ote.ui.test.manager/images/ofp.gif Binary files differnew file mode 100644 index 000000000..d19d763eb --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/ofp.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/red_bug.gif b/org.eclipse.osee.ote.ui.test.manager/images/red_bug.gif Binary files differnew file mode 100644 index 000000000..df3ed441b --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/red_bug.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/save_edit.gif b/org.eclipse.osee.ote.ui.test.manager/images/save_edit.gif Binary files differnew file mode 100644 index 000000000..9302c4ec6 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/save_edit.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/saveas_edit.gif b/org.eclipse.osee.ote.ui.test.manager/images/saveas_edit.gif Binary files differnew file mode 100644 index 000000000..d7f9c6144 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/saveas_edit.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled.gif Binary files differnew file mode 100644 index 000000000..6cb4431c6 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled_sm.gif Binary files differnew file mode 100644 index 000000000..a1feb00a6 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelled_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling.gif Binary files differnew file mode 100644 index 000000000..41991b2e3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling_sm.gif Binary files differnew file mode 100644 index 000000000..e1dde912d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptCancelling_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete.gif Binary files differnew file mode 100644 index 000000000..da16deae3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete_sm.gif Binary files differnew file mode 100644 index 000000000..e7903b5c4 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptComplete_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue.gif Binary files differnew file mode 100644 index 000000000..dcdb06c0f --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue_sm.gif Binary files differnew file mode 100644 index 000000000..f96466208 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptInQueue_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput.gif Binary files differnew file mode 100644 index 000000000..7793f3b82 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput_sm.gif Binary files differnew file mode 100644 index 000000000..ad403d95d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptOutput_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptReady.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptReady.gif Binary files differnew file mode 100644 index 000000000..b8e969feb --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptReady.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptReady_sm.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptReady_sm.gif Binary files differnew file mode 100644 index 000000000..07c5346e0 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptReady_sm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/scriptRunning.gif b/org.eclipse.osee.ote.ui.test.manager/images/scriptRunning.gif Binary files differnew file mode 100644 index 000000000..0849e03b6 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/scriptRunning.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/sel_abort_stop.gif b/org.eclipse.osee.ote.ui.test.manager/images/sel_abort_stop.gif Binary files differnew file mode 100644 index 000000000..8fa8ea101 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/sel_abort_stop.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/sel_batch_abort_stop.gif b/org.eclipse.osee.ote.ui.test.manager/images/sel_batch_abort_stop.gif Binary files differnew file mode 100644 index 000000000..f0b55748b --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/sel_batch_abort_stop.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/sel_run_exec.gif b/org.eclipse.osee.ote.ui.test.manager/images/sel_run_exec.gif Binary files differnew file mode 100644 index 000000000..4a70a050c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/sel_run_exec.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/showerr_tsk.gif b/org.eclipse.osee.ote.ui.test.manager/images/showerr_tsk.gif Binary files differnew file mode 100644 index 000000000..170b0e15f --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/showerr_tsk.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/test.gif b/org.eclipse.osee.ote.ui.test.manager/images/test.gif Binary files differnew file mode 100644 index 000000000..d4848c0e1 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/test.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/tm.gif b/org.eclipse.osee.ote.ui.test.manager/images/tm.gif Binary files differnew file mode 100644 index 000000000..c0b47e195 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/tm.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/tmError.gif b/org.eclipse.osee.ote.ui.test.manager/images/tmError.gif Binary files differnew file mode 100644 index 000000000..96f464d67 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/tmError.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/tracability.gif b/org.eclipse.osee.ote.ui.test.manager/images/tracability.gif Binary files differnew file mode 100644 index 000000000..28f1fd5ee --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/tracability.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/unsel_abort_stop.gif b/org.eclipse.osee.ote.ui.test.manager/images/unsel_abort_stop.gif Binary files differnew file mode 100644 index 000000000..9ba15cf84 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/unsel_abort_stop.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/unsel_batch_abort_stop.gif b/org.eclipse.osee.ote.ui.test.manager/images/unsel_batch_abort_stop.gif Binary files differnew file mode 100644 index 000000000..deee2f43c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/unsel_batch_abort_stop.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/images/unsel_run_exec.gif b/org.eclipse.osee.ote.ui.test.manager/images/unsel_run_exec.gif Binary files differnew file mode 100644 index 000000000..d7726f75b --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/images/unsel_run_exec.gif diff --git a/org.eclipse.osee.ote.ui.test.manager/plugin.xml b/org.eclipse.osee.ote.ui.test.manager/plugin.xml new file mode 100644 index 000000000..cbfdc7666 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/plugin.xml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin> + + <extension point="org.eclipse.ui.actionSets"> + <actionSet + label="OSEE TM" + visible="true" + id="org.eclipse.osee.ote.ui.test.manager.actionSet"> + + + </actionSet> + </extension> + + +<!-- this changes the marker image in the editor marker bar --> + + + + <extension + point="org.eclipse.ui.newWizards"> + <category + name="Test Manager" + id="org.eclipse.osee.ote.ui.test.manager"> + </category> + <wizard + name="Test Manager File" + icon="images/tm.gif" + category="org.eclipse.osee.ote.ui.test.manager" + class="org.eclipse.osee.ote.ui.test.manager.wizards.TestManagerNewWizard" + id="org.eclipse.osee.ote.ui.test.manager.wizards.TestManagerNewWizard"> + </wizard> + </extension> + <extension + point="org.eclipse.ui.popupMenus"> + <objectContribution adaptable="true" + objectClass="org.eclipse.core.resources.IFile" + nameFilter="*.java" id="org.eclipse.osee.ote.ui.menucontribution"> + <menu + label="OTE" + path="additions" + id="org.eclipse.osee.ote.ui"> + <separator + name="placeholder"> + </separator> + </menu> + </objectContribution> + <objectContribution adaptable="true" + objectClass="org.eclipse.core.resources.IFile" + nameFilter="*.java" + id="org.eclipse.osee.ote.ui.test.manager.contribution1"> + <action + enablesFor="+" + label="Add to Test Manager" + icon="images/tm.gif" + class="org.eclipse.osee.ote.ui.test.manager.actions.AddToTestManagerPopupAction" + menubarPath="org.eclipse.osee.ote.ui/placeholder" + id="org.eclipse.osee.ote.ui.test.manager.addtotestmanager"> + </action> + </objectContribution> + <viewerContribution + targetID="#CompilationUnitEditorContext" + id="viewConf"> + <action + label="Add To Test Manager" + icon="images/tm.gif" + menubarPath="org.eclipse.osee.ote.ui.viewer/placeholder" + id="org.eclipse.osee.ote.ui.test.manager.actions.AddToTestManagerEditorAction" + class="org.eclipse.osee.ote.ui.test.manager.actions.AddToTestManagerEditorAction"/> + + </viewerContribution> + + </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.osee.framework.ui.skynet.OseePreferencePage" + class="org.eclipse.osee.ote.ui.test.manager.preferences.TestManagerPreferencePage" + id="org.eclipse.osee.ote.ui.test.manager.PreferencePage" + name="Test Manager"/> + </extension> + <extension + point="org.eclipse.osee.framework.ui.plugin.PropertyStoreControl"> + <PropertyStoreControl + classname="org.eclipse.osee.ote.ui.test.manager.pages.contributions.ScriptExecutionContribution" + viewId="org.eclipse.osee.ote.ui.test.manager"> + </PropertyStoreControl> + </extension> +</plugin> diff --git a/org.eclipse.osee.ote.ui.test.manager/pom.xml b/org.eclipse.osee.ote.ui.test.manager/pom.xml new file mode 100644 index 000000000..d2ee20791 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/pom.xml @@ -0,0 +1,35 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.ote.parent</artifactId> + <version>0.25.3-SNAPSHOT</version> + <relativePath>../org.eclipse.osee.ote.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.ote.ui.test.manager</artifactId> + <packaging>eclipse-plugin</packaging> + <name>OTE Ui Test Manager (Incubation)</name> + + <build> + <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 --> + <resources> + <resource> + <directory>src</directory> + <excludes> + <exclude>**/*.java</exclude> + </excludes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-source-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project>
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/ITestManagerFactory.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/ITestManagerFactory.java new file mode 100644 index 000000000..56d0e2844 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/ITestManagerFactory.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager; + +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.pages.AdvancedPage; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.swt.widgets.Composite; + +/** + * TODO Add a summary of extension points and other classes that will need to be added to create a new test manager. + * + * @author Roberto E. Escobar + */ +public interface ITestManagerFactory { + + public AdvancedPage getAdvancedPageNewInstance(Composite parent, int style, TestManagerEditor parentTestManager); + + public String getEditorId(); + + public String getEditorLastOpenedKey(); + + public ScriptPage getScriptPageNewInstance(Composite parent, int style, TestManagerEditor parentTestManager); + + public String getTestManagerExtension(); + + public String getTestManagerFileName(); + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/OteTestManagerImage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/OteTestManagerImage.java new file mode 100644 index 000000000..27c26698c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/OteTestManagerImage.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2010 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.framework.ui.swt.KeyedImage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; + +/** + * @author Andrew M. Finkbeiner + * @author Ryan Schmitt + */ +public enum OteTestManagerImage implements KeyedImage { + ADD("add.gif"), + ALERT_OBJ("alert_obj.gif"), + CHECK("check.gif"), + CHECKBOX_ENABLED("chkbox_enabled.gif"), + CHECKBOX_DISABLED("chkbox_disabled.gif"), + DELETE("delete.gif"), + ENVIRONMENT("environment.gif"), + ERROR("error.gif"), + ERROR_STACK("error_stack.gif"), + FILE("file.gif"), + FILE_DELETE("file_delete.gif"), + FLDR_OBJ("fldr_obj.gif"), + LOAD_CONFIG("loadConfig.gif"), + OFP("ofp.gif"), + PROJECT_SET_IMAGE("import_wiz.gif"), + SAVE_EDIT("save_edit.gif"), + SAVEAS_EDIT("saveas_edit.gif"), + SEL_ABORT_STOP("sel_abort_stop.gif"), + SEL_BATCH_ABORT_STOP("sel_batch_abort_stop.gif"), + SEL_RUN_EXEC("sel_run_exec.gif"), + SCRIPT_CANCELLED("scriptCancelled.gif"), + SCRIPT_CANCELLED_SM("scriptCancelled_sm.gif"), + SCRIPT_CANCELLING("scriptCancelling.gif"), + SCRIPT_CANCELLING_SM("scriptCancelling_sm.gif"), + SCRIPT_COMPLETE("scriptComplete.gif"), + SCRIPT_COMPLETE_SM("scriptComplete_sm.gif"), + SCRIPT_IN_QUEUE("scriptInQueue.gif"), + SCRIPT_IN_QUEUE_SM("scriptInQueue_sm.gif"), + SCRIPT_OUTPUT("scriptOutput.gif"), + SCRIPT_OUTPUT_SM("scriptOutput_sm.gif"), + SCRIPT_READY("scriptReady.gif"), + SCRIPT_READY_SM("scriptReady_sm.gif"), + SCRIPT_RUNNING("scriptRunning.gif"), + TEST("test.gif"), + TEST_BATCH_IMAGE("file.gif"), + TEST_MANAGER("tm.gif"), + UNSEL_ABORT_STOP("unsel_abort_stop.gif"), + UNSEL_BATCH_ABORT_STOP("unsel_batch_abort_stop.gif"), + UNSEL_RUN_EXEC("unsel_run_exec.gif"); + + private final String fileName; + + private OteTestManagerImage(String fileName) { + this.fileName = fileName; + } + + @Override + public ImageDescriptor createImageDescriptor() { + return ImageManager.createImageDescriptor(TestManagerPlugin.PLUGIN_ID, "images", fileName); + } + + @Override + public String getImageKey() { + return TestManagerPlugin.PLUGIN_ID + ".images." + fileName; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerEditorAction.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerEditorAction.java new file mode 100644 index 000000000..64b5e3e97 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerEditorAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.actions; + +import java.util.logging.Level; +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.operations.AddIFileToTestManager; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; + +public class AddToTestManagerEditorAction implements IEditorActionDelegate { + + @Override + public void run(IAction action) { + // Get IFile of current editor + IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput editorInput = editorPart.getEditorInput(); + IFile iFile = null; + if (editorInput instanceof IFileEditorInput) { + iFile = ((IFileEditorInput) editorInput).getFile(); + if (iFile != null) { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "iFile *" + iFile + "*"); + } + } + if (iFile == null) { + AWorkbench.popup("ERROR", "Can't retrieve IFile"); + return; + } + AddIFileToTestManager.getOperation().addIFileToScriptsPage(new String[]{iFile.getLocation().toOSString()}); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + } + + @Override + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + } + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java new file mode 100644 index 000000000..000f0b8d3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.actions; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Level; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IMember; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.operations.AddIFileToTestManager; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +public class AddToTestManagerPopupAction implements IWorkbenchWindowActionDelegate { + + public static String[] getSelection() { + List<String> selection = new ArrayList<>(); + ISelection sel1 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection(); + if(sel1 instanceof StructuredSelection){ + Iterator<?> i = ((StructuredSelection)sel1).iterator(); + + while (i.hasNext()) { + Object obj = i.next(); + if (obj instanceof IResource) { + IResource resource = (IResource) obj; + if (resource != null) { + selection.add(resource.getLocation().toOSString()); + } + } else if (obj instanceof ICompilationUnit) { + ICompilationUnit resource = (ICompilationUnit) obj; + if (resource != null) { + selection.add(resource.getResource().getLocation().toOSString()); + } + } else if (obj instanceof IMember){ + ICompilationUnit resource = ((IMember) obj).getCompilationUnit(); + if (resource != null) { + selection.add(resource.getResource().getLocation().toOSString()); + } + } + } + } else if (sel1 instanceof TextSelection){ + IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput editorInput = editorPart.getEditorInput(); + IFile iFile = null; + if (editorInput instanceof IFileEditorInput) { + iFile = ((IFileEditorInput) editorInput).getFile(); + if (iFile != null) { + selection.add(iFile.getLocation().toOSString()); + } + } + } + return selection.toArray(new String[0]); + } + + IWorkbenchWindow activeWindow = null; + + // IWorkbenchWindowActionDelegate method + @Override + public void dispose() { + // nothing to do + } + + // IWorkbenchWindowActionDelegate method + @Override + public void init(IWorkbenchWindow window) { + activeWindow = window; + } + + @Override + public void run(IAction proxyAction) { + String[] files = getSelection(); + if (files.length == 0) { + AWorkbench.popup("ERROR", "Can't retrieve file"); + return; + } + AddIFileToTestManager.getOperation().addIFileToScriptsPage(files); + } + + // IActionDelegate method + @Override + public void selectionChanged(IAction proxyAction, ISelection selection) { + + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/TMBugAction.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/TMBugAction.java new file mode 100644 index 000000000..07d1d2889 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/TMBugAction.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IEditorPart; + +public class TMBugAction implements IEditorActionDelegate { + + @Override + public void run(IAction action) { + + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + } + + @Override + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFactory.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFactory.java new file mode 100644 index 000000000..39b35919c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFactory.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.util.logging.Level; +import javax.xml.parsers.ParserConfigurationException; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.configuration.pages.LoadScriptPage; +import org.eclipse.osee.ote.ui.test.manager.configuration.pages.SaveScriptPage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.AdvancedPage; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.TestManagerPage; + +public class ConfigFactory { + private static ConfigFactory instance = null; + + private ConfigFactory() { + } + + public static ConfigFactory getInstance() { + if (instance == null) { + instance = new ConfigFactory(); + } + return instance; + } + + public ILoadConfig getLoadConfigHandler(TestManagerPage tmPage) { + ILoadConfig toReturn = null; + + if (tmPage instanceof ScriptPage) { + toReturn = new LoadScriptPage((ScriptPage) tmPage); + } else if (tmPage instanceof AdvancedPage) { + // toReturn = new AdvancedPageLoad(tmPage); + } + return toReturn; + } + + public ISaveConfig getSaveConfigHandler(TestManagerPage tmPage) { + ISaveConfig toReturn = null; + + if (tmPage instanceof ScriptPage) { + try { + toReturn = new SaveScriptPage((ScriptPage) tmPage); + } catch (ParserConfigurationException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + } else if (tmPage instanceof AdvancedPage) { + // toReturn = new AdvancedPageSave(tmPage); + } + return toReturn; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFileHandler.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFileHandler.java new file mode 100644 index 000000000..75f4f489d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ConfigFileHandler.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; +import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class ConfigFileHandler { + + /** + * Writes the XML in sourceDoc to the test manager config file specified. If the destination file already exists, and + * contains the XML specified for the sourceDoc's root node, it will be replaced, otherwise it will be appended to + * the file. If the file does not exist, a new file will be created only containing the sourceDoc underneath a root + * TestManagerConfig node. + */ + public static void writeFile(Document sourceDoc, String fileString) throws Exception { + Document doc; + File file = new File(fileString); + if (file.exists()) { + doc = writeSectionToFile(sourceDoc, file); + } else { + doc = Jaxp.newDocumentNamespaceAware(); + Element root = doc.createElement("TestManagerConfig"); + root.appendChild(doc.importNode(sourceDoc.getDocumentElement(), true)); + doc.appendChild(root); + } + Jaxp.writeXmlDocument(doc, file, Jaxp.getPrettyFormat()); + } + + private static Document writeSectionToFile(Document docToAdd, File file) throws Exception { + Element nodeToAdd = docToAdd.getDocumentElement(); + String configType = nodeToAdd.getNodeName(); + Document doc = Jaxp.readXmlDocument(file); + Element root = doc.getDocumentElement(); + Element configNode = Jaxp.getChild(root, configType); + if (configNode != null) { + root.removeChild(configNode); + root.appendChild(doc.importNode(nodeToAdd, true)); + } else { + root.appendChild(doc.importNode(nodeToAdd, true)); + } + return doc; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ILoadConfig.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ILoadConfig.java new file mode 100644 index 000000000..4ec313e56 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ILoadConfig.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; + +public abstract interface ILoadConfig { + + public abstract void loadConfiguration(File toProcess) throws Exception; + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ISaveConfig.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ISaveConfig.java new file mode 100644 index 000000000..08fb29c12 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/ISaveConfig.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public abstract interface ISaveConfig { + + public abstract Element toXml(Document doc); + + public abstract void saveConfig(File fileName) throws Exception; + + public abstract void printXmlTree(); +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadConfigurationOperation.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadConfigurationOperation.java new file mode 100644 index 000000000..16c19cf68 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadConfigurationOperation.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.StatusWindowWidget; +import org.eclipse.osee.ote.ui.test.manager.util.Dialogs; + +/** + * @author Roberto E. Escobar + */ +public class LoadConfigurationOperation { + + private LoadConfigurationOperation() { + } + + public static boolean load(TestManagerEditor testManager, File selectedFile) { + boolean isOk = updateFileStatus(testManager, selectedFile); + if (isOk != false) { + isOk &= reLoad(testManager); + } + return isOk; + } + + private static boolean updateFileStatus(TestManagerEditor testManager, File selectedFile) { + boolean result = false; + StatusWindowWidget statusWindow = testManager.getPageManager().getScriptPage().getStatusWindow(); + if (statusWindow != null) { + String filePath = selectedFile.getAbsolutePath(); + statusWindow.setValue(ScriptPage.UpdateableLabel.CONFIGPATHLABEL.name(), filePath); + testManager.storeValue(testManager.configFileName, filePath); + statusWindow.refresh(); + result = true; + } + return result; + } + + public static boolean reLoad(TestManagerEditor testManager) { + boolean result = false; + String configFile = testManager.loadValue(testManager.configFileName); + + ILoadConfig loadConfig = + ConfigFactory.getInstance().getLoadConfigHandler(testManager.getPageManager().getScriptPage()); + try { + loadConfig.loadConfiguration(new File(configFile)); + result = true; + } catch (Exception ex) { + Dialogs.popupError("Error Loading File", + String.format("Error loading file: [%s]\n%s", configFile, OseeUiActivator.getStackMessages(ex))); + } + return result; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadWidget.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadWidget.java new file mode 100644 index 000000000..af53a7c79 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/LoadWidget.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.StatusWindowWidget; +import org.eclipse.osee.ote.ui.test.manager.pages.TestManagerPage; +import org.eclipse.osee.ote.ui.test.manager.util.Dialogs; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +public class LoadWidget { + public static final OseeUiActivator plugin = TestManagerPlugin.getInstance(); + private StatusWindowWidget statusWindow; + private final TestManagerPage tmPage; + + public LoadWidget(TestManagerPage tmPage) { + this.tmPage = tmPage; + this.statusWindow = null; + } + + public void createToolItem(final ToolBar toolBar) { + final Shell shell = toolBar.getShell(); + + final Menu menu = new Menu(shell, SWT.POP_UP); + + MenuItem menuItem = new MenuItem(menu, SWT.PUSH); + menuItem.setText("Load File..."); + menuItem.setImage(ImageManager.getImage(OteTestManagerImage.FLDR_OBJ)); + menuItem.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + String[] filterExtensions = {"*.xml"}; + FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); + fileDialog.setText("Load " + tmPage.getPageName() + "Page Settings From..."); + fileDialog.setFilterExtensions(filterExtensions); + + String defaultConfigDir = statusWindow.getValue(ScriptPage.UpdateableLabel.CONFIGPATHLABEL.name()); + File dir = new File(defaultConfigDir); + if (dir.isFile() || dir.isDirectory()) { + fileDialog.setFilterPath(defaultConfigDir); + } else { + fileDialog.setFilterPath("Y:\\"); + } + String result = fileDialog.open(); + + if (Strings.isValid(result)) { + File newFile = new File(result); + if (newFile.exists() && newFile.isFile()) { + LoadConfigurationOperation.load(tmPage.getTestManager(), newFile); + } else { + handleFileSelectError(); + } + } + } + }); + + final ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN); + item.setImage(ImageManager.getImage(OteTestManagerImage.LOAD_CONFIG)); + item.setToolTipText("Load current page configuration from file"); + item.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + // If they clicked the arrow, we show the list + if (event.detail == SWT.ARROW) { + // Determine where to put the dropdown list + ToolItem item = (ToolItem) event.widget; + Rectangle rect = item.getBounds(); + Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); + menu.setLocation(pt.x, pt.y + rect.height); + menu.setVisible(true); + } else { + LoadConfigurationOperation.reLoad(tmPage.getTestManager()); + } + } + }); + toolBar.pack(); + } + + public void setStatusLabel(StatusWindowWidget statusWindow) { + this.statusWindow = statusWindow; + } + + private void handleFileSelectError() { + Dialogs.popupError("Load Configuration File", "Invalid Configuration File Selected."); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/SaveWidget.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/SaveWidget.java new file mode 100644 index 000000000..10f285473 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/SaveWidget.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration; + +import java.io.File; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.StatusWindowWidget; +import org.eclipse.osee.ote.ui.test.manager.pages.TestManagerPage; +import org.eclipse.osee.ote.ui.test.manager.util.Dialogs; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +public class SaveWidget { + public static final OseeUiActivator plugin = TestManagerPlugin.getInstance(); + private StatusWindowWidget statusWindow; + private String selectedFile; + private final TestManagerPage tmPage; + + public SaveWidget(TestManagerPage tmPage) { + this.tmPage = tmPage; + selectedFile = null; + statusWindow = null; + } + + public void createToolItem(final ToolBar toolBar) { + final Shell shell = toolBar.getShell(); + + final Menu menu = new Menu(shell, SWT.POP_UP); + + MenuItem saveAsMenuItem = new MenuItem(menu, SWT.PUSH); + saveAsMenuItem.setText("SaveAs..."); + saveAsMenuItem.setImage(ImageManager.getImage(OteTestManagerImage.SAVEAS_EDIT)); + saveAsMenuItem.addSelectionListener(new SelectionListener() { + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + String[] filterExtensions = {"*.xml"}; + FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); + fileDialog.setText("Save " + tmPage.getPageName() + "Page Settings To..."); + fileDialog.setFilterExtensions(filterExtensions); + + String defaultConfigDir = statusWindow.getValue(ScriptPage.UpdateableLabel.CONFIGPATHLABEL.name()); + + File dir = new File(defaultConfigDir); + if (dir.isFile() || dir.isDirectory()) { + fileDialog.setFilterPath(defaultConfigDir); + } else { + fileDialog.setFilterPath("Y:\\"); + } + + String result = fileDialog.open(); + + if (Strings.isValid(result)) { + selectedFile = result; + if (statusWindow != null) { + statusWindow.setValue(ScriptPage.UpdateableLabel.CONFIGPATHLABEL.name(), selectedFile); + TestManagerEditor tm = tmPage.getTestManager(); + tm.storeValue(tm.configFileName, selectedFile); + statusWindow.refresh(); + handleSaveEvent(); + } else { + handleFileSelectError(); + } + } + } + }); + + final ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN); + item.setImage(ImageManager.getImage(OteTestManagerImage.SAVE_EDIT)); + item.setToolTipText("Saves current page configuration to file"); + item.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + // If they clicked the arrow, we show the list + if (event.detail == SWT.ARROW) { + // Determine where to put the dropdown list + ToolItem item = (ToolItem) event.widget; + Rectangle rect = item.getBounds(); + Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); + menu.setLocation(pt.x, pt.y + rect.height); + menu.setVisible(true); + } else { + handleSaveEvent(); + } + } + }); + toolBar.pack(); + } + + public void setStatusLabel(StatusWindowWidget statusWindow) { + this.statusWindow = statusWindow; + selectedFile = statusWindow.getValue(ScriptPage.UpdateableLabel.CONFIGPATHLABEL.name()); + } + + private void handleFileSelectError() { + Dialogs.popupError("Save Configuration File", "Invalid Configuration File Selected"); + } + + private void handleSaveEvent() { + TestManagerEditor tm = tmPage.getTestManager(); + String configFile = tm.loadValue(tm.configFileName); + + ISaveConfig saveConfig = ConfigFactory.getInstance().getSaveConfigHandler(tmPage); + try { + + saveConfig.saveConfig(new File(configFile)); + } catch (Exception ex) { + Dialogs.popupError("Error Saving File", + String.format("Error saving file: [%s]\n%s", configFile, OseeUiActivator.getStackMessages(ex))); + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java new file mode 100644 index 000000000..3546306d8 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration.pages; + +import java.io.File; +import java.io.IOException; +import java.util.Vector; +import java.util.logging.Level; +import javax.xml.parsers.ParserConfigurationException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.ui.test.manager.configuration.ILoadConfig; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTableViewer; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class LoadScriptPage implements ILoadConfig, ScriptPageConstants { + + private final ScriptPage scriptPage; + private final ScriptTableViewer scriptTableViewer; + private final Vector<ScriptTask> scriptTasks; + + public LoadScriptPage(ScriptPage tmPage) { + this.scriptPage = tmPage; + this.scriptTableViewer = scriptPage.getScriptTableViewer(); + scriptTasks = new Vector<>(); + } + + @Override + public void loadConfiguration(final File toProcess) throws Exception { + + Job job = new Job(String.format("Loading Script Run List [%s]", toProcess.getName())) { + + @Override + protected IStatus run(IProgressMonitor monitor) { + Document doc; + try { + doc = Jaxp.readXmlDocument(toProcess); + parseConfig(doc); + + Displays.pendInDisplayThread(new Runnable() { + @Override + public void run() { + scriptTableViewer.loadTasksFromList(scriptTasks); + scriptTableViewer.refresh(); + debug(toProcess.getAbsolutePath()); + } + }); + } catch (ParserConfigurationException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } catch (SAXException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } catch (IOException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + + return Status.OK_STATUS; + } + + }; + job.schedule(); + } + + private void debug(String val) { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "Loaded From: " + val); + } + + private void parseConfig(Document doc) { + NodeList nl = doc.getElementsByTagName(ScriptPageConstants.SCRIPTPAGE_CONFIG); + + for (int i = 0; i < nl.getLength(); i++) { + Element element = (Element) nl.item(i); + parseMiscellaneousInfo(element); + parseScriptEntries(element); + } + } + + private void parseMiscellaneousInfo(Element element) { + // Iterator iterator = node.getDescendants(new RegExElementFilter( + // Pattern.compile(ScriptPageConstants.SERVICES_ENTRY))); + // while (iterator.hasNext()) { + // Element child = (Element) iterator.next(); + // TODO load miscellaneous information to page + // } + } + + private class LoadScriptHelper implements Runnable { + private boolean stopLoading = false; + private final String path; + + public LoadScriptHelper(String path) { + this.path = path; + } + + @Override + public void run() { + if (!MessageDialog.openQuestion( + Displays.getActiveShell(), + "Script not found", + "The script " + path + " was not found in this workspace. Do you want to continue loading from the script list file. ")) { + stopLoading = true; + } + } + + public boolean stop() { + return stopLoading; + } + } + + private void parseScriptEntries(Element element) { + NodeList nl = element.getElementsByTagName(ScriptPageConstants.SCRIPT_ENTRY); + String alternatePath = scriptPage.getTestManager().getAlternateOutputDir(); + for (int i = 0; i < nl.getLength(); i++) { + try{ + Element child = (Element) nl.item(i); + final String path = Jaxp.getChildText(child, ScriptPageConstants.RAW_FILENAME_FIELD); + String runnable = Jaxp.getChildText(child, ScriptPageConstants.RUNNABLE_FIELD); + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); + if (file.exists()) { + try { + ScriptTask task = new ScriptTask(file.getLocation().toString(), alternatePath); + task.setRun(Boolean.parseBoolean(runnable)); + scriptTasks.add(task); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } else { + LoadScriptHelper helper = new LoadScriptHelper(path); + Displays.pendInDisplayThread(helper); + if (helper.stop()) { + break; + } + } + } catch (Throwable th){ + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, th); + } + } + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/SaveScriptPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/SaveScriptPage.java new file mode 100644 index 000000000..b649352e5 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/SaveScriptPage.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration.pages; + +import java.io.File; +import java.util.Vector; +import java.util.logging.Level; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable; +import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.configuration.ConfigFileHandler; +import org.eclipse.osee.ote.ui.test.manager.configuration.ISaveConfig; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTableViewer; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class SaveScriptPage implements ISaveConfig, ScriptPageConstants, Xmlizable { + + private final Document doc; + private final Element root; + private final ScriptPage scriptPage; + + public SaveScriptPage(ScriptPage tmPage) throws ParserConfigurationException { + this.scriptPage = tmPage; + doc = Jaxp.newDocumentNamespaceAware(); + root = doc.createElement(ScriptPageConstants.SCRIPTPAGE_CONFIG); + doc.appendChild(root); + } + + @Override + public void printXmlTree() { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "Script Page Tree: "); + try { + OseeLog.log(TestManagerPlugin.class, Level.INFO, Jaxp.xmlToString(doc, true)); + } catch (TransformerException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + } + + @Override + public void saveConfig(File fileName) throws Exception { + ScriptTableViewer scriptTable = scriptPage.getScriptTableViewer(); + Vector<ScriptTask> tasks = scriptTable.getTasks(); + + root.appendChild(miscellaneousInfoToXml(doc)); + + for (ScriptTask task : tasks) { + root.appendChild(scriptTaskToXml(doc, task)); + } + + ConfigFileHandler.writeFile(doc, fileName.getAbsolutePath()); + debug(fileName.getAbsolutePath()); + } + + @Override + public Element toXml(Document doc) { + return root; + } + + private void debug(String val) { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "Saved to: " + val); + } + + private Element miscellaneousInfoToXml(Document doc) { + Element node = doc.createElement(ScriptPageConstants.SERVICES_ENTRY); + // TODO add preferred host + // TODO add ofp + // TODO add view if unit test config + + return node; + } + + private Element scriptTaskToXml(Document doc, ScriptTask task) { + Element taskRoot = doc.createElement(ScriptPageConstants.SCRIPT_ENTRY); + taskRoot.appendChild(Jaxp.createElement(doc, ScriptPageConstants.SCRIPT_NAME_FIELD, task.getName())); + taskRoot.appendChild(Jaxp.createElement(doc, ScriptPageConstants.RAW_FILENAME_FIELD, + task.getScriptModel().getWorkspaceRelativePath())); + taskRoot.appendChild(Jaxp.createElement(doc, ScriptPageConstants.RUNNABLE_FIELD, + Boolean.toString(task.isRunnable()))); + return taskRoot; + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/ScriptPageConstants.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/ScriptPageConstants.java new file mode 100644 index 000000000..b988a2e3b --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/ScriptPageConstants.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.configuration.pages; + +public interface ScriptPageConstants { + + public static final String RAW_FILENAME_FIELD = "Path"; + public static final String RESULT_FIELD = "Result"; + public static final String RUNNABLE_FIELD = "IsRunnable"; + public static final String SCRIPT_ENTRY = "ScriptEntry"; + public static final String SCRIPT_NAME_FIELD = "Name"; + public static final String SCRIPTPAGE_CONFIG = "ScriptPageConfig"; + public static final String SERVICES_ENTRY = "ServicesSettings"; + public static final String STATUS_FIELD = "Status"; + public static final String CLASS_NAME = "ClassName"; + public static final String CLASS_PATH = "ClassPath"; +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java new file mode 100644 index 000000000..a06aa1c85 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java @@ -0,0 +1,227 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.rmi.RemoteException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment; +import org.eclipse.osee.ote.core.environment.status.TestComplete; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.jobs.StoreOutfileJob; +import org.eclipse.osee.ote.ui.test.manager.models.OutputModelJob; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask.ScriptStatusEnum; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTaskList; + +/** + * @author Andrew M. Finkbeiner + */ +public abstract class ScriptManager implements Runnable { + private final Map<String, ScriptTask> guidToScriptTask = new HashMap<>(); + private TestManagerStatusListener statusListenerImpl; + private final TestManagerEditor testManager; + + private volatile boolean updateScriptTable; + private StructuredViewer stv; + private ScheduledExecutorService updater; + private Set<ScriptTask> tasksToUpdate; + private ITestEnvironment connectedEnv; + private UUID sessionKey; + + public ScriptManager(TestManagerEditor testManager, StructuredViewer stv) { + this.testManager = testManager; + this.stv = stv; + + tasksToUpdate = new HashSet<>(); + updater = Executors.newScheduledThreadPool(1, new ThreadFactory() { + + @Override + public Thread newThread(Runnable r) { + Thread th = new Thread(r, "TM Table updater"); + th.setDaemon(true); + return th; + } + + }); + updater.scheduleAtFixedRate(this, 0, 2000, TimeUnit.MILLISECONDS); + OutputModelJob.createSingleton(this); + } + + public abstract void abortScript(boolean isBatchAbort) throws RemoteException; + + public void notifyScriptDequeued(String className) { + ScriptTask task = guidToScriptTask.get(className); + if (task != null) { + + ScriptTask value = guidToScriptTask.remove(task); + if(value == null){ + System.out.println("did not dq"); + } + } + } + + /** + * This should be called after the environment is received in order to configure necessary items. + * + * @return null if successful, otherwise a string describing the error + */ + public boolean connect(ConnectionEvent event) { + + connectedEnv = event.getEnvironment(); + sessionKey = event.getSessionKey(); + try { + /* + * Setup the status listener for commands + */ + statusListenerImpl = new TestManagerStatusListener(testManager, this); + return false; + } catch (Exception e) { + TestManagerPlugin.log(Level.SEVERE, "failed to connect script manager", e); + return true; + } + } + + /** + * This should NOT be called directly, users should call the HostDataStore's disconnect. + */ + public boolean disconnect(ConnectionEvent event) { + connectedEnv = null; + sessionKey = null; + guidToScriptTask.clear(); + statusListenerImpl.unregisterEventListener(); + return false; + } + + public boolean onConnectionLost() { + connectedEnv = null; + sessionKey = null; + guidToScriptTask.clear(); + statusListenerImpl.unregisterEventListener(); + return false; + } + + public ScriptTask getScriptTask(String name) { + ScriptTask t = guidToScriptTask.get(name); + if(t == null){ + Object obj = stv.getInput(); + if(obj instanceof ScriptTaskList){ + ScriptTaskList stl = (ScriptTaskList)obj; + for(ScriptTask task:stl.getTasks()){ + String clazz = task.getScriptModel().getTestClass(); + if(clazz.equals(name)){ + t = task; + break; + } + } + } + } + return t; + } + + public void notifyScriptQueued(GUID theGUID, final ScriptTask script) { + guidToScriptTask.put(script.getScriptModel().getTestClass(), script); + script.setStatus(ScriptStatusEnum.IN_QUEUE); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (stv.getControl().isDisposed()) { + return; + } + stv.refresh(script); + } + }); + } + + public void updateScriptTableViewer(final ScriptTask task) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (stv.getControl().isDisposed()) { + return; + } + stv.refresh(task); + } + }); + } + + public void updateScriptTableViewerTimed(ScriptTask task) { + updateScriptTable = true; + synchronized (tasksToUpdate) { + tasksToUpdate.add(task); + } + } + + @Override + public void run() { + if (updateScriptTable) { + updateScriptTable = false; + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + synchronized (tasksToUpdate) { + if (stv.getControl().isDisposed()) { + return; + } + for (ScriptTask task : tasksToUpdate) { + stv.refresh(task); + } + tasksToUpdate.clear(); + } + } + }); + } + } + + protected TestManagerEditor getTestManagerEditor() { + return testManager; + } + + public abstract void addTestsToQueue(List<ScriptTask> scripts); + + public void notifyScriptStart(final ScriptTask task) { + task.setStatus(ScriptStatusEnum.RUNNING); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + stv.refresh(task); + } + }); + } + + public void storeOutFile(ScriptTask task, TestComplete testComplete, boolean isValidRun) { + if (task.getScriptModel() != null) { + Job job = + new StoreOutfileJob(connectedEnv, testManager, this, task, testComplete.getClientOutfilePath(), + testComplete.getServerOutfilePath(), isValidRun); + StoreOutfileJob.scheduleJob(job); + } + } + + protected UUID getSessionKey() { + return sessionKey; + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptQueue.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptQueue.java new file mode 100644 index 000000000..659dbf331 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptQueue.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.util.List; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; + +public abstract class ScriptQueue implements Runnable { + + private final List<ScriptTask> scripts; + private final TestManagerEditor testManager; + + public ScriptQueue(List<ScriptTask> scripts, TestManagerEditor testManager) { + super(); + this.scripts = scripts; + this.testManager = testManager; + } + + @Override + public abstract void run(); + + protected List<ScriptTask> getScriptsToExecute() { + return scripts; + } + + protected TestManagerEditor getTestManagerEditor() { + return testManager; + } + + protected ScriptManager getScriptManager() { + return testManager.getPageManager().getScriptPage().getScriptManager(); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.done b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.done new file mode 100644 index 000000000..9a76b02f4 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.done @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.util.concurrent.Callable; + +/** + * @author b1528444 + * + */ +public abstract class StatusBoardRecieveEvent<V> implements Callable<V> { + + private V data; + + /** + * + */ + public StatusBoardRecieveEvent(V data) { + this.data = data; + } + + /* (non-Javadoc) + * @see java.util.concurrent.Callable#call() + */ + @Override + public V call() throws Exception { + run(); + return data; + } + + public abstract void run(); + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.java new file mode 100644 index 000000000..abb197da4 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/StatusBoardRecieveEvent.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.util.concurrent.Callable; + +/** + * @author Andrew M. Finkbeiner + */ +public abstract class StatusBoardRecieveEvent<V> implements Callable<V> { + + private final V data; + + public StatusBoardRecieveEvent(V data) { + this.data = data; + } + + @Override + public V call() throws Exception { + run(); + return data; + } + + public abstract void run(); + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java new file mode 100644 index 000000000..85ab6ad86 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java @@ -0,0 +1,353 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.logging.Level; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.IHealthStatus; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.core.environment.status.CommandAdded; +import org.eclipse.osee.ote.core.environment.status.CommandEndedStatusEnum; +import org.eclipse.osee.ote.core.environment.status.CommandRemoved; +import org.eclipse.osee.ote.core.environment.status.EnvironmentError; +import org.eclipse.osee.ote.core.environment.status.IServiceStatusData; +import org.eclipse.osee.ote.core.environment.status.IServiceStatusDataCommand; +import org.eclipse.osee.ote.core.environment.status.IServiceStatusDataVisitor; +import org.eclipse.osee.ote.core.environment.status.SequentialCommandBegan; +import org.eclipse.osee.ote.core.environment.status.SequentialCommandEnded; +import org.eclipse.osee.ote.core.environment.status.TestComplete; +import org.eclipse.osee.ote.core.environment.status.TestPointUpdate; +import org.eclipse.osee.ote.core.environment.status.TestServerCommandComplete; +import org.eclipse.osee.ote.core.environment.status.TestStart; +import org.eclipse.osee.ote.core.framework.command.TestCommandStatus; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask.ScriptStatusEnum; + +/** + * @author Roberto E. Escobar + */ +final class TestManagerServiceStatusDataVisitor implements IServiceStatusDataVisitor { + + private final ScriptManager scriptManager; + private final TestManagerEditor testManagerEditor; + private final ExecutorService executor; + + protected TestManagerServiceStatusDataVisitor(ScriptManager scriptManager, TestManagerEditor testManagerEditor) { + this.scriptManager = scriptManager; + this.testManagerEditor = testManagerEditor; + executor = Executors.newSingleThreadExecutor(); + + } + + @Override + public void asCommandAdded(final CommandAdded commandAdded) { + executor.submit(new StatusBoardRecieveEvent<CommandAdded>(commandAdded) { + @Override + public void run() { + checkServiceStatusDataValid(commandAdded); + logServiceStatusData(commandAdded); + final ScriptTask task = getScriptTask(commandAdded); + if (task != null) { + task.setStatus(ScriptStatusEnum.IN_QUEUE); + scriptManager.updateScriptTableViewer(task); + } + } + }); + logExecutorSize(); + } + + @Override + public void asCommandRemoved(final CommandRemoved commandRemoved) { + executor.submit(new StatusBoardRecieveEvent<CommandRemoved>(commandRemoved) { + @Override + public void run() { + checkServiceStatusDataValid(commandRemoved); + logServiceStatusData(commandRemoved); + + final ScriptTask task = getScriptTask(commandRemoved); + if (task != null) { + CommandEndedStatusEnum cmdStat = commandRemoved.getReason(); + if (cmdStat.equals(CommandEndedStatusEnum.ABORTED)) { + logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName())); + task.setStatus(ScriptStatusEnum.CANCELLED); + } + notifyExecutionComplete(task); + scriptManager.updateScriptTableViewer(task); + } + } + }); + logExecutorSize(); + } + + @Override + public void asEnvironmentError(final EnvironmentError environmentError) { + executor.submit(new StatusBoardRecieveEvent<EnvironmentError>(environmentError) { + @Override + public void run() { + checkServiceStatusDataValid(environmentError); + + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, + "errorOccured: " + environmentError.getErr().getMessage()); + environmentError.getErr().printStackTrace(); + final String msg = Lib.exceptionToString(environmentError.getErr()); + logOnConsole(Level.SEVERE, String.format("Test Environment Error: [%s]", msg)); + disconnectOnError(msg); + } + }); + logExecutorSize(); + } + + @Override + public void asSequentialCommandBegan(final SequentialCommandBegan sequentialCommandBegan) { + executor.submit(new StatusBoardRecieveEvent<SequentialCommandBegan>(sequentialCommandBegan) { + @Override + public void run() { + checkServiceStatusDataValid(sequentialCommandBegan); + logServiceStatusData(sequentialCommandBegan); + + final ScriptTask task = getScriptTask(sequentialCommandBegan); + if (task != null && task.getScriptModel() != null) { + OseeLog.logf(TestManagerPlugin.class, Level.INFO, "Script Task: [%s]", task); + logOnConsole(Level.INFO, String.format("Test Starting: [%s]", task.getName())); + task.setStatus(ScriptStatusEnum.RUNNING); + scriptManager.updateScriptTableViewer(task); + } + } + }); + logExecutorSize(); + } + + @Override + public void asSequentialCommandEnded(final SequentialCommandEnded sequentialCommandEnded) { + + executor.submit(new StatusBoardRecieveEvent<SequentialCommandEnded>(sequentialCommandEnded) { + @Override + public void run() { + checkServiceStatusDataValid(sequentialCommandEnded); + logServiceStatusData(sequentialCommandEnded); + final ScriptTask task = getScriptTask(sequentialCommandEnded); + if (task != null) { + OseeLog.logf(TestManagerPlugin.class, Level.INFO, "Script Task: [%s]", task); + CommandEndedStatusEnum cmdStat = sequentialCommandEnded.getStatus(); + switch (cmdStat) { + case ABORTED: + logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName())); + task.setStatus(ScriptStatusEnum.CANCELLED); + break; + case EXCEPTION: + task.setStatus(ScriptStatusEnum.CANCELLED); + logOnConsole(Level.SEVERE, + String.format("Test Aborted: [%s] - Exception Occurred", task.getName())); + break; + case HUNG: + task.setStatus(ScriptStatusEnum.CANCELLED); + logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName())); + break; + case RAN_TO_COMPLETION: + task.setStatus(ScriptStatusEnum.COMPLETE); + break; + default: + task.setStatus(ScriptStatusEnum.COMPLETE); + logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName())); + break; + } + logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName())); + notifyExecutionComplete(task); + scriptManager.updateScriptTableViewer(task); + } + } + }); + logExecutorSize(); + } + + @Override + public void asTestPointUpdate(final TestPointUpdate testPointUpdate) { + executor.submit(new StatusBoardRecieveEvent<TestPointUpdate>(testPointUpdate) { + @Override + public void run() { + checkServiceStatusDataValid(testPointUpdate); + final ScriptTask task = scriptManager.getScriptTask(testPointUpdate.getClassName()); + if (task != null) { + task.getScriptModel().getOutputModel().setAborted(false); + task.getScriptModel().getOutputModel().setPassedTestPoints(testPointUpdate.getPass()); + task.getScriptModel().getOutputModel().setFailedTestPoints(testPointUpdate.getFail()); + scriptManager.updateScriptTableViewerTimed(task); + } +// else { +// OseeLog.log(TestManagerPlugin.class, Level.WARNING, "testPointsUpdated: task is null"); +// } + } + }); + logExecutorSize(); + } + + private synchronized void logOnConsole(final Level level, final String msg) { + if (level.equals(Level.SEVERE)) { + TestManagerPlugin.getInstance().getOteConsoleService().writeError(msg); + } else { + TestManagerPlugin.getInstance().getOteConsoleService().write(msg); + } + } + + private void checkServiceStatusDataValid(IServiceStatusData statusData) { + if (statusData == null) { + throw new IllegalArgumentException(String.format("Error [%s] was null.", IServiceStatusData.class.getName())); + } + } + + private void disconnectOnError(final String cause) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + TestManagerPlugin.getInstance().getOteConsoleService().writeError(cause); + } + }); + } + + private void logServiceStatusData(IServiceStatusDataCommand statusData) { + OseeLog.logf(TestManagerPlugin.class, Level.FINE, + "%s: %s ", statusData.getClass().getName(), statusData.getDescription()); + } + + private ScriptTask getScriptTask(IServiceStatusDataCommand statusData) { + return scriptManager.getScriptTask(statusData.getDescription().getDescription()); + } + + private void notifyExecutionComplete(ScriptTask scriptTask) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + testManagerEditor.executionCompleted(); + } + }); + logExecutorSize(); + } + + @Override + public void asTestServerCommandComplete(final TestServerCommandComplete end) { + + executor.submit(new StatusBoardRecieveEvent<TestServerCommandComplete>(end) { + @Override + public void run() { + try { + TestCommandStatus result = end.getCmdStatus(); + Throwable th = end.getThrowable(); + if (th != null && result != null) { + OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("TestServer Command Completed [%s]", result.name()), th); + } else if ( result != null){ + OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("TestServer Command Completed [%s]", result.name())); + } + } catch (Exception ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } finally { + notifyExecutionComplete(null); + } + } + }); + logExecutorSize(); + } + + @Override + public void asTestComplete(final TestComplete testComplete) { + executor.submit(new StatusBoardRecieveEvent<TestComplete>(testComplete) { + @Override + public void run() { + ScriptTask task = scriptManager.getScriptTask(testComplete.getClassName()); + if (task != null) { + OseeLog.logf(TestManagerPlugin.class, Level.INFO, "Script Task: [%s]", task); + boolean isValidRun = true; + CommandEndedStatusEnum cmdStat = testComplete.getStatus(); + switch (cmdStat) { + case ABORTED: + logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName())); + for (IHealthStatus status : testComplete.getHealthStatus()) { + String msg; + if (status.getException() != null) { + msg = Lib.exceptionToString(status.getException()); + } else { + msg = status.getMessage(); + } + logOnConsole(status.getLevel(), msg); + } + task.setStatus(ScriptStatusEnum.CANCELLED); + break; + case EXCEPTION: + task.setStatus(ScriptStatusEnum.CANCELLED); + logOnConsole(Level.SEVERE, + String.format("Test Exception: [%s] - Exception Occurred", task.getName())); + StringBuilder sb = new StringBuilder(); + try { + for (IHealthStatus status : testComplete.getHealthStatus()) { + if (status.getException() != null) { + sb.append(Lib.exceptionToString(status.getException())); + } else if (status.getLevel().intValue() >= Level.SEVERE.intValue()) { + sb.append(status.getMessage()); + } + } + logOnConsole(Level.SEVERE, sb.toString()); + } catch (Throwable th) { + th.printStackTrace(); + } + break; + case HUNG: + task.setStatus(ScriptStatusEnum.CANCELLED); + logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName())); + break; + case RAN_TO_COMPLETION: + task.setStatus(ScriptStatusEnum.COMPLETE); + break; + default: + task.setStatus(ScriptStatusEnum.COMPLETE); + logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName())); + isValidRun = false; + break; + } + scriptManager.storeOutFile(task, testComplete, isValidRun); + logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName())); + + scriptManager.notifyScriptDequeued(testComplete.getClassName()); + scriptManager.updateScriptTableViewer(task); + + } + } + }); + logExecutorSize(); + } + + @Override + public void asTestStart(final TestStart testStart) { + executor.submit(new StatusBoardRecieveEvent<TestStart>(testStart) { + @Override + public void run() { + ScriptTask task = scriptManager.getScriptTask(testStart.getTestClassName()); + if (task != null) { + scriptManager.notifyScriptStart(task); + logOnConsole(Level.INFO, String.format("Test Started: [%s]", task.getName())); + } + + } + }); + logExecutorSize(); + } + + private void logExecutorSize() { + if (executor instanceof ThreadPoolExecutor) { + OseeLog.logf(TestManagerServiceStatusDataVisitor.class, Level.FINE, + "Current StatusBoard Executor Size [%d]", ((ThreadPoolExecutor) executor).getQueue().size()); + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerStatusListener.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerStatusListener.java new file mode 100644 index 000000000..d3a79789f --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerStatusListener.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.connection; + +import java.io.IOException; +import java.util.Hashtable; +import java.util.logging.Level; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.core.environment.status.IServiceStatusData; +import org.eclipse.osee.ote.core.environment.status.msg.CommandAddedMessage; +import org.eclipse.osee.ote.core.environment.status.msg.CommandRemovedMessage; +import org.eclipse.osee.ote.core.environment.status.msg.EnvErrorMessage; +import org.eclipse.osee.ote.core.environment.status.msg.SequentialCommandBeganMessage; +import org.eclipse.osee.ote.core.environment.status.msg.SequentialCommandEndedMessage; +import org.eclipse.osee.ote.core.environment.status.msg.TestCompleteMessage; +import org.eclipse.osee.ote.core.environment.status.msg.TestPointUpdateMessage; +import org.eclipse.osee.ote.core.environment.status.msg.TestServerCommandCompleteMessage; +import org.eclipse.osee.ote.core.environment.status.msg.TestStartMessage; +import org.eclipse.osee.ote.message.event.OteEventMessageUtil; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.event.Event; +import org.osgi.service.event.EventHandler; + +/** + * @author Andrew M. Finkbeiner + */ +public final class TestManagerStatusListener implements EventHandler { + + private final TestManagerServiceStatusDataVisitor testManagerServiceDataVisitor; + private ServiceRegistration<?> eventReference; + + + public TestManagerStatusListener(TestManagerEditor testManagerEditor, ScriptManager userEnvironment) { + this.testManagerServiceDataVisitor = new TestManagerServiceStatusDataVisitor(userEnvironment, testManagerEditor); + Hashtable<String, Object> properties = new Hashtable<>(); + properties.put("event.topics", "ote/status/*"); + eventReference = FrameworkUtil.getBundle(getClass()).getBundleContext().registerService(EventHandler.class.getName(), this, properties); + } + + @Override + public void handleEvent(Event event) { + try { + IServiceStatusData statusData = null; + if(event.getTopic().equals(CommandAddedMessage.EVENT)){ + CommandAddedMessage message = new CommandAddedMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(CommandRemovedMessage.EVENT)){ + CommandRemovedMessage message = new CommandRemovedMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(EnvErrorMessage.EVENT)){ + EnvErrorMessage message = new EnvErrorMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(SequentialCommandBeganMessage.EVENT)){ + SequentialCommandBeganMessage message = new SequentialCommandBeganMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(SequentialCommandEndedMessage.EVENT)){ + SequentialCommandEndedMessage message = new SequentialCommandEndedMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(TestCompleteMessage.EVENT)){ + TestCompleteMessage message = new TestCompleteMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(TestPointUpdateMessage.EVENT)){ + TestPointUpdateMessage message = new TestPointUpdateMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(TestServerCommandCompleteMessage.EVENT)){ + TestServerCommandCompleteMessage message = new TestServerCommandCompleteMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } else if(event.getTopic().equals(TestStartMessage.EVENT)){ + TestStartMessage message = new TestStartMessage(OteEventMessageUtil.getBytes(event)); + statusData = message.getObject(); + } + if(statusData != null){ + statusData.accept(testManagerServiceDataVisitor); + } + } catch (IOException e) { + OseeLog.log(getClass(), Level.SEVERE, event.getTopic(), e); + } catch (ClassNotFoundException e) { + OseeLog.log(getClass(), Level.SEVERE, event.getTopic(), e); + } + + } + + public void unregisterEventListener() { + eventReference.unregister(); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/ITestManagerModel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/ITestManagerModel.java new file mode 100644 index 000000000..f78896929 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/ITestManagerModel.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import org.eclipse.osee.framework.jdk.core.type.Pair; + +public interface ITestManagerModel { + + public abstract boolean hasParseExceptions(); + + public abstract Pair<Integer, Integer> getParseErrorRange(); + + public abstract String getParseError(); + + public abstract boolean setFromXml(String xmlText); + + public abstract String getRawXml(); + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/PageManager.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/PageManager.java new file mode 100644 index 000000000..92487589e --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/PageManager.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.ITestManagerFactory; +import org.eclipse.osee.ote.ui.test.manager.pages.AdvancedPage; +import org.eclipse.osee.ote.ui.test.manager.pages.HostPage; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.TestManagerPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Roberto E. Escobar + */ +public class PageManager { + + protected AdvancedPage advancedPage; + protected HostPage hostPage; + protected ScriptPage scriptPage; + private final List<TestManagerPage> pages; + + private final TestManagerEditor testManager; + private final ITestManagerFactory factory; + + public PageManager(ITestManagerFactory factory, TestManagerEditor testManager) { + this.factory = factory; + this.testManager = testManager; + this.pages = new ArrayList<>(); + } + + protected void createPages(Composite parent) { + hostPage = new HostPage(parent, SWT.NONE, testManager); + registerPage(hostPage, false); + + scriptPage = this.factory.getScriptPageNewInstance(parent, SWT.NONE, testManager); + scriptPage.createPage(); + registerPage(scriptPage, true); + + advancedPage = this.factory.getAdvancedPageNewInstance(parent, SWT.NONE, testManager); + advancedPage.createPage(); + registerPage(advancedPage, false); + + } + + private void registerPage(TestManagerPage page, boolean isScriptPage) { + pages.add(page); + testManager.registerPage(testManager.addPage(page), page.getPageName(), isScriptPage); + } + + /** + * Dispose pages + */ + public void dispose() { + for (TestManagerPage page : pages) { + page.dispose(); + } + pages.clear(); + } + + /** + * Save page settings to storage + */ + public void save() { + for (TestManagerPage page : pages) { + page.saveData(); + } + } + + /** + * Restore page from stored settings + */ + public void restore() { + for (TestManagerPage page : pages) { + page.restoreData(); + } + } + + /** + * @return the advancedPage + */ + public AdvancedPage getAdvancedPage() { + return advancedPage; + } + + /** + * @return the hostPage + */ + public HostPage getHostPage() { + return hostPage; + } + + /** + * @return the scriptPage + */ + public ScriptPage getScriptPage() { + return scriptPage; + } + + /** + * Checks that all page setting are set correctly for a script run + * + * @return <b>True</b> if page setting are valid for script run + */ + public boolean areSettingsValidForRun() { + boolean result = true; + for (TestManagerPage page : pages) { + result &= page.areSettingsValidForRun(); + } + return result; + } + + /** + * Gets page error message + * + * @return The Page error message + */ + public String getErrorMessage() { + StringBuilder builder = new StringBuilder(); + for (TestManagerPage page : pages) { + String pageMessage = page.getErrorMessage(); + if (Strings.isValid(pageMessage)) { + if (builder.length() > 0) { + builder.append("\n"); + } + builder.append(page.getPageName()); + builder.append(" Page:\n"); + builder.append(pageMessage); + builder.append("\n"); + } + } + return builder.toString(); + } + + public boolean onPostConnect(ConnectionEvent event) { + boolean problemEncountered = false; + for (TestManagerPage page : pages) { + problemEncountered |= page.onConnection(event); + } + return problemEncountered; + } + + public boolean onPreDisconnect(ConnectionEvent event) { + boolean problemEncountered = false; + for (TestManagerPage page : pages) { + problemEncountered |= page.onDisconnect(event); + } + return problemEncountered; + } + + public boolean onConnectionLost() { + boolean problemEncountered = false; + for (TestManagerPage page : pages) { + problemEncountered |= page.onConnectionLost(); + } + return problemEncountered; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java new file mode 100644 index 000000000..6619d219e --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java @@ -0,0 +1,593 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.logging.Level; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.osee.connection.service.IServiceConnector; +import org.eclipse.osee.framework.jdk.core.type.IPropertyStore; +import org.eclipse.osee.framework.jdk.core.type.Pair; +import org.eclipse.osee.framework.jdk.core.type.PropertyStore; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.util.OseeData; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment; +import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.service.ITestConnectionListener; +import org.eclipse.osee.ote.ui.test.manager.ITestManagerFactory; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.contributions.TestManagerStorageKeys; +import org.eclipse.osee.ote.ui.test.manager.util.ClassServerInst; +import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.part.MultiPageEditorPart; + +/** + * Resource Test Manager Editor Pages: + * <ul> + * <li>Overview Page + * <li>Target Page + * <li>Scripts Page + * <li>Advanced Page + * <li>Source Page + * </ul> + */ +public abstract class TestManagerEditor extends MultiPageEditorPart implements ITestConnectionListener { + private static final Image errorImage = ImageManager.getImage(OteTestManagerImage.ERROR); + public static final String namespace = "org.eclipse.osee.ote.ui.test.manager.editors.TestManagerEditor"; + + public final QualifiedName clearCaseViewName = new QualifiedName(namespace, "CLEARCASEVIEW"); + public final QualifiedName configFileName = new QualifiedName(namespace, "CONFIGFILENAME"); + public final QualifiedName ofpQualName = new QualifiedName(namespace, "OFP"); + public final QualifiedName scriptsQualName = new QualifiedName(namespace, "SCRIPTS"); + + private boolean fileIsDirty = false; + + private boolean fileWasSaved = false; + + private int lastPageIndex = 0; + + private final ITestManagerModel model; + + private boolean reloadSourcePage = false; + + private int scriptPageIndex = 1; + + private TextEditor sourceEditor; + + private int sourcePage; + + private final ITestManagerFactory testManagerFactory; + + private IFile thisIFile = null; + + private final IPropertyStore propertyStore; + + private final PageManager pageManager; + + private ITestEnvironment connectedEnv = null; + private IServiceConnector connector = null; + private IHostTestEnvironment connectedHost; + + public TestManagerEditor(final ITestManagerFactory testManagerFactory, ITestManagerModel model) { + super(); + + this.testManagerFactory = testManagerFactory; + this.pageManager = new PageManager(testManagerFactory, this); + this.model = model; + this.propertyStore = new PropertyStore(testManagerFactory.getClass().getSimpleName()); + } + + public void activateScriptsPage() { + setActivePage(scriptPageIndex); + } + + + public void addFile(String fullPath) { + pageManager.getScriptPage().addFile(fullPath); + } + + @Override + public void dispose() { + super.dispose(); + TestManagerPlugin.getInstance().getOteClientService().removeConnectionListener(this); + try { + pageManager.dispose(); + } catch (Throwable t) { + TestManagerPlugin.log(Level.SEVERE, "exception while disposing test manager", t); + } + } + + /** + * Saves the multi-page editor's document. + */ + @Override + public void doSave(IProgressMonitor monitor) { + if (getActivePage() != sourcePage) { + pageSourceLoad(); + } + if(isDirty()){ + getEditor(sourcePage).doSave(monitor); + } + fileIsDirty = false; + fileWasSaved = true; + doSave(); + firePropertyChange(PROP_DIRTY); + } + + /** + * Saves the multi-page editor's document as another file. Also updates the text for page 0's tab, and updates this + * multi-page editor's input to correspond to the nested editor's. + */ + @Override + public void doSaveAs() { + if (getActivePage() != sourcePage) { + pageSourceLoad(); + } + IEditorPart editor = getEditor(sourcePage); + editor.doSaveAs(); + setPageText(sourcePage, "Source"); + setInput(editor.getEditorInput()); + doSave(); + } + + protected void registerPage(int pageNumber, String pageName, boolean isScriptPage) { + setPageText(pageNumber, pageName); + if(isScriptPage){ + scriptPageIndex = pageNumber; + } + } + + public void executionCompleted() { + pageManager.getScriptPage().onScriptRunning(false); + } + + public void fireSaveNeeded() { + fileIsDirty = true; + firePropertyChange(PROP_DIRTY); + } + + public String getAlternateOutputDir() { + String scriptOutput = ""; + + IPropertyStore propertyStore = getPropertyStore(); + scriptOutput = propertyStore.get(TestManagerStorageKeys.SCRIPT_OUTPUT_DIRECTORY_KEY); + if (scriptOutput == null) { + scriptOutput = ""; + // TODO: Escobar + // try { + // IEditorInput coreinput = getEditorInput(); + // if (coreinput instanceof IFileEditorInput) { + // scriptOutput = + // thisIFile.getPersistentProperty(scriptOutputQualName); + // } else if (coreinput instanceof TestManagerInput) { + // TestManagerInput input = (TestManagerInput) getEditorInput(); + // scriptOutput = + // input.getValue(scriptOutputQualName.getLocalName()); + // } + // + // scriptOutput = + // thisIFile.getPersistentProperty(scriptOutputQualName); + // } catch (CoreException e) { + // e.printStackTrace(); + // } + } + return scriptOutput; + } + + public String getDefaultConfigPath() { + Location user = Platform.getUserLocation(); + String path = user.getURL().getPath(); + File file = new File(path + File.separator + "org.eclipse.osee.ote.ui.test.manager"); + file.mkdirs(); + file = + new File( + path + File.separator + "org.eclipse.osee.ote.ui.test.manager" + File.separator + this.getClass().getName() + ".scriptConfig.xml"); + file.getParentFile().mkdirs(); + return file.getAbsolutePath(); + } + + /** + * @return Returns the model. + */ + public ITestManagerModel getModel() { + return model; + } + + public String getName() { + return this.getTitle(); + } + + public ClassServerInst getScriptClassServer() { + return ClassServerInst.getInstance(); + } + + public ITestManagerFactory getTestManagerFactory() { + return testManagerFactory; + } + + @Override + public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { + if (!(editorInput instanceof IFileEditorInput || editorInput instanceof TestManagerInput || editorInput instanceof IEditorInput)) { + throw new PartInitException("Invalid Input: Must be IFileEditorInput"); + } + super.init(site, editorInput); + } + + @Override + public boolean isDirty() { + if (super.isDirty()) { + return true; + } + return fileIsDirty; + } + + @Override + public boolean isSaveAsAllowed() { + return true; + } + + /** + * Retrieves the value for the key. See <code>storeValue</code>. If the key could not be found, an empty string is + * returned. + * + * @param key The <code>QualifiedName</code> whose value is to be retrieved. + * @return The value of key, or an empty string if the key does not exist. + */ + public String loadValue(QualifiedName key) { + TestManagerPlugin.log(Level.INFO, "loadValue: " + key.getQualifier()); + try { + IEditorInput coreinput = getEditorInput(); + if (coreinput instanceof IFileEditorInput) { + return thisIFile.getPersistentProperty(key); + } else if (coreinput instanceof TestManagerInput) { + TestManagerInput input = (TestManagerInput) getEditorInput(); + return input.getValue(key.getLocalName()); + } + } catch (CoreException ex) { + TestManagerPlugin.log(Level.SEVERE, "Can't get value: " + ex); + } + return ""; + } + + public void setPageError(int page, boolean set) { + if (set) { + setPageImage(page, errorImage); + } else { + setPageImage(page, null); + } + } + + /** + * Stores the value for the key. The key should be one of the publicly available <code>QualifiedName</code>'s in + * <code>this</code>. + * + * @param key The <code>QualifiedName</code> associated with the value to be stored + * @param value What will be stored under the key. + */ + public void storeValue(QualifiedName key, String value) { + TestManagerPlugin.log(Level.INFO, "storeValue: " + key.getQualifier()); + try { + IEditorInput coreinput = getEditorInput(); + if (coreinput instanceof IFileEditorInput) { + thisIFile.setPersistentProperty(key, value); + } else if (coreinput instanceof TestManagerInput) { + TestManagerInput input = (TestManagerInput) getEditorInput(); + input.storeValue(key.getLocalName(), value); + } + } catch (Exception ex) { + TestManagerPlugin.log(Level.SEVERE, "Can't set value: " + ex); + } + } + + private void pageSourceCheck() { + setPageError(sourcePage, model.hasParseExceptions()); + } + + private void readXmlData() { + TestManagerPlugin.log(Level.INFO, "readXmlData"); + IEditorInput coreinput = getEditorInput(); + String xmlText = ""; + if (coreinput instanceof IFileEditorInput) { + IFileEditorInput input = (IFileEditorInput) getEditorInput(); + thisIFile = input.getFile(); + try { + thisIFile.refreshLocal(IResource.DEPTH_ZERO, null); + } catch (CoreException e) { + e.printStackTrace(); + } + String name = thisIFile.getName(); + this.setPartName(name); + if (thisIFile != null) { + try { + xmlText = Lib.inputStreamToString(thisIFile.getContents()); + } catch (Exception ex) { + ex.printStackTrace(); + } + } else { + TestManagerPlugin.log(Level.SEVERE, "Can't open xml file!"); + } + } else if (coreinput instanceof TestManagerInput) { + TestManagerInput input = (TestManagerInput) getEditorInput(); + String name = "TestManager"; + this.setPartName(name); + xmlText = input.getDefaultXML(); + } + model.setFromXml(xmlText); + } + + /** + * Creates the pages of the multi-page editor. + */ + @Override + protected void createPages() { + readXmlData(); + + pageManager.createPages(getContainer()); + pageSourceCreate(); + + fileIsDirty = false; + reloadSourcePage = false; + pageSourceCheck(); + restoreSettings(); + + // If parse errors, send to sourcePage and set error on page + if (model.hasParseExceptions()) { + if (sourceEditor == null) { + pageSourceCreate(); + } + handleSourceEditorError(); + } + fileIsDirty = false; + firePropertyChange(PROP_DIRTY); + TestManagerPlugin.getInstance().getOteClientService().addConnectionListener(this); + } + + protected void handleSelection() { + fireSaveNeeded(); + reloadSourcePage = true; + } + + /** + * reloads pages as necessary + */ + @Override + protected void pageChange(int newPageIndex) { + // NOTE: Hosts page will be updated continuously, even it if it is not + // the current page. + // so it is unnecessary to update it on pageChange. + + super.pageChange(newPageIndex); + if (newPageIndex == sourcePage) { + pageSourceLoad(); + } else { + if (sourceEditor == null) { + return; + } + String newXml = sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).get(); + if (sourceEditor.isDirty() || fileWasSaved) { + fileWasSaved = false; + // If we just came from sourcePage, re-parse + if (lastPageIndex == sourcePage) { + // if parse error, goto source and error + if (!model.setFromXml(newXml)) { + handleSourceEditorError(); + return; + } + setPageError(sourcePage, false); + } + } + } + doSave(null); + lastPageIndex = newPageIndex; + } + + private void handleSourceEditorError() { + if (model.hasParseExceptions()) { + try { + setActivePage(sourcePage); + pageSourceCheck(); + MessageDialog.openError(getSite().getShell(), "Source Page Error", + "Error parsing Source page\n "+model.getParseError()); + Pair<Integer, Integer> parseErrorRange = model.getParseErrorRange(); + sourceEditor.setHighlightRange(parseErrorRange.getFirst(), parseErrorRange.getSecond(), false); + sourceEditor.getSelectionProvider().setSelection(new TextSelection(parseErrorRange.getFirst(), parseErrorRange.getSecond())); + } catch (Throwable th) {} + } + } + + public void updateFromTestManagerModel() { + IDocument doc = sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()); + if (!doc.get().equals(model.getRawXml())) { + doc.set(model.getRawXml()); + try { + sourceEditor.getDocumentProvider().saveDocument(new NullProgressMonitor(), null, doc, true); + } catch (CoreException e) { + OseeLog.log(getClass(), Level.SEVERE, e); + } + } + } + + void pageSourceCreate() { + try { + if (getEditorInput() instanceof IFileEditorInput) { + sourceEditor = new TextEditor(); + int index = addPage(sourceEditor, getEditorInput()); + sourcePage = index; + setPageText(sourcePage, "Source"); + } + } catch (PartInitException e) { + TestManagerPlugin.log(Level.SEVERE, "Error creating nested text editor", e); + ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); + } + } + + void pageSourceLoad() { + if (reloadSourcePage) { + sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).set(model.getRawXml()); + reloadSourcePage = false; + } + pageSourceCheck(); + } + + public void doSave() { + pageManager.save(); + OutputStream outputStream = null; + try { + File file = OseeData.getFile("testManagerSettings.xml"); + outputStream = new FileOutputStream(file); + getPropertyStore().save(outputStream); + } catch (Exception ex) { + TestManagerPlugin.log(Level.SEVERE, "Error storing settings.", ex); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException ex) { + TestManagerPlugin.log(Level.WARNING, "Error closing stream during settings storage.", ex); + } + } + } + } + + public void restoreSettings() { + InputStream inputStream = null; + try { + File file = OseeData.getFile("testManagerSettings.xml"); + if(file.exists()){ + inputStream = new FileInputStream(file); + getPropertyStore().load(inputStream); + pageManager.restore(); + } + } catch (Exception ex) { + TestManagerPlugin.log(Level.WARNING, "Stored settings not available. Using defaults.", ex); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException ex) { + TestManagerPlugin.log(Level.WARNING, "Error closing stream while loading settings.", ex); + } + } + } + } + + public IPropertyStore getPropertyStore() { + return propertyStore; + } + + public PageManager getPageManager() { + return pageManager; + } + + @Override + public void onConnectionLost(IServiceConnector connector) { + connectedEnv = null; + connector = null; + boolean problemEncountered = pageManager.onConnectionLost(); + if (problemEncountered) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + MessageDialog.openError(Displays.getActiveShell(), "Disconnect Error", + "Test manager has encountered a problem while processing the disconnect event. See Error Log for details"); + } + }); + } + connectedHost = null; + } + + @Override + public void onPostConnect(ConnectionEvent event) { + connectedEnv = event.getEnvironment(); + connectedHost = event.getHostEnvironment(); + connector = event.getConnector(); + boolean problemEncountered = pageManager.onPostConnect(event); + if (problemEncountered) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + MessageDialog.openError(Displays.getActiveShell(), "Connection Error", + "Test manager has encountered a problem while processing the connection event. See Error Log for details"); + } + }); + } + } + + @Override + public void onPreDisconnect(ConnectionEvent event) { + event.getEnvironment(); + connectedEnv = null; + + connector = null; + boolean problemEncountered = pageManager.onPreDisconnect(event); + if (problemEncountered) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + MessageDialog.openError(Displays.getActiveShell(), "Disconnect Error", + "Test manager has encountered a problem while processing the disconnect event. See Error Log for details"); + } + }); + } + connectedHost = null; + } + + public boolean isConnected() { + return connectedEnv != null; + } + + public ITestEnvironment getConnectedEnvironment() { + return connectedEnv; + } + + public IHostTestEnvironment getConnectedHostEnvironment() { + return connectedHost; + } + + public IServiceConnector getConnector() { + return connector; + } + + public abstract void createHostWidget(Composite parent); + + public void addFiles(String[] files) { + pageManager.getScriptPage().addFiles(files); + } + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorContributor.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorContributor.java new file mode 100644 index 000000000..c4e4456d6 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorContributor.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.ide.IDEActionFactory; +import org.eclipse.ui.part.MultiPageEditorActionBarContributor; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.ITextEditorActionConstants; + +/** + * Manages the installation/deinstallation of global actions for multi-page editors. Responsible for the redirection of + * global actions to the active editor. Multi-page contributor replaces the contributors for the individual editors in + * the multi-page editor. + */ +public class TestManagerEditorContributor extends MultiPageEditorActionBarContributor { + private IEditorPart activeEditorPart; + + /** + * Creates a multi-page contributor. + */ + public TestManagerEditorContributor() { + super(); + createActions(); + } + + @Override + public void setActivePage(IEditorPart part) { + if (activeEditorPart == part) { + return; + } + + activeEditorPart = part; + + IActionBars actionBars = getActionBars(); + if (actionBars != null) { + + ITextEditor editor = part instanceof ITextEditor ? (ITextEditor) part : null; + + actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), + getAction(editor, ITextEditorActionConstants.DELETE)); + actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), + getAction(editor, ITextEditorActionConstants.UNDO)); + actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), + getAction(editor, ITextEditorActionConstants.REDO)); + actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction(editor, ITextEditorActionConstants.CUT)); + actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), + getAction(editor, ITextEditorActionConstants.COPY)); + actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), + getAction(editor, ITextEditorActionConstants.PASTE)); + actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), + getAction(editor, ITextEditorActionConstants.SELECT_ALL)); + actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), + getAction(editor, ITextEditorActionConstants.FIND)); + actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), + getAction(editor, IDEActionFactory.BOOKMARK.getId())); + actionBars.updateActionBars(); + } + } + + /** + * Returns the action registered with the given text editor. + * + * @return IAction or null if editor is null. + */ + protected IAction getAction(ITextEditor editor, String actionID) { + return editor == null ? null : editor.getAction(actionID); + } + + private void createActions() { + //Left here for future actions that might want to be contributed to the status + //line for Test Manager. + } + + @Override + public void setActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + + if (part instanceof TestManagerEditor) { + + //Left here for future actions that might want to be contributed to the status + //line for Test Manager. + } + + } + + @Override + public void contributeToStatusLine(final IStatusLineManager statusLineManager) { + super.contributeToStatusLine(statusLineManager); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInput.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInput.java new file mode 100644 index 000000000..3936ab2e4 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInput.java @@ -0,0 +1,186 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import java.io.File; +import java.io.InputStream; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IPersistableElement; + +public class TestManagerEditorInput implements IFileEditorInput, IPersistableElement { + + private static final String FACTORY_ID = TestManagerEditorInputFactory.class.getCanonicalName(); + private final IFile iFile; + + public TestManagerEditorInput(File file) { + this(getIFile(file)); + } + + public TestManagerEditorInput(IFile iFile) { + super(); + this.iFile = iFile; + } + + private static IFile getIFile(File file){ + IFile ifile = AWorkspace.fileToIFile(file); + if(ifile == null){ + IWorkspace workspace= ResourcesPlugin.getWorkspace(); + IPath location= Path.fromOSString(file.getAbsolutePath()); + ifile= workspace.getRoot().getFileForLocation(location); + } + return ifile; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (iFile != null && o instanceof TestManagerEditorInput) { + TestManagerEditorInput input = (TestManagerEditorInput) o; + return iFile.equals(input.getFile()); + } + return false; + } + + /* + * @see org.eclipse.ui.IEditorInput#exists() + */ + @Override + public boolean exists() { + return true; + } + + /* + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + return iFile.getAdapter(adapter); + } + + @Override + public String getFactoryId() { + return FACTORY_ID; + } + + @Override + public IFile getFile() { + return iFile; + } + + /* + * @see org.eclipse.ui.IEditorInput#getImageDescriptor() + */ + @Override + public ImageDescriptor getImageDescriptor() { + return null; + } + + // /* + // * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object) + // */ + // public IPath getPath(Object element) { + // if (element instanceof NonExistingFileEditorInput) { + // NonExistingFileEditorInput input= (NonExistingFileEditorInput) element; + // return Path.fromOSString(input.fFile.getAbsolutePath()); + // } + // return null; + // } + + /* + * @see org.eclipse.ui.IEditorInput#getName() + */ + @Override + public String getName() { + if(iFile == null){ + return "TestManager"; + } + return iFile.getName(); + } + + /* + * @see org.eclipse.ui.IEditorInput#getPersistable() + */ + @Override + public IPersistableElement getPersistable() { + return this; + } + + @Override + public IStorage getStorage() throws CoreException { + return new IStorage() { + + @Override + public Object getAdapter(Class adapter) { + return iFile.getAdapter(adapter); + } + + @Override + public InputStream getContents() throws CoreException { + return iFile.getContents(); + } + + @Override + public IPath getFullPath() { + return iFile.getFullPath(); + } + + @Override + public String getName() { + return iFile.getName(); + } + + @Override + public boolean isReadOnly() { + return false; + } + + }; + } + + /* + * @see org.eclipse.ui.IEditorInput#getToolTipText() + */ + @Override + public String getToolTipText() { + return iFile.getName(); + } + + /* + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return iFile.hashCode(); + } + + @Override + public void saveState(IMemento memento) { + if (iFile != null && iFile.getLocation().toFile().exists()) { + memento.putString("path", iFile.getLocation().toFile().getAbsolutePath()); + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInputFactory.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInputFactory.java new file mode 100644 index 000000000..6eefd9b10 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditorInputFactory.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import java.io.File; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.IElementFactory; +import org.eclipse.ui.IMemento; + +public class TestManagerEditorInputFactory implements IElementFactory { + + public TestManagerEditorInputFactory() { + } + + @Override + public IAdaptable createElement(IMemento memento) { + String path = memento.getString("path"); + if(path != null){ + File file = new File(path); + TestManagerEditorInput input = new TestManagerEditorInput(file); + return input; + } else { + return null; + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerInput.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerInput.java new file mode 100644 index 000000000..eb96246e3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerInput.java @@ -0,0 +1,151 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.core; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.logging.Level; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPersistableElement; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class TestManagerInput implements IEditorInput { + private final HashMap<String, String> keyValue; + + public TestManagerInput() { + keyValue = new HashMap<>(); + loadFromFile(); + } + + @Override + public boolean equals(Object object) { + if (object instanceof TestManagerInput) { + return true; + } + return false; + } + + @Override + public boolean exists() { + return false; + } + + @Override + public Object getAdapter(Class adapter) { + return null; + } + + public String getDefaultXML() { + return "<testManager>" + "<contact></contact>" + "<description>Test Manager</description>" + + "<distributionStatement></distributionStatement>" + "</testManager>"; + + } + + @Override + public ImageDescriptor getImageDescriptor() { + return null; + } + + @Override + public String getName() { + return "TestManager"; + } + + @Override + public IPersistableElement getPersistable() { + return null; + } + + @Override + public String getToolTipText() { + return "OSEE TestManager"; + } + + public String getValue(String key) { + return keyValue.get(key); + } + + public void storeValue(String key, String value) throws ParserConfigurationException, TransformerException, IOException { + keyValue.put(key, value); + saveToFile(); + } + + private File getFile() { + Location user = Platform.getUserLocation(); + String path = user.getURL().getPath(); + File file = + new File( + path + File.separator + "org.eclipse.osee.ote.ui.test.manager" + File.separator + this.getClass().getName() + ".xml"); + file.getParentFile().mkdirs(); + return file; + } + + private void loadFromFile() { + keyValue.clear(); + Document document; + try { + document = Jaxp.readXmlDocument(getFile()); + NodeList viewList = document.getElementsByTagName("Pair"); + for (int index = 0; index < viewList.getLength(); index++) { + Node node = viewList.item(index); + if (node != null && node instanceof Element) { + Element element = (Element) node; + String key = Jaxp.getChildText(element, "Key"); + String value = Jaxp.getChildText(element, "Value"); + if (key != null && value != null && !key.equals("") && !value.equals("")) { + keyValue.put(key, value); + } + } + } + } catch (Exception ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + } + + private void saveToFile() throws ParserConfigurationException, TransformerException, IOException { + Document document = Jaxp.newDocumentNamespaceAware(); + Element root = document.createElement("ValuePairs"); + document.appendChild(root); + + Iterator<String> it = keyValue.keySet().iterator(); + while (it.hasNext()) { + String key = it.next(); + String value = keyValue.get(key); + if (key != null && value != null && !key.equals("") && !value.equals("")) { + Element pair = document.createElement("Pair"); + + Element keyElement = document.createElement("Key"); + keyElement.setTextContent(key); + pair.appendChild(keyElement); + + Element valueElement = document.createElement("Value"); + valueElement.setTextContent(value); + pair.appendChild(valueElement); + root.appendChild(pair); + } + } + + Jaxp.writeXmlDocument(document, getFile(), Jaxp.getPrettyFormat()); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/ServiceUtility.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/ServiceUtility.java new file mode 100644 index 000000000..c990a1042 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/ServiceUtility.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.internal; + +import org.eclipse.osee.ote.version.FileVersionInformation; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; + +public class ServiceUtility { + + public static FileVersionInformation getFileVersionInformation(){ + return getService(FileVersionInformation.class); + } + + public static Class<ServiceUtility> getClazz(){ + return ServiceUtility.class; + } + + public static <T> T getService(Class<T> clazz){ + BundleContext context = getContext(); + if(context == null){ + return null; + } + ServiceReference serviceReference = context.getServiceReference(clazz.getName()); + if(serviceReference == null){ + return null; + } + return (T)getContext().getService(serviceReference); + } + + public static <T> T[] getServices(Class<T> clazz) throws InvalidSyntaxException{ + ServiceReference[] serviceReferences = getContext().getServiceReferences(clazz.getName(), null); + T[] data = (T[])new Object[serviceReferences.length]; + for(int i = 0; i < serviceReferences.length; i ++){ + data[i] = (T)getContext().getService(serviceReferences[i]); + } + return data; + } + + public static BundleContext getContext(){ + return FrameworkUtil.getBundle(getClazz()).getBundleContext(); + } +} + diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/TestManagerPlugin.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/TestManagerPlugin.java new file mode 100644 index 000000000..4c5413fc0 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/internal/TestManagerPlugin.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.internal; + +import java.util.logging.Level; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.ote.service.IOteClientService; +import org.eclipse.osee.ote.ui.IOteConsoleService; +import org.osgi.framework.BundleContext; +import org.osgi.util.tracker.ServiceTracker; + +/** + * The main plugin class to be used in the desktop. + */ +public class TestManagerPlugin extends OseeUiActivator { + private static TestManagerPlugin pluginInstance; // The shared instance. + public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui.test.manager"; + + private static String username = null; + + private ServiceTracker oteClientServiceTracker; + private ServiceTracker oteConsoleServiceTracker; + + /** + * Returns the shared instance. + */ + public static TestManagerPlugin getInstance() { + return pluginInstance; + } + + public static String getUsername() { + if (username == null) { + username = java.lang.System.getProperty("user.name"); + username = username.replaceAll("b", ""); + if (username.length() == 6) { + username = "0" + username; + } + } + return username; + } + + /** + * The constructor. + */ + public TestManagerPlugin() { + super(PLUGIN_ID); + pluginInstance = this; + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + oteClientServiceTracker = new ServiceTracker(context, IOteClientService.class.getName(), null); + oteClientServiceTracker.open(); + + oteConsoleServiceTracker = new ServiceTracker(context, IOteConsoleService.class.getName(), null); + oteConsoleServiceTracker.open(); + } + + @Override + public void stop(BundleContext context) throws Exception { + if (oteConsoleServiceTracker != null) { + oteConsoleServiceTracker.close(); + } + if (oteClientServiceTracker != null) { + oteClientServiceTracker.close(); + } + super.stop(context); + } + + public IOteClientService getOteClientService() { + return (IOteClientService) oteClientServiceTracker.getService(); + } + + public IOteConsoleService getOteConsoleService() { + return (IOteConsoleService) oteConsoleServiceTracker.getService(); + } + + public static void log(Level level, String message, Throwable t) { + OseeLog.log(TestManagerPlugin.class, level, message, t); + } + + public static void log(Level level, String message) { + log(level, message, null); + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java new file mode 100644 index 000000000..8cd6db92d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.jobs; + +import java.io.File; +import java.util.LinkedList; +import java.util.List; +import java.util.logging.Level; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; + +/** + * @author Roberto E. Escobar + */ +public class ScriptRunJob extends Job { + private static final String JOB_NAME = "Script Run Job"; + + private final TestManagerEditor testManagerEditor; + private final List<ScriptTask> runTasks; + + public ScriptRunJob(TestManagerEditor testManagerEditor) { + super(JOB_NAME); + this.testManagerEditor = testManagerEditor; + this.testManagerEditor.doSave(); + ScriptPage scriptPage = getScriptPage(); + scriptPage.getScriptTableViewer().refresh(); + this.runTasks = scriptPage.getScriptTableViewer().getRunTasks(); + } + + public IStatus verifyOutfileLocations() { + final LinkedList<IStatus> failedLocations = new LinkedList<>(); + for (ScriptTask task : runTasks) { + final String fileName = task.getScriptModel().getOutputModel().getRawFilename(); + final File file = new File(fileName); + if (file.exists() && (!file.canWrite() || !file.canRead())) { + failedLocations.add(new Status(IStatus.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName)); + } else if (!file.getParentFile().canWrite()) { + failedLocations.add(new Status(IStatus.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName)); + } + } + if (failedLocations.isEmpty()) { + return Status.OK_STATUS; + } else { + return new Status(IStatus.ERROR, TestManagerPlugin.PLUGIN_ID, "unable to access out files") { + + @Override + public boolean isMultiStatus() { + return true; + } + + @Override + public IStatus[] getChildren() { + return failedLocations.toArray(new IStatus[failedLocations.size()]); + } + + }; + } + } + + @Override + public IStatus run(IProgressMonitor monitor) { + IStatus toReturn = Status.CANCEL_STATUS; + final IStatus status = verifyOutfileLocations(); + + if (status != Status.OK_STATUS) { + Displays.pendInDisplayThread(new Runnable() { + @Override + public void run() { + ErrorDialog.openError( + Displays.getActiveShell(), + "Script Run Error", + "Could not access some out file locations. Check access permissions. Click Details to see a list of failed locations", + status, -1); + } + + }); + + return Status.OK_STATUS; + } + + long time = System.currentTimeMillis(); + + clearMarkers(); + getScriptPage().onScriptRunning(true); + + long elapsed = System.currentTimeMillis() - time; + OseeLog.logf(TestManagerPlugin.class, Level.FINE, + "%d milliseconds to initialize the running of scripts.", elapsed); + OseeLog.logf(TestManagerPlugin.class, Level.INFO, "%d scripts have been batched.", runTasks.size()); + + Displays.pendInDisplayThread(new Runnable() { + @Override + public void run() { + getScriptPage().getScriptManager().addTestsToQueue(runTasks); + } + + }); + toReturn = Status.OK_STATUS; + return toReturn; + } + + private ScriptPage getScriptPage() { + return this.testManagerEditor.getPageManager().getScriptPage(); + } + + public boolean isRunAllowed() { + + return this.testManagerEditor.getPageManager().areSettingsValidForRun(); + + } + + public String getErrorMessage() { + return this.testManagerEditor.getPageManager().getErrorMessage(); + } + + private void clearMarkers() { + // TODO can we somehow wait until the script is actually run to remove + // the markers? Otherwise if the run is aborted before the script + // runs... + + // Remove markers from scripts to be run + // for (ScriptTask task : runTasks) { + // try { + // MarkerSupport.deleteMarkersFromInputFile(task.getScriptModel().getIFile()); + // } + // catch (Exception ex) { + // OseeLog.log(Activator.class, Level.SEVERE, "Unable to clear the tests markers before + // running the test.", ex); + // } + // } + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java new file mode 100644 index 000000000..488c64ddb --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.jobs; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.util.AIFile; +import org.eclipse.osee.framework.ui.plugin.util.OseeConsole; +import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment; +import org.eclipse.osee.ote.ui.markers.MarkerPlugin; +import org.eclipse.osee.ote.ui.test.manager.connection.ScriptManager; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.models.OutputModel; +import org.eclipse.osee.ote.ui.test.manager.pages.contributions.TestManagerStorageKeys; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; + +/** + * @author Roberto E. Escobar + */ +public class StoreOutfileJob extends Job { + + private final ScriptManager userEnvironment; + private final ScriptTask scriptTask; + private final boolean isValidRun; + private final TestManagerEditor testManagerEditor; + private final ITestEnvironment env; + + private final String clientOutfilePath; + + private final String serverOutfilePath; + + public StoreOutfileJob(ITestEnvironment env, TestManagerEditor testManagerEditor, ScriptManager userEnvironment, ScriptTask scriptTask, String clientOutfilePath, String serverOutfilePath, boolean isValidRun) { + super("Store: " + scriptTask.getName()); + this.env = env; + this.scriptTask = scriptTask; + this.testManagerEditor = testManagerEditor; + this.userEnvironment = userEnvironment; + this.isValidRun = isValidRun; + this.clientOutfilePath = clientOutfilePath; + this.serverOutfilePath = serverOutfilePath; + } + + public static void scheduleJob(Job job) { + job.setUser(false); + job.setPriority(Job.SHORT); + job.schedule(); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + if (isValidRun == true) { + try { + storeOutfile(scriptTask); + } catch (Exception e) { + return new Status(IStatus.ERROR, TestManagerPlugin.PLUGIN_ID, "Failed to write out file to workspace", + e); + } + } + // scriptTask.computeExists(); + userEnvironment.updateScriptTableViewer(scriptTask); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + processOutFile(scriptTask); + } catch (Exception ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + return Status.OK_STATUS; + } + + public void processOutFile(ScriptTask task) { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "Processing Outfile: " + task.getName()); + // task.computeExists(); + File xmlSourceFile = task.getScriptModel().getOutputModel().getFile(); + IFile javaSourceIFile = task.getScriptModel().getIFile(); + + if (!xmlSourceFile.exists()) { + TestManagerPlugin.getInstance().getOteConsoleService().writeError("Output File Not Created"); + } else { + // Refresh the parent so the workspace knows the new tmo file exists + AWorkspace.refreshResource(javaSourceIFile); + task.getScriptModel().getOutputModel().updateTestPointsFromOutfile(); + int failedPoints = task.getScriptModel().getOutputModel().getFailedTestPoints(); + userEnvironment.updateScriptTableViewer(scriptTask); + if (failedPoints > 0) { + // Print fails in red, but don't force the console to popup + TestManagerPlugin.getInstance().getOteConsoleService().write( + String.format("Test Point Failures => %s[%d]", task.getName(), failedPoints), OseeConsole.CONSOLE_ERROR, + false); + } + } + } + + private boolean isKeepSavedOutfileEnabled() { + return testManagerEditor.getPropertyStore().getBoolean( + TestManagerStorageKeys.KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY); + } + + private void storeOutfile(ScriptTask scriptTask) throws Exception { + if (clientOutfilePath.equals(serverOutfilePath) != true) { + // the paths are different so we need to copy the file + byte[] outBytes = env.getScriptOutfile(serverOutfilePath); + if (outBytes != null && outBytes.length > 0) { + + if (isKeepSavedOutfileEnabled()) { + moveOutputToNextAvailableSpot(scriptTask); + } + IFile file = null; + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI( + org.eclipse.core.filesystem.URIUtil.toURI(clientOutfilePath)); + if (files.length > 0) { + file = files[0]; + } + if (file != null) { + AIFile.writeToFile(file, new ByteArrayInputStream(outBytes)); + MarkerPlugin.addMarkers(file); + } else { + Lib.writeBytesToFile(outBytes, new File(clientOutfilePath)); + } + } + } + } + + private void moveOutputToNextAvailableSpot(ScriptTask task) { + OutputModel outputModel = task.getScriptModel().getOutputModel(); + File oldFile = outputModel.getFile(); + if (oldFile != null && oldFile.exists() && oldFile.isFile() && oldFile.canRead()) { + String outputExtension = "." + outputModel.getFileExtension(); + String extensionRegex = "\\" + outputExtension + "\\b";//escape the . and should be the end of the string (word b + int fileNum = 1; + File destFile = new File( + oldFile.getAbsoluteFile().toString().replaceFirst(extensionRegex, "." + fileNum + outputExtension)); + if (destFile.exists()) { + while (destFile.exists()) { + fileNum++; + destFile = new File( + oldFile.getAbsoluteFile().toString().replaceFirst(extensionRegex, "." + fileNum + outputExtension)); + } + } + try { + Lib.copyFile(oldFile, destFile); + } catch (IOException e2) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Failed to move output file to next available spot", e2); + } + } + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/FileModel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/FileModel.java new file mode 100644 index 000000000..17ad692e7 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/FileModel.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.models; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +public class FileModel { + + private File file = null; + private IFile iFile = null; + private long lastModified = 0; + private String path = ""; + private String rawFilename = ""; + private String text = null; + + public FileModel(String rawFilename) { + this.rawFilename = rawFilename; + if (getIFile() != null) { + lastModified = getIFile().getModificationStamp(); + } + } + + public boolean exists() { + return getFile().exists(); + } + + /** + * @return Returns the file. + */ + public File getFile() { + if (file == null) { + file = new File(rawFilename); + } + return file; + } + + /** + * @return Returns the iFile for the given local data {@link #rawFilename}. You may still have to check if the file actually exists. + */ + public IFile getIFile() { + if (iFile == null) { + if (path.equals("")) { + if (!rawFilename.equals("")) { + iFile = AWorkspace.getIFile(rawFilename); + if(iFile == null){ + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(org.eclipse.core.filesystem.URIUtil.toURI(rawFilename)); + if(files.length > 0){ + iFile = files[0]; + } + } + } + } + } + return iFile; + } + + /** + * @return Returns the name. + */ + public String getName() { + return new File(rawFilename).getName(); + } + + /** + * @return Returns the path. + */ + public String getPath() { + if (iFile == null) { + iFile = getIFile(); + } + if (iFile != null) { + path = iFile.getFullPath().toString(); + } + return path; + } + + /** + * @return Returns the rawFilename. + */ + public String getRawFilename() { + return rawFilename; + } + + public String getWorkspaceRelativePath() { + IWorkspace ws = ResourcesPlugin.getWorkspace(); + IFile ifile = ws.getRoot().getFileForLocation(new Path(rawFilename)); + if(ifile == null){ + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(org.eclipse.core.filesystem.URIUtil.toURI(rawFilename)); + if(files.length > 0){ + ifile = files[0]; + } + } + if (!ifile.exists()) { + return null; + } else { + return ifile.getFullPath().toString(); + } + } + + public String getText() throws IOException { + if (iFile == null) { + getIFile(); + } + if (iFile == null) { + return ""; + } + if (text == null || iFile.getModificationStamp() != lastModified) { + text = Lib.fileToString(new File(rawFilename)); + OseeLog.log(TestManagerPlugin.class, Level.INFO, "getText: Reading file " + getName()); + } else { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "getText: Using buffered file " + getName()); + } + lastModified = iFile.getModificationStamp(); + return text; + } + + public boolean isModified() { + if (iFile == null) { + getIFile(); + } + if (iFile == null) { + OseeLog.log(TestManagerPlugin.class, Level.WARNING, "Can't Read iFile"); + return true; + } + return iFile.getModificationStamp() != lastModified; + } + + public void openEditor() { + if (getIFile() != null) { + AWorkspace.openEditor(getIFile()); + } else { + IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(file.getAbsolutePath())); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditorOnFileStore(page, fileStore); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + } + + public void openPackageExplorer() { + OseeLog.log(TestManagerPlugin.class, Level.INFO, "Show in explorer " + getName()); + // Open in Package Explorer and error if can't + boolean success = AWorkspace.showInPackageExplorer(getIFile()); + // if(!success){ + // success = AWorkspace.showInResourceNavigator(getIFile()); + // } + if (!success) { + MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Open Error", + "Can't Show in Explorer\n\n" + getName()); + } + // As a convenience, open in Navigator, but don't error + success = AWorkspace.showInResourceNavigator(getIFile()); + } + + /** + * @param path The path to set. + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @param rawFilename The rawFilename to set. + */ + public void setRawFilename(String rawFilename) { + this.rawFilename = rawFilename; + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModel.java new file mode 100644 index 000000000..646594b41 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModel.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.models; + +import java.io.File; +import java.io.FileInputStream; +import java.util.logging.Level; +import org.eclipse.osee.framework.jdk.core.util.io.xml.AbstractSaxHandler; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + +/** + * Base Class for all TestManagers + */ +public class OutputModel extends FileModel { + + private static final String OUTPUT_EXTENSION = "tmo"; + + private int failedTestPoints = 0; + private int passedTestPoints = 0; + private boolean aborted = false; + private boolean exists = false; + + public OutputModel(String rawFilename) { + super(rawFilename); + } + + public boolean doesOutfileExist() { + return exists; + } + + public void updateTestPointsFromOutfile() { + try { + File outfile = getFile(); + exists = outfile.exists(); + if (outfile.exists() && outfile.length() > 0) { + XMLReader xmlReader = XMLReaderFactory.createXMLReader(); + xmlReader.setContentHandler(new ParseTestPoints()); + xmlReader.parse(new InputSource(new FileInputStream(outfile))); + } + } catch (Exception ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + } + + public int getFailedTestPoints() { + return failedTestPoints; + } + + public int getPassedTestPoints() { + return passedTestPoints; + } + + public void setFailedTestPoints(int failedTestPoints) { + this.failedTestPoints = failedTestPoints; + } + + public void setPassedTestPoints(int passedTestPoints) { + this.passedTestPoints = passedTestPoints; + } + + private class ParseTestPoints extends AbstractSaxHandler { + + @Override + public void endElementFound(String uri, String localName, String name) throws SAXException { + } + + @Override + public void startElementFound(String uri, String localName, String name, Attributes attributes) throws SAXException { + if ("TestPointResults".equals(name)) { + String fail = attributes.getValue("fail"); + String pass = attributes.getValue("pass"); + String aborted = attributes.getValue("aborted"); + try { + failedTestPoints = Integer.parseInt(fail); + passedTestPoints = Integer.parseInt(pass); + if (aborted != null && aborted.length() > 0) { + OutputModel.this.aborted = Boolean.parseBoolean(aborted); + } + } catch (NumberFormatException ex) { + + } + } + } + } + + public String getFileExtension() { + return OUTPUT_EXTENSION; + } + + public boolean isAborted() { + return aborted; + } + + public void setAborted(boolean b) { + aborted = b; + + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.done b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.done new file mode 100644 index 000000000..bc716d4df --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.done @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.models; + +import java.util.concurrent.ConcurrentLinkedQueue; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osee.ote.ui.test.manager.connection.ScriptManager; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; + +/** + * @author b1528444 + * + */ +public class OutputModelJob extends Job { + + private static OutputModelJob singleton = null; + private ScriptManager scriptManager; + private ConcurrentLinkedQueue<ScriptTask> outputModels = new ConcurrentLinkedQueue<ScriptTask>(); + + + public static void createSingleton(ScriptManager scriptManager){ + if(singleton == null){ + singleton = new OutputModelJob(scriptManager); + } + } + + public static OutputModelJob getSingleton(){ + return singleton; + } + + /** + * @param name + */ + private OutputModelJob(ScriptManager scriptManager) { + super("Parsing OTE Output File"); + setUser(false); + this.scriptManager = scriptManager; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + while(!outputModels.isEmpty()){ + ScriptTask task = outputModels.remove(); + task.getScriptModel().getOutputModel().updateTestPointsFromOutfile(); + task.getPassFail(); + scriptManager.updateScriptTableViewerTimed(task); + } + return Status.OK_STATUS; + } + + public void addTask(ScriptTask task){ + outputModels.add(task); + schedule(); + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.java new file mode 100644 index 000000000..b7bce05ea --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/OutputModelJob.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.models; + +import java.util.concurrent.ConcurrentLinkedQueue; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osee.ote.ui.test.manager.connection.ScriptManager; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; + +/** + * @author Andrew M. Finkbeiner + */ +public class OutputModelJob extends Job { + + private static OutputModelJob singleton = null; + private final ScriptManager scriptManager; + private final ConcurrentLinkedQueue<ScriptTask> outputModels = new ConcurrentLinkedQueue<>(); + + public static void createSingleton(ScriptManager scriptManager) { + if (singleton == null) { + singleton = new OutputModelJob(scriptManager); + } + } + + public static OutputModelJob getSingleton() { + return singleton; + } + + private OutputModelJob(ScriptManager scriptManager) { + super("Parsing OTE Output File"); + setUser(false); + this.scriptManager = scriptManager; + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + while (!outputModels.isEmpty()) { + ScriptTask task = outputModels.remove(); + task.getScriptModel().getOutputModel().updateTestPointsFromOutfile(); + task.getPassFail(); + scriptManager.updateScriptTableViewerTimed(task); + } + return Status.OK_STATUS; + } + + public void addTask(ScriptTask task) { + outputModels.add(task); + schedule(); + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/ScriptModel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/ScriptModel.java new file mode 100644 index 000000000..fd8206dd7 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/models/ScriptModel.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.models; + +import java.io.File; +import org.eclipse.core.filebuffers.manipulation.ContainerCreator; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.ws.AJavaProject; +import org.eclipse.osee.ote.core.TestScript; +import org.eclipse.osee.ote.core.environment.config.ScriptVersionConfig; +import org.eclipse.osee.ote.version.FileVersion; + +public class ScriptModel extends FileModel { + + public enum ScriptInteractionEnum { + BATCH, + MANUAL, + UNKNOWN + } + + public class TestFileData { + public String absoluteFilePath = null; + public String classPath = null; + public String error = ""; + public String name = null; + public String outFile = null; + public String projectPath = null; + public String rawFileName; + + public ScriptVersionConfig getVersionInfo(FileVersion version) { + ScriptVersionConfig scriptVersion = new ScriptVersionConfig(); + if (version != null) { + scriptVersion.setLastChangedRevision(version.getLastChangedRevision()); + scriptVersion.setLocation(version.getURL()); + scriptVersion.setRepositoryType(version.getVersionControlSystem()); + scriptVersion.setLastAuthor(version.getLastAuthor()); + scriptVersion.setLastModificationDate(version.getLastModificationDate()); + scriptVersion.setModifiedFlag(version.getModifiedFlag()); + } + return scriptVersion; + } + } + + private TestFileData javaFileData; + private OutputModel outputModel; + private TestScript testScript; + + /** + * @param outputDir alternate output directory for tmo output files null will default to script directory + */ + public ScriptModel(String rawFilename, String outputDir) { + super(rawFilename); + javaFileData = new TestFileData(); + javaFileData = getSunData(outputDir); + javaFileData.rawFileName = rawFilename; + outputModel = new OutputModel(javaFileData.outFile); + } + + public ScriptInteractionEnum getInteraction() { + if (testScript == null) { + return ScriptInteractionEnum.UNKNOWN; + } + if (testScript.isBatchable()) { + return ScriptInteractionEnum.BATCH; + } else { + return ScriptInteractionEnum.MANUAL; + } + } + + /** + * @return Returns the outputModel. + */ + public OutputModel getOutputModel() { + outputModel.setRawFilename(javaFileData.outFile); + return outputModel; + + } + + /** + * @param alternateOutputDir place output files here instead of at location of the script + * @return Returns sun data. + */ + private TestFileData getSunData(String alternateOutputDir) { + javaFileData.absoluteFilePath = getRawFilename(); + String temp = null; + if (javaFileData.absoluteFilePath.endsWith(".java")) { + temp = AJavaProject.getClassName(this.getRawFilename()); + } + javaFileData.name = temp == null ? new File(getRawFilename()).getName() : temp; + javaFileData.classPath = ""; + alternateOutputDir = alternateOutputDir.trim(); + if (!Strings.isValid(alternateOutputDir)) { + javaFileData.outFile = javaFileData.absoluteFilePath.replaceFirst(".java$", ".tmo"); + if (!javaFileData.outFile.endsWith(".tmo")) { + javaFileData.outFile += ".tmo"; + } + } else { + try { + File dir = new File(alternateOutputDir); + if (dir.exists() && dir.isDirectory()) { + javaFileData.outFile = alternateOutputDir; + } else { + if (getIFile() != null) { + IProject project = getIFile().getProject(); + IFolder folder = project.getFolder(alternateOutputDir); + if (!folder.exists()) { + ContainerCreator containerCreator = + new ContainerCreator(folder.getWorkspace(), folder.getFullPath()); + containerCreator.createContainer(new NullProgressMonitor()); + } + javaFileData.outFile = folder.getLocation().toFile().getAbsolutePath(); + } + } + + javaFileData.outFile += File.separator; + javaFileData.outFile += getName(); + javaFileData.outFile = javaFileData.outFile.replaceFirst(".java$", ".tmo"); + if (!javaFileData.outFile.endsWith(".tmo")) { + javaFileData.outFile += ".tmo"; + } + } catch (CoreException ex) { + ex.printStackTrace(); + javaFileData.outFile = javaFileData.absoluteFilePath.replaceFirst(".java$", ".tmo"); + if (!javaFileData.outFile.endsWith(".tmo")) { + javaFileData.outFile += ".tmo"; + } + } + } + // outputModel = new OutputModel(javaFileData.outFile); + + // OseeLog.log(TestManagerPlugin.class, Level.FINE, "javaFileData.absoluteJavaPath *"+ javaFileData.absoluteFilePath + "*"); + // OseeLog.log(TestManagerPlugin.class, Level.FINE, "javaFileData.className *" + javaFileData.name + "*"); + // OseeLog.log(TestManagerPlugin.class, Level.FINE, "javaFileData.classPath *" + javaFileData.classPath + "*"); + // OseeLog.log(TestManagerPlugin.class, Level.FINE, "javaFileData.outFile *" + javaFileData.outFile+ "*"); + + return javaFileData; + } + + public TestFileData updateScriptModelInfo(String alternateOutputDir) { + TestFileData javaFileData = getSunData(alternateOutputDir); + outputModel = new OutputModel(javaFileData.outFile); + return javaFileData; + } + + public String getTestClass() { + return javaFileData.name; + } + + /** + * @param outputModel The outputModel to set. + */ + public void setOutputModel(OutputModel outputModel) { + this.outputModel = outputModel; + } + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/operations/AddIFileToTestManager.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/operations/AddIFileToTestManager.java new file mode 100644 index 000000000..359579e53 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/operations/AddIFileToTestManager.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.operations; + +import java.util.List; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.util.PluginUtil; +import org.eclipse.osee.ote.ui.test.manager.util.TestManagerSelectDialog; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; + +/** + * @author Roberto E. Escobar + */ +public class AddIFileToTestManager { + private static AddIFileToTestManager instance = null; + + private AddIFileToTestManager() { + } + + public static AddIFileToTestManager getOperation() { + if (instance == null) { + instance = new AddIFileToTestManager(); + } + return instance; + } + + public void removeAllScriptsFromPage() { + if (PluginUtil.areTestManagersAvailable() != true) { + AWorkbench.popup("ERROR", "Test Manager Not Opened"); + return; + } + for (TestManagerEditor editor : PluginUtil.getTestManagers()) { + editor.getPageManager().getScriptPage().getScriptTableViewer().getTaskList().removeAllTasks(); + } + } + + public void addFilesToScriptPage(List<String> files, boolean removeOtherScripts) { + if (PluginUtil.areTestManagersAvailable() != true) { + AWorkbench.popup("ERROR", "Test Manager Not Opened"); + return; + } + TestManagerEditor[] itemsToOpen = PluginUtil.getTestManagers(); + for (TestManagerEditor tme : itemsToOpen) { + if (removeOtherScripts) { + tme.getPageManager().getScriptPage().getScriptTableViewer().getTaskList().removeAllTasks(); + } + tme.addFiles(files.toArray(new String[files.size()])); + } + } + + public void addIFileToScriptsPage(String[] fullPath) { + if (PluginUtil.areTestManagersAvailable() != true) { + AWorkbench.popup("ERROR", "Test Manager Not Opened"); + return; + } + TestManagerEditor[] itemsToOpen = PluginUtil.getTestManagers(); + if (itemsToOpen.length > 1) { + TestManagerEditor[] selected = TestManagerSelectDialog.getTestManagerFromUser(); + if (selected.length > 0) { + for(int i = 0; i < fullPath.length; i++){ + handleItemsSelected(itemsToOpen, fullPath[i]); + } + } + } else { + for(int i = 0; i < fullPath.length; i++){ + handleItemsSelected(itemsToOpen, fullPath[i]); + } + } + } + + private void handleItemsSelected(TestManagerEditor[] items, String fullPath) { + for (TestManagerEditor tme : items) { + tme.addFile(fullPath); + } + openFirstItemSelected(items); + } + + private void openFirstItemSelected(TestManagerEditor[] items) { + // Show first Test Manager Editor + TestManagerEditor tme = items[0]; + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + page.activate(tme.getSite().getPart()); + tme.activateScriptsPage(); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/AdvancedPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/AdvancedPage.java new file mode 100644 index 000000000..0e3880cf0 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/AdvancedPage.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.logging.Level; +import org.eclipse.osee.framework.jdk.core.type.IPropertyStore; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; +import org.eclipse.osee.framework.ui.plugin.widgets.IPropertyStoreBasedControl; +import org.eclipse.osee.framework.ui.plugin.widgets.PropertyStoreControlContributions; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +public class AdvancedPage extends TestManagerPage { + + public static final OseeUiActivator plugin = TestManagerPlugin.getInstance(); + private static final String pageName = "Advanced"; + private final List<IPropertyStoreBasedControl> contributions; + private volatile boolean contributionsInitialized; + + public AdvancedPage(Composite parent, int style, TestManagerEditor parentTestManager) { + super(parent, style, parentTestManager); + this.contributions = new ArrayList<>(); + contributionsInitialized = false; + } + + private synchronized List<IPropertyStoreBasedControl> getContributions() { + if (!contributionsInitialized) { + contributionsInitialized = true; + contributions.addAll(PropertyStoreControlContributions.getContributions(TestManagerPlugin.PLUGIN_ID)); + } + return contributions; + } + + @Override + public void createPage() { + super.createPage(); + Composite parent = (Composite) getContent(); + Composite extensionPanel = new Composite(parent, SWT.NONE); + GridLayout gL = new GridLayout(); + gL.marginWidth = 0; + gL.marginHeight = 0; + extensionPanel.setLayout(gL); + extensionPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + + Collections.sort(getContributions(), new Comparator<IPropertyStoreBasedControl>() { + + @Override + public int compare(IPropertyStoreBasedControl o1, IPropertyStoreBasedControl o2) { + return Integer.valueOf(o1.getPriority()).compareTo(Integer.valueOf(o2.getPriority())); + } + }); + for (IPropertyStoreBasedControl widget : getContributions()) { + + try { + widget.createControl(extensionPanel); + } catch (Throwable e) { + TestManagerPlugin.log(Level.SEVERE, "problem creating advance page contribution", e); + } + } + + createBlankArea(parent, 0, true); + computeScrollSize(); + + // TODO: Change to use OteHelpContext + HelpUtil.setHelp(this, "test_manager_advanced_page", "org.eclipse.osee.ote.help.ui"); + } + + @Override + public String getPageName() { + return pageName; + } + + private Control createBlankArea(Composite parent, int height, boolean allVertical) { + Composite blank = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + GridData gd = new GridData(); + gd.minimumHeight = height; + gd.grabExcessHorizontalSpace = true; + gd.grabExcessVerticalSpace = allVertical; + blank.setLayout(gridLayout); + blank.setLayoutData(gd); + return parent; + } + + protected void createAreaDefaultLayout(Composite parent, boolean allHorizontal, boolean allVertical) { + GridLayout layout = new GridLayout(); + GridData data = new GridData(GridData.FILL_BOTH); + data.grabExcessHorizontalSpace = allHorizontal; + data.grabExcessVerticalSpace = allVertical; + parent.setLayout(layout); + parent.setLayoutData(data); + } + + @Override + public void saveData() { + IPropertyStore propertyStore = getTestManager().getPropertyStore(); + for (IPropertyStoreBasedControl contribution : getContributions()) { + contribution.save(propertyStore); + } + } + + @Override + public void restoreData() { + IPropertyStore propertyStore = getTestManager().getPropertyStore(); + for (IPropertyStoreBasedControl contribution : getContributions()) { + contribution.load(propertyStore); + } + } + + @Override + public boolean areSettingsValidForRun() { + boolean result = true; + for (IPropertyStoreBasedControl contribution : getContributions()) { + result &= contribution.areSettingsValid(); + } + return result; + } + + @Override + public String getErrorMessage() { + StringBuilder builder = new StringBuilder(); + for (IPropertyStoreBasedControl contribution : getContributions()) { + String message = contribution.getErrorMessage(); + if (Strings.isValid(message)) { + if (builder.length() > 0) { + builder.append("\n"); + } + builder.append(message); + } + } + return builder.toString(); + } + + @Override + public boolean onConnection(ConnectionEvent event) { + return false; + } + + @Override + public boolean onDisconnect(ConnectionEvent event) { + return false; + } + + @Override + public boolean onConnectionLost() { + return false; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/HostPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/HostPage.java new file mode 100644 index 000000000..4ad76fa68 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/HostPage.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages; + +import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; + +public class HostPage extends TestManagerPage { + + private static final String pageName = "Hosts"; + + public HostPage(Composite parent, int style, TestManagerEditor parentTestManager) { + super(parent, style, parentTestManager); + createPage(); + + // TODO: Change to use OteHelpContext + HelpUtil.setHelp(this, "test_manager_hosts_page", "org.eclipse.osee.ote.help.ui"); + } + + @Override + public String getPageName() { + return pageName; + } + + @Override + protected void createPage() { + super.createPage(); + Composite parent = (Composite) getContent(); + + Group hostGroup = new Group(parent, SWT.NONE); + hostGroup.setLayout(new GridLayout()); + hostGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + hostGroup.setText("Double click a Host to Connect/Disconnect"); + + getTestManager().createHostWidget(hostGroup); + setMinSize(0, 0); + } + + @Override + public boolean areSettingsValidForRun() { + return getTestManager().isConnected(); + } + + @Override + public void restoreData() { + // Do Nothing + } + + @Override + public void saveData() { + // Do Nothing + } + + @Override + public String getErrorMessage() { + StringBuilder builder = new StringBuilder(); + if (areSettingsValidForRun() != true) { + builder.append("Connect to a Test Server"); + } + return builder.toString(); + } + + @Override + public boolean onConnection(ConnectionEvent event) { + return false; + + } + + @Override + public boolean onDisconnect(ConnectionEvent event) { + return false; + + } + + @Override + public boolean onConnectionLost() { + return false; + } + + @Override + public void dispose() { + super.dispose(); + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java new file mode 100644 index 000000000..c79672397 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java @@ -0,0 +1,476 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages; + +import java.rmi.RemoteException; +import java.util.Timer; +import java.util.TimerTask; +import java.util.logging.Level; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.configuration.LoadWidget; +import org.eclipse.osee.ote.ui.test.manager.configuration.SaveWidget; +import org.eclipse.osee.ote.ui.test.manager.connection.ScriptManager; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.jobs.ScriptRunJob; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.CoolBar; +import org.eclipse.swt.widgets.CoolItem; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +public abstract class ScriptPage extends TestManagerPage { + + private static final String NOT_CONNECTED = "<< NOT_CONNECTED >>"; + private static final int ABORT_BTN_TIMER = 5000; + + public enum UpdateableLabel { + HOSTLABEL, + CONFIGPATHLABEL; + } + + public static final OseeUiActivator plugin = TestManagerPlugin.getInstance(); + private static final String pageName = "Scripts"; + private ToolItem abortButton; + private ToolItem abortBatchButton; + private CoolBar coolBar; + private ToolItem deleteButton; + private Label hostConnectLabel; + private LoadWidget loadWidget; + protected ToolItem runButton; + private SaveWidget saveWidget; + private ScriptTableViewer scriptTable; + private StatusWindowWidget statusWindow; + private final TestManagerEditor testManagerEditor; + + public ScriptPage(Composite parent, int style, TestManagerEditor parentTestManager) { + super(parent, style, parentTestManager); + this.testManagerEditor = parentTestManager; + } + + public void addFile(String fullPath) { + scriptTable.addFile(fullPath); + } + + @Override + public void createPage() { + super.createPage(); + Composite parent = (Composite) getContent(); + coolBar = new CoolBar(parent, SWT.FLAT); + + createControlsToolBar(coolBar); + createConfigurationToolBar(coolBar); + packCoolBar(); + + SashForm sashForm = new SashForm(parent, SWT.NONE); + sashForm.setLayout(new GridLayout()); + sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + sashForm.setOrientation(SWT.VERTICAL); + sashForm.SASH_WIDTH = 3; + + createScriptTableSection(sashForm); + createStatusWindow(sashForm); + + sashForm.setWeights(new int[] {8, 2}); + setMinSize(0, 0); + + // TODO: Change to use OteHelpContext + HelpUtil.setHelp(this, "test_manager_scripts_page", "org.eclipse.osee.framework.help.ui"); + } + + public void loadStorageString() { + scriptTable.loadStorageString(testManagerEditor.loadValue(testManagerEditor.scriptsQualName)); + } + + @Override + public void dispose() { + scriptTable.dispose(); + testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString()); + OseeLog.log(TestManagerPlugin.class, Level.INFO, "ScriptPage Dispose Called"); + super.dispose(); + } + + public CoolBar getCoolBar() { + return coolBar; + } + + public String getOFP() { + if (hostConnectLabel == null) { + return ""; + } + return hostConnectLabel.getText(); + } + + @Override + public String getPageName() { + return pageName; + } + + public String getScripts() { + if (scriptTable == null) { + return ""; + } else if (scriptTable.getTaskList() == null) { + return ""; + } + return scriptTable.getTaskList().toString(); + } + + public ScriptTableViewer getScriptTableViewer() { + return scriptTable; + } + + public StatusWindowWidget getStatusWindow() { + return statusWindow; + } + + public void onScriptRunning(final boolean running) { + AWorkbench.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + if(runButton.isDisposed()){ + return; + } + if (running) { + runButton.setEnabled(false); + abortButton.setEnabled(true); + abortBatchButton.setEnabled(true); + } else { + runButton.setEnabled(true); + abortButton.setEnabled(false); + abortBatchButton.setEnabled(false); + } + } + }); + } + + public void packCoolBar() { + Point size = this.getSize(); + coolBar.setSize(coolBar.computeSize(size.x, size.y)); + } + + private void createConfigurationToolBar(CoolBar coolBar) { + CoolItem configCoolItem = new CoolItem(coolBar, SWT.NONE); + ToolBar configToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL); + + saveWidget = new SaveWidget(this); + saveWidget.createToolItem(configToolBar); + + loadWidget = new LoadWidget(this); + loadWidget.createToolItem(configToolBar); + + deleteButton = new ToolItem(configToolBar, SWT.PUSH | SWT.CENTER); + deleteButton.setImage(ImageManager.getImage(OteTestManagerImage.FILE_DELETE)); + deleteButton.setToolTipText("Deletes Selected (highlighted) Scripts"); + deleteButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleDeleteButton(); + } + }); + deleteButton.addListener(SWT.MouseUp, new Listener() { + @Override + public void handleEvent(Event e) { + if (e.button == 3) { + handleDeleteButton(); + } + } + }); + + configToolBar.pack(); + + Point size = configToolBar.getSize(); + configCoolItem.setControl(configToolBar); + configCoolItem.setSize(configCoolItem.computeSize(size.x, size.y)); + configCoolItem.setMinimumSize(size); + } + + private void createControlsToolBar(CoolBar coolBar) { + CoolItem controlsCoolItem = new CoolItem(coolBar, SWT.NONE); + ToolBar controlsToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL); + + runButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); + runButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_RUN_EXEC)); + runButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_RUN_EXEC)); + runButton.setToolTipText("Runs the Checked Scripts"); + runButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleRunButton(); + } + }); + runButton.addListener(SWT.MouseUp, new Listener() { + @Override + public void handleEvent(Event e) { + if (e.button == 3) { + handleRunButton(); + } + } + }); + runButton.setEnabled(false); + + // Create and configure the "Abort" button + abortButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); + abortButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_ABORT_STOP)); + abortButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_ABORT_STOP)); + abortButton.setToolTipText("Abort Currently Running Script"); + abortButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleAbortButton(); + abortBatchButton.setEnabled(false); + abortButton.setEnabled(false); + Timer timer = new Timer(); + timer.schedule(new EnabledAbortsTimer(), ABORT_BTN_TIMER); + } + }); + abortButton.addListener(SWT.MouseUp, new Listener() { + @Override + public void handleEvent(Event e) { + if (e.button == 3) { + handleAbortButton(); + abortBatchButton.setEnabled(false); + abortButton.setEnabled(false); + Timer timer = new Timer(); + timer.schedule(new EnabledAbortsTimer(), ABORT_BTN_TIMER); + } + } + }); + abortButton.setEnabled(false); + + abortBatchButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER); + abortBatchButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_BATCH_ABORT_STOP)); + abortBatchButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_BATCH_ABORT_STOP)); + abortBatchButton.setToolTipText("Abort Script Batch"); + abortBatchButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleBatchAbortButton(); + abortBatchButton.setEnabled(false); + abortButton.setEnabled(false); + Timer timer = new Timer(); + timer.schedule(new EnabledAbortsTimer(), ABORT_BTN_TIMER); + } + }); + abortBatchButton.addListener(SWT.MouseUp, new Listener() { + @Override + public void handleEvent(Event e) { + if (e.button == 3) { + handleBatchAbortButton(); + abortBatchButton.setEnabled(false); + abortButton.setEnabled(false); + Timer timer = new Timer(); + timer.schedule(new EnabledAbortsTimer(), ABORT_BTN_TIMER); + } + } + }); + abortBatchButton.setEnabled(false); + + controlsToolBar.pack(); + + Point size = controlsToolBar.getSize(); + controlsCoolItem.setControl(controlsToolBar); + controlsCoolItem.setSize(controlsCoolItem.computeSize(size.x, size.y)); + controlsCoolItem.setMinimumSize(size); + } + + private void createScriptTableSection(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + scriptTable = new ScriptTableViewer(composite, this.getTestManager()); + // scriptTable.addDisposeListener(new DisposeListener() { + // public void widgetDisposed(DisposeEvent e) { + // testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString()); + // } + // }); + + } + + private void createStatusWindow(Composite parent) { + statusWindow = new StatusWindowWidget(parent); + + statusWindow.setLabelAndValue(UpdateableLabel.HOSTLABEL.name(), "Selected Host", NOT_CONNECTED, SWT.BOLD, + SWT.COLOR_DARK_RED); + + String selectedFile = testManagerEditor.loadValue(testManagerEditor.configFileName); + if (!Strings.isValid(selectedFile)) { + selectedFile = testManagerEditor.getDefaultConfigPath(); + testManagerEditor.storeValue(testManagerEditor.configFileName, selectedFile); + } + OseeLog.log(TestManagerPlugin.class, Level.INFO, "The default config is: " + selectedFile); + + statusWindow.setLabelAndValue(UpdateableLabel.CONFIGPATHLABEL.name(), "Config File Path", selectedFile); + + saveWidget.setStatusLabel(statusWindow); + loadWidget.setStatusLabel(statusWindow); + + // // Status ICON Labels + // connectStatusIconLabel = new + // Label(statusWindow.getStatusIconComposite(), SWT.NONE); + // hostWidget.setConnectStatusLabel(connectStatusIconLabel); + // connectStatusIconLabel.setVisible(false); + + statusWindow.refresh(); + } + + // TODO this stuff needs some updating too... + protected void handleAbortButton() { + TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script..."); + try { + getScriptManager().abortScript(false); + } catch (RemoteException e) { + TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e)); + } + } + + // TODO this stuff needs some updating too... + protected void handleBatchAbortButton() { + TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script Batch..."); + try { + getScriptManager().abortScript(true); + } catch (RemoteException e) { + TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e)); + } + } + + private void handleDeleteButton() { + scriptTable.removeSelectedTasks(); + } + + private void handleRunButton() { + ScriptRunJob runJob = new ScriptRunJob(getTestManager()); + if (runJob.isRunAllowed()) { + runJob.setPriority(Job.LONG); + runJob.setUser(true); + runJob.schedule(); + } else { + MessageDialog.openError(Displays.getActiveShell(), "Error", runJob.getErrorMessage()); + } + } + + private class EnabledAbortsTimer extends TimerTask { + + @Override + public void run() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + try { + if (!runButton.isEnabled()) { + abortBatchButton.setEnabled(true); + abortButton.setEnabled(true); + } + } catch (Throwable th) { + + } + } + }); + + } + + } + + @Override + public boolean areSettingsValidForRun() { + return getScriptTableViewer().getRunTasks().size() > 0; + } + + @Override + public String getErrorMessage() { + StringBuilder builder = new StringBuilder(); + if (getScriptTableViewer().getRunTasks().size() <= 0) { + builder.append("Scripts not selected."); + } + return builder.toString(); + } + + @Override + public boolean onConnection(final ConnectionEvent event) { + boolean result = getScriptManager().connect(event); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + runButton.setEnabled(true); + abortButton.setEnabled(false); + abortBatchButton.setEnabled(false); + scriptTable.onConnectionChanged(true); + statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), event.getProperties().getStation(), SWT.BOLD, + SWT.COLOR_DARK_GREEN); + statusWindow.refresh(); + } + + }); + return result; + } + + @Override + public boolean onDisconnect(ConnectionEvent event) { + boolean result = getScriptManager().disconnect(event); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + runButton.setEnabled(false); + abortButton.setEnabled(false); + abortBatchButton.setEnabled(false); + scriptTable.onConnectionChanged(false); + statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED); + statusWindow.refresh(); + } + }); + return result; + } + + @Override + public boolean onConnectionLost() { + boolean result = getScriptManager().onConnectionLost(); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + runButton.setEnabled(false); + abortButton.setEnabled(false); + abortBatchButton.setEnabled(false); + scriptTable.onConnectionChanged(false); + statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED); + statusWindow.refresh(); + } + }); + return result; + } + + public abstract ScriptManager getScriptManager(); + + public void addFiles(String[] files) { + scriptTable.addFiles(files); + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java new file mode 100644 index 000000000..61d168417 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.framework.ui.swt.FormattedText; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Roberto E. Escobar + */ +public class StatusWindowWidget { + private final Map<String, Map<EntryAttribute, Object>> labelValueMap; + private final List<String> keys; + private final FormattedText statusTextArea; + + private enum EntryAttribute { + LABEL, + VALUE, + STYLE, + COLOR; + } + + public StatusWindowWidget(Composite parent) { + keys = new ArrayList<>(); + labelValueMap = new HashMap<>(); + statusTextArea = new FormattedText(parent, SWT.BORDER, SWT.DEFAULT, SWT.DEFAULT, false); + statusTextArea.setTextAreaBackground(SWT.COLOR_WHITE); + } + + public void setLabelAndValue(String key, String label, String value, int style, int color) { + if (!keys.contains(key)) { + keys.add(key); + } + Map<EntryAttribute, Object> entry = new HashMap<>(); + entry.put(EntryAttribute.LABEL, label); + entry.put(EntryAttribute.VALUE, value); + entry.put(EntryAttribute.STYLE, new Integer(style)); + entry.put(EntryAttribute.COLOR, new Integer(color)); + + labelValueMap.put(key, entry); + } + + public void setLabelAndValue(String key, String label, String value) { + setLabelAndValue(key, label, value, SWT.NORMAL, SWT.COLOR_BLACK); + } + + public String getValue(String key) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + EntryAttribute attribute = EntryAttribute.VALUE; + return entry != null && entry.get(attribute) != null ? (String) entry.get(attribute) : ""; + } + + public String getLabel(String key) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + EntryAttribute attribute = EntryAttribute.LABEL; + return entry != null && entry.get(attribute) != null ? (String) entry.get(attribute) : ""; + } + + public void setLabel(String key, String label) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + entry.put(EntryAttribute.LABEL, label); + } else { + setLabelAndValue(key, label, ""); + } + } + + public void setValueStyle(String key, int style) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + entry.put(EntryAttribute.STYLE, new Integer(style)); + } + } + + public void setValueColor(String key, int color) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + entry.put(EntryAttribute.STYLE, new Integer(color)); + } + } + + public void setValue(String key, String value, int style, int color) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + entry.put(EntryAttribute.VALUE, value); + entry.put(EntryAttribute.STYLE, new Integer(style)); + entry.put(EntryAttribute.COLOR, new Integer(color)); + } else { + setLabelAndValue(key, "", value, style, color); + } + } + + public void setValue(String key, String value) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + entry.put(EntryAttribute.VALUE, value); + } else { + setLabelAndValue(key, "", value); + } + } + + public void refresh() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if(!statusTextArea.isDisposed()){ + statusTextArea.clearTextArea(); + for (String key : keys) { + Map<EntryAttribute, Object> entry = labelValueMap.get(key); + if (entry != null) { + String label = (String) entry.get(EntryAttribute.LABEL); + String value = (String) entry.get(EntryAttribute.VALUE); + Integer style = (Integer) entry.get(EntryAttribute.STYLE); + Integer color = (Integer) entry.get(EntryAttribute.COLOR); + statusTextArea.addText("\t" + label + ": ", SWT.BOLD, SWT.COLOR_DARK_BLUE); + statusTextArea.addText(value + "\n", style, color); + } + } + } + } + }); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/TestManagerPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/TestManagerPage.java new file mode 100644 index 000000000..d35c44adc --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/TestManagerPage.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages; + +import org.eclipse.osee.ote.service.ConnectionEvent; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +/** + * @author David Diepenbrock + */ +public abstract class TestManagerPage extends ScrolledComposite { + + private final TestManagerEditor testManager; + private Composite mainComposite; + + public TestManagerPage(Composite parent, int style, TestManagerEditor parentTestManager) { + super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL); + this.testManager = parentTestManager; + } + + protected void createPage() { + GridLayout gridLayout = new GridLayout(1, true); + this.setLayout(gridLayout); + + this.mainComposite = new Composite(this, SWT.NONE); + this.mainComposite.setLayout(new GridLayout()); + this.mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + this.setContent(mainComposite); + this.setExpandHorizontal(true); + this.setExpandVertical(true); + getVerticalBar().setIncrement(25); + getVerticalBar().setPageIncrement(200); + getHorizontalBar().setIncrement(25); + getHorizontalBar().setPageIncrement(200); + } + + public void computeScrollSize() { + this.computeScrollSize(mainComposite); + } + + private void computeScrollSize(Composite viewableArea) { + this.setMinSize(viewableArea.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + } + + public TestManagerEditor getTestManager() { + return testManager; + } + + public abstract String getPageName(); + + public abstract void saveData(); + + public abstract void restoreData(); + + public abstract boolean areSettingsValidForRun(); + + public abstract String getErrorMessage(); + + /** + * called when test manager is connected to a test host. A return value of true will cause test manager to prompt the + * user to check the log. Thus any problems that occur during connection processing should be handled and logged. + * + * @return true if there were problems during processing and false otherwise. + */ + public abstract boolean onConnection(ConnectionEvent event); + + public abstract boolean onDisconnect(ConnectionEvent event); + + public abstract boolean onConnectionLost(); + + @Override + public void dispose() { + super.dispose(); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/ScriptExecutionContribution.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/ScriptExecutionContribution.java new file mode 100644 index 000000000..b2b352fcc --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/ScriptExecutionContribution.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.contributions; + +import org.eclipse.osee.framework.jdk.core.type.IPropertyStore; +import org.eclipse.osee.framework.ui.plugin.widgets.IPropertyStoreBasedControl; +import org.eclipse.osee.ote.ui.test.manager.panels.FileOrDirectorySelectionPanel; +import org.eclipse.osee.ote.ui.test.manager.panels.LoggingPanel; +import org.eclipse.osee.ote.ui.test.manager.panels.ScriptExecutionOptionsPanel; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; + +/** + * @author Roberto E. Escobar + */ +public class ScriptExecutionContribution implements IPropertyStoreBasedControl { + private static final String GROUP_TITLE = "Script Execution Options"; + private static final String LOGGING_GROUP = "Select a logging level"; + private static final String EXECUTION_OPTIONS_GROUP = "Execution Options"; + private static final String SCRIPT_OUTPUT_TOOLTIP = + "If the path in the text box is an existing directory all files will be written there.\n" + "If the path is empty the files will be written to the same location as the script.\n" + "In all other cases the path will be relative to the parent project of the file.\n"; + private static final String SCRIPT_OUTPUT_LABEL = "Script Output Directory: "; + + private FileOrDirectorySelectionPanel scriptDirectoryPanel; + private LoggingPanel loggingPanel; + private ScriptExecutionOptionsPanel optionsPanel; + + @Override + public Control createControl(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout()); + group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + group.setText(GROUP_TITLE); + + this.scriptDirectoryPanel = + new FileOrDirectorySelectionPanel(group, SWT.NONE, SCRIPT_OUTPUT_LABEL, SCRIPT_OUTPUT_TOOLTIP, true); + + Composite composite = new Composite(group, SWT.NONE); + GridLayout gl = new GridLayout(2, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + composite.setLayout(gl); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + + Group scriptOptionsGroup = new Group(composite, SWT.NONE); + scriptOptionsGroup.setLayout(new GridLayout()); + scriptOptionsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + scriptOptionsGroup.setText(EXECUTION_OPTIONS_GROUP); + + this.optionsPanel = new ScriptExecutionOptionsPanel(scriptOptionsGroup, SWT.NONE); + + Group loggingGroup = new Group(composite, SWT.NONE); + loggingGroup.setLayout(new GridLayout()); + loggingGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + loggingGroup.setText(LOGGING_GROUP); + + this.loggingPanel = new LoggingPanel(loggingGroup, SWT.NONE); + return group; + } + + @Override + public void load(IPropertyStore propertyStore) { + this.scriptDirectoryPanel.setSelected(propertyStore.get(TestManagerStorageKeys.SCRIPT_OUTPUT_DIRECTORY_KEY)); + + this.optionsPanel.setKeepOldCopiesEnabled(propertyStore.getBoolean(TestManagerStorageKeys.KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY)); + this.optionsPanel.setBatchModeEnabled(propertyStore.getBoolean(TestManagerStorageKeys.BATCH_MODE_ENABLED_KEY)); + this.optionsPanel.setAbortOnFail(propertyStore.getBoolean(TestManagerStorageKeys.ABORT_ON_FAIL_KEY)); + this.optionsPanel.setPauseOnFail(propertyStore.getBoolean(TestManagerStorageKeys.PAUSE_ON_FAIL_KEY)); + this.optionsPanel.setPrintFailToConsole(propertyStore.getBoolean(TestManagerStorageKeys.PRINT_FAIL_TO_CONSOLE)); + + this.loggingPanel.setSelected(propertyStore.get(TestManagerStorageKeys.LOGGING_LEVEL_KEY)); + } + + @Override + public void save(IPropertyStore propertyStore) { + propertyStore.put(TestManagerStorageKeys.SCRIPT_OUTPUT_DIRECTORY_KEY, this.scriptDirectoryPanel.getSelected()); + + propertyStore.put(TestManagerStorageKeys.LOGGING_LEVEL_KEY, this.loggingPanel.getSelected()); + + propertyStore.put(TestManagerStorageKeys.KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY, + this.optionsPanel.isKeepOldCopiesEnabled()); + propertyStore.put(TestManagerStorageKeys.BATCH_MODE_ENABLED_KEY, this.optionsPanel.isBatchModeEnabled()); + propertyStore.put(TestManagerStorageKeys.ABORT_ON_FAIL_KEY, this.optionsPanel.isAbortOnFail()); + propertyStore.put(TestManagerStorageKeys.PAUSE_ON_FAIL_KEY, this.optionsPanel.isPauseOnFail()); + propertyStore.put(TestManagerStorageKeys.PRINT_FAIL_TO_CONSOLE, this.optionsPanel.isPrintFailToConsole()); + } + + @Override + public boolean areSettingsValid() { + return scriptDirectoryPanel.isValid(); + } + + @Override + public String getErrorMessage() { + StringBuilder builder = new StringBuilder(); + if (scriptDirectoryPanel.isValid() != true) { + builder.append("Script Output Directory: "); + builder.append(scriptDirectoryPanel.getErrorMessage()); + } + return builder.toString(); + } + + @Override + public int getPriority() { + return 0; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/TestManagerStorageKeys.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/TestManagerStorageKeys.java new file mode 100644 index 000000000..628b913aa --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/contributions/TestManagerStorageKeys.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.contributions; + + +/** + * @author Roberto E. Escobar + */ +public class TestManagerStorageKeys { + + public static final String BATCH_MODE_ENABLED_KEY = "is.batch.mode.enabled"; + public static final String KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY = "is.keep.old.outfile.copies.enabled"; + public static final String ABORT_ON_FAIL_KEY = "is.abort.mode.enabled"; + public static final String PAUSE_ON_FAIL_KEY = "is.pause.mode.enabled"; + public static final String PRINT_FAIL_TO_CONSOLE = "is.print.fail.enabled"; + public static final String LOGGING_LEVEL_KEY = "logging.level"; + public static final String SCRIPT_OUTPUT_DIRECTORY_KEY = "script.output.directory"; + + private TestManagerStorageKeys() { + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ITaskListViewer.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ITaskListViewer.java new file mode 100644 index 000000000..1a2302136 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ITaskListViewer.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable; + +public interface ITaskListViewer { + + /** + * Update the view to reflect the fact that a task was added to the task list + */ + public void addTask(ScriptTask task); + + /** + * Update the view to reflect the fact that multiple tasks were added to the task list + */ + public void addTasks(ScriptTask[] tasks); + + /** + * Update the view to reflect the fact that a task was removed from the task list + */ + public void removeTask(ScriptTask task); + + /** + * Update the view to reflect the fact that one of the tasks was modified + */ + public void updateTask(ScriptTask task); +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTableViewer.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTableViewer.java new file mode 100644 index 000000000..59ab45060 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTableViewer.java @@ -0,0 +1,528 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable; + +import java.io.File; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; +import java.util.logging.Level; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.nebula.widgets.xviewer.XViewer; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.util.OseeData; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.plugin.PluginUiImage; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.markers.MarkerPlugin; +import org.eclipse.osee.ote.ui.test.manager.configuration.ConfigFactory; +import org.eclipse.osee.ote.ui.test.manager.configuration.ILoadConfig; +import org.eclipse.osee.ote.ui.test.manager.configuration.ISaveConfig; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.models.OutputModel; +import org.eclipse.osee.ote.ui.test.manager.models.OutputModelJob; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript.XScriptTable; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript.XScriptTableContentProvider; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript.XScriptTableLabelProvider; +import org.eclipse.osee.ote.ui.test.manager.util.Dialogs; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTarget; +import org.eclipse.swt.dnd.DropTargetAdapter; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.DropTargetListener; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ResourceTransfer; + +public class ScriptTableViewer { + + private final ScriptTaskList taskList = new ScriptTaskList(); + private TestManagerEditor testManagerEditor = null; + final int POPUP_NAVIGATOR = 2; + final int POPUP_OUTPUT = 0; + final int POPUP_SCRIPT = 1; + final int POPUP_RESULTS = 3; + private XScriptTable scriptTable; + + public ScriptTableViewer(Composite parent, TestManagerEditor editor) { + this.testManagerEditor = editor; + createWidget(parent); + } + + public ScriptTableViewer(Composite parent, TestManagerEditor editor, List<ScriptTask> scriptList) { + this(parent, editor); + taskList.addTasks(scriptList); + } + + public void addFile(String fullPath) { + processDroppedFiles(new String[] {fullPath}); + } + + /* + * Close the window and dispose of resources + */ + public void close() { + // Shell shell = table.getShell(); + // if (shell != null && !shell.isDisposed()) shell.dispose(); + } + + /** + * Release resources + */ + public void dispose() { + scriptTable.dispose(); + // Tell the label provider to release its resources + // tableViewer.getLabelProvider().dispose(); + } + + /** + * Return the column names in a collection + * + * @return List containing column names + */ + // public List<String> getColumnNames() { + // return Arrays.asList(columnNames); + // } + /** + * Return the parent composite + */ + // public Control getControl() { + // return table.getParent(); + // } + /** + * Get all tasks marked for run. + * + * @return Vector of ScriptTask to run + */ + public List<ScriptTask> getRunTasks() { + return scriptTable.getVisibleSortedScriptTasksToRun(); + } + + /** + * @return currently selected item + */ + public ISelection getSelection() { + return scriptTable.getSelection(); + } + + /** + * Get string of scripts and run selections for storage + * + * @return <script>-ISRUN-, <script>, <script>-ISRUN + */ + public String getStorageString() { + File file = OseeData.getFile("tm.xml"); + String configFile = testManagerEditor.loadValue(testManagerEditor.configFileName); + ISaveConfig saveConfig = + ConfigFactory.getInstance().getSaveConfigHandler(testManagerEditor.getPageManager().getScriptPage()); + try { + saveConfig.saveConfig(file); + } catch (Exception ex) { + Dialogs.popupError("Error Loading File", + String.format("Error loading file: [%s]\n%s", configFile, OseeUiActivator.getStackMessages(ex))); + } + + return "file:"; + } + + /** + * Return the ExampleTaskList + */ + public ScriptTaskList getTaskList() { + return taskList; + } + + public Vector<ScriptTask> getTasks() { + return taskList.getTasks(); + } + + /** + * @return Returns the testManagerEditor. + */ + public TestManagerEditor getTestManagerEditor() { + return testManagerEditor; + } + + /** + * Set taskList from input list of scripts and run selections + * + * @param str <script>-ISRUN-, <script>, <script>-ISRUN + */ + public void loadStorageString(String str) { + OseeLog.logf(TestManagerPlugin.class, Level.INFO, "Storage String [%s]", str); + if (str != null) { + if (str.equals("file:")) { + File configFile = OseeData.getFile("tm.xml"); + ILoadConfig loadConfig = + ConfigFactory.getInstance().getLoadConfigHandler(this.testManagerEditor.getPageManager().getScriptPage()); + try { + loadConfig.loadConfiguration(configFile); + } catch (Exception ex) { + Dialogs.popupError("Error Saving File", + String.format("Error saving file: [%s]\n%s", configFile, OseeUiActivator.getStackMessages(ex))); + } + } else { + String scripts[] = str.split(","); + for (int i = 0; i < scripts.length; i++) { + String script = scripts[i]; + if (!script.equals("")) { + boolean run = false; + if (script.endsWith("-ISRUN-")) { + run = true; + script = script.replaceFirst("-ISRUN-", ""); + } + try { + ScriptTask task = new ScriptTask(script, testManagerEditor.getAlternateOutputDir()); + task.setRun(run); + taskList.addTask(task); + } catch (Exception ex) { + OseeLog.logf(TestManagerPlugin.class, Level.SEVERE, + ex, "Unable to add file [%s] to script view.", script); + } + } + } + } + } + refresh(); + } + + public void loadTasksFromList(Vector<ScriptTask> tasks) { + taskList.removeAllTasks(); + taskList.addTasks(tasks); + refresh(); + } + + public void onConnectionChanged(boolean connected) { + taskList.onConnected(connected); + refresh(); + } + + public void refresh() { + scriptTable.refresh(); + } + + public void refresh(ScriptTask task) { + scriptTable.refresh(task); + } + + public void removeSelectedTasks() { + IStructuredSelection sel = (IStructuredSelection) scriptTable.getSelection(); + Iterator<?> iter = sel.iterator(); + while (iter.hasNext()) { + ScriptTask task = (ScriptTask) iter.next(); + if (task != null) { + taskList.removeTask(task); + } + } + refresh(); + } + + /** + * Calls setRun() on all of the tasks in the table with runState. + * + * @param runState - the state to set all of the tasks's run value to + */ + public void setAllTasksRun(boolean runState) { + Iterator<ScriptTask> iter = taskList.getTasks().iterator(); + while (iter.hasNext()) { + ScriptTask task = iter.next(); + task.setRun(runState); + taskList.taskChanged(task); + } + refresh(); + } + + /** + * Create a new shell, add the widgets, open the shell + */ + private void createWidget(Composite parent) { + scriptTable = new XScriptTable(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); + scriptTable.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); + scriptTable.setContentProvider(new XScriptTableContentProvider()); + scriptTable.setLabelProvider(new XScriptTableLabelProvider(scriptTable)); + scriptTable.setInput(taskList); + attachDragDropListener(); + attachKeyListeners(); + scriptTable.getMenuManager().addMenuListener(new IMenuListener() { + @Override + public void menuAboutToShow(IMenuManager manager) { + getPopupMenu(); + } + }); + } + + private void attachDragDropListener() { + final FileTransfer fileTransfer = FileTransfer.getInstance(); + final TextTransfer textTransfer = TextTransfer.getInstance(); + final ResourceTransfer resourceTransfer = ResourceTransfer.getInstance(); + + final Transfer types[] = new Transfer[] {fileTransfer, textTransfer, resourceTransfer}; + // Add Drag/Drop to Table + DropTargetListener scriptDropTargetListener = new DropTargetAdapter() { + @Override + public void drop(DropTargetEvent event) { + if (fileTransfer.isSupportedType(event.currentDataType)) { + processDroppedFiles((String[]) event.data); + } else if(textTransfer.isSupportedType(event.currentDataType)) { + processDroppedFiles((String[]) event.data); + } else if(resourceTransfer.isSupportedType(event.currentDataType)){ + IResource[] resources = (IResource[])event.data; + String[] asStrings = new String[resources.length]; + for(int i = 0; i < resources.length; i++) { + asStrings[i] = resources[i].getLocation().toOSString(); + } + processDroppedFiles(asStrings); + } + } + @Override + public void dropAccept( DropTargetEvent event ) + { + event.detail = DND.DROP_COPY; + } + + @Override + public void dragEnter( DropTargetEvent event ) + { + event.detail = DND.DROP_COPY; + } + }; + // Setup drag/drop of files + int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT; + DropTarget scriptsTarget = new DropTarget(scriptTable.getTree(), operations); + scriptsTarget.setTransfer(types); + scriptsTarget.addDropListener(scriptDropTargetListener); + } + + private void getPopupMenu() { + + MenuManager menuManager = scriptTable.getMenuManager(); + + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Action("Open Script") { + @Override + public void run() { + handlePopupMenu(POPUP_SCRIPT); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Action("Open Output File") { + @Override + public void run() { + handlePopupMenu(POPUP_OUTPUT); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Action("Refresh Output Results") { + @Override + public void run() { + handlePopupMenu(POPUP_RESULTS); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Action("Open in Package Explorer") { + @Override + public void run() { + handlePopupMenu(POPUP_NAVIGATOR); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Separator()); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, + new Action("Set Selected to Run", ImageManager.getImageDescriptor(PluginUiImage.CHECKBOX_ENABLED)) { + @Override + public void run() { + IStructuredSelection sel = (IStructuredSelection) getSelection(); + Iterator<?> iter = sel.iterator(); + while (iter.hasNext()) { + ScriptTask task = (ScriptTask) iter.next(); + task.setRun(true); + taskList.taskChanged(task); + } + refresh(); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, + new Action("Set Selected to Not Run", ImageManager.getImageDescriptor(PluginUiImage.CHECKBOX_DISABLED)) { + @Override + public void run() { + IStructuredSelection sel = (IStructuredSelection) getSelection(); + Iterator<?> iter = sel.iterator(); + while (iter.hasNext()) { + ScriptTask task = (ScriptTask) iter.next(); + task.setRun(false); + taskList.taskChanged(task); + } + refresh(); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Separator()); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, + new Action("Select All to Run", ImageManager.getImageDescriptor(PluginUiImage.CHECKBOX_ENABLED)) { + @Override + public void run() { + setAllTasksRun(true); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, + new Action("Deselect All to Run", ImageManager.getImageDescriptor(PluginUiImage.CHECKBOX_DISABLED)) { + @Override + public void run() { + setAllTasksRun(false); + } + }); + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Separator()); + + // item = new MenuItem(previewMenu, SWT.CASCADE); + // item.setText("Load Test Output Markers"); + // item.addSelectionListener(new SelectionAdapter() { + // + // public void widgetSelected(SelectionEvent e) { + // TableItem items[] = table.getSelection(); + // ScriptTask task = null; + // if (items.length > 0) { + // task = (ScriptTask) items[0].getData(); + // testManagerEditor.processOutFile(task); + // } + // AWorkbench.popupView(IPageLayout.ID_PROBLEM_VIEW); + // } + // }); + // item = new MenuItem(previewMenu, SWT.CASCADE); + // item.setText("Remove Test Output Markers"); + // item.addSelectionListener(new SelectionAdapter() { + // + // public void widgetSelected(SelectionEvent e) { + // TableItem items[] = table.getSelection(); + // ScriptTask task = null; + // if (items.length > 0) { + // task = (ScriptTask) items[0].getData(); + // MarkerSupport.deleteMarkersFromInputFile(task.getScriptModel().getIFile()); + // } + // } + // }); + // + // item = new MenuItem(previewMenu, SWT.CASCADE); + // item.setText("Remove All Test Output Markers"); + // item.addSelectionListener(new SelectionAdapter() { + // + // public void widgetSelected(SelectionEvent e) { + // MarkerSupport.deleteAllMarkers(); + // } + // }); + + // item = new MenuItem(previewMenu, SWT.SEPARATOR); + + // return previewMenu; + } + + private void handlePopupMenu(int type) { + TreeSelection selection = (TreeSelection) scriptTable.getSelection(); + Object objs = selection.getFirstElement(); + if (objs instanceof ScriptTask) { + ScriptTask task = (ScriptTask) objs; + if (type == POPUP_SCRIPT) { + task.getScriptModel().openEditor(); + } else if (type == POPUP_OUTPUT) { + task.getScriptModel().getOutputModel().openEditor(); + refresh(); + } else if (type == POPUP_NAVIGATOR) { + task.getScriptModel().openPackageExplorer(); + } else if (type == POPUP_RESULTS) { + Iterator<?> it = selection.iterator(); + while (it.hasNext()) { + ScriptTask currentTask = (ScriptTask) it.next(); + OutputModelJob.getSingleton().addTask(currentTask); + } + } + } + } + + private void processDroppedFiles(String files[]) { + for (int i = 0; i < files.length; i++) { + String toProcess = files[i]; + + if (toProcess.endsWith(".xml")) { + batchDropHandler(new File(toProcess)); + } else { + if (toProcess.endsWith(".java") || toProcess.endsWith(".vxe") || !new File(toProcess).getName().matches( + ".*\\..*")) { + ScriptTask newTask = new ScriptTask(files[i], testManagerEditor.getAlternateOutputDir()); + if (!taskList.contains(newTask)) { + // newTask.computeExists(); + OutputModel outputModel = newTask.getScriptModel().getOutputModel(); + if (outputModel != null) { + IFile outputIFile = outputModel.getIFile(); + if (outputIFile != null && outputIFile.exists()) { + MarkerPlugin.addMarkers(newTask.getScriptModel().getOutputModel().getIFile()); + } + } + taskList.addTask(newTask); + } + } else { + Dialogs.popupError("Invalid Drop", "Only Java scripts and cppUnit executables can be dropped here."); + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "not .java or cppExe file"); + return; + } + } + } + refresh(); + this.testManagerEditor.storeValue(testManagerEditor.scriptsQualName, getStorageString()); + } + + private void batchDropHandler(File batchFile) { + try { + ILoadConfig loadConfig = + ConfigFactory.getInstance().getLoadConfigHandler(testManagerEditor.getPageManager().getScriptPage()); + loadConfig.loadConfiguration(batchFile); + } catch (Exception ex) { + Dialogs.popupError("Invalid Drop", String.format("Unable to read batch file\nFile [%s]\n%s", + (batchFile != null ? batchFile.getAbsolutePath() : "NULL"), OseeUiActivator.getStackMessages(ex))); + } + } + + public StructuredViewer getXViewer() { + return scriptTable; + } + + private void attachKeyListeners() { + scriptTable.getTree().addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (e.character == SWT.DEL && (e.stateMask & SWT.CTRL) == 0) { + removeSelectedTasks(); + refresh(); + } + if (e.character == 'r') { + refresh(); + } + } + }); + } + + public void addFiles(String[] files) { + processDroppedFiles(files); + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTask.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTask.java new file mode 100644 index 000000000..af00dc87c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTask.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable; + +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.ote.ui.test.manager.models.OutputModelJob; +import org.eclipse.osee.ote.ui.test.manager.models.ScriptModel; +import org.eclipse.osee.ote.ui.test.manager.models.ScriptModel.ScriptInteractionEnum; + +public class ScriptTask { + + public enum ScriptStatusEnum { + CANCELLED, + CANCELLING, + COMPLETE, + IN_QUEUE, + INCOMPATIBLE, + INVALID, + NOT_CONNECTED, + READY, + RUNNING + } + + private GUID guid = null; + private boolean run = true; + private ScriptModel scriptModel = null; + + private ScriptStatusEnum status = ScriptStatusEnum.INCOMPATIBLE; + + /** + * @param outputDir alternate output directory for tmo output files null will default to script directory + */ + public ScriptTask(String rawFilename, String outputDir) { + scriptModel = new ScriptModel(rawFilename, outputDir); + updateStatusOnConnected(false); + OutputModelJob.getSingleton().addTask(this); + } + + /** + * @return Returns the guid. + */ + public GUID getGuid() { + return guid; + } + + /** + * @return Returns the interaction. + */ + public ScriptInteractionEnum getInteraction() { + return scriptModel.getInteraction(); + } + + /** + * @return Returns the name. + */ + public String getName() { + if (scriptModel == null) { + return ""; + } else { + return scriptModel.getName(); + } + } + + /** + * @return Returns the passFail. + */ + public String getPassFail() { + + int passTP = scriptModel.getOutputModel().getPassedTestPoints(); + int failTP = scriptModel.getOutputModel().getFailedTestPoints(); + if (status == ScriptStatusEnum.RUNNING && scriptModel.getOutputModel().isAborted()){ + return "(0/0)"; + } + if (scriptModel.getOutputModel().isAborted()) { + return "ABORTED"; + } else if (passTP > 0 || failTP > 0) { + if (failTP == 0) { + return "PASS (" + passTP + ")"; + } else { + return "FAIL (" + failTP + "/" + (passTP + failTP) + ")"; + } + } else if (status == ScriptStatusEnum.RUNNING) { + return "(0/0)"; + } + return ""; + } + + /** + * @return Returns the path. + */ + public String getPath() { + return scriptModel.getPath(); + } + + /** + * @return Returns the scriptModel. + */ + public ScriptModel getScriptModel() { + return scriptModel; + } + + /** + * @return Returns the status. + */ + public ScriptStatusEnum getStatus() { + return status; + } + + public Boolean getRunStatus() { + return run; + } + + /** + * @return Returns the outputExists. + */ + public boolean isOutputExists() { + return scriptModel.getOutputModel().exists(); + + } + + // public void computeExists() { + // exists = scriptModel.getOutputModel().exists(); + // } + + // public boolean isOutputReadonly() { + // return !scriptModel.getOutputModel().getFile().canWrite(); + // } + + /** + * @return Returns the run. + */ + public boolean isRun() { + return run; + } + + public boolean isRunnable() { + return isRun();// && status != ScriptStatusEnum.INCOMPATIBLE + // && status != ScriptStatusEnum.INVALID); + } + + /** + * @param guid The guid to set. + */ + public void setGuid(GUID guid) { + this.guid = guid; + } + + /** + * @param run The run to set. + */ + public void setRun(boolean run) { + this.run = run; + } + + /** + * @param status The status to set. + */ + public void setStatus(ScriptStatusEnum status) { + this.status = status; + } + + public void updateStatusOnConnected(boolean connected) { + /* Always leave the status of INVALID alone */ + if (status != ScriptStatusEnum.INVALID) { + /* If we're not connected, we'll leave the display blank */ + if (!connected) { + status = ScriptStatusEnum.NOT_CONNECTED; + } else { + status = ScriptStatusEnum.READY; + } + } + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTaskList.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTaskList.java new file mode 100644 index 000000000..50796e268 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/ScriptTaskList.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.Vector; + +public class ScriptTaskList { + + private final Set<ITaskListViewer> changeListeners = new HashSet<>(); + private final Vector<ScriptTask> tasks = new Vector<>(); + private boolean isConnected = false; + + /** + * Constructor + */ + public ScriptTaskList() { + super(); + } + + public void addChangeListener(ITaskListViewer viewer) { + changeListeners.add(viewer); + } + + /** + * Add a new task to the collection of tasks + */ + public void addTask(ScriptTask inTask) { + inTask.updateStatusOnConnected(this.isConnected); + tasks.add(tasks.size(), inTask); + Iterator<ITaskListViewer> iterator = changeListeners.iterator(); + while (iterator.hasNext()) { + iterator.next().addTask(inTask); + } + } + + public void addTasks(List<ScriptTask> inTasks) { + for (ScriptTask task : inTasks) { + task.updateStatusOnConnected(isConnected); + } + ScriptTask[] array = new ScriptTask[inTasks.size()]; + this.tasks.addAll(inTasks); + Iterator<ITaskListViewer> iterator = changeListeners.iterator(); + while (iterator.hasNext()) { + iterator.next().addTasks(this.tasks.toArray(array)); + } + } + + /** + * Return the collection of ScriptTask + */ + public Vector<ScriptTask> getTasks() { + return tasks; + } + + public void onConnected(boolean connected) { + synchronized (tasks) { + this.isConnected = connected; + Iterator<ScriptTask> iter = tasks.iterator(); + while (iter.hasNext()) { + ScriptTask task = iter.next(); + // task.computeExists(); + task.updateStatusOnConnected(connected); + } + } + } + + public void removeAllTasks() { + this.tasks.removeAllElements(); + } + + public void removeChangeListener(ITaskListViewer viewer) { + changeListeners.remove(viewer); + } + + public void removeTask(ScriptTask task) { + tasks.remove(task); + Iterator<ITaskListViewer> iterator = changeListeners.iterator(); + while (iterator.hasNext()) { + iterator.next().removeTask(task); + } + } + + public void taskChanged(ScriptTask task) { + Iterator<ITaskListViewer> iterator = changeListeners.iterator(); + while (iterator.hasNext()) { + iterator.next().updateTask(task); + } + } + + @Override + public String toString() { + String str = ""; + for (int i = 0; i < tasks.size(); i++) { + ScriptTask task = tasks.get(i); + str += "\nTask " + task.getName() + " Status: " + task.getStatus(); + } + return str + "\n\n"; + } + + public boolean contains(ScriptTask newTask) { + for (ScriptTask task : tasks) { + if (task.getPath().equals(newTask.getPath())) { + return true; + } + } + return false; + } + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTable.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTable.java new file mode 100644 index 000000000..afd7e05da --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTable.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.nebula.widgets.xviewer.XViewer; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.swt.widgets.TreeItem; + +/** + * @author Donald G. Dunne + */ +public class XScriptTable extends XViewer { + + public XScriptTable(Composite parent, int style) { + super(parent, style, new XScriptTableFactory(), false, false); + } + + @Override + public void handleDoubleClick(TreeColumn col, TreeItem item) { + XViewerColumn xcol = (XViewerColumn) col.getData(); + ScriptTask task = (ScriptTask) item.getData(); + if (XScriptTableFactory.RESULT.equals(xcol) || XScriptTableFactory.OUPUT_FILE.equals(xcol)) { + task.getScriptModel().getOutputModel().openEditor(); + } else if (XScriptTableFactory.TEST_LOCATION.equals(xcol)) { + task.getScriptModel().openPackageExplorer(); + } else if (XScriptTableFactory.TEST.equals(xcol)) {// != k) { + task.getScriptModel().openEditor(); + } + } + + @Override + public boolean handleLeftClick(TreeColumn treeColumn, TreeItem treeItem) { + XViewerColumn aCol = (XViewerColumn) treeColumn.getData(); + if (XScriptTableFactory.RUN.equals(aCol)) { + ScriptTask task = (ScriptTask) treeItem.getData(); + task.setRun(!task.isRun()); + refresh(task); + } + return super.handleLeftClick(treeColumn, treeItem); + } + + @Override + public boolean handleLeftClickInIconArea(TreeColumn treeColumn, TreeItem treeItem) { + XViewerColumn aCol = (XViewerColumn) treeColumn.getData(); + if (XScriptTableFactory.RUN.equals(aCol)) { + ScriptTask task = (ScriptTask) treeItem.getData(); + task.setRun(!task.isRun()); + refresh(task); + } + return super.handleLeftClickInIconArea(treeColumn, treeItem); + } + + public List<ScriptTask> getVisibleSortedScriptTasksToRun() { + Object[] objs = getSortedChildren(getInput()); + List<ScriptTask> runs = new ArrayList<>(); + for (Object obj : objs) { + if (((ScriptTask) obj).isRun()) { + runs.add((ScriptTask) obj); + } + } + return runs; + } + + public List<ScriptTask> getVisibibleSortedScriptTasks() { + Object[] objs = getSortedChildren(getInput()); + List<ScriptTask> runs = new ArrayList<>(); + for (Object obj : objs) { + runs.add((ScriptTask) obj); + } + return runs; + } + + public boolean isRemoveItemsMenuOptionEnabled() { + return false; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableContentProvider.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableContentProvider.java new file mode 100644 index 000000000..91c7bffb3 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableContentProvider.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ITaskListViewer; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTaskList; + +/** + * @author Ken J. Aguilar + */ +public class XScriptTableContentProvider implements IStructuredContentProvider, ITaskListViewer, ITreeContentProvider { + + @Override + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + @Override + public void addTask(ScriptTask task) { + } + + @Override + public void addTasks(ScriptTask[] tasks) { + } + + @Override + public void removeTask(ScriptTask task) { + } + + @Override + public void updateTask(ScriptTask task) { + } + + @Override + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof ScriptTaskList) { + return ((ScriptTaskList) parentElement).getTasks().toArray(); + } + return null; + } + + @Override + public Object getParent(Object element) { + return null; + } + + @Override + public boolean hasChildren(Object element) { + Object[] children = getChildren(element); + if (children != null && children.length > 0) { + return true; + } + return false; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableFactory.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableFactory.java new file mode 100644 index 000000000..6b1cb7471 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableFactory.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript; + +import java.io.File; +import java.util.logging.Level; +import org.eclipse.nebula.widgets.xviewer.XViewerFactory; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.nebula.widgets.xviewer.customize.FileStoreCustomizations; +import org.eclipse.nebula.widgets.xviewer.customize.IXViewerCustomizations; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.util.OseeData; + +/** + * @author Donald G. Dunne + */ +public class XScriptTableFactory extends XViewerFactory { + private static String COLUMN_NAMESPACE = "xviewer.script.table"; + public static XViewerColumn RUN = new XViewerColumn(COLUMN_NAMESPACE + ".run", "Run", 42, XViewerAlign.Left, true, + SortDataType.Boolean, false, null); + public static XViewerColumn TEST = new XViewerColumn(COLUMN_NAMESPACE + ".test", "Test", 275, XViewerAlign.Left, true, + SortDataType.String, false, null); + public static XViewerColumn STATUS = new XViewerColumn(COLUMN_NAMESPACE + ".status", "Status", 125, XViewerAlign.Left, true, + SortDataType.String, false, null); + public static XViewerColumn RESULT = new XViewerColumn(COLUMN_NAMESPACE + ".result", "Result", 125, XViewerAlign.Left, true, + SortDataType.String, false, null); + public static XViewerColumn OUPUT_FILE = new XViewerColumn(COLUMN_NAMESPACE + ".outfile", "Output File", 70, + XViewerAlign.Left, true, SortDataType.String, false, null); + public static XViewerColumn TEST_LOCATION = new XViewerColumn(COLUMN_NAMESPACE + ".testlocation", "Test Location", + 160, XViewerAlign.Left, true, SortDataType.String, false, null); + + private final FileStoreCustomizations propertyStoreCustomizations; + + private static final String defaultCustomDataXml = + "<XTreeProperties name=\"default\" namespace=\"xviewer.script.table\" guid=\"710h7sah9dtt01464nvkkv\"><xSorter><id>xviewer.script.table.test</id></xSorter><xSorter><id>xviewer.script.table.test</id></xSorter><xFilter></xFilter><xCol><id>xviewer.script.table.run</id><name>Run</name><wdth>42</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol><xCol><id>xviewer.script.table.test</id><name>Test</name><wdth>351</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol><xCol><id>xviewer.script.table.result</id><name>Result</name><wdth>110</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol><xCol><id>xviewer.script.table.status</id><name>Status</name><wdth>125</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol><xCol><id>xviewer.script.table.outfile</id><name>Output File</name><wdth>75</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol><xCol><id>xviewer.script.table.testlocation</id><name>Test Location</name><wdth>160</wdth><algn>left</algn><srtFwd>true</srtFwd><show>true</show></xCol></XTreeProperties>"; + + public XScriptTableFactory() { + super(COLUMN_NAMESPACE); + File folder; + try { + folder = OseeData.getFolder("OteScriptTable").getLocation().toFile(); + } catch (OseeCoreException ex) { + OseeLog.log(XScriptTableFactory.class, Level.SEVERE, ex); + folder = new File(System.getProperty("java.io.tmpdir")); + } + propertyStoreCustomizations = + new FileStoreCustomizations(folder, "OteScript", ".xml", "DefaultOteScript.xml", defaultCustomDataXml); + registerColumns(RUN, TEST, RESULT, STATUS, OUPUT_FILE, TEST_LOCATION); + } + + @Override + public IXViewerCustomizations getXViewerCustomizations() { + return propertyStoreCustomizations; + } + + @Override + public boolean isAdmin() { + return true; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableLabelProvider.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableLabelProvider.java new file mode 100644 index 000000000..0fb36e4bd --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/scriptTable/xscript/XScriptTableLabelProvider.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.xscript; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.nebula.widgets.xviewer.XViewerLabelProvider; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask; +import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask.ScriptStatusEnum; +import org.eclipse.swt.graphics.Image; + +public class XScriptTableLabelProvider extends XViewerLabelProvider { + public static final OseeUiActivator plugin = TestManagerPlugin.getInstance(); + private static Image checkedImage = ImageManager.getImage(OteTestManagerImage.CHECKBOX_ENABLED); + private static Image outputImage = ImageManager.getImage(OteTestManagerImage.CHECK); + private static Map<ScriptStatusEnum, Image> statusImage = new HashMap<>(); + private static Image uncheckedImage = ImageManager.getImage(OteTestManagerImage.CHECKBOX_DISABLED); + + public XScriptTableLabelProvider(XScriptTable viewer) { + super(viewer); + if (statusImage.isEmpty()) { + statusImage.put(ScriptStatusEnum.NOT_CONNECTED, ImageManager.getImage(OteTestManagerImage.ALERT_OBJ)); + statusImage.put(ScriptStatusEnum.READY, ImageManager.getImage(OteTestManagerImage.SCRIPT_READY_SM)); + statusImage.put(ScriptStatusEnum.IN_QUEUE, ImageManager.getImage(OteTestManagerImage.SCRIPT_IN_QUEUE_SM)); + statusImage.put(ScriptStatusEnum.RUNNING, ImageManager.getImage(OteTestManagerImage.SCRIPT_RUNNING)); + statusImage.put(ScriptStatusEnum.COMPLETE, ImageManager.getImage(OteTestManagerImage.SCRIPT_COMPLETE_SM)); + statusImage.put(ScriptStatusEnum.CANCELLED, ImageManager.getImage(OteTestManagerImage.SCRIPT_CANCELLED_SM)); + statusImage.put(ScriptStatusEnum.CANCELLING, ImageManager.getImage(OteTestManagerImage.SCRIPT_CANCELLING_SM)); + statusImage.put(ScriptStatusEnum.INVALID, ImageManager.getImage(OteTestManagerImage.ERROR_STACK)); + statusImage.put(ScriptStatusEnum.INCOMPATIBLE, ImageManager.getImage(OteTestManagerImage.ERROR_STACK)); + } + }; + + private Image getOutputImage(ScriptTask task) { + if (task.isOutputExists()) { + return outputImage; + } + return null; + } + + private Image getPassFailImage(ScriptTask task) { + Matcher m = Pattern.compile("(FAIL|ABORTED)").matcher(task.getPassFail()); + if (m.find()) { + return statusImage.get(ScriptStatusEnum.INVALID); + } + return null; + } + + /** + * Returns the image with the given key, or <code>null</code> if not found. + */ + private Image getRunImage(boolean isSelected) { + return isSelected ? checkedImage : uncheckedImage; + } + + private Image getStatusImage(ScriptStatusEnum status) { + return statusImage.get(status); + } + + @Override + public Image getColumnImage(Object element, XViewerColumn col, int columnIndex) throws Exception { + if (XScriptTableFactory.OUPUT_FILE.equals(col)) { + return getOutputImage(((ScriptTask) element)); + } else if (XScriptTableFactory.RUN.equals(col)) { + return getRunImage(((ScriptTask) element).isRun()); + } else if (XScriptTableFactory.STATUS.equals(col)) { + return getStatusImage(((ScriptTask) element).getStatus()); + } else if (XScriptTableFactory.RESULT.equals(col)) { + return getPassFailImage(((ScriptTask) element)); + } + return null; + } + + @Override + public String getColumnText(Object element, XViewerColumn col, int columnIndex) throws Exception { + ScriptTask task = (ScriptTask) element; + if (XScriptTableFactory.STATUS.equals(col)) { + return task.getStatus().toString(); + } else if (XScriptTableFactory.RESULT.equals(col)) { + return task.getPassFail(); + } else if (XScriptTableFactory.TEST.equals(col)) { + return task.getName(); + } else if (XScriptTableFactory.TEST_LOCATION.equals(col)) { + return task.getPath(); + } else if (XScriptTableFactory.RUN.equals(col)) { + return task.getRunStatus().toString(); + } + + return ""; + } + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/FileOrDirectorySelectionPanel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/FileOrDirectorySelectionPanel.java new file mode 100644 index 000000000..3aa64e986 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/FileOrDirectorySelectionPanel.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.panels; + +import java.io.File; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.util.Dialogs; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Roberto E. Escobar + */ +public class FileOrDirectorySelectionPanel extends Composite { + + private static final Image FILE_SELECT_IMAGE = ImageManager.getImage(OteTestManagerImage.FILE); + private static final String DIRECTORY_ERROR_MESSAGE = "Directory should be blank or set an accessible directory."; + private static final String FILE_ERROR_MESSAGE = "Unable to access file."; + private static final String DEFAULT_FILE = "/dev/null"; + + private StyledText textField; + private Label labelField; + private final String labelText; + private final String toolTipText; + private final boolean isDirectory; + + public FileOrDirectorySelectionPanel(Composite parent, int style, String labelText, String toolTipText, boolean isDirectory) { + super(parent, style); + this.labelText = labelText; + this.toolTipText = toolTipText; + this.isDirectory = isDirectory; + GridLayout gl = new GridLayout(3, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + this.setLayout(gl); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + createControl(this); + } + + private void createControl(Composite parent) { + labelField = new Label(parent, SWT.NONE); + labelField.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false)); + labelField.setText(labelText); + labelField.setToolTipText(toolTipText); + + textField = new StyledText(parent, SWT.BORDER); + textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + if (isDirectory != true) { + textField.setText(DEFAULT_FILE); + } + Button fileDialog = new Button(parent, SWT.NONE); + fileDialog.setLayoutData(new GridData(SWT.FILL, SWT.END, false, false)); + fileDialog.setImage(FILE_SELECT_IMAGE); + fileDialog.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + createDialog(); + } + }); + + } + + private void createDialog() { + Shell shell = AWorkbench.getActiveShell(); + String selection = ""; + if (isDirectory == true) { + DirectoryDialog directoryDialog = new DirectoryDialog(shell, SWT.OPEN); + + String defaultDir = textField.getText(); + File dir = new File(defaultDir); + if (dir.isFile() || dir.isDirectory()) { + directoryDialog.setFilterPath(defaultDir); + } else { + directoryDialog.setFilterPath("Y:\\"); + } + selection = directoryDialog.open(); + } else { + FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); + selection = fileDialog.open(); + } + setSelected(selection); + } + + private void verifySelection() { + String text = getSelected(); + if (isValid() != true) { + if (isDirectory == true) { + text = ""; + } else { + text = DEFAULT_FILE; + } + Dialogs.popupError("Error", getErrorMessage()); + } + if (textField.getText().equals(text) != true) { + textField.setText(text); + } + } + + private boolean isValidFile(String text) { + File file = new File(text); + return file != null && file.exists() != false && file.canWrite() != false; + } + + public boolean isValid() { + boolean toReturn = false; + String text = getSelected(); + if (isDirectory == true) { + toReturn = Strings.isValid(text) == true ? isValidFile(text) : true; + } else { + // if (Strings.isValid(text) == true) { + // if (text.equals(DEFAULT_FILE) == true) { + toReturn = true; + // } else { + // toReturn = isValidFile(text); + // } + // } + } + return toReturn; + } + + public String getErrorMessage() { + return isDirectory == true ? DIRECTORY_ERROR_MESSAGE : FILE_ERROR_MESSAGE; + } + + public String getSelected() { + return textField != null && textField.isDisposed() != true ? textField.getText() : ""; + } + + public void setSelected(String value) { + if (textField != null && textField.isDisposed() != true) { + if (Strings.isValid(value)) { + textField.setText(value); + } + verifySelection(); + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/LoggingPanel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/LoggingPanel.java new file mode 100644 index 000000000..7139e96ed --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/LoggingPanel.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.panels; + +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Roberto E. Escobar + */ +public class LoggingPanel extends Composite { + + private enum LoggingLevel { + Minimal(Level.WARNING), + Detailed(Level.INFO), + All(Level.ALL); + + private Level level; + + LoggingLevel(Level level) { + this.level = level; + } + + public Level getLevel() { + return level; + } + + public static LoggingLevel fromLevel(Level value) { + LoggingLevel toReturn = LoggingLevel.Detailed; + if (value != null) { + for (LoggingLevel formatType : LoggingLevel.values()) { + if (formatType.getLevel().equals(value)) { + toReturn = formatType; + break; + } + } + } + return toReturn; + } + + } + + private Map<LoggingLevel, Button> buttonMap; + private LoggingLevel lastSelected; + + public LoggingPanel(Composite parent, int style) { + super(parent, style); + GridLayout gl = new GridLayout(); + gl.marginHeight = 0; + gl.marginWidth = 0; + this.setLayout(gl); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + createControl(this); + } + + private void createControl(Composite parent) { + LoggingLevel[] levels = LoggingLevel.values(); + this.buttonMap = new HashMap<>(); + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gl = new GridLayout(); + gl.marginHeight = 0; + gl.marginWidth = 0; + composite.setLayout(gl); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + + for (int index = 0; index < levels.length; index++) { + LoggingLevel level = levels[index]; + + Button button = new Button(composite, SWT.RADIO); + button.setData(level); + button.setText(level.name()); + button.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + Object object = e.getSource(); + if (object instanceof Button) { + setSelected((Button) object); + } + } + + }); + boolean isDefault = index == 1; + button.setSelection(isDefault); + if (isDefault != false) { + lastSelected = level; + } + buttonMap.put(level, button); + } + } + + private void setSelected(Button button) { + if (button.getSelection() != false) { + lastSelected = (LoggingLevel) button.getData(); + } + } + + public String getSelected() { + return lastSelected.getLevel().toString(); + } + + public void setSelected(String value) { + Level level = LoggingLevel.Detailed.getLevel(); + try { + level = Level.parse(value); + } catch (Exception ex) { + OseeLog.logf(TestManagerPlugin.class, Level.WARNING, + "Error parsing log level [%s] using default [%s]", value, level); + } + + LoggingLevel loggingLevel = LoggingLevel.fromLevel(level); + this.lastSelected = loggingLevel; + for (LoggingLevel keys : buttonMap.keySet()) { + Button button = buttonMap.get(keys); + button.setSelection(keys.equals(loggingLevel)); + } + } + +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/ScriptExecutionOptionsPanel.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/ScriptExecutionOptionsPanel.java new file mode 100644 index 000000000..6b41c5e52 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/panels/ScriptExecutionOptionsPanel.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.panels; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Roberto E. Escobar + */ +public class ScriptExecutionOptionsPanel extends Composite { + private Button saveOutputCheck; + private Button batchModeCheck; + private Button abortScriptOnFirstFail; + private Button pauseScriptOnFail; + private Button printFailToConsole; + + public ScriptExecutionOptionsPanel(Composite parent, int style) { + super(parent, style); + GridLayout gl = new GridLayout(); + gl.marginHeight = 0; + gl.marginWidth = 0; + this.setLayout(gl); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + createControl(this); + } + + private void createControl(Composite parent) { + saveOutputCheck = new Button(parent, SWT.CHECK); + saveOutputCheck.setText("Keep copies of old Output Files"); + saveOutputCheck.setToolTipText("Select to save existing output filename\n" + "to file \"<output>.[num].tmo\" for each succssive run.\n" + "De-select overwrites output file.\n\n" + " eg. myScript.tmo = current output\n" + " myScript.1.tmo = oldest output file\n" + " myScript.2.tmo = output before current"); + + batchModeCheck = new Button(parent, SWT.CHECK); + batchModeCheck.setText("Run in batch mode"); + batchModeCheck.setToolTipText("If any prompts exist, they are skipped if this option is selected."); + + abortScriptOnFirstFail = new Button(parent, SWT.CHECK); + abortScriptOnFirstFail.setText("Abort script on first fail"); + abortScriptOnFirstFail.setToolTipText("Any script fail will cause the current script to be aborted."); + + pauseScriptOnFail = new Button(parent, SWT.CHECK); + pauseScriptOnFail.setText("Pause script on fail"); + pauseScriptOnFail.setToolTipText("Each script failure will cause a promptPause to occur."); + + printFailToConsole = new Button(parent, SWT.CHECK); + printFailToConsole.setText("Print failures to console"); + printFailToConsole.setToolTipText("Prints each failure to the console as the script runs."); + } + + public boolean isKeepOldCopiesEnabled() { + return saveOutputCheck.getSelection(); + } + + public void setKeepOldCopiesEnabled(boolean isEnabled) { + saveOutputCheck.setSelection(isEnabled); + } + + public boolean isBatchModeEnabled() { + return batchModeCheck.getSelection(); + } + + public void setBatchModeEnabled(boolean isEnabled) { + batchModeCheck.setSelection(isEnabled); + } + + public boolean isAbortOnFail(){ + return abortScriptOnFirstFail.getSelection(); + } + + public void setAbortOnFail(boolean isEnabled){ + abortScriptOnFirstFail.setSelection(isEnabled); + } + + public boolean isPauseOnFail(){ + return pauseScriptOnFail.getSelection(); + } + + public void setPauseOnFail(boolean isEnabled){ + pauseScriptOnFail.setSelection(isEnabled); + } + + public boolean isPrintFailToConsole(){ + return printFailToConsole.getSelection(); + } + + public void setPrintFailToConsole(boolean isEnabled){ + printFailToConsole.setSelection(isEnabled); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/TestManagerPreferencePage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/TestManagerPreferencePage.java new file mode 100644 index 000000000..06e2e7b0d --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/TestManagerPreferencePage.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.preferences; + +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.osee.ote.ui.test.manager.preferences.environment.EnvironmentPreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * @author Roberto E. Escobar + */ +public class TestManagerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + public static final String TEST_MANAGER_KEY = "org.eclipse.osee.ote.ui.test.manager.PreferencePage"; + private EnvironmentPreferencePage environmentPreferencePage; + + @Override + public void init(IWorkbench workbench) { + // Initialize the preference store we wish to use + setPreferenceStore(TestManagerPlugin.getInstance().getPreferenceStore()); + } + + @Override + public boolean performOk() { + environmentPreferencePage.storeVariables(); + + return super.performOk(); + } + + private Control createBlankArea(Composite parent, int height, boolean allVertical) { + Composite blank = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + GridData gd = new GridData(); + gd.minimumHeight = height; + gd.grabExcessHorizontalSpace = true; + gd.grabExcessVerticalSpace = allVertical; + blank.setLayout(gridLayout); + blank.setLayoutData(gd); + return parent; + } + + private Control createDefaultEvironmentVariablesArea(Composite parent) { + + SashForm sashForm = new SashForm(parent, SWT.VERTICAL); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + + GridData d = new GridData(GridData.FILL_BOTH); + d.grabExcessHorizontalSpace = true; + d.grabExcessVerticalSpace = true; + sashForm.setLayout(gridLayout); + sashForm.setLayoutData(d); + + environmentPreferencePage = new EnvironmentPreferencePage(sashForm); + + return parent; + } + + private void createPageDescription(Composite parent) { + new Label(parent, SWT.NONE).setText("Test Manager Settings:"); + } + + @Override + protected Control createContents(Composite parent) { + + createPageDescription(parent); + createBlankArea(parent, 0, false); + createDefaultEvironmentVariablesArea(parent); + // createBlankArea(parent, 300, true); + + return parent; + } + + @Override + protected void performApply() { + performOk(); + } + + @Override + protected void performDefaults() { + + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java new file mode 100644 index 000000000..eeebfb510 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.preferences.environment; + +import java.util.ArrayList; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; + +/** + * @author Roberto E. Escobar + */ +public class EnvironmentPageDataViewer { + + private Group environmentVariable; + private EnvironmentPreferenceNode nodeToDisplay; + private final ArrayList<StyleRange> styleArray; + private StyledText textArea; + + public EnvironmentPageDataViewer(Composite parent) { + createArea(parent); + styleArray = new ArrayList<>(); + } + + public void clearTextArea() { + textArea.setText(""); + styleArray.clear(); + textArea.redraw(); + } + + public void setNodeToDisplay(EnvironmentPreferenceNode nodeToDisplay) { + this.nodeToDisplay = nodeToDisplay; + update(); + } + + public void setTitleName(String name) { + environmentVariable.setText("Preview Environment Variable: " + name); + environmentVariable.redraw(); + } + + public void update() { + clearTextArea(); + if (nodeToDisplay != null) { + setTitleName(nodeToDisplay.getEnvName()); + addEntry(nodeToDisplay.getEnvName(), nodeToDisplay.getValue()); + } else { + setTitleName("NONE SELECTED"); + } + } + + private void addEntry(String name, String value) { + addEntryName(name); + addEntryValue(value); + } + + private void addEntryName(String name) { + if (name != null) { + String temp = textArea.getText(); + temp += "\n\t"; + int startIndex = temp.length(); + temp += name; + textArea.setText(temp); + StyleRange tempStyle = new StyleRange(); + styleArray.add(tempStyle); + tempStyle.fontStyle = SWT.BOLD; + tempStyle.start = startIndex; + tempStyle.length = name.length(); + tempStyle.underline = true; + tempStyle.foreground = Displays.getSystemColor(SWT.COLOR_DARK_BLUE); + textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()])); + textArea.redraw(); + } + } + + private void addEntryValue(String value) { + if (value != null) { + String temp = textArea.getText(); + temp += " = "; + int startIndex = temp.length(); + String toAdd = value.replaceAll(":", ":\n\t\t"); + temp += toAdd; + textArea.setText(temp + "\n"); + StyleRange tempStyle = new StyleRange(); + styleArray.add(tempStyle); + tempStyle.fontStyle = SWT.ITALIC; + tempStyle.start = startIndex; + tempStyle.length = toAdd.length(); + tempStyle.foreground = Displays.getSystemColor(SWT.COLOR_BLACK); + textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()])); + textArea.redraw(); + } + } + + private Control createArea(Composite parent) { + GridData d = new GridData(GridData.FILL_BOTH); + + environmentVariable = new Group(parent, SWT.NONE); + environmentVariable.setText("Preview Environment Variable:"); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + environmentVariable.setLayout(gridLayout); + environmentVariable.setLayoutData(d); + + Composite topLevelComposite = new Composite(environmentVariable, SWT.NONE); + gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + topLevelComposite.setLayout(gridLayout); + topLevelComposite.setLayoutData(d); + topLevelComposite.setToolTipText("Select a Value From the Tree to Display"); + + textArea = new StyledText(topLevelComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + textArea.setEditable(false); + GridLayout gL = new GridLayout(); + gL.numColumns = 1; + textArea.setLayout(gL); + textArea.setLayoutData(d); + textArea.setBackground(Displays.getSystemColor(SWT.COLOR_WHITE)); + textArea.setToolTipText("Select a Value From the Tree to Display"); + + return parent; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java new file mode 100644 index 000000000..8544f9eaf --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.preferences.environment; + +import java.util.ArrayList; +import java.util.Iterator; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTreeViewer; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.jdk.core.type.TreeObject; +import org.eclipse.osee.framework.jdk.core.type.TreeParent; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.ui.test.manager.util.EnvVariableDetailsDialogHelper; +import org.eclipse.osee.ote.ui.test.manager.util.EnvVariableDialogHelper; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Roberto E. Escobar + */ +public class EnvironmentPageEventHandler { + + private EnvironmentPreferenceNode currentSelection; + private final EnvironmentPageDataViewer environmentPageDataViewer; + private final ArrayList<EnvironmentPreferenceNode> treeInputList; + private final CheckboxTreeViewer treeViewer; + + public EnvironmentPageEventHandler(Composite parent, CheckboxTreeViewer treeViewer, ArrayList<EnvironmentPreferenceNode> treeInputList) { + this.treeViewer = treeViewer; + this.treeInputList = treeInputList; + this.environmentPageDataViewer = new EnvironmentPageDataViewer(parent); + } + + public void editEnvVariable(EnvironmentPreferenceNode node) { + EnvVariableDetailsDialogHelper selection = new EnvVariableDetailsDialogHelper(node.getEnvName(), node.getValue()); + Displays.pendInDisplayThread(selection); + if (selection.getResult() != Window.CANCEL) { + node.setValue(selection.getSelection()); + environmentPageDataViewer.update(); + } + } + + public void handleAddEnvironmentVariableEvent() { + EnvVariableDialogHelper selection = new EnvVariableDialogHelper(); + Displays.pendInDisplayThread(selection); + if (selection.getResult() != Window.CANCEL) { + this.addEnvironmentVariable(selection.getSelection()); + treeViewer.refresh(); + } + } + + public void handleCheckStateChangeEvent(CheckStateChangedEvent event) { + Object obj = event.getElement(); + if (obj != null) { + EnvironmentPreferenceNode tempSelection = null; + + if (obj instanceof EnvironmentPreferenceNode) { + tempSelection = (EnvironmentPreferenceNode) obj; + tempSelection.setChecked(event.getChecked()); + currentSelection = tempSelection; + environmentPageDataViewer.setNodeToDisplay(currentSelection); + } + } + } + + public void handleEditVariableEvent() { + ISelection sel = this.treeViewer.getSelection(); + if (!sel.isEmpty()) { + TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement(); + if (selectedItem instanceof EnvironmentPreferenceNode) { + editEnvVariable((EnvironmentPreferenceNode) selectedItem); + } + } + } + + public void handleRemoveSelectedViewEvent() { + StructuredSelection sel = (StructuredSelection) treeViewer.getSelection(); + if (!sel.isEmpty()) { + Iterator<?> it = sel.iterator(); + while (it.hasNext()) { + TreeObject leaf = (TreeObject) it.next(); + if (leaf instanceof TreeParent) { + treeInputList.remove(leaf); + environmentPageDataViewer.setNodeToDisplay(null); + } else { + leaf.getParent().removeChild(leaf); + environmentPageDataViewer.update(); + } + } + treeViewer.refresh(); + } + } + + public void handleTreeSelectionEvent(SelectionChangedEvent event) { + ISelection sel = event.getSelection(); + if (!sel.isEmpty()) { + TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement(); + + EnvironmentPreferenceNode tempSelection = null; + + if (selectedItem instanceof EnvironmentPreferenceNode) { + tempSelection = (EnvironmentPreferenceNode) selectedItem; + currentSelection = tempSelection; + environmentPageDataViewer.setNodeToDisplay(currentSelection); + } + treeViewer.refresh(); + } + } + + private void addEnvironmentVariable(String name) { + EnvironmentPreferenceNode node = new EnvironmentPreferenceNode(name); + treeInputList.add(node); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferenceNode.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferenceNode.java new file mode 100644 index 000000000..1d2cbe6b8 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferenceNode.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.preferences.environment; + +import org.eclipse.osee.framework.jdk.core.type.TreeParent; + +/** + * @author Roberto E. Escobar + */ +public class EnvironmentPreferenceNode extends TreeParent { + + public boolean checked; + public String value; + + public EnvironmentPreferenceNode(String name) { + super(name); + checked = false; + value = ""; + } + + public String getEnvName() { + return getName(); + } + + public String getValue() { + return value; + } + + @Override + public boolean isChecked() { + return checked; + } + + @Override + public void setChecked(boolean selected) { + this.checked = selected; + } + + public void setEnvName(String name) { + setName(name); + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferencePage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferencePage.java new file mode 100644 index 000000000..2fe8f8626 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPreferencePage.java @@ -0,0 +1,331 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.preferences.environment; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTreeViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.osee.framework.jdk.core.type.TreeObject; +import org.eclipse.osee.framework.jdk.core.type.TreeParent; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; + +/** + * @author Roberto E. Escobar + */ +public class EnvironmentPreferencePage { + public static final String CHECKED = "selected"; + public static final String NAME = "name"; + public static final String NUMBER_OF_VALUES = "numberOfValues"; + public static final String PAGE_KEY = "org.eclipse.osee.ote.ui.test.manager.EnvironmentPreferencePage"; + public static final String VALUE = "value"; + + public static Map<String, String> getSelectedItems() { + Map<String, String> environmentVariables = new HashMap<>(); + + ArrayList<EnvironmentPreferenceNode> envList = loadVariables(); + + for (EnvironmentPreferenceNode node : envList) { + if (node.isChecked()) { + String name = node.getEnvName(); + String value = node.getValue(); + if (Strings.isValid(name)) { + environmentVariables.put(name, value != null ? value : ""); + } + } + } + return environmentVariables; + } + + private static ArrayList<EnvironmentPreferenceNode> loadVariables() { + ArrayList<EnvironmentPreferenceNode> list = new ArrayList<>(); + IPreferenceStore prefStore = TestManagerPlugin.getInstance().getPreferenceStore(); + + int numberOfValues = prefStore.getInt(PAGE_KEY + "." + NUMBER_OF_VALUES); + for (int index = 0; index < numberOfValues; index++) { + String name = prefStore.getString(PAGE_KEY + "." + NAME + "_" + index); + String value = prefStore.getString(PAGE_KEY + "." + VALUE + "_" + index); + String selectedString = prefStore.getString(PAGE_KEY + "." + CHECKED + "_" + index); + boolean selected = Boolean.parseBoolean(selectedString); + + if (name != null && name != "") { + EnvironmentPreferenceNode node = new EnvironmentPreferenceNode(name); + node.setValue((value != null ? value : "")); + node.setChecked(selected); + list.add(node); + } + } + return list; + } + + private Button addButton; + + private Composite buttonComposite; + private EnvironmentPageEventHandler environmentPageEventHandler; + private Button removeButton; + + private final ArrayList<EnvironmentPreferenceNode> treeInputList; + + private CheckboxTreeViewer treeViewer; + + public EnvironmentPreferencePage(Composite parent) { + this.treeInputList = loadVariables(); + this.createTreeArea(parent); + } + + public ISelection getSelection() { + return treeViewer.getSelection(); + } + + public void refresh() { + treeViewer.refresh(); + } + + public void storeVariables() { + IPreferenceStore prefStore = TestManagerPlugin.getInstance().getPreferenceStore(); + prefStore.setValue(PAGE_KEY + "." + NUMBER_OF_VALUES, treeInputList.size()); + int index = 0; + for (EnvironmentPreferenceNode node : treeInputList) { + index = treeInputList.indexOf(node); + String name = node.getEnvName(); + if (name != null && name != "") { + prefStore.putValue(PAGE_KEY + "." + NAME + "_" + index, name); + String value = node.getValue(); + prefStore.putValue(PAGE_KEY + "." + VALUE + "_" + index, (value != null ? value : "")); + prefStore.putValue(PAGE_KEY + "." + CHECKED + "_" + index, Boolean.toString(node.isChecked())); + } + } + } + + private void attachListeners() { + treeViewer.getTree().addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (e.character == SWT.DEL && (e.stateMask & SWT.CTRL) == 0) { + environmentPageEventHandler.handleRemoveSelectedViewEvent(); + } + } + }); + + treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + environmentPageEventHandler.handleTreeSelectionEvent(event); + } + }); + + treeViewer.getTree().addMouseListener(new MouseListener() { + @Override + public void mouseDoubleClick(MouseEvent e) { + environmentPageEventHandler.handleEditVariableEvent(); + } + + @Override + public void mouseDown(MouseEvent e) { + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + treeViewer.addCheckStateListener(new ICheckStateListener() { + + @Override + public void checkStateChanged(CheckStateChangedEvent event) { + environmentPageEventHandler.handleCheckStateChangeEvent(event); + } + + }); + } + + private Control createButtonArea(Composite parent) { + + buttonComposite = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + GridData gd = new GridData(SWT.FILL); + buttonComposite.setLayout(gridLayout); + buttonComposite.setLayoutData(gd); + + addButton = new Button(buttonComposite, SWT.PUSH); + addButton.setText("Add"); + addButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + environmentPageEventHandler.handleAddEnvironmentVariableEvent(); + } + }); + + removeButton = new Button(buttonComposite, SWT.PUSH); + removeButton.setText("Remove"); + removeButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + environmentPageEventHandler.handleRemoveSelectedViewEvent(); + } + + }); + return parent; + } + + private Control createTreeArea(Composite parent) { + + Group defaultEnvironmentVariablesGroup = new Group(parent, SWT.NONE); + defaultEnvironmentVariablesGroup.setText("Select Default Environment Variables to Use"); + GridLayout gL = new GridLayout(); + gL.numColumns = 2; + GridData gd = new GridData(GridData.FILL_BOTH); + gd.grabExcessHorizontalSpace = true; + gd.grabExcessVerticalSpace = true; + defaultEnvironmentVariablesGroup.setLayout(gL); + defaultEnvironmentVariablesGroup.setLayoutData(gd); + + Composite areaComposite = new Composite(defaultEnvironmentVariablesGroup, SWT.NONE); + GridLayout treeLayout = new GridLayout(); + treeLayout.numColumns = 1; + GridData gd1 = new GridData(); + gd1.horizontalAlignment = GridData.FILL; + gd1.verticalAlignment = GridData.FILL; + gd1.grabExcessHorizontalSpace = true; + gd1.grabExcessVerticalSpace = true; + areaComposite.setLayout(treeLayout); + areaComposite.setLayoutData(gd1); + + GridData treeGridData = new GridData(); + treeGridData.grabExcessHorizontalSpace = true; + treeGridData.grabExcessVerticalSpace = true; + treeGridData.horizontalAlignment = GridData.FILL; + treeGridData.verticalAlignment = GridData.FILL; + + treeViewer = + new CheckboxTreeViewer(areaComposite, SWT.MULTI | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + treeViewer.getTree().setLayoutData(treeGridData); + treeViewer.setContentProvider(new ITreeContentProvider() { + + @Override + public void dispose() { + + } + + @Override + public Object[] getChildren(Object parentElement) { + if (parentElement != null && parentElement instanceof TreeParent) { + TreeParent parent = (TreeParent) parentElement; + if (parent.hasChildren()) { + return parent.getChildren(); + } + } + return new Object[0]; + } + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement != null && inputElement instanceof ArrayList<?>) { + ArrayList<?> elementArray = (ArrayList<?>) inputElement; + return elementArray.toArray(); + } + return new Object[0]; + } + + @Override + public Object getParent(Object element) { + if (element != null && element instanceof TreeObject) { + TreeObject child = (TreeObject) element; + return child.getParent(); + } + return new Object(); + } + + @Override + public boolean hasChildren(Object element) { + if (element instanceof TreeParent) { + TreeParent parent = (TreeParent) element; + return parent.hasChildren(); + } + return false; + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + + } + }); + treeViewer.setLabelProvider(new LabelProvider() { + + @Override + public Image getImage(Object obj) { + return ImageManager.getImage(OteTestManagerImage.ENVIRONMENT); + } + + @Override + public String getText(Object obj) { + return obj.toString(); + } + }); + treeViewer.setInput(treeInputList); + treeViewer.getTree().setToolTipText("Double click on an item to edit.\nClick once to preview content."); + + environmentPageEventHandler = new EnvironmentPageEventHandler(parent, treeViewer, treeInputList); + + createButtonArea(defaultEnvironmentVariablesGroup); + + attachListeners(); + + for (EnvironmentPreferenceNode parentNode : treeInputList) { + treeViewer.setChecked(parentNode, parentNode.isChecked()); + } + + return parent; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java new file mode 100644 index 000000000..7a8549a03 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java @@ -0,0 +1,209 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import java.io.File; +import java.net.BindException; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.CorePreferences; +import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.osee.ote.classserver.ClassServer; +import org.eclipse.osee.ote.classserver.PathResourceFinder; +import org.eclipse.osee.ote.runtimemanager.UserLibResourceFinder; + +public class ClassServerInst { + private ClassServer classServer; + private String classServerPath; + private PathResourceFinder pathResourceFinder; + + private static ClassServerInst instance = null; + + public static ClassServerInst getInstance() { + if (instance == null) { + instance = new ClassServerInst(); + } + return instance; + } + + /** + * Creates a new ClassServer which will serve all projects currently in the workspace + */ + private ClassServerInst() { + try { + InetAddress useHostAddress = CorePreferences.getDefaultInetAddress(); + classServer = new ClassServer(0, useHostAddress)//; + { + @Override + protected void fileDownloaded(String fp, InetAddress addr) { + System.out.println("ClassServerInst: File " + fp + " downloaded to " + addr); + } + }; + pathResourceFinder = new PathResourceFinder(new String[] {}, false); + classServer.addResourceFinder(new UserLibResourceFinder()); + classServer.addResourceFinder(new OTEBuilderResourceFinder()); + classServer.addResourceFinder(pathResourceFinder); + classServer.start(); + + classServerPath = classServer.getHostName().toString();// "http://" + useHostAddress.getHostAddress() + ":" + classServer.getPort() + "/"; + + Job job = new Job("Populating TM classserver with projects.") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + addAnyNewProjects(); + } catch (Throwable th) { + OseeLog.log(ClassServerInst.class, Level.SEVERE, th.getMessage(), th); + } + return Status.OK_STATUS; + } + + }; + job.schedule(); + } catch (BindException ex) { + OseeLog.log( + ClassServerInst.class, + Level.SEVERE, + "Class Server not started. Likely the IP address used is not local. Set your IP address in the advanced page.", + ex); + } catch (Exception ex) { + OseeLog.log(ClassServerInst.class, Level.SEVERE, "Class Server not started.", ex); + } + } + + /** + * Adds any newly created or checked out projects in the workspace to the ClassServer. + */ + public void addAnyNewProjects() { + // the ClassServer maintains a list and checks that any passed in projects are not already in + // its list before adding new ones, so it is safe to simply pass the entire list of projects + pathResourceFinder.addPaths(getAllProjects()); + } + + /** + * @return the path to the class server, to be passed to the environment upon connection + */ + public String getClassServerPath() { + return classServerPath; + } + + /** + * Stops the class server. This should be called upon termination of the testManager + */ + public void stopServer() { + classServer.terminate(); + } + + private String[] getAllProjects() { + ArrayList<String> list = new ArrayList<>(); + + IProject[] projects = AWorkspace.getProjects(); + for (IProject project : projects) { + // If the project start with a '.', (i.e. a hidden project) do not include it in the class + // server + // This will keep .osee.data and others from being served + if (!project.isOpen()) { + continue; + } + + IProjectDescription description; + try { + description = project.getDescription(); + if (!project.getName().startsWith(".") && description.hasNature("org.eclipse.jdt.core.javanature")) { + List<File> fileList = getJavaProjectProjectDependancies(JavaCore.create(project)); + for (File file : fileList) { + list.add(file.getAbsolutePath()); + } + } + } catch (CoreException ex) { + ex.printStackTrace(); + } + } + + return list.toArray(new String[list.size()]); + } + + /* + * START Code Duplicated from AJavaProject because of release dependencies + */ + private final Map<IJavaProject, IClasspathEntry[]> cachedPath = + new HashMap<IJavaProject, IClasspathEntry[]>(); + + private IClasspathEntry[] localGetResolvedClasspath(IJavaProject javaProject) throws JavaModelException { + IClasspathEntry[] paths = cachedPath.get(javaProject); + if (paths == null) { + paths = javaProject.getResolvedClasspath(true); + cachedPath.put(javaProject, paths); + } + return paths; + } + + private ArrayList<File> getJavaProjectProjectDependancies(IJavaProject javaProject) { + ArrayList<File> urls = new ArrayList<File>(); + try { + IClasspathEntry[] paths = localGetResolvedClasspath(javaProject); + for (int i = 0; i < paths.length; i++) { + if (paths[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { + if (paths[i].getPath().toFile().exists()) { + // urls.add(paths[i].getPath().toFile()); + } else { + File file = null; + file = new File(AWorkspace.getWorkspacePath().concat(paths[i].getPath().toOSString())); + if (file.exists()) { + urls.add(file); + } + } + } else if (paths[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) { + urls.add(new File(AWorkspace.getWorkspacePath().concat( + paths[i].getPath().toFile().getPath().concat(File.separator + "bin" + File.separator)))); + } else if (paths[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { + File projectlocation = javaProject.getProject().getLocation().toFile(); + File projecttricky = javaProject.getProject().getFullPath().toFile(); + IPath output = paths[i].getOutputLocation(); + File fileLocation; + if (output == null) { + fileLocation = javaProject.getOutputLocation().toFile(); + } else { + fileLocation = paths[i].getOutputLocation().toFile(); + } + String realLocation = + fileLocation.toString().replace(projecttricky.toString(), projectlocation.toString()); + urls.add(new File(realLocation)); + } + } + + } catch (JavaModelException ex) { + ex.printStackTrace(); + } + return urls; + } + /* + * STOP Code Duplicated from AJavaProject because of release dependencies + */ +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/Dialogs.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/Dialogs.java new file mode 100644 index 000000000..6b11da236 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/Dialogs.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.PlatformUI; + +public class Dialogs { + + public static void popupError(String title, String message) { + MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message); + } + + public static void popupInformational(String title, String message) { + MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message); + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialog.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialog.java new file mode 100644 index 000000000..083c4caaf --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialog.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Roberto E. Escobar + */ +public class EnvVariableDetailsDialog extends MessageDialog { + + private Button cancelButton; + private final String dialogMessage; + + private Button okButton; + + private Button importButton; + + private String selection; + private boolean selectionOk; + private StyledText textArea; + + public EnvVariableDetailsDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, String oldValue) { + super(parentShell, dialogTitle, dialogTitleImage, null, dialogImageType, dialogButtonLabels, defaultIndex); + + this.selectionOk = false; + this.selection = oldValue; + this.dialogMessage = dialogMessage; + } + + public String getSelection() { + return selection; + } + + public boolean isValid() { + return selectionOk; + } + + @Override + protected Control createButtonBar(Composite parent) { + Control c = super.createButtonBar(parent); + okButton = getButton(0); + cancelButton = getButton(1); + + okButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = true; + + } + }); + + cancelButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = false; + } + }); + return c; + } + + @Override + protected Control createCustomArea(Composite parent) { + // super.createCustomArea(parent); + + GridData d = new GridData(GridData.FILL); + + Group setValueGroup = new Group(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + setValueGroup.setLayout(gridLayout); + setValueGroup.setText(dialogMessage); + + Composite topLevelComposite = new Composite(setValueGroup, SWT.NONE); + gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + topLevelComposite.setLayout(gridLayout); + topLevelComposite.setLayoutData(d); + + importButton = new Button(setValueGroup, SWT.NONE); + importButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); + importButton.setText("Import"); + importButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(EnvVariableDetailsDialog.this.getShell(), SWT.OPEN); + + String result = dialog.open(); + if (Strings.isValid(result)) { + String importedData; + try { + importedData = Lib.fileToString(new File(result)); + textArea.setText(textArea.getText() + importedData); + selection = textArea.getText(); + } catch (IOException ex) { + OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex); + } + } + } + }); + + textArea = new StyledText(setValueGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); + GridData gd = new GridData(); + gd.grabExcessHorizontalSpace = true; + gd.horizontalAlignment = GridData.FILL; + gd.horizontalSpan = 1; + gd.heightHint = 200; + gd.widthHint = 400; + textArea.setLayoutData(gd); + + textArea.setText((selection != null ? selection : "")); + + textArea.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + selection = textArea.getText(); + } + }); + + return parent; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialogHelper.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialogHelper.java new file mode 100644 index 000000000..25b96be5c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDetailsDialogHelper.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; + +/** + * @author Roberto E. Escobar + */ +public class EnvVariableDetailsDialogHelper implements Runnable { + + private final String nameOfVariableToSet; + private int result; + private String selection; + + public EnvVariableDetailsDialogHelper(String nameOfVariableToSet, String oldValue) { + this.nameOfVariableToSet = nameOfVariableToSet; + this.selection = oldValue; + } + + public int getResult() { + return result; + } + + public String getSelection() { + return selection; + } + + @Override + public void run() { + EnvVariableDetailsDialog dlg = + new EnvVariableDetailsDialog(null, "Edit " + nameOfVariableToSet, null, nameOfVariableToSet + " Value:", + MessageDialog.NONE, new String[] {"OK", "Cancel"}, 0, selection); + + result = dlg.open(); + + if (result == Window.OK) { + if (dlg.isValid()) { + String info = dlg.getSelection(); + if (info != null) { + selection = info; + } else { + selection = ""; + } + } + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialog.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialog.java new file mode 100644 index 000000000..a2e3acd19 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialog.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Roberto E. Escobar + */ +public class EnvVariableDialog extends MessageDialog { + + private Button cancelButton; + private final String dialogMessage; + + private Button okButton; + + private String selection; + private boolean selectionOk; + private StyledText textArea; + + public EnvVariableDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { + super(parentShell, dialogTitle, dialogTitleImage, null, dialogImageType, dialogButtonLabels, defaultIndex); + this.dialogMessage = dialogMessage; + this.selectionOk = false; + } + + public String getSelection() { + return selection; + } + + public boolean isValid() { + return selectionOk; + } + + @Override + protected Control createButtonBar(Composite parent) { + Control c = super.createButtonBar(parent); + okButton = getButton(0); + cancelButton = getButton(1); + + okButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = true; + + } + }); + + cancelButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = false; + } + }); + return c; + } + + @Override + protected Control createCustomArea(Composite parent) { + super.createCustomArea(parent); + + GridData gd = new GridData(SWT.FILL); + // gd.minimumWidth = 200; + gd.grabExcessHorizontalSpace = true; + + Composite addView = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + addView.setLayout(gridLayout); + addView.setLayoutData(gd); + + new Label(addView, SWT.NONE).setText(dialogMessage); + + GridData gd1 = new GridData(SWT.FILL); + gd1.minimumWidth = 200; + gd1.grabExcessHorizontalSpace = true; + + textArea = new StyledText(addView, SWT.SINGLE | SWT.BORDER); + textArea.setLayoutData(gd1); + textArea.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + selection = textArea.getText(); + } + }); + + return parent; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialogHelper.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialogHelper.java new file mode 100644 index 000000000..5664f06be --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/EnvVariableDialogHelper.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; + +/** + * @author Roberto E. Escobar + */ +public class EnvVariableDialogHelper implements Runnable { + + private int result; + private String selection; + + public EnvVariableDialogHelper() { + + } + + public int getResult() { + return result; + } + + public String getSelection() { + return selection; + } + + @Override + public void run() { + EnvVariableDialog dlg = + new EnvVariableDialog(null, "Add Environment Variable", null, "Enter Name:", MessageDialog.NONE, new String[] { + "OK", + "Cancel"}, 0); + + result = dlg.open(); + + if (result == Window.OK) { + if (dlg.isValid()) { + String info = dlg.getSelection(); + if (info != null) { + selection = info; + } else { + selection = ""; + } + } + } + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/OTEBuilderResourceFinder.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/OTEBuilderResourceFinder.java new file mode 100644 index 000000000..f1e1a6f48 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/OTEBuilderResourceFinder.java @@ -0,0 +1,42 @@ +package org.eclipse.osee.ote.ui.test.manager.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.logging.Level; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.classserver.ResourceFinder; +import org.eclipse.osee.ote.ui.builder.OTEPackagingBuilder; + +/** + * Resource finder for the OTE builder jars. This will enable the downloading of jars from the + * same http server that provides the precompiled jars. + * + * @author Andrew M. Finkbeiner + */ +public class OTEBuilderResourceFinder extends ResourceFinder { + private File rootFolder; + + public OTEBuilderResourceFinder() { + super(); + rootFolder = OTEPackagingBuilder.getWorkspaceArchiveFolder(); + } + + @Override + public byte[] find(String path) throws IOException { + try { + File bundleFile = new File(rootFolder, path); + if(bundleFile.exists()){ + return Lib.inputStreamToBytes(new FileInputStream(bundleFile)); + } + } catch (Exception ex) { + OseeLog.logf(getClass(), Level.SEVERE, "Error trying to read: [%s]", path); + } + return null; + } + + @Override + public void dispose() { + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/PluginUtil.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/PluginUtil.java new file mode 100644 index 000000000..b74dee98c --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/PluginUtil.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class PluginUtil { + + public static List<IViewReference> findAllViews(String viewID) { + ArrayList<IViewReference> list = new ArrayList<>(); + IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); + for (IWorkbenchWindow window : windows) { + IWorkbenchPage pages[] = window.getPages(); + for (IWorkbenchPage page : pages) { + IViewReference viewRefs[] = page.getViewReferences(); + for (IViewReference viewRef : viewRefs) { + if (viewRef.getId().equals(viewID)) { + list.add(viewRef); + } + } + + } + } + return list; + } + + public static boolean areTestManagersAvailable() { + return getTestManagers().length > 0; + } + + public static TestManagerEditor[] getTestManagers() { + List<TestManagerEditor> tmes = new ArrayList<>(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + IEditorReference editors[] = page.getEditorReferences(); + if (editors != null) { + for (int j = 0; j < editors.length; j++) { + IEditorReference editor = editors[j]; + IWorkbenchPart part = editor.getPart(true); + if (part instanceof TestManagerEditor) { + tmes.add((TestManagerEditor) part); + } + } + } + } + } + return tmes.toArray(new TestManagerEditor[tmes.size()]); + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/TestManagerSelectDialog.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/TestManagerSelectDialog.java new file mode 100644 index 000000000..51283fff7 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/TestManagerSelectDialog.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor; +import org.eclipse.ui.dialogs.ListSelectionDialog; + +/** + * @author Roberto E. Escobar + */ +public class TestManagerSelectDialog { + private final static String MESSAGE = "Select A Test Manager"; + private ListSelectionDialog listSelectionDialog; + private LabelProvider labelProvider; + + private TestManagerSelectDialog() { + this.labelProvider = new LabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof TestManagerEditor) { + return ((TestManagerEditor) element).getPartName(); + } + return "Unknown element type"; + } + }; + TestManagerEditor[] input = PluginUtil.getTestManagers(); + this.listSelectionDialog = + new ListSelectionDialog(Displays.getActiveShell(), input, new ArrayContentProvider(), labelProvider, MESSAGE); + this.listSelectionDialog.setTitle(MESSAGE); + if (input.length > 0) { + this.listSelectionDialog.setInitialSelections(new Object[] {input[0]}); + } + } + + public int open() { + return listSelectionDialog.open(); + } + + public TestManagerEditor[] getResult() { + List<TestManagerEditor> tmes = new ArrayList<>(); + for (Object object : listSelectionDialog.getResult()) { + tmes.add((TestManagerEditor) object); + } + return tmes.toArray(new TestManagerEditor[tmes.size()]); + } + + public static TestManagerEditor[] getTestManagerFromUser() { + TestManagerEditor[] toReturn = null; + TestManagerSelectDialog dialog = new TestManagerSelectDialog(); + int result = dialog.open(); + if (result == Window.OK) { + toReturn = dialog.getResult(); + } + return toReturn != null ? toReturn : new TestManagerEditor[0]; + } +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/WidgetFactory.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/WidgetFactory.java new file mode 100644 index 000000000..fe1a5e612 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/WidgetFactory.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.util; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * @author David Diepenbrock + */ +public class WidgetFactory { + + /** + * Creates a <code>Label</code> for use on a GridLayout. + * + * @param comp The composite this label will be on. + * @param horizontalSpan The number of columns this Label should span in the grid + * @return The created label - with no text + */ + public static Label createLabelForGrid(Composite comp, int horizontalSpan) { + Label label = new Label(comp, SWT.NONE); + GridData gd = new GridData(); + gd.horizontalSpan = horizontalSpan; + label.setLayoutData(gd); + return label; + } + + /** + * Creates a <code>Label</code> for use on a GridLayout. The <code>Label</code> will only span 1 column in the grid. + * + * @param comp The composite this label will be on. + * @param str The text for the label + * @return The created label + */ + public static Label createLabelForGrid(Composite comp, String str) { + return createLabelForGrid(comp, str, 1); + } + + /** + * Creates a <code>Label</code> for use on a GridLayout. + * + * @param comp The composite this label will be on. + * @param labelText The text for the label + * @param horizontalSpan The number of columns this Label should span in the grid + * @return The created label + */ + public static Label createLabelForGrid(Composite comp, String labelText, int horizontalSpan) { + Label label = createLabelForGrid(comp, horizontalSpan); + label.setText(labelText); + return label; + } + +} diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizard.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizard.java new file mode 100644 index 000000000..16c9979ac --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizard.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.wizards; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +/** + * This is a sample new wizard. Its role is to create a new file resource in the provided container. If the container + * resource (a folder or a project) is selected in the workspace when the wizard is opened, it will accept it as the + * target container. The wizard creates one file with the extension "mpe". If a sample multi-page editor (also available + * as a template) is registered for the same extension, it will be able to open it. + */ + +public class TestManagerNewWizard extends Wizard implements INewWizard { + private TestManagerNewWizardPage page; + + private ISelection selection; + + /** + * Constructor for SampleNewWizard. + */ + public TestManagerNewWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * Adding the page to the wizard. + */ + + @Override + public void addPages() { + page = new TestManagerNewWizardPage(selection); + addPage(page); + } + + /** + * We will accept the selection in the workbench to see if we can initialize from it. + * + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } + + /** + * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using + * wizard as execution context. + */ + @Override + public boolean performFinish() { + final String containerName = page.getContainerName(); + final String fileName = page.getFileName(); + IRunnableWithProgress op = new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(containerName, fileName, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + + private void doFinish(String containerName, String fileName, IProgressMonitor monitor) throws CoreException { + // create a sample file + monitor.beginTask("Creating " + fileName, 2); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = root.findMember(new Path(containerName)); + if (!resource.exists() || !(resource instanceof IContainer)) { + throwCoreException("Container \"" + containerName + "\" does not exist."); + } + IContainer container = (IContainer) resource; + final IFile file = container.getFile(new Path(fileName + ".tmc")); + try { + InputStream stream = openContentStream(); + if (file.exists()) { + file.setContents(stream, true, true, monitor); + } else { + file.create(stream, true, monitor); + } + stream.close(); + } catch (IOException e) { + } + monitor.worked(1); + monitor.setTaskName("Opening file for editing..."); + getShell().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, file, true); + } catch (PartInitException e) { + } + } + }); + monitor.worked(1); + } + + /** + * We will initialize file contents with a sample text. + */ + + private InputStream openContentStream() { + String contents = + "<testManager>\n" + "<contact></contact>\n" + "<description>Find those bugs</description>\n" + + "<distributionStatement></distributionStatement>\n</testManager>\n"; + return new ByteArrayInputStream(contents.getBytes()); + } + + private void throwCoreException(String message) throws CoreException { + IStatus status = new Status(IStatus.ERROR, "org.eclipse.osee.ote.ui.test.manager", IStatus.OK, message, null); + throw new CoreException(status); + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizardPage.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizardPage.java new file mode 100644 index 000000000..288146838 --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/wizards/TestManagerNewWizardPage.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui.test.manager.wizards; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +/** + * The "New" wizard page allows setting the container for the new file as well as the file name. The page will only + * accept file name without the extension OR with the extension that matches the expected one (mpe). + */ + +public class TestManagerNewWizardPage extends WizardPage { + private Text containerText; + + private Text fileText; + + private final ISelection selection; + + /** + * Constructor for SampleNewWizardPage. + */ + public TestManagerNewWizardPage(ISelection selection) { + super("wizardPage"); + setTitle("Test Manager Editor File"); + setDescription("This wizard creates a new Test Manager file."); + this.selection = selection; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + @Override + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 3; + layout.verticalSpacing = 9; + Label label = new Label(container, SWT.NULL); + label.setText("&Container:"); + + containerText = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + containerText.setLayoutData(gd); + containerText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + Button button = new Button(container, SWT.PUSH); + button.setText("Browse..."); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleBrowse(); + } + }); + label = new Label(container, SWT.NULL); + label.setText("&File name:"); + + fileText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + fileText.setLayoutData(gd); + fileText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + initialize(); + dialogChanged(); + setControl(container); + } + + public String getContainerName() { + return containerText.getText(); + } + + public String getFileName() { + return fileText.getText(); + } + + /** + * Ensures that both text fields are set. + */ + + private void dialogChanged() { + String container = getContainerName(); + String fileName = getFileName(); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = root.findMember(new Path(container)); + IContainer rcontainer = (IContainer) resource; + + if (container.length() == 0) { + updateStatus("File container must be specified"); + return; + } + if (fileName.length() == 0) { + updateStatus("File name must be specified"); + return; + } + + // verify extension isn't there + if (fileName.endsWith("tmc") == true || fileName.endsWith(".") == true) { + updateStatus("Do not add .tmc extenstion."); + return; + } + // verify title is alpha-numeric with spaces and dashes + Matcher m = Pattern.compile("^[\\w]+([\\w_]*[\\w])?$").matcher(fileName); + boolean match = false; + while (m.find()) { + match = true; + } + if (!match) { + updateStatus("Filename must be alpha-numeric with \"_\" \n" + "And can not begin or end with a space."); + return; + } + // verify existing file doesn't exist + final IFile file = rcontainer.getFile(new Path(fileName + ".tmc")); + if (file.exists()) { + updateStatus("File with this name already exists."); + return; + } + int dotLoc = fileName.lastIndexOf('.'); + if (dotLoc != -1) { + String ext = fileName.substring(dotLoc + 1); + if (ext.equalsIgnoreCase("tmc") == false) { + updateStatus("File extension must be \"tmc\""); + return; + } + } + updateStatus(null); + } + + /** + * Uses the standard container selection dialog to choose the new value for the container field. + */ + + private void handleBrowse() { + ContainerSelectionDialog dialog = + new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, + "Select new file container"); + if (dialog.open() == Window.OK) { + Object[] result = dialog.getResult(); + if (result.length == 1) { + containerText.setText(((Path) result[0]).toOSString()); + } + } + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + + private void initialize() { + if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) selection; + if (ssel.size() > 1) { + return; + } + Object obj = ssel.getFirstElement(); + if (obj instanceof IResource) { + IContainer container; + if (obj instanceof IContainer) { + container = (IContainer) obj; + } else { + container = ((IResource) obj).getParent(); + } + containerText.setText(container.getFullPath().toString()); + } + } + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.ote.ui.test.manager/support/output.xsd b/org.eclipse.osee.ote.ui.test.manager/support/output.xsd new file mode 100644 index 000000000..e1731d7fc --- /dev/null +++ b/org.eclipse.osee.ote.ui.test.manager/support/output.xsd @@ -0,0 +1,191 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <!-- ====================== --> + <!-- AUTHOR: Charles Shaw --> + <!-- ====================== --> + + <!-- This is included only once as the first element in TestScript --> + <xs:element name="Config"> + <xs:complexType> + <xs:sequence> + <xs:element name="ScriptName" type="xs:string"/> + <xs:element name="Environment" type="xs:string"/> + <xs:element name="TestEnvironmentVersion" type="xs:string"/> + <xs:element name="UserName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <!-- This is included only once as the last element in TestScript --> + <xs:element name="ScriptResult"> + <xs:complexType> + <xs:sequence> + <xs:element name="ElapsedTime" type="xs:integer"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <!-- Location is used in multiple elements --> + <xs:element name="Location"> + <xs:complexType> + <xs:sequence> + <xs:element name="Source" type="xs:string"/> + <xs:element name="Line" type="xs:integer"/> + <xs:element name="Time" type="xs:integer"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="Debug"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Location"/> + <xs:element name="Message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="Support"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Location"/> + <xs:element name="Message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="Severe"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Location"/> + <xs:element name="Message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="Warning"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Location"/> + <xs:element name="Message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="Attention"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Location"/> + <xs:element name="Message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <!-- CheckPoint and CheckGroup are both used by TestPoint --> + <xs:element name="CheckPoint"> + <xs:complexType> + <xs:sequence> + <xs:element name="TestPointName" type="xs:string"/> + <xs:element name="Expected" type="xs:string"/> + <xs:element name="Actual" type="xs:string"/> + <xs:element name="Result" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <!-- Used to build permutations or the elements in the group --> + <xs:group name="Checks"> + <xs:choice> + <xs:element ref="CheckPoint" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="CheckGroup" minOccurs="0" maxOccurs="unbounded"/> + </xs:choice> + </xs:group> + + <xs:element name="CheckGroup"> + <xs:complexType> + <xs:sequence> + <xs:element name="GroupName"/> + <xs:element name="Result"/> + <xs:group ref="Checks" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="Mode" type="xs:string" use="required"/> + </xs:complexType> + </xs:element> + + <xs:element name="TestPoint"> + <xs:complexType> + <xs:sequence> + <xs:element name="Number" type="xs:integer"/> + <xs:element name="Result" type="xs:string"/> + <xs:element ref="Location"/> + <xs:group ref="Checks" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <!-- Used to build permutations or the elements in the group --> + <xs:group name="Messages"> + <xs:choice> + <xs:element ref="Trace" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="Debug" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="TestPoint" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="Support" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="Severe" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="Warning" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="Attention" minOccurs="0" maxOccurs="unbounded"/> + </xs:choice> + </xs:group> + + <!-- Both Trace and TestCase can hold any element, any number of times --> + <!-- With the exception that only TestScript can hold a TestCase --> + <xs:element name="Trace"> + <xs:complexType> + <xs:sequence> + <xs:element name="ObjectName" type="xs:string"/> + <xs:element name="MethodName" type="xs:string"/> + <xs:element name="MethodArgument" type="xs:string"/> + <xs:element ref="Location"/> + <xs:group ref="Messages" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + + <xs:element name="Tracability"> + <xs:complexType> + <xs:sequence> + <xs:element name="RequirementId" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="TestCase"> + <xs:complexType> + <xs:sequence> + <xs:element name="Number" type="xs:integer"/> + <xs:element ref="Tracability"/> + <xs:group ref="Messages" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="ScriptInit"> + <xs:complexType> + <xs:group ref="Messages" minOccurs="0" maxOccurs="unbounded"/> + </xs:complexType> + </xs:element> + + <!-- Base Element in the XML --> + <xs:element name="TestScript"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Config"/> + <xs:element ref="ScriptInit"/> + <xs:element ref="TestCase" maxOccurs="unbounded"/> + <xs:element ref="ScriptResult"/> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema>
\ No newline at end of file |