diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui.terminals')
54 files changed, 6441 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.classpath b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.classpath new file mode 100644 index 000000000..8a8f1668c --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.options b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.options new file mode 100644 index 000000000..011f13645 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.options @@ -0,0 +1,2 @@ +org.eclipse.tcf.te.ui.terminals/debugmode = 0 +org.eclipse.tcf.te.ui.terminals/trace/outputStreamMonitor = false diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.project b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.project new file mode 100644 index 000000000..020be02e5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.tcf.te.ui.terminals</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.core.prefs b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..e18689090 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,362 @@ +#Fri Oct 07 16:14:53 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=0
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=100
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=4
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=4
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true
+org.eclipse.jdt.core.formatter.lineSplit=100
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.ui.prefs b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..ec52ff1b4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,4 @@ +#Fri Oct 07 16:14:53 CEST 2011
+eclipse.preferences.version=1
+formatter_profile=_Target Explorer Java STD
+formatter_settings_version=12
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF new file mode 100644 index 000000000..52741df3e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF @@ -0,0 +1,42 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.tcf.te.ui.terminals;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.tcf.te.ui.terminals.activator.UIPlugin +Bundle-Vendor: %providerName +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", + org.eclipse.core.expressions;bundle-version="3.4.300", + org.eclipse.core.resources;bundle-version="3.7.100";resolution:=optional, + org.eclipse.ui;bundle-version="3.7.0", + org.eclipse.ui.ide;bundle-version="3.7.0", + org.eclipse.ui.forms;bundle-version="3.5.100", + org.eclipse.tm.terminal;bundle-version="3.1.1", + org.eclipse.tm.terminal.telnet;bundle-version="2.1.0", + org.eclipse.tm.terminal.view;bundle-version="2.2.0", + org.eclipse.tcf.te.runtime;bundle-version="1.0.0", + org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0", + org.eclipse.tcf.te.ui;bundle-version="1.0.0", + org.eclipse.tcf.te.ui.controls;bundle-version="1.0.0", + org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-Localization: plugin +Export-Package: org.eclipse.tcf.te.ui.terminals.actions, + org.eclipse.tcf.te.ui.terminals.activator;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.events, + org.eclipse.tcf.te.ui.terminals.help, + org.eclipse.tcf.te.ui.terminals.interfaces, + org.eclipse.tcf.te.ui.terminals.internal;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.internal.dialogs;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.internal.handler;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.internal.tracing;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.launcher, + org.eclipse.tcf.te.ui.terminals.manager, + org.eclipse.tcf.te.ui.terminals.nls;x-internal:=true, + org.eclipse.tcf.te.ui.terminals.panels, + org.eclipse.tcf.te.ui.terminals.services, + org.eclipse.tcf.te.ui.terminals.streams, + org.eclipse.tcf.te.ui.terminals.tabs, + org.eclipse.tcf.te.ui.terminals.types, + org.eclipse.tcf.te.ui.terminals.view diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties new file mode 100644 index 000000000..73a5119ed --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties @@ -0,0 +1,6 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ plugin.xml
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties new file mode 100644 index 000000000..7b6f0d298 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties @@ -0,0 +1,31 @@ +################################################################################## +# Copyright (c) 2011 Wind River Systems, Inc. and others. 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: +# Wind River Systems - initial API and implementation +################################################################################## + +pluginName = Target Explorer, Terminals +providerName = Eclipse.org + +# ----- Terminals View ----- + +TerminalsView.name=Terminals + +# ----- Terminal Connectors ----- + +TerminalConnector.streams=Streams Connector (hidden) + +# ----- Terminal Connector Types ----- + +TelnetConnectorType.label=Telnet Connector Type +StreamsConnectorType.label=Streams Connector Type + +# ----- Commands and Menu contributions ----- + +command.launch.name=Launch Terminal Command +command.launch.label=&Launch Terminal... +command.launch.tooltip=Opens a terminal on the selected peer. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml new file mode 100644 index 000000000..cca7423f9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!-- Extension points -->
+ <extension-point id="connectorTypes" name="Terminal Connector Types" schema="schema/connectorTypes.exsd"/>
+ <extension-point id="launcherDelegates" name="Terminal Launcher Delegates" schema="schema/launcherDelegates.exsd"/>
+
+<!-- View contributions -->
+ <extension point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.tcf.te.ui.views.category"
+ class="org.eclipse.tcf.te.ui.terminals.view.TerminalsView"
+ icon="platform:/plugin/org.eclipse.ui.console/icons/full/eview16/console_view.gif"
+ id="org.eclipse.tcf.te.ui.terminals.TerminalsView"
+ name="%TerminalsView.name">
+ </view>
+ </extension>
+
+<!-- Perspective extension contributions -->
+ <extension point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID="*">
+ <view
+ id="org.eclipse.tcf.te.ui.terminals.TerminalsView"
+ minimized="false"
+ relationship="stack"
+ relative="org.eclipse.ui.views.TaskList"
+ visible="false">
+ </view>
+ </perspectiveExtension>
+
+ <perspectiveExtension targetID="org.eclipse.tcf.te.ui.perspective">
+ <!-- Register the view shortcuts -->
+ <viewShortcut id="org.eclipse.tcf.te.ui.terminals.TerminalsView"/>
+ </perspectiveExtension>
+ </extension>
+
+<!-- Terminal connector contributions -->
+ <extension point="org.eclipse.tm.terminal.terminalConnectors">
+ <connector
+ name="%TerminalConnector.streams"
+ id="org.eclipse.tcf.te.ui.terminals.StreamsConnector"
+ hidden="true"
+ class="org.eclipse.tcf.te.ui.terminals.streams.StreamsConnector"/>
+ </extension>
+
+<!-- Preferences contributions -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer class="org.eclipse.tcf.te.ui.terminals.internal.PreferenceInitializer"/>
+ </extension>
+
+<!-- Eclipse core expressions property tester -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.ui.terminals.internal.PropertyTester"
+ id="org.eclipse.tcf.te.ui.terminals.PropertyTester"
+ namespace="org.eclipse.tcf.te.ui.terminals"
+ properties="hasApplicableLauncherDelegates"
+ type="java.lang.Object">
+ </propertyTester>
+ </extension>
+
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <genericServices>
+ <service class="org.eclipse.tcf.te.ui.terminals.services.TerminalService">
+ <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService"/>
+ </service>
+ </genericServices>
+ </extension>
+
+<!-- Terminal connector type contributions -->
+ <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes">
+ <connectorType
+ class="org.eclipse.tcf.te.ui.terminals.types.TelnetConnectorType"
+ id="org.eclipse.tcf.te.ui.terminals.type.telnet"
+ label="%TelnetConnectorType.label">
+ </connectorType>
+
+ <connectorType
+ class="org.eclipse.tcf.te.ui.terminals.types.StreamsConnectorType"
+ id="org.eclipse.tcf.te.ui.terminals.type.streams"
+ label="%StreamsConnectorType.label">
+ </connectorType>
+ </extension>
+
+<!-- Menu contributions -->
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.TargetExplorer#Popup?after=group.launch">
+ <command
+ commandId="org.eclipse.tcf.te.ui.terminals.command.launch"
+ helpContextId="org.eclipse.tcf.te.ui.terminals.command_Launch"
+ icon="platform:/plugin/org.eclipse.ui.console/icons/full/eview16/console_view.gif"
+ id="org.eclipse.tcf.te.ui.terminals.commands.launch"
+ label="%command.launch.label"
+ style="push"
+ tooltip="%command.launch.tooltip">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <test property="org.eclipse.tcf.te.ui.terminals.hasApplicableLauncherDelegates" value="true"/>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+<!-- Command contributions -->
+ <extension point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.ui.terminals.command_Launch"
+ id="org.eclipse.tcf.te.ui.terminals.command.launch"
+ name="%command.launch.name">
+ </command>
+ </extension>
+
+<!-- Handler contributions -->
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.tcf.te.ui.terminals.internal.handler.LaunchTerminalCommandHandler"
+ commandId="org.eclipse.tcf.te.ui.terminals.command.launch">
+ </handler>
+ </extension>
+
+</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/pom.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/pom.xml new file mode 100644 index 000000000..162cfe8e5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/pom.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.tcf</groupId> + <artifactId>tcf-parent</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../../pom.xml</relativePath> + </parent> + + <version>1.0.0.qualifier</version> + <artifactId>org.eclipse.tcf.te.ui.terminals</artifactId> + <packaging>eclipse-plugin</packaging> +</project> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd new file mode 100644 index 000000000..4f1321c40 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd @@ -0,0 +1,200 @@ +<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.ui.terminals" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.ui.terminals" id="connectorTypes" name="Terminals Connector Types"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute terminals connector types.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="connectorType" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="connectorType">
+ <annotation>
+ <documentation>
+ Declares a Target Explorer terminal connector type contribution.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="class" minOccurs="0" maxOccurs="1"/>
+ <element ref="description" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique id of the terminal connector type contribution.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+ The label representing the terminal connector type within the UI.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</code> or extends <code>org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType</code>.
+<p>
+The terminal connector type implementation class must be specified either by the class attribute or the class child element!
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType:org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="description" type="string">
+ <annotation>
+ <documentation>
+ A short description of the terminal connector type to be presented in the UI.
+ </documentation>
+ </annotation>
+ </element>
+
+ <element name="class">
+ <annotation>
+ <documentation>
+ Used when creating an <code>IExecutableExtension</code> with a named parameter, or more than one.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</code> or extends <code>org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType</code>.
+<p>
+The terminal connector type implementation class must be specified either by the class attribute or the class child element!
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType:org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="parameter">
+ <annotation>
+ <documentation>
+ A parameter for an <code>IExecutableExtension</code>.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ <p>The parameter name.</p>
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+ <p>The parameter value.</p>
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ This is an example of the extension point usage:
+<p>
+<pre><code>
+ <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes">
+ <connectorType
+ id="org.eclipse.tcf.te.ui.terminals.connector.telnet"
+ class="org.eclipse.tcf.te.ui.terminals.internal.TelnetConnectorType"
+ label="Telnet Terminal Connector Type">
+ </connectorType>
+ </extension>
+</code></pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ The provider of a connector type must implement <samp>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</samp>.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011 Wind River Systems, Inc. and others.
+
+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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/launcherDelegates.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/launcherDelegates.exsd new file mode 100644 index 000000000..ac5814981 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/launcherDelegates.exsd @@ -0,0 +1,208 @@ +<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.ui.terminals" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.ui.terminals" id="launcherDelegates" name="Terminal Launcher Delegates"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute terminal launcher delegates.
+<p>
+Terminal launcher delegates contributes terminal settings widget to the <code>LaunchTerminalSettingsDialog</code> required to open a remote terminal through a specific communication channel, like TCF or SSH.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="delegate" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="delegate">
+ <annotation>
+ <documentation>
+ Declares a Target Explorer terminal launcher delegate contribution.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="class" minOccurs="0" maxOccurs="1"/>
+ <element ref="description" minOccurs="0" maxOccurs="1"/>
+ <element ref="enablement" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique id of the terminal launcher delegate contribution.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+ The label representing the terminal launcher delegate within the UI.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate</code> or extends <code>org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate</code>.
+<p>
+The terminal launcher delegate implementation class must be specified either by the class attribute or the class child element!
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate:org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="description" type="string">
+ <annotation>
+ <documentation>
+ A short description of the terminal connector type to be presented in the UI.
+ </documentation>
+ </annotation>
+ </element>
+
+ <element name="class">
+ <annotation>
+ <documentation>
+ Used when creating an <code>IExecutableExtension</code> with a named parameter, or more than one.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate</code> or extends <code>org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate</code>.
+<p>
+The terminal launcher delegate implementation class must be specified either by the class attribute or the class child element!
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate:org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="parameter">
+ <annotation>
+ <documentation>
+ A parameter for an <code>IExecutableExtension</code>.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ <p>The parameter name.</p>
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+ <p>The parameter value.</p>
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ This is an example of the extension point usage:
+<p>
+<pre><code>
+ <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates">
+ <delegate
+ id="org.eclipse.tcf.te.ui.terminals.launcher.tcf"
+ class="org.eclipse.tcf.te.tcf.terminals.ui.internal.TerminalLauncherDelegate"
+ label="TCF Terminal">
+ <enablement>
+ ...
+ </enablement>
+ </delegate>
+ </extension>
+</code></pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ The provider of a launcher delegate must implement <samp>org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate</samp>.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2011 Wind River Systems, Inc. and others.
+
+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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/AbstractAction.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/AbstractAction.java new file mode 100644 index 000000000..20b92005b --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/AbstractAction.java @@ -0,0 +1,184 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.actions; + +import java.util.Collections; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.expressions.EvaluationContext; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderToolbarHandler; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.ui.ISources; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; + +/** + * Abstract terminal action wrapper implementation. + */ +@SuppressWarnings("restriction") +public abstract class AbstractAction extends AbstractTerminalAction { + // Reference to the parent toolbar handler + private final TabFolderToolbarHandler parent; + + /** + * Constructor. + * + * @param parent + * The parent toolbar handler instance. Must not be + * <code>null</code>. + * @param id + * The terminal action id. Must not be <code>null</code>. + */ + public AbstractAction(TabFolderToolbarHandler parent, String id) { + super(id); + + Assert.isNotNull(parent); + this.parent = parent; + } + + /** + * Returns the parent toolbar handler. + * + * @return The parent toolbar handler. + */ + protected final TabFolderToolbarHandler getParent() { + return parent; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getParent().getActiveTerminalViewControl(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#run() + */ + @Override + public void run() { + // Get the active tab item from the tab folder manager + TabFolderManager manager = (TabFolderManager)getParent().getAdapter(TabFolderManager.class); + if (manager != null) { + // If we have the active tab item, we can get the active terminal control + CTabItem activeTabItem = manager.getActiveTabItem(); + if (activeTabItem != null) { + // And execute the command + executeCommand(activeTabItem.getData("customData")); //$NON-NLS-1$ + } + } + } + + /** + * Executes the command for the given data node as current and active menu selection. + * <p> + * <b>Node:</b> If the provided data node is <code>null</code>, the method will trigger + * the command with an empty selection. + * + * @param data The terminal custom data node or <code>null</code>. + */ + protected void executeCommand(Object data) { + // Get the command service from the workbench + ICommandService service = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class); + if (service != null && getCommandId() != null) { + // Get the command + final Command command = service.getCommand(getCommandId()); + if (command != null && command.isDefined()) { + // Construct a selection element + IStructuredSelection selection = data != null ? new StructuredSelection(data) : new StructuredSelection(); + // Construct the application context + EvaluationContext context = new EvaluationContext(null, selection); + // Apply the selection to the "activeMenuSelection" and "selection" variable too + context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); + context.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection); + // Construct the execution event + ExecutionEvent execEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, this, context); + // And execute the event + try { + command.executeWithChecks(execEvent); + } catch (Exception e) { + IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), + NLS.bind(Messages.AbstractAction_error_commandExecutionFailed, getCommandId(), e.getLocalizedMessage()), + e); + UIPlugin.getDefault().getLog().log(status); + } + } + } + } + + /** + * Returns the command id of the command to execute. + * + * @return The command id. Must be never <code>null</code>. + */ + protected abstract String getCommandId(); + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#updateAction(boolean) + */ + @Override + public void updateAction(boolean aboutToShow) { + // Ignore the flag given from outside. We have to decide ourself + // what the enabled state of the action is + boolean enabled = getTarget() != null; + + // If a target terminal control is available, we need to find the corresponding + // VLM target object which we need to trigger the handler + if (enabled) { + // The action will be enabled if we can determine the VLM target object + enabled = false; + // Get the active tab item from the tab folder manager + TabFolderManager manager = (TabFolderManager)getParent().getAdapter(TabFolderManager.class); + if (manager != null) { + // If we have the active tab item, we can get the active terminal control + CTabItem activeTabItem = manager.getActiveTabItem(); + if (activeTabItem != null) { + enabled = checkEnableAction(activeTabItem.getData("customData")); //$NON-NLS-1$ + } + } + } + + setEnabled(enabled); + } + + /** + * Checks if the action should be enabled based on the given terminal data object. + * + * @param data The terminal data node or <code>null</code>. + * @return <code>True</code> to enable the action, <code>false</code> otherwise. + */ + protected boolean checkEnableAction(Object data) { + return data != null; + } + + /** + * Returns if the action is a separator. Returning <code>true</code> here + * means that an additional separator toolbar element is added right or + * above of the action. + * + * @return <code>True</code> if the action is separating the parent contribution manager, <code>false</code> otherwise. + */ + public boolean isSeparator() { + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java new file mode 100644 index 000000000..762f1b585 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts; +import org.eclipse.tm.internal.terminal.actions.ActionMessages; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; + +/** + * Terminal console tab scroll lock action. + */ +@SuppressWarnings("restriction") +public class TabScrollLockAction extends AbstractTerminalAction { + + /** + * Constructor. + */ + public TabScrollLockAction() { + super(null, TabScrollLockAction.class.getName(), IAction.AS_RADIO_BUTTON); + + setupAction(ActionMessages.SCROLL_LOCK_0, + ActionMessages.SCROLL_LOCK_1, + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ScrollLock_Hover), + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ScrollLock_Enabled), + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ScrollLock_Disabled), + true); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#run() + */ + @Override + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.setScrollLock(!target.isScrollLock()); + setChecked(target.isScrollLock()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#updateAction(boolean) + */ + @Override + public void updateAction(boolean aboutToShow) { + setEnabled(getTarget() != null && aboutToShow); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java new file mode 100644 index 000000000..ca8bbe651 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java @@ -0,0 +1,143 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.activator;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+ // The shared instance
+ private static UIPlugin plugin;
+
+ private static ScopedEclipsePreferences scopedPreferences = null;
+ // The trace handler instance
+ private static TraceHandler traceHandler;
+
+ /**
+ * The constructor
+ */
+ public UIPlugin() {
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getDefault() != null && getDefault().getBundle() != null) {
+ return getDefault().getBundle().getSymbolicName();
+ }
+ return null;
+ }
+
+ /**
+ * Return the scoped preferences for this plugin.
+ */
+ public static ScopedEclipsePreferences getScopedPreferences() {
+ if (scopedPreferences == null) {
+ scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
+ }
+ return scopedPreferences;
+ }
+
+ /**
+ * Returns the bundles trace handler.
+ *
+ * @return The bundles trace handler.
+ */
+ public static TraceHandler getTraceHandler() {
+ if (traceHandler == null) {
+ traceHandler = new TraceHandler(getUniqueIdentifier());
+ }
+ return traceHandler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ scopedPreferences = null;
+ traceHandler = null;
+ super.stop(context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
+ */
+ @Override
+ protected void initializeImageRegistry(ImageRegistry registry) {
+ Bundle bundle = Platform.getBundle("org.eclipse.ui.console"); //$NON-NLS-1$
+ if (bundle != null) {
+ URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_EVIEW + "console_view.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ registry.put(ImageConsts.VIEW_Terminals, ImageDescriptor.createFromURL(url));
+
+ url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_CLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ registry.put(ImageConsts.ACTION_ScrollLock_Hover, ImageDescriptor.createFromURL(url));
+ url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ registry.put(ImageConsts.ACTION_ScrollLock_Enabled, ImageDescriptor.createFromURL(url));
+ url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ registry.put(ImageConsts.ACTION_ScrollLock_Disabled, ImageDescriptor.createFromURL(url));
+ }
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>Image</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>Image</code> object instance or <code>null</code>.
+ */
+ public static Image getImage(String key) {
+ return getDefault().getImageRegistry().get(key);
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>ImageDescriptor</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>ImageDescriptor</code> object instance or <code>null</code>.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return getDefault().getImageRegistry().getDescriptor(key);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/events/SelectionChangedBroadcastEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/events/SelectionChangedBroadcastEvent.java new file mode 100644 index 000000000..037952335 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/events/SelectionChangedBroadcastEvent.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.events; + +import java.util.EventObject; + +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tcf.te.runtime.events.EventManager; + +/** + * Terminal console selection changed broadcast event. The event is typically fired + * by a terminal console tab folder manager to signal a tab switch to all listeners. + */ +public class SelectionChangedBroadcastEvent extends EventObject { + private static final long serialVersionUID = -4970244776543572896L; + + // The selection changed event to broadcast + private final SelectionChangedEvent selectionChangedEvent; + + /** + * Constructor. + * + * @param source The event source. Must not be <code>null</code>. + * @param selectionChangedEvent The selection changed event or <code>null</code>. + */ + public SelectionChangedBroadcastEvent(TabFolderManager source, SelectionChangedEvent selectionChangedEvent) { + super(source); + this.selectionChangedEvent = selectionChangedEvent; + } + + /** + * Convenience method to return the source tab folder manager. + * + * @return The source tab folder manager. + */ + public TabFolderManager getSourceTabFolderManager() { + return (TabFolderManager)getSource(); + } + + /** + * Returns the broadcasted selection changed event. + * + * @return The broadcasted selection changed event or <code>null</code>. + */ + public SelectionChangedEvent getSelectionChangedEvent() { + return selectionChangedEvent; + } + + /* (non-Javadoc) + * @see java.util.EventObject#toString() + */ + @Override + public String toString() { + StringBuilder toString = new StringBuilder(getClass().getName()); + + String prefix = ""; //$NON-NLS-1$ + // if debugging the event, formating them a little bit better readable. + if (EventManager.isTracingEnabled()) + prefix = "\n\t\t"; //$NON-NLS-1$ + + toString.append(prefix + "source="); //$NON-NLS-1$ + toString.append(source); + toString.append("," + prefix + "selectionChangedEvent="); //$NON-NLS-1$ //$NON-NLS-2$ + toString.append(selectionChangedEvent); + toString.append("}"); //$NON-NLS-1$ + + return toString.toString(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/help/IContextHelpIds.java new file mode 100644 index 000000000..ce492cc31 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/help/IContextHelpIds.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.help; + +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; + + +/** + * UI Context help id definitions. + */ +public interface IContextHelpIds { + + /** + * UI plug-in common context help id prefix. + */ + public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$ + + /** + * Launch terminal settings dialog. + */ + public final static String LAUNCH_TERMINAL_SETTINGS_DIALOG = PREFIX + "LaunchTerminalSettingsDialog"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConfigurationPanel.java new file mode 100644 index 000000000..53d278495 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConfigurationPanel.java @@ -0,0 +1,33 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.interfaces;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel;
+
+/**
+ * Terminal launcher configuration panel.
+ */
+public interface IConfigurationPanel extends IWizardConfigurationPanel {
+
+ /**
+ * Set the selection to the configuration panel.
+ *
+ * @param selection The selection or <code>null</code>.
+ */
+ public void setSelection(ISelection selection);
+
+ /**
+ * Returns the selection associated with the configuration panel.
+ *
+ * @return The selection or <code>null</code>.
+ */
+ public ISelection getSelection();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java new file mode 100644 index 000000000..cecaf0060 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java @@ -0,0 +1,30 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.interfaces;
+
+import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+
+/**
+ * Terminal connector type.
+ */
+@SuppressWarnings("restriction")
+public interface IConnectorType extends IExecutableExtension {
+
+ /**
+ * Creates the terminal connector for this terminal connector type
+ * based on the given properties.
+ *
+ * @param properties The terminal properties. Must not be <code>null</code>.
+ * @return The terminal connector or <code>null</code>.
+ */
+ public ITerminalConnector createTerminalConnector(IPropertiesContainer properties);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java new file mode 100644 index 000000000..6d1afb090 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java @@ -0,0 +1,59 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.interfaces;
+
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+
+/**
+ * Terminal launcher delegate.
+ */
+public interface ILauncherDelegate extends IExecutableExtension {
+
+ /**
+ * Returns the enablement expression.
+ *
+ * @return The enablement expression or <code>null</code>.
+ */
+ public Expression getEnablement();
+
+ /**
+ * Returns if or if not the user needs to set configuration details for this launcher to work.
+ * The settings to configure are provided to the user through the configuration panel returned
+ * by {@link #getPanel(BaseDialogPageControl)}.
+ *
+ * @return <code>True</code> if a user configuration is required, <code>false</code> otherwise.
+ */
+ public boolean needsUserConfiguration();
+
+ /**
+ * Returns the configuration panel instance to present to the user. The instance must be always
+ * the same on subsequent calls until disposed.
+ * <p>
+ * The method may return <code>null</code> if the launcher does not provide any user
+ * configurable settings. In this case, {@link #needsUserConfiguration()} should return
+ * <code>false</code>.
+ *
+ * @param parentControl The parent control. Must not be <code>null</code>.
+ * @return The configuration panel instance or <code>null</code>
+ */
+ public IConfigurationPanel getPanel(BaseDialogPageControl parentControl);
+
+ /**
+ * Execute the terminal launch.
+ *
+ * @param properties The properties. Must not be <code>null</code>.
+ * @param callback The callback or <code>null</code>.
+ */
+ public void execute(IPropertiesContainer properties, ICallback callback);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IPreferenceKeys.java new file mode 100644 index 000000000..905b568aa --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IPreferenceKeys.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.interfaces; + +/** + * Terminals plug-in preference key definitions. + */ +public interface IPreferenceKeys { + /** + * Preference keys family prefix. + */ + public final String PREF_TERMINAL = "terminals"; //$NON-NLS-1$ + + /** + * Preference key: Remove terminated terminals when a new terminal is created. + */ + public final String PREF_REMOVE_TERMINATED_TERMINALS = PREF_TERMINAL + ".removeTerminatedTerminals"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ITerminalsView.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ITerminalsView.java new file mode 100644 index 000000000..6e42a43bb --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ITerminalsView.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.interfaces; + +import org.eclipse.ui.IViewPart; + +/** + * Terminals view public interface. + */ +public interface ITerminalsView extends IViewPart { + + /** + * Switch to the empty page control. + */ + public void switchToEmptyPageControl(); + + /** + * Switch to the tab folder control. + */ + public void switchToTabFolderControl(); + + /** + * Returns the context help id associated with the terminal + * console view instance. + * + * @return The context help id or <code>null</code> if none is associated. + */ + public String getContextHelpId(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IUIConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IUIConstants.java new file mode 100644 index 000000000..7c733a0e6 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IUIConstants.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.interfaces; + +/** + * Terminals common UI constants. + */ +public interface IUIConstants { + /** + * The view id of the terminals view. + */ + public static final String ID = "org.eclipse.tcf.te.ui.terminals.TerminalsView"; //$NON-NLS-1$ + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java new file mode 100644 index 000000000..faf6af528 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.interfaces; + +/** + * Image registry constants. + */ +public interface ImageConsts { + /** + * The root directory where to load the images from, relative to + * the bundle directory. + */ + public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ + + /** + * The directory where to load colored local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_CLCL = "clcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load disabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_DLCL = "dlcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load enabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_ELCL = "elcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load view related images from, relative to + * the image root directory. + */ + public final static String IMAGE_DIR_EVIEW = "eview16/"; //$NON-NLS-1$ + + /** + * The key to access the terminal consoles view image. + */ + public static final String VIEW_Terminals = "TerminalsView"; //$NON-NLS-1$ + + /** + * The key to access the scroll lock action image (enabled). + */ + public static final String ACTION_ScrollLock_Enabled = "ScrollLockAction_enabled"; //$NON-NLS-1$ + + /** + * The key to access the scroll lock action image (disabled). + */ + public static final String ACTION_ScrollLock_Disabled = "ScrollLockAction_disabled"; //$NON-NLS-1$ + + /** + * The key to access the scroll lock action image (hover). + */ + public static final String ACTION_ScrollLock_Hover = "ScrollLockAction_hover"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PreferenceInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PreferenceInitializer.java new file mode 100644 index 000000000..269613742 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PreferenceInitializer.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.internal; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.interfaces.IPreferenceKeys; +import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; + +/** + * Terminals default preferences initializer. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /** + * Constructor. + */ + public PreferenceInitializer() { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + @Override + public void initializeDefaultPreferences() { + ScopedEclipsePreferences prefs = UIPlugin.getScopedPreferences(); + + prefs.putDefaultBoolean(IPreferenceKeys.PREF_REMOVE_TERMINATED_TERMINALS, true); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java new file mode 100644 index 000000000..dfe166721 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.internal; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager; + + +/** + * Terminals property tester implementation. + */ +public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { + + /* (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if ("hasApplicableLauncherDelegates".equals(property)) { //$NON-NLS-1$ + ISelection selection = receiver instanceof ISelection ? (ISelection)receiver : new StructuredSelection(receiver); + return expectedValue.equals(Boolean.valueOf(LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection).length > 0)); + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/SettingsStore.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/SettingsStore.java new file mode 100644 index 000000000..bd9cfd284 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/SettingsStore.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.internal; + +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; + +/** + * Simple default Terminal settings store implementation keeping the settings + * within memory. + */ +@SuppressWarnings("restriction") +public class SettingsStore extends PropertiesContainer implements ISettingsStore { + + /** + * Constructor. + */ + public SettingsStore() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String, java.lang.String) + */ + @Override + public String get(String key, String defaultValue) { + String value = getStringProperty(key); + return value != null ? value : defaultValue; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String) + */ + @Override + public String get(String key) { + return getStringProperty(key); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.ISettingsStore#put(java.lang.String, java.lang.String) + */ + @Override + public void put(String key, String value) { + setProperty(key, value); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java new file mode 100644 index 000000000..c524314c4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java @@ -0,0 +1,334 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ * Max Weninger (Wind River) - [361352] [TERMINALS][SSH] Add SSH terminal support
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.internal.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.terminals.help.IContextHelpIds;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
+import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
+import org.eclipse.tcf.te.ui.terminals.nls.Messages;
+import org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel;
+import org.eclipse.tm.internal.terminal.view.ViewMessages;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.BaseWizardConfigurationPanelControl;
+import org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Launch terminal settings dialog implementation.
+ */
+@SuppressWarnings("restriction")
+public class LaunchTerminalSettingsDialog extends CustomTrayDialog {
+ // The parent selection
+ private ISelection selection = null;
+
+ // The subcontrols
+ /* default */ Combo terminals;
+ /* default */ SettingsPanelControl settings;
+
+ // Map the label added to the combobox to the corresponding launcher delegate.
+ private final Map<String, ILauncherDelegate> label2delegate = new HashMap<String, ILauncherDelegate>();
+
+ // The data object containing the currently selected settings
+ private IPropertiesContainer data = null;
+
+ /**
+ * The control managing the terminal setting panels.
+ */
+ protected class SettingsPanelControl extends BaseWizardConfigurationPanelControl {
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public SettingsPanelControl(IDialogPage parentPage) {
+ super(parentPage);
+ setPanelIsGroup(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseWizardConfigurationPanelControl#getGroupLabel()
+ */
+ @Override
+ public String getGroupLabel() {
+ return Messages.LaunchTerminalSettingsDialog_group_label;
+ }
+ }
+
+ /**
+ * An empty terminal settings panel.
+ */
+ protected class EmptySettingsPanel extends AbstractConfigurationPanel {
+
+ /**
+ * Constructor.
+ *
+ * @param parentControl The parent control. Must not be <code>null</code>!
+ */
+ public EmptySettingsPanel(BaseDialogPageControl parentControl) {
+ super(parentControl);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.controls.interfaces.FormToolkit)
+ */
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void setupPanel(Composite parent, FormToolkit toolkit) {
+ Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayout(new GridLayout());
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label label = new Label(panel, SWT.HORIZONTAL);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ layoutData.widthHint = convertWidthInCharsToPixels(30);
+ layoutData.heightHint = convertHeightInCharsToPixels(5);
+ label.setLayoutData(layoutData);
+
+ setControl(panel);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#dataChanged(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.swt.events.TypedEvent)
+ */
+ @Override
+ public boolean dataChanged(IPropertiesContainer data, TypedEvent e) {
+ return false;
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param shell The parent shell or <code>null</code>.
+ */
+ public LaunchTerminalSettingsDialog(Shell shell) {
+ super(shell, IContextHelpIds.LAUNCH_TERMINAL_SETTINGS_DIALOG);
+ }
+
+ /**
+ * Sets the parent selection.
+ *
+ * @param selection The parent selection or <code>null</code>.
+ */
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ }
+
+ /**
+ * Returns the parent selection.
+ *
+ * @return The parent selection or <code>null</code>.
+ */
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#dispose()
+ */
+ @Override
+ protected void dispose() {
+ if (settings != null) { settings.dispose(); settings = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setDialogTitle(Messages.LaunchTerminalSettingsDialog_title);
+
+ Composite composite = (Composite)super.createDialogArea(parent);
+
+ Composite panel = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+
+ Label label = new Label(panel, SWT.HORIZONTAL);
+ label.setText(Messages.LaunchTerminalSettingsDialog_combo_label);
+
+ terminals = new Combo(panel, SWT.READ_ONLY);
+ terminals.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ terminals.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ settings.showConfigurationPanel(terminals.getText());
+ }
+ });
+
+ // fill the combo with content
+ fillCombo(terminals);
+
+ // Create the settings panel control
+ settings = new SettingsPanelControl(null);
+
+ // Create and add the panels
+ for (String terminalLabel : terminals.getItems()) {
+ // Get the corresponding delegate
+ ILauncherDelegate delegate = label2delegate.get(terminalLabel);
+ Assert.isNotNull(delegate);
+ // Get the wizard configuration panel instance
+ IConfigurationPanel configPanel = delegate.getPanel(settings);
+ if (configPanel == null) configPanel = new EmptySettingsPanel(settings);
+ // Push the selection to the configuration panel
+ Assert.isNotNull(configPanel);
+ configPanel.setSelection(getSelection());
+ // Add it
+ settings.addConfigurationPanel(terminalLabel, configPanel);
+ }
+
+ // Setup the panel control
+ settings.setupPanel(panel, terminals.getItems(), new FormToolkit(panel.getDisplay()));
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ layoutData.horizontalSpan = 2;
+ settings.getPanel().setLayoutData(layoutData);
+
+ // Preselect the first terminal launcher
+ terminals.select(0);
+ settings.showConfigurationPanel(terminals.getText());
+
+ SWTControlUtil.setEnabled(terminals, terminals.getItemCount() > 1);
+
+ restoreWidgetValues();
+
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ /**
+ * Fill the given combo with content. The content are the terminal
+ * launcher delegate labels.
+ *
+ * @param combo The combo. Must not be <code>null</code>.
+ */
+ protected void fillCombo(Combo combo) {
+ Assert.isNotNull(combo);
+
+ List<String> items = new ArrayList<String>();
+
+ ILauncherDelegate[] delegates = LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection);
+ for (ILauncherDelegate delegate : delegates) {
+ String label = delegate.getLabel();
+ if (label == null || "".equals(label.trim())) label = delegate.getId(); //$NON-NLS-1$
+ label2delegate.put(label, delegate);
+ items.add(label);
+ }
+
+ Collections.sort(items);
+ combo.setItems(items.toArray(new String[items.size()]));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#saveWidgetValues()
+ */
+ @Override
+ protected void saveWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ settings.put("terminalLabel", SWTControlUtil.getText(terminals)); //$NON-NLS-1$
+ this.settings.saveWidgetValues(settings, null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#restoreWidgetValues()
+ */
+ @Override
+ protected void restoreWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ String terminalLabel = settings.get("terminalLabel"); //$NON-NLS-1$
+ int index = terminalLabel != null ? Arrays.asList(terminals.getItems()).indexOf(terminalLabel) : -1;
+ if (index != -1) {
+ terminals.select(index);
+ this.settings.showConfigurationPanel(terminals.getText());
+ }
+
+ this.settings.restoreWidgetValues(settings, null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ IWizardConfigurationPanel panel = this.settings.getConfigurationPanel(terminals.getText());
+
+ if(!panel.isValid()){
+ String strTitle = ViewMessages.TERMINALSETTINGS;
+ MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
+ mb.setText(strTitle);
+ mb.setMessage(ViewMessages.INVALID_SETTINGS);
+ mb.open();
+ return;
+ }
+ data = new PropertiesContainer();
+
+ // Store the id of the selected delegate
+ data.setProperty("delegateId", label2delegate.get(terminals.getText()).getId()); //$NON-NLS-1$
+ // Store the selection
+ data.setProperty("selection", selection); //$NON-NLS-1$
+
+ // Store the delegate specific settings
+ if (panel instanceof ISharedDataWizardPage) {
+ ((ISharedDataWizardPage)panel).extractData(data);
+ }
+
+ super.okPressed();
+ }
+
+ /**
+ * Returns the configured terminal launcher settings.
+ * <p>
+ * The settings are extracted from the UI widgets once
+ * OK got pressed.
+ *
+ * @return The configured terminal launcher settings or <code>null</code>.
+ */
+ public IPropertiesContainer getSettings() {
+ return data;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/LaunchTerminalCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/LaunchTerminalCommandHandler.java new file mode 100644 index 000000000..19e62c288 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/LaunchTerminalCommandHandler.java @@ -0,0 +1,74 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.internal.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
+import org.eclipse.tcf.te.ui.terminals.internal.dialogs.LaunchTerminalSettingsDialog;
+import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Launch terminal command handler implementation.
+ */
+public class LaunchTerminalCommandHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Get the active shell
+ Shell shell = HandlerUtil.getActiveShell(event);
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ // Check if the dialog needs to be shown at all
+ ILauncherDelegate[] delegates = LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection);
+ if (delegates.length > 1 || (delegates.length == 1 && delegates[0].needsUserConfiguration())) {
+ // Create the launch terminal settings dialog
+ LaunchTerminalSettingsDialog dialog = new LaunchTerminalSettingsDialog(shell);
+ dialog.setSelection(selection);
+ if (dialog.open() == Window.OK) {
+ // Get the terminal settings from the dialog
+ IPropertiesContainer properties = dialog.getSettings();
+ if (properties != null) {
+ String delegateId = properties.getStringProperty("delegateId"); //$NON-NLS-1$
+ Assert.isNotNull(delegateId);
+ ILauncherDelegate delegate = LauncherDelegateManager.getInstance().getLauncherDelegate(delegateId, false);
+ Assert.isNotNull(delegateId);
+ delegate.execute(properties, null);
+ }
+ }
+ } else if (delegates.length == 1) {
+ ILauncherDelegate delegate = delegates[0];
+ IPropertiesContainer properties = new PropertiesContainer();
+
+ // Store the id of the selected delegate
+ properties.setProperty("delegateId", delegate.getId()); //$NON-NLS-1$
+ // Store the selection
+ properties.setProperty("selection", selection); //$NON-NLS-1$
+
+ // Execute
+ delegate.execute(properties, null);
+ }
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/tracing/ITraceIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/tracing/ITraceIds.java new file mode 100644 index 000000000..aa4a8b4e2 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/tracing/ITraceIds.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.internal.tracing; + +/** + * Core plug-in trace slot identifiers. + */ +public interface ITraceIds { + + /** + * If activated, tracing information about the terminals output stream monitor is printed out. + */ + public static final String TRACE_OUTPUT_STREAM_MONITOR = "trace/outputStreamMonitor"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/AbstractLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/AbstractLauncherDelegate.java new file mode 100644 index 000000000..29f89d565 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/AbstractLauncherDelegate.java @@ -0,0 +1,48 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.launcher;
+
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+
+/**
+ * Abstract launcher delegate implementation.
+ */
+public abstract class AbstractLauncherDelegate extends ExecutableExtension implements ILauncherDelegate {
+ // The converted expression
+ private Expression expression;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#doSetInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void doSetInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ super.doSetInitializationData(config, propertyName, data);
+
+ // Read the sub elements of the extension
+ IConfigurationElement[] children = config != null ? config.getChildren() : null;
+ // The "enablement" element is the only expected one
+ if (children != null && children.length > 0) {
+ expression = ExpressionConverter.getDefault().perform(children[0]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#getEnablement()
+ */
+ @Override
+ public Expression getEnablement() {
+ return expression;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/LauncherDelegateManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/LauncherDelegateManager.java new file mode 100644 index 000000000..c82a83799 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/launcher/LauncherDelegateManager.java @@ -0,0 +1,156 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.launcher;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.ui.ISources;
+
+/**
+ * Terminal launcher delegate manager implementation.
+ */
+public class LauncherDelegateManager extends AbstractExtensionPointManager<ILauncherDelegate> {
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstanceHolder {
+ public static LauncherDelegateManager instance = new LauncherDelegateManager();
+ }
+
+ /**
+ * Returns the singleton instance.
+ */
+ public static LauncherDelegateManager getInstance() {
+ return LazyInstanceHolder.instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ LauncherDelegateManager() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.terminals.launcherDelegates"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "delegate"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the list of all contributed terminal launcher delegates.
+ *
+ * @param unique If <code>true</code>, the method returns new instances for each
+ * contributed terminal launcher delegate.
+ *
+ * @return The list of contributed terminal launcher delegates, or an empty array.
+ */
+ public ILauncherDelegate[] getLauncherDelegates(boolean unique) {
+ List<ILauncherDelegate> contributions = new ArrayList<ILauncherDelegate>();
+ Collection<ExecutableExtensionProxy<ILauncherDelegate>> launcherDelegates = getExtensions().values();
+ for (ExecutableExtensionProxy<ILauncherDelegate> launcherDelegate : launcherDelegates) {
+ ILauncherDelegate instance = unique ? launcherDelegate.newInstance() : launcherDelegate.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+
+ return contributions.toArray(new ILauncherDelegate[contributions.size()]);
+ }
+
+ /**
+ * Returns the terminal launcher delegate identified by its unique id. If no terminal
+ * launcher delegate with the specified id is registered, <code>null</code> is returned.
+ *
+ * @param id The unique id of the terminal launcher delegate or <code>null</code>
+ * @param unique If <code>true</code>, the method returns new instances of the terminal launcher delegate contribution.
+ *
+ * @return The terminal launcher delegate instance or <code>null</code>.
+ */
+ public ILauncherDelegate getLauncherDelegate(String id, boolean unique) {
+ ILauncherDelegate contribution = null;
+ if (getExtensions().containsKey(id)) {
+ ExecutableExtensionProxy<ILauncherDelegate> proxy = getExtensions().get(id);
+ // Get the extension instance
+ contribution = unique ? proxy.newInstance() : proxy.getInstance();
+ }
+
+ return contribution;
+ }
+
+ /**
+ * Returns the applicable terminal launcher delegates for the given selection.
+ *
+ * @param selection The selection or <code>null</code>.
+ * @return The list of applicable terminal launcher delegates or an empty array.
+ */
+ public ILauncherDelegate[] getApplicableLauncherDelegates(ISelection selection) {
+ List<ILauncherDelegate> applicable = new ArrayList<ILauncherDelegate>();
+
+ for (ILauncherDelegate delegate : getLauncherDelegates(false)) {
+ Expression enablement = delegate.getEnablement();
+
+ // The launcher delegate is applicable by default if
+ // no expression is specified.
+ boolean isApplicable = enablement == null;
+
+ if (enablement != null) {
+ if (selection != null) {
+ // Set the default variable to selection.
+ EvaluationContext context = new EvaluationContext(null, selection);
+ // Set the "selection" variable to the selection.
+ context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
+ // Evaluate the expression
+ try {
+ isApplicable = enablement.evaluate(context).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ e.getLocalizedMessage(), e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ } else {
+ // The enablement is false by definition if
+ // there is no selection.
+ isApplicable = false;
+ }
+ }
+
+ // Add the page if applicable
+ if (isApplicable) applicable.add(delegate);
+ }
+
+ return applicable.toArray(new ILauncherDelegate[applicable.size()]);
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java new file mode 100644 index 000000000..54bcc119f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java @@ -0,0 +1,304 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.manager; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.interfaces.IPreferenceKeys; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tcf.te.ui.terminals.view.TerminalsView; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.ui.IPerspectiveDescriptor; +import org.eclipse.ui.IPerspectiveListener; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PerspectiveAdapter; +import org.eclipse.ui.PlatformUI; + +/** + * Terminals console manager. + */ +@SuppressWarnings("restriction") +public class ConsoleManager { + // Reference to the perspective listener instance + private final IPerspectiveListener perspectiveListener; + + // Internal perspective listener implementation + static class ConsoleManagerPerspectiveListener extends PerspectiveAdapter { + private final List<IViewReference> references = new ArrayList<IViewReference>(); + + /* (non-Javadoc) + * @see org.eclipse.ui.PerspectiveAdapter#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor) + */ + @Override + public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + // If the old references list is empty, just return + if (references.isEmpty()) return; + // Create a copy of the old view references list + List<IViewReference> oldReferences = new ArrayList<IViewReference>(references); + + // Get the current list of view references + List<IViewReference> references = new ArrayList<IViewReference>(Arrays.asList(page.getViewReferences())); + for (IViewReference reference : oldReferences) { + if (references.contains(reference)) continue; + // Previous visible terminal console view reference, make visible again + try { + page.showView(reference.getId(), reference.getSecondaryId(), IWorkbenchPage.VIEW_VISIBLE); + } catch (PartInitException e) { /* Failure on part instantiation is ignored */ } + } + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.PerspectiveAdapter#perspectivePreDeactivate(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor) + */ + @Override + public void perspectivePreDeactivate(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + references.clear(); + for (IViewReference reference : page.getViewReferences()) { + IViewPart part = reference.getView(false); + if (part instanceof TerminalsView && !references.contains(reference)) { + references.add(reference); + } + } + } + } + + /* + * Thread save singleton instance creation. + */ + private static class LazyInstanceHolder { + public static ConsoleManager fInstance = new ConsoleManager(); + } + + /** + * Returns the singleton instance for the console manager. + */ + public static ConsoleManager getInstance() { + return LazyInstanceHolder.fInstance; + } + + /** + * Constructor. + */ + ConsoleManager() { + super(); + + // Attach the perspective listener + perspectiveListener = new ConsoleManagerPerspectiveListener(); + if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener); + } + } + + /** + * Returns the active workbench window page if the workbench is still running. + * + * @return The active workbench window page or <code>null</code> + */ + private final IWorkbenchPage getActiveWorkbenchPage() { + // To lookup the console view, the workbench must be still running + if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } + return null; + } + + /** + * Returns the console view if available within the active workbench window page. + * <p> + * <b>Note:</b> The method must be called within the UI thread. + * + * @param id The terminal console view id or <code>null</code> to show the default terminal console view. + * @return The console view instance if available or <code>null</code> otherwise. + */ + public ITerminalsView findConsoleView(String id) { + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + ITerminalsView view = null; + + // Get the active workbench page + IWorkbenchPage page = getActiveWorkbenchPage(); + if (page != null) { + // Look for the view + IViewPart part = page.findView(id != null ? id : IUIConstants.ID); + // Check the interface + if (part instanceof ITerminalsView) { + view = (ITerminalsView)part; + } + } + + return view; + } + + /** + * Show the terminal console view specified by the given id. + * <p> + * <b>Note:</b> The method must be called within the UI thread. + * + * @param id The terminal console view id or <code>null</code> to show the default terminal console view. + */ + public void showConsoleView(String id) { + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + // Get the active workbench page + IWorkbenchPage page = getActiveWorkbenchPage(); + if (page != null) { + try { + // show the view + IViewPart part = page.showView(id != null ? id : IUIConstants.ID); + // and force the view to the foreground + page.bringToTop(part); + } catch (PartInitException e) { + IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), + e.getLocalizedMessage(), e); + UIPlugin.getDefault().getLog().log(status); + } + } + } + + /** + * Bring the terminal console view, specified by the given id, to the top of the view stack. + * + * @param id The terminal console view id or <code>null</code> to show the default terminal console view. + * @param activate If <code>true</code> activate the console view. + */ + private void bringToTop(String id, boolean activate) { + // Get the active workbench page + IWorkbenchPage page = getActiveWorkbenchPage(); + if (page != null) { + // Look for the view + IViewPart part = page.findView(id != null ? id : IUIConstants.ID); + if (part != null) { + if (activate) { + page.activate(part); + } + else { + page.bringToTop(part); + } + } else if (activate) showConsoleView(id != null ? id : IUIConstants.ID); + } + } + + /** + * Opens the console with the given title and connector. + * <p> + * <b>Note:</b> The method must be called within the UI thread. + * + * @param id The terminal console view id or <code>null</code> to show the default terminal console view. + * @param title The console title. Must not be <code>null</code>. + * @param connector The terminal connector. Must not be <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * @param activate If <code>true</code> activate the console view. + */ + public void openConsole(String id, String title, ITerminalConnector connector, Object data, boolean activate) { + Assert.isNotNull(title); + Assert.isNotNull(connector); + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + // make the consoles view visible + bringToTop(id, activate); + + // Get the console view + ITerminalsView view = findConsoleView(id); + if (view == null) return; + + // Get the tab folder manager associated with the view + TabFolderManager manager = (TabFolderManager)view.getAdapter(TabFolderManager.class); + if (manager == null) return; + + // Lookup an existing console first + CTabItem item = findConsole(id, title, connector, data); + + // If no existing console exist -> Create the tab item + if (item == null) { + // If configured, check all existing tab items if they are associated + // with terminated consoles + if (UIPlugin.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_REMOVE_TERMINATED_TERMINALS)) { + manager.removeTerminatedItems(); + } + + // Create a new tab item + item = manager.createTabItem(title, connector, data); + } + // If still null, something went wrong + if (item == null) { + return; + } + + // Make the item the active console + manager.bringToTop(item); + + // Show the tab folder page + view.switchToTabFolderControl(); + } + + /** + * Lookup a console with the given title and the given terminal connector. + * <p> + * <b>Note:</b> The method must be called within the UI thread. + * <b>Note:</b> The method will handle unified console titles itself. + * + * @param id The terminal console view id or <code>null</code> to show the default terminal console view. + * @param title The console title. Must not be <code>null</code>. + * @param connector The terminal connector. Must not be <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * + * @return The corresponding console tab item or <code>null</code>. + */ + public CTabItem findConsole(String id, String title, ITerminalConnector connector, Object data) { + Assert.isNotNull(title); + Assert.isNotNull(connector); + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + // Get the console view + ITerminalsView view = findConsoleView(id); + if (view == null) return null; + + // Get the tab folder manager associated with the view + TabFolderManager manager = (TabFolderManager)view.getAdapter(TabFolderManager.class); + if (manager == null) return null; + + return manager.findTabItem(title, connector, data); + } + + /** + * Close the console with the given title and the given terminal connector. + * <p> + * <b>Note:</b> The method must be called within the UI thread. + * <b>Note:</b> The method will handle unified console titles itself. + * + * @param title The console title. Must not be <code>null</code>. + * @param connector The terminal connector. Must not be <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + */ + public void closeConsole(String id, String title, ITerminalConnector connector, Object data) { + Assert.isNotNull(title); + Assert.isNotNull(connector); + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + // Lookup the console + CTabItem console = findConsole(id, title, connector, data); + // If found, dispose the console + if (console != null) console.dispose(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java new file mode 100644 index 000000000..fe60fca58 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.nls; + +import org.eclipse.osgi.util.NLS; + +/** + * Terminals plug-in externalized strings management. + */ +public class Messages extends NLS { + + // The plug-in resource bundle name + private static final String BUNDLE_NAME = "org.eclipse.tcf.te.ui.terminals.nls.Messages"; //$NON-NLS-1$ + + /** + * Static constructor. + */ + static { + // Load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + // **** Declare externalized string id's down here ***** + + public static String AbstractAction_error_commandExecutionFailed; + + public static String TabTerminalListener_consoleTerminated; + + public static String ProcessSettingsPage_dialogTitle; + public static String ProcessSettingsPage_processImagePathSelectorControl_label; + public static String ProcessSettingsPage_processImagePathSelectorControl_button; + public static String ProcessSettingsPage_processArgumentsControl_label; + public static String ProcessSettingsPage_localEchoSelectorControl_label; + + public static String OutputStreamMonitor_error_readingFromStream; + + public static String InputStreamMonitor_error_writingToStream; + + public static String TerminalService_error_cannotCreateConnector; + public static String TerminalService_defaultTitle; + + public static String LaunchTerminalSettingsDialog_title; + public static String LaunchTerminalSettingsDialog_combo_label; + public static String LaunchTerminalSettingsDialog_group_label; +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties new file mode 100644 index 000000000..4010007d5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties @@ -0,0 +1,25 @@ +# +# org.eclipse.tcf.te.ui.terminals +# Externalized Strings. +# + +AbstractAction_error_commandExecutionFailed="Failed to execute command (id = {0}). Possibly caused by: {1} + +TabTerminalListener_consoleTerminated=<terminated> {0} + +ProcessSettingsPage_dialogTitle=Select Process Image +ProcessSettingsPage_processImagePathSelectorControl_label=Image Path: +ProcessSettingsPage_processImagePathSelectorControl_button=Browse +ProcessSettingsPage_processArgumentsControl_label=Arguments: +ProcessSettingsPage_localEchoSelectorControl_label=Local Echo + +OutputStreamMonitor_error_readingFromStream=Exception when reading from stream. Possibly caused by: {0} + +InputStreamMonitor_error_writingToStream=Exception when writing to stream. Possibly caused by: {0} + +TerminalService_error_cannotCreateConnector=Cannot create a valid terminal connector instance from the provided terminal properties. +TerminalService_defaultTitle=Console + +LaunchTerminalSettingsDialog_title=Launch Terminal +LaunchTerminalSettingsDialog_combo_label=Choose terminal: +LaunchTerminalSettingsDialog_group_label=Settings diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java new file mode 100644 index 000000000..91609921f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java @@ -0,0 +1,50 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.panels;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+
+/**
+ * Abstract terminal configuration panel implementation.
+ */
+public abstract class AbstractConfigurationPanel extends AbstractWizardConfigurationPanel implements IConfigurationPanel {
+ // The selection
+ private ISelection selection;
+
+ /**
+ * Constructor.
+ *
+ * @param parentControl The parent control. Must not be <code>null</code>!
+ */
+ public AbstractConfigurationPanel(BaseDialogPageControl parentControl) {
+ super(parentControl);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel#setSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel#getSelection()
+ */
+ @Override
+ public ISelection getSelection() {
+ return selection;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java new file mode 100644 index 000000000..0d83a9b6f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java @@ -0,0 +1,205 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.services; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType; +import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants; +import org.eclipse.tcf.te.ui.terminals.manager.ConsoleManager; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tcf.te.ui.terminals.types.ConnectorManager; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.services.AbstractService; +import org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.ui.swt.DisplayUtil; + +/** + * Terminal service implementation. + */ +@SuppressWarnings("restriction") +public class TerminalService extends AbstractService implements ITerminalService { + + /** + * Common terminal service runnable implementation. + */ + protected static abstract class TerminalServiceRunnable { + + /** + * Invoked to execute the terminal service runnable. + * + * @param id The terminals view id or <code>null</code>. + * @param title The terminal tab title. Must not be <code>null</code>. + * @param connector The terminal connector. Must not be <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * @param callback The target callback to invoke if the operation finished or <code>null</code>. + */ + public abstract void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback); + + /** + * Returns if or if not to execute the runnable asynchronously. + * <p> + * The method returns per default <code>true</code>. Overwrite to + * modify the behavior. + * + * @return <code>True</code> to execute the runnable asynchronously, <code>false</code> otherwise. + */ + public boolean isExecuteAsync() { return true; } + } + + /** + * Executes the given runnable operation and invokes the given callback, if any, + * after the operation finished. + * + * @param properties The terminal properties. Must be not <code>null</code>. + * @param runnable The terminal service runnable. Must be not <code>null</code>. + * @param callback The target callback to invoke if the operation has been finished or <code>null</code>. + */ + protected final void executeServiceOperation(final IPropertiesContainer properties, final TerminalServiceRunnable runnable, final ICallback callback) { + Assert.isNotNull(properties); + Assert.isNotNull(runnable); + + // Extract the properties + String id = properties.getStringProperty(ITerminalsConnectorConstants.PROP_ID); + String title = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TITLE); + Object data = properties.getProperty(ITerminalsConnectorConstants.PROP_DATA); + + // Normalize the terminal console view id + id = normalizeId(id, data); + // Normalize the terminal console tab title + title = normalizeTitle(title, data); + + // Create the terminal connector instance + final ITerminalConnector connector = createTerminalConnector(properties); + if (connector == null) { + // Properties contain invalid connector arguments + if (callback != null) { + callback.done(this, StatusHelper.getStatus(new IllegalArgumentException(Messages.TerminalService_error_cannotCreateConnector))); + } + return; + } + + // Finalize the used variables + final String finId = id; + final String finTitle = title; + final Object finData = data; + + // Execute the operation + if (!runnable.isExecuteAsync()) { + runnable.run(finId, finTitle, connector, finData, callback); + } + else { + DisplayUtil.safeAsyncExec(new Runnable() { + @Override + public void run() { + runnable.run(finId, finTitle, connector, finData, callback); + } + }); + } + } + + /** + * Normalize the terminals view id. + * + * @param id The terminals view id or <code>null</code>. + * @param data The custom data object or <code>null</code>. + * + * @return The normalized terminal console view id. + */ + protected String normalizeId(String id, Object data) { + return id != null ? id : IUIConstants.ID; + } + + /** + * Normalize the terminal tab title. + * + * @param title The terminal tab title or <code>null</code>. + * @param data The custom data object or <code>null</code>. + * + * @return The normalized terminal tab title. + */ + protected String normalizeTitle(String title, Object data) { + // If the title is explicitly specified, return as is + if (title != null) return title; + + // Return the default console title in all other cases + return Messages.TerminalService_defaultTitle; + } + + /** + * Creates the terminal connector configured within the given properties. + * + * @param properties The terminal console properties. Must be not <code>null</code>. + * @return The terminal connector or <code>null</code>. + */ + protected ITerminalConnector createTerminalConnector(IPropertiesContainer properties) { + Assert.isNotNull(properties); + + // The terminal connector result object + ITerminalConnector connector = null; + + // Get the connector type id from the properties + String connectorTypeId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID); + if (connectorTypeId != null) { + // Get the connector type + IConnectorType connectorType = ConnectorManager.getInstance().getConnectorType(connectorTypeId, false); + if (connectorType != null) { + // Create the connector + connector = connectorType.createTerminalConnector(properties); + } + } + + return connector; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService#openConsole(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void openConsole(final IPropertiesContainer properties, final ICallback callback) { + Assert.isNotNull(properties); + + executeServiceOperation(properties, new TerminalServiceRunnable() { + @Override + public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) { + // Open the new console + ConsoleManager.getInstance().openConsole(id, title, connector, data, true); + // Invoke the callback + if (callback != null) { + callback.done(this, Status.OK_STATUS); + } + } + }, callback); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService#closeConsole(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void closeConsole(final IPropertiesContainer properties, final ICallback callback) { + Assert.isNotNull(properties); + + executeServiceOperation(properties, new TerminalServiceRunnable() { + @Override + public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) { + // Close the console + ConsoleManager.getInstance().closeConsole(id, title, connector, data); + // Invoke the callback + if (callback != null) { + callback.done(this, Status.OK_STATUS); + } + } + }, callback); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/AbstractStreamsConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/AbstractStreamsConnector.java new file mode 100644 index 000000000..11f846bfd --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/AbstractStreamsConnector.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.streams; + +import java.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl; +import org.eclipse.ui.services.IDisposable; + +/** + * Streams connector implementation. + */ +@SuppressWarnings("restriction") +public abstract class AbstractStreamsConnector extends TerminalConnectorImpl { + // Reference to the stdin monitor + private InputStreamMonitor stdInMonitor; + // Reference to the stdout monitor + private OutputStreamMonitor stdOutMonitor; + // Reference to the stderr monitor + private OutputStreamMonitor stdErrMonitor; + + /** + * Connect the given streams. The streams connector will wrap each stream + * with a corresponding terminal stream monitor. + * + * @param terminalControl The terminal control. Must not be <code>null</code>. + * @param stdin The stdin stream or <code>null</code>. + * @param stdout The stdout stream or <code>null</code>. + * @param stderr The stderr stream or <code>null</code>. + * @param localEcho Local echo on or off. + * @param lineSeparator The line separator used by the stream. + */ + protected void connectStreams(ITerminalControl terminalControl, OutputStream stdin, InputStream stdout, InputStream stderr, boolean localEcho, String lineSeparator) { + Assert.isNotNull(terminalControl); + + // Create the input stream monitor + if (stdin != null) { + stdInMonitor = createStdInMonitor(terminalControl, stdin, localEcho, lineSeparator); + // Register the connector if it implements IDisposable and stdout/stderr are not monitored + if (stdout == null && stderr == null && this instanceof IDisposable) stdInMonitor.addDisposable((IDisposable)this); + // Start the monitoring + stdInMonitor.startMonitoring(); + } + + // Create the output stream monitor + if (stdout != null) { + stdOutMonitor = createStdOutMonitor(terminalControl, stdout, lineSeparator); + // Register the connector if it implements IDisposable + if (this instanceof IDisposable) stdOutMonitor.addDisposable((IDisposable)this); + // Start the monitoring + stdOutMonitor.startMonitoring(); + } + + // Create the error stream monitor + if (stderr != null) { + stdErrMonitor = createStdErrMonitor(terminalControl, stderr, lineSeparator); + // Register the connector if it implements IDisposable and stdout is not monitored + if (stdout == null && this instanceof IDisposable) stdErrMonitor.addDisposable((IDisposable)this); + // Start the monitoring + stdErrMonitor.startMonitoring(); + } + } + + /** + * Creates an stdin monitor for the given terminal control and stdin stream. + * Subclasses may override to create a specialized stream monitor. + * + * @param terminalControl The terminal control. Must not be <code>null</code>. + * @param stdin The stdin stream or <code>null</code>. + * @param localEcho Local echo on or off. + * @param lineSeparator The line separator used by the stream. + * + * @return input stream monitor + */ + protected InputStreamMonitor createStdInMonitor(ITerminalControl terminalControl, OutputStream stdin, boolean localEcho, String lineSeparator) { + return new InputStreamMonitor(terminalControl, stdin, localEcho, lineSeparator); + } + + /** + * Creates an stdout monitor for the given terminal control and stdout stream. + * Subclasses may override to create a specialized stream monitor. + * + * @param terminalControl The terminal control. Must not be <code>null</code>. + * @param stdout The stdout stream or <code>null</code>. + * @param lineSeparator The line separator used by the stream. + * + * @return output stream monitor + */ + protected OutputStreamMonitor createStdOutMonitor(ITerminalControl terminalControl, InputStream stdout, String lineSeparator) { + return new OutputStreamMonitor(terminalControl, stdout, lineSeparator); + } + + /** + * Creates an stderr monitor for the given terminal control and stderr stream. + * Subclasses may override to create a specialized stream monitor. + * + * @param terminalControl The terminal control. Must not be <code>null</code>. + * @param stderr The stderr stream or <code>null</code>. + * @param lineSeparator The line separator used by the stream. + * + * @return output stream monitor + */ + protected OutputStreamMonitor createStdErrMonitor(ITerminalControl terminalControl, InputStream stderr, String lineSeparator) { + return new OutputStreamMonitor(terminalControl, stderr, lineSeparator); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#doDisconnect() + */ + @Override + protected void doDisconnect() { + // Dispose the streams + if (stdInMonitor != null) { stdInMonitor.dispose(); stdInMonitor = null; } + if (stdOutMonitor != null) { stdOutMonitor.dispose(); stdOutMonitor = null; } + if (stdErrMonitor != null) { stdErrMonitor.dispose(); stdErrMonitor = null; } + + super.doDisconnect(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#getTerminalToRemoteStream() + */ + @Override + public OutputStream getTerminalToRemoteStream() { + return stdInMonitor; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/InputStreamMonitor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/InputStreamMonitor.java new file mode 100644 index 000000000..f8e8a26e9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/InputStreamMonitor.java @@ -0,0 +1,344 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.streams; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ILineSeparatorConstants; +import org.eclipse.ui.services.IDisposable; + +/** + * Input stream monitor implementation. + * <p> + * <b>Note:</b> The input is coming <i>from</i> the terminal. Therefore, the input + * stream monitor is attached to the stdin stream of the monitored (remote) process. + */ +@SuppressWarnings("restriction") +public class InputStreamMonitor extends OutputStream implements IDisposable { + // Reference to the parent terminal control + @SuppressWarnings("unused") + private final ITerminalControl terminalControl; + + // Reference to the monitored (output) stream + private final OutputStream stream; + + // Reference to the thread writing the stream + private Thread thread; + + // Flag to mark the monitor disposed. When disposed, + // no further data is written from the monitored stream. + private boolean disposed; + + // A list of object to dispose if this monitor is disposed + private final List<IDisposable> disposables = new ArrayList<IDisposable>(); + + // Queue to buffer the data to write to the output stream + private final Queue<byte[]> queue = new LinkedList<byte[]>(); + + // ***** Line separator replacement logic ***** + // ***** Adapted from org.eclipse.tcf.internal.terminal.local.LocalTerminalOutputStream ***** + + private final static int TERMINAL_SENDS_CR = 0; + private final static int TERMINAL_SENDS_CRLF = 1; + private final static int PROGRAM_EXPECTS_LF = 0; + private final static int PROGRAM_EXPECTS_CRLF = 1; + private final static int PROGRAM_EXPECTS_CR = 2; + private final static int NO_CHANGE = 0; + private final static int CHANGE_CR_TO_LF = 1; + private final static int INSERT_LF_AFTER_CR = 2; + private final static int REMOVE_CR = 3; + private final static int REMOVE_LF = 4; + + // CRLF conversion table: + // + // Expected line separator --> | LF | CRLF | CR | + // ------------------------------------+-----------------+--------------------+----------------+ + // Local echo off - control sends CR | change CR to LF | insert LF after CR | no change | + // ------------------------------------+-----------------+--------------------+----------------+ + // Local echo on - control sends CRLF | remove CR | no change | remove LF | + // + private final static int[][] CRLF_REPLACEMENT = { + + {CHANGE_CR_TO_LF, INSERT_LF_AFTER_CR, NO_CHANGE}, + {REMOVE_CR, NO_CHANGE, REMOVE_LF} + }; + + private int replacement; + + /** + * Constructor. + * + * @param terminalControl The parent terminal control. Must not be <code>null</code>. + * @param stream The stream. Must not be <code>null</code>. + * @param localEcho Local echo on or off. + * @param lineSeparator The line separator used by the stream. + */ + public InputStreamMonitor(ITerminalControl terminalControl, OutputStream stream, boolean localEcho, String lineSeparator) { + super(); + + Assert.isNotNull(terminalControl); + this.terminalControl = terminalControl; + Assert.isNotNull(stream); + this.stream = stream; + + // Determine the line separator replacement setting + int terminalSends = localEcho ? TERMINAL_SENDS_CRLF : TERMINAL_SENDS_CR; + if (lineSeparator == null) { + replacement = NO_CHANGE; + } else { + int programExpects; + if (lineSeparator.equals(ILineSeparatorConstants.LINE_SEPARATOR_LF)) { + programExpects = PROGRAM_EXPECTS_LF; + } + else if (lineSeparator.equals(ILineSeparatorConstants.LINE_SEPARATOR_CR)) { + programExpects = PROGRAM_EXPECTS_CR; + } + else { + programExpects = PROGRAM_EXPECTS_CRLF; + } + replacement = CRLF_REPLACEMENT[terminalSends][programExpects]; + } + + } + + /** + * Adds the given disposable object to the list. The method will do nothing + * if either the disposable object is already part of the list or the monitor + * is disposed. + * + * @param disposable The disposable object. Must not be <code>null</code>. + */ + public final void addDisposable(IDisposable disposable) { + Assert.isNotNull(disposable); + if (!disposed && !disposables.contains(disposable)) disposables.add(disposable); + } + + /** + * Removes the disposable object from the list. + * + * @param disposable The disposable object. Must not be <code>null</code>. + */ + public final void removeDisposable(IDisposable disposable) { + Assert.isNotNull(disposable); + disposables.remove(disposable); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.services.IDisposable#dispose() + */ + @Override + public void dispose() { + // If already disposed --> return immediately + if (disposed) return; + + // Mark the monitor disposed + disposed = true; + + // Close the stream (ignore exceptions on close) + try { stream.close(); } catch (IOException e) { /* ignored on purpose */ } + // And interrupt the thread + close(); + + // Dispose all registered disposable objects + for (IDisposable disposable : disposables) disposable.dispose(); + // Clear the list + disposables.clear(); + } + + /** + * Close the terminal input stream monitor. + */ + @Override + public void close() { + // Not initialized -> return immediately + if (thread == null) return; + + // Copy the reference + final Thread oldThread = thread; + // Unlink the monitor from the thread + thread = null; + // And interrupt the writer thread + oldThread.interrupt(); + } + + /** + * Starts the terminal output stream monitor. + */ + public void startMonitoring() { + // If already initialized -> return immediately + if (thread != null) return; + + // Create a new runnable which is constantly reading from the stream + Runnable runnable = new Runnable() { + @Override + public void run() { + writeStream(); + } + }; + + // Create the writer thread + thread = new Thread(runnable, "Terminal Input Stream Monitor Thread"); //$NON-NLS-1$ + + // Configure the writer thread + thread.setDaemon(true); + + // Start the processing + thread.start(); + } + + + /** + * Reads from the queue and writes the read content to the stream. + */ + protected void writeStream() { + // Read from the queue and write to the stream until disposed + while (thread != null && !disposed) { + // If the queue is empty, wait until notified + if (queue.isEmpty()) { + synchronized(queue) { + try { queue.wait(); } catch (InterruptedException e) { /* ignored on purpose */ } + } + } + + // If the queue is not empty, take the first element + // and write the data to the stream + while (!queue.isEmpty() && !disposed) { + // Retrieves the queue head (is null if queue is empty (should never happen)) + byte[] data = queue.poll(); + if (data != null) { + try { + // Write the data to the stream + stream.write(data); + // Flush the stream immediately + stream.flush(); + } catch (IOException e) { + // IOException received. If this is happening when already disposed -> ignore + if (!disposed) { + IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), + NLS.bind(Messages.InputStreamMonitor_error_writingToStream, e.getLocalizedMessage()), e); + UIPlugin.getDefault().getLog().log(status); + } + } + } + } + } + + // Dispose the stream + dispose(); + } + + /* (non-Javadoc) + * @see java.io.OutputStream#write(int) + */ + @Override + public void write(int b) throws IOException { + synchronized(queue) { + queue.add(new byte[] { (byte)b }); + queue.notifyAll(); + } + } + + /* (non-Javadoc) + * @see java.io.OutputStream#write(byte[], int, int) + */ + @Override + public void write(byte[] b, int off, int len) throws IOException { + // Write the whole block to the queue to avoid synchronization + // to happen for every byte. To do so, we have to avoid calling + // the super method. Therefore we have to do the same checking + // here as the base class does. + + // Null check. See the implementation in OutputStream. + if (b == null) throw new NullPointerException(); + + // Boundary check. See the implementation in OutputStream. + if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } + else if (len == 0) { + return; + } + + // Make sure that the written block is not interlaced with other input. + synchronized(queue) { + // Preprocess the block to be written + byte[] processedBytes = onWriteContentToStream(b, off, len); + // If the returned array is not the original one, adjust offset and length + if (processedBytes != b) { + off = 0; len = processedBytes.length; + } + + // Get the content from the byte buffer specified by offset and length + byte[] bytes = new byte[len]; + int j = 0; + for (int i = 0 ; i < len ; i++) { + bytes[j++] = b[off + i]; + } + + queue.add(bytes); + queue.notifyAll(); + } + } + + /** + * Allow for processing of data from byte stream from the terminal before + * it is written to the output stream. If the returned byte array is different + * than the one that was passed in with the bytes argument, then the + * length value will be adapted. + * + * @param bytes The byte stream. Must not be <code>null</code>. + * @param off The offset. + * @param len the length. + * + * @return The processed byte stream. + * + */ + protected byte[] onWriteContentToStream(byte[] bytes, int off, int len) { + Assert.isNotNull(bytes); + + if (replacement != NO_CHANGE && len > 0) { + String text = new String(bytes, off, len); + // + // TODO: check whether this is correct! new String(byte[], int, int) always uses the default + // encoding! + + if (replacement == CHANGE_CR_TO_LF) { + text = text.replace('\r', '\n'); + } + else if (replacement == INSERT_LF_AFTER_CR) { + text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_CR, "\r\n"); //$NON-NLS-1$ + } + else if (replacement == REMOVE_CR) { + text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_CR, ""); //$NON-NLS-1$ + } + else if (replacement == REMOVE_LF) { + text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_LF, ""); //$NON-NLS-1$ + } + + if (text.length() > 0) { + bytes = text.getBytes(); + } + } + + return bytes; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/OutputStreamMonitor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/OutputStreamMonitor.java new file mode 100644 index 000000000..1185a5b97 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/OutputStreamMonitor.java @@ -0,0 +1,262 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.streams; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.internal.tracing.ITraceIds; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ILineSeparatorConstants; +import org.eclipse.ui.services.IDisposable; + +/** + * Output stream monitor implementation. + * <p> + * <b>Note:</b> The output is going <i>to</i> the terminal. Therefore, the output + * stream monitor is attached to the stdout and/or stderr stream of the monitored + * (remote) process. + */ +@SuppressWarnings("restriction") +public class OutputStreamMonitor implements IDisposable { + // The default buffer size to use + private static final int BUFFER_SIZE = 8192; + + // Reference to the parent terminal control + private final ITerminalControl terminalControl; + + // Reference to the monitored (input) stream + private final InputStream stream; + + // The line separator used by the monitored (input) stream + private final String lineSeparator; + + // Reference to the thread reading the stream + private Thread thread; + + // Flag to mark the monitor disposed. When disposed, + // no further data is read from the monitored stream. + private boolean disposed; + + // A list of object to dispose if this monitor is disposed + private final List<IDisposable> disposables = new ArrayList<IDisposable>(); + + /** + * Constructor. + * + * @param terminalControl The parent terminal control. Must not be <code>null</code>. + * @param stream The stream. Must not be <code>null</code>. + * @param lineSeparator The line separator used by the stream. + */ + public OutputStreamMonitor(ITerminalControl terminalControl, InputStream stream, String lineSeparator) { + super(); + + Assert.isNotNull(terminalControl); + this.terminalControl = terminalControl; + Assert.isNotNull(stream); + this.stream = new BufferedInputStream(stream, BUFFER_SIZE); + + this.lineSeparator = lineSeparator; + } + + /** + * Adds the given disposable object to the list. The method will do nothing + * if either the disposable object is already part of the list or the monitor + * is disposed. + * + * @param disposable The disposable object. Must not be <code>null</code>. + */ + public final void addDisposable(IDisposable disposable) { + Assert.isNotNull(disposable); + if (!disposed && !disposables.contains(disposable)) disposables.add(disposable); + } + + /** + * Removes the disposable object from the list. + * + * @param disposable The disposable object. Must not be <code>null</code>. + */ + public final void removeDisposable(IDisposable disposable) { + Assert.isNotNull(disposable); + disposables.remove(disposable); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.services.IDisposable#dispose() + */ + @Override + public void dispose() { + // If already disposed --> return immediately + if (disposed) return; + + // Mark the monitor disposed + disposed = true; + + // Close the stream (ignore exceptions on close) + try { stream.close(); } catch (IOException e) { /* ignored on purpose */ } + + // Dispose all registered disposable objects + for (IDisposable disposable : disposables) disposable.dispose(); + // Clear the list + disposables.clear(); + } + + /** + * Starts the terminal output stream monitor. + */ + protected void startMonitoring() { + // If already initialized -> return immediately + if (thread != null) return; + + // Create a new runnable which is constantly reading from the stream + Runnable runnable = new Runnable() { + @Override + public void run() { + readStream(); + } + }; + + // Create the reader thread + thread = new Thread(runnable, "Terminal Output Stream Monitor Thread"); //$NON-NLS-1$ + + // Configure the reader thread + thread.setDaemon(true); + thread.setPriority(Thread.MIN_PRIORITY); + + // Start the processing + thread.start(); + } + + /** + * Returns the terminal control that this stream monitor is associated with. + */ + protected ITerminalControl getTerminalControl() { + return terminalControl; + } + + /** + * Reads from the output stream and write the read content + * to the terminal control output stream. + */ + void readStream() { + // Creates the read buffer + byte[] readBuffer = new byte[BUFFER_SIZE]; + + // We need to maintain UI responsiveness but still stream the content + // to the terminal control fast. Put the thread to a short sleep each second. + long sleepMarker = System.currentTimeMillis(); + + // Read from the stream until EOS is reached or the + // monitor is marked disposed. + int read = 0; + while (read >= 0 && !disposed) { + try { + // Read from the stream + read = stream.read(readBuffer); + // If some data has been read, append to the terminal + // control output stream + if (read > 0) { + // Allow for post processing the read content before appending + byte[] processedReadBuffer = onContentReadFromStream(readBuffer, read); + if (processedReadBuffer != readBuffer) { + read = processedReadBuffer.length; + } + terminalControl.getRemoteToTerminalOutputStream().write(processedReadBuffer, 0, read); + } + } catch (IOException e) { + // IOException received. If this is happening when already disposed -> ignore + if (!disposed) { + IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), + NLS.bind(Messages.OutputStreamMonitor_error_readingFromStream, e.getLocalizedMessage()), e); + UIPlugin.getDefault().getLog().log(status); + } + break; + } catch (NullPointerException e) { + // killing the stream monitor while reading can cause an NPE + // when reading from the stream + if (!disposed && thread != null) { + IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), + NLS.bind(Messages.OutputStreamMonitor_error_readingFromStream, e.getLocalizedMessage()), e); + UIPlugin.getDefault().getLog().log(status); + } + break; + } + + // See above -> Thread will go to sleep each second + if (System.currentTimeMillis() - sleepMarker > 1000) { + sleepMarker = System.currentTimeMillis(); + try { Thread.sleep(1); } catch (InterruptedException e) { /* ignored on purpose */ } + } + } + + // Dispose ourself + dispose(); + } + + /** + * Allow for processing of data from byte stream after it is read from + * client but before it is appended to the terminal. If the returned byte + * array is different than the one that was passed in with the byteBuffer + * argument, then the bytesRead value will be ignored and the full + * returned array will be written out. + * + * @param byteBuffer The byte stream. Must not be <code>null</code>. + * @param bytesRead The number of bytes that were read into the read buffer. + * @return The processed byte stream. + * + */ + protected byte[] onContentReadFromStream(byte[] byteBuffer, int bytesRead) { + Assert.isNotNull(byteBuffer); + + // If tracing is enabled, print out the decimal byte values read + if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_OUTPUT_STREAM_MONITOR)) { + StringBuilder debug = new StringBuilder("byteBuffer [decimal, " + bytesRead + " bytes] : "); //$NON-NLS-1$ //$NON-NLS-2$ + for (int i = 0; i < bytesRead; i++) { + debug.append(Byte.valueOf(byteBuffer[i]).intValue()); + debug.append(' '); + } + System.out.println(debug.toString()); + } + + // Remember if the text got changed. + boolean changed = false; + + // How can me make sure that we don't mess with the encoding here? + String text = new String(byteBuffer, 0, bytesRead); + + // Shift-In (14) and Shift-Out(15) confuses the terminal widget + if (text.indexOf(14) != -1 || text.indexOf(15) != -1) { + text = text.replaceAll("\\x0e", "").replaceAll("\\x0f", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + changed = true; + } + + // Check on the line separator setting + if (lineSeparator != null + && !ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator) + && text.contains(lineSeparator)) { + text = text.replaceAll(lineSeparator, "\r\n"); //$NON-NLS-1$ + changed = true; + } + + // If changed, get the new bytes array + if (changed) byteBuffer = text.getBytes(); + + return byteBuffer; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsConnector.java new file mode 100644 index 000000000..5c3e1dd0c --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsConnector.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.streams; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.ui.services.IDisposable; + +/** + * Streams connector implementation. + */ +@SuppressWarnings("restriction") +public class StreamsConnector extends AbstractStreamsConnector implements IDisposable { + // Reference to the streams settings + private final StreamsSettings settings; + + /** + * Constructor. + */ + public StreamsConnector() { + this(new StreamsSettings()); + } + + /** + * Constructor. + * + * @param settings The streams settings. Must not be <code>null</code> + */ + public StreamsConnector(StreamsSettings settings) { + super(); + + Assert.isNotNull(settings); + this.settings = settings; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#connect(org.eclipse.tcf.internal.terminal.provisional.api.ITerminalControl) + */ + @Override + public void connect(ITerminalControl control) { + Assert.isNotNull(control); + super.connect(control); + + // connect the streams + connectStreams(control, settings.getStdinStream(), settings.getStdoutStream(), settings.getStderrStream(), settings.isLocalEcho(), settings.getLineSeparator()); + + // Set the terminal control state to CONNECTED + control.setState(TerminalState.CONNECTED); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#isLocalEcho() + */ + @Override + public boolean isLocalEcho() { + return settings.isLocalEcho(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.services.IDisposable#dispose() + */ + @Override + public void dispose() { + disconnect(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#doDisconnect() + */ + @Override + public void doDisconnect() { + // Dispose the streams + super.doDisconnect(); + + // Set the terminal control state to CLOSED. + fControl.setState(TerminalState.CLOSED); + } + + // ***** Process Connector settings handling ***** + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#getSettingsSummary() + */ + @Override + public String getSettingsSummary() { + return ""; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#load(org.eclipse.tcf.internal.terminal.provisional.api.ISettingsStore) + */ + @Override + public void load(ISettingsStore store) { + settings.load(store); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.provisional.api.provider.TerminalConnectorImpl#save(org.eclipse.tcf.internal.terminal.provisional.api.ISettingsStore) + */ + @Override + public void save(ISettingsStore store) { + settings.save(store); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsSettings.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsSettings.java new file mode 100644 index 000000000..ad78d7af4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsSettings.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.streams; + +import java.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; + +/** + * Streams connector settings implementation. + */ +@SuppressWarnings("restriction") +public class StreamsSettings { + // Reference to the stdin stream + private OutputStream stdin; + // Reference to the stdout stream + private InputStream stdout; + // Reference to the stderr stream + private InputStream stderr; + // Flag to control the local echo + private boolean localEcho = true; + // The line separator setting + private String lineSeparator = null; + + /** + * Sets the stdin stream instance. + * + * @param stdin The stream instance or <code>null</code>. + */ + public void setStdinStream(OutputStream stdin) { + this.stdin = stdin; + } + + /** + * Returns the stdin stream instance. + * + * @return The stream instance or <code>null</code>. + */ + public OutputStream getStdinStream() { + return stdin; + } + + /** + * Sets the stdout stream instance. + * + * @param stdout The stream instance or <code>null</code>. + */ + public void setStdoutStream(InputStream stdout) { + this.stdout = stdout; + } + + /** + * Returns the stdout stream instance. + * + * @return The stream instance or <code>null</code>. + */ + public InputStream getStdoutStream() { + return stdout; + } + + /** + * Sets the stderr stream instance. + * + * @param stderr The stream instance or <code>null</code>. + */ + public void setStderrStream(InputStream stderr) { + this.stderr = stderr; + } + + /** + * Returns the stderr stream instance. + * + * @return The stream instance or <code>null</code>. + */ + public InputStream getStderrStream() { + return stderr; + } + + /** + * Sets if the process requires a local echo from the terminal widget. + * + * @param value Specify <code>true</code> to enable the local echo, <code>false</code> otherwise. + */ + public void setLocalEcho(boolean value) { + this.localEcho = value; + } + + /** + * Returns <code>true</code> if the process requires a local echo + * from the terminal widget. + * + * @return <code>True</code> if local echo is enabled, <code>false</code> otherwise. + */ + public boolean isLocalEcho() { + return localEcho; + } + + /** + * Sets the stream line separator. + * + * @param separator The stream line separator <code>null</code>. + */ + public void setLineSeparator(String separator) { + this.lineSeparator = separator; + } + + /** + * Returns the stream line separator. + * + * @return The stream line separator or <code>null</code>. + */ + public String getLineSeparator() { + return lineSeparator; + } + + /** + * Loads the streams settings from the given settings store. + * + * @param store The settings store. Must not be <code>null</code>. + */ + public void load(ISettingsStore store) { + Assert.isNotNull(store); + localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$ + lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$ + if (store instanceof IPropertiesContainer) { + stdin = (OutputStream)((IPropertiesContainer)store).getProperty("stdin"); //$NON-NLS-1$ + stdout = (InputStream)((IPropertiesContainer)store).getProperty("stdout"); //$NON-NLS-1$ + stderr = (InputStream)((IPropertiesContainer)store).getProperty("stderr"); //$NON-NLS-1$ + } + } + + /** + * Saves the process settings to the given settings store. + * + * @param store The settings store. Must not be <code>null</code>. + */ + public void save(ISettingsStore store) { + Assert.isNotNull(store); + store.put("LocalEcho", Boolean.toString(localEcho)); //$NON-NLS-1$ + store.put("LineSeparator", lineSeparator); //$NON-NLS-1$ + if (store instanceof IPropertiesContainer) { + ((IPropertiesContainer)store).setProperty("stdin", stdin); //$NON-NLS-1$ + ((IPropertiesContainer)store).setProperty("stdout", stdout); //$NON-NLS-1$ + ((IPropertiesContainer)store).setProperty("stderr", stderr); //$NON-NLS-1$ + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java new file mode 100644 index 000000000..bfe352682 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tcf.te.runtime.events.DisposedEvent; +import org.eclipse.tcf.te.runtime.events.EventManager; + +/** + * Terminals tab default dispose listener implementation. + */ +@SuppressWarnings("restriction") +public class TabDisposeListener implements DisposeListener { + private final TabFolderManager parentTabFolderManager; + + /** + * Constructor. + * + * @param parentTabFolderManager The parent tab folder manager. Must be not <code>null</code> + */ + public TabDisposeListener(TabFolderManager parentTabFolderManager) { + Assert.isNotNull(parentTabFolderManager); + this.parentTabFolderManager = parentTabFolderManager; + } + + /** + * Returns the parent terminal console tab folder manager instance. + * + * @return The parent terminal console tab folder manager instance. + */ + protected final TabFolderManager getParentTabFolderManager() { + return parentTabFolderManager; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) + */ + @Override + public void widgetDisposed(DisposeEvent e) { + // If a tab item gets disposed, we have to dispose the terminal as well + if (e.getSource() instanceof CTabItem) { + // Get the terminal control (if any) from the tab item + Object candidate = ((CTabItem)e.getSource()).getData(); + if (candidate instanceof ITerminalViewControl) ((ITerminalViewControl)candidate).disposeTerminal(); + + // If all items got removed, we have to switch back to the empty page control + if (parentTabFolderManager.getTabFolder() != null && parentTabFolderManager.getTabFolder().getItemCount() == 0) { + parentTabFolderManager.getParentView().switchToEmptyPageControl(); + } + // Fire selection changed event + parentTabFolderManager.fireSelectionChanged(); + // Fire the terminal console disposed event + EventManager.getInstance().fireEvent(new DisposedEvent(e.getSource(), ((CTabItem)e.getSource()).getData("customData"))); //$NON-NLS-1$ + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java new file mode 100644 index 000000000..c06c0367b --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java @@ -0,0 +1,720 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.events.SelectionChangedBroadcastEvent; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts; +import org.eclipse.tm.internal.terminal.control.ITerminalListener; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.tcf.te.runtime.events.EventManager; +import org.eclipse.tcf.te.ui.events.AbstractEventListener; +import org.eclipse.tcf.te.ui.swt.DisplayUtil; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDEEncoding; + +/** + * Terminals tab folder manager. + */ +@SuppressWarnings("restriction") +public class TabFolderManager extends PlatformObject implements ISelectionProvider { + // Reference to the parent terminal consoles view + private final ITerminalsView parentView; + // Reference to the selection listener instance + private final SelectionListener selectionListener; + // Reference to the broadcasted selection changed event listener instance + private final BroadcastedSelectionChangedEventListener broadcastedSelectionChangedEventListener; + + /** + * List of selection changed listeners. + */ + private final List<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); + + /** + * The terminal control selection listener implementation. + */ + private class TerminalControlSelectionListener implements DisposeListener, MouseListener { + private final ITerminalViewControl terminal; + private boolean selectMode; + + /** + * Constructor. + * + * @param terminal The terminal control. Must be not <code>null</code>. + */ + public TerminalControlSelectionListener(ITerminalViewControl terminal) { + Assert.isNotNull(terminal); + this.terminal = terminal; + + // Register ourself as the required listener + terminal.getControl().addDisposeListener(this); + terminal.getControl().addMouseListener(this); + } + + /** + * Returns the associated terminal view control. + * + * @return The terminal view control. + */ + protected final ITerminalViewControl getTerminal() { + return terminal; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) + */ + @Override + public void widgetDisposed(DisposeEvent e) { + // Widget got disposed, check if it is ours + // If a tab item gets disposed, we have to dispose the terminal as well + if (e.getSource().equals(terminal.getControl())) { + // Remove as listener + getTerminal().getControl().removeDisposeListener(this); + getTerminal().getControl().removeMouseListener(this); + } + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) + */ + @Override + public void mouseDown(MouseEvent e) { + // Left button down -> select mode starts + if (e.button == 1) selectMode = true; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) + */ + @Override + public void mouseUp(MouseEvent e) { + if (e.button == 1 && selectMode) { + selectMode = false; + // Fire a selection changed event with the terminal controls selection + DisplayUtil.safeAsyncExec(new Runnable() { + @Override + public void run() { + fireSelectionChanged(new StructuredSelection(getTerminal().getSelection())); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) + */ + @Override + public void mouseDoubleClick(MouseEvent e) { + } + } + + /** + * The event listener to process broadcasted selection changed events + */ + private class BroadcastedSelectionChangedEventListener extends AbstractEventListener { + private final TabFolderManager parent; + + /** + * Constructor. + * + * @param parent The parent tab folder manager. Must not be <code>null</code>. + */ + public BroadcastedSelectionChangedEventListener(TabFolderManager parent) { + super(); + + Assert.isNotNull(parent); + this.parent = parent; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject) + */ + @Override + public void eventFired(EventObject event) { + if (event instanceof SelectionChangedBroadcastEvent && !event.getSource().equals(parent)) { + // Don't need to do anything if the parent tab folder is disposed or does not have a open tab + CTabFolder tabFolder = parent.getTabFolder(); + if (tabFolder == null || tabFolder.isDisposed() || tabFolder.getItemCount() == 0) return; + + // Received a broadcasted selection changed event from another tab folder manager. + SelectionChangedEvent selectionChangedEvent = ((SelectionChangedBroadcastEvent)event).getSelectionChangedEvent(); + if (selectionChangedEvent != null && selectionChangedEvent.getSelection() instanceof IStructuredSelection && !selectionChangedEvent.getSelection().isEmpty()) { + // Extract the selection from the selection changed event + IStructuredSelection selection = (IStructuredSelection)selectionChangedEvent.getSelection(); + // Determine the first element in the selection being a CTabItem + CTabItem item = null; + Iterator<?> iterator = selection.iterator(); + while (iterator.hasNext()) { + Object candidate = iterator.next(); + if (candidate instanceof CTabItem) { item = (CTabItem)candidate; break; } + } + // If we got an CTabItem from the selection, try to find a CTabItem in our own tab folder manager + // which is associated with the exact same data object. + if (item != null && item.getData("customData") != null) { //$NON-NLS-1$ + Object data = item.getData("customData"); //$NON-NLS-1$ + + CTabItem[] ourItems = tabFolder.getItems(); + for (CTabItem ourItem : ourItems) { + Object ourData = ourItem.getData("customData"); //$NON-NLS-1$ + if (data.equals(ourData) && !ourItem.equals(parent.getActiveTabItem())) { + // Select this item and we are done + parent.setSelection(new StructuredSelection(ourItem)); + break; + } + } + } + } + } + } + + } + + /** + * Constructor. + * + * @param parentView The parent terminal console view. Must be not <code>null</code>. + */ + public TabFolderManager(ITerminalsView parentView) { + super(); + Assert.isNotNull(parentView); + this.parentView = parentView; + + // Attach a selection listener to the tab folder + selectionListener = doCreateTabFolderSelectionListener(this); + if (getTabFolder() != null) getTabFolder().addSelectionListener(selectionListener); + + + // Create and register the broadcasted selection changed event listener + broadcastedSelectionChangedEventListener = doCreateBroadcastedSelectionChangedEventListener(this); + if (isListeningToBroadcastedSelectionChangedEvent() && broadcastedSelectionChangedEventListener != null) { + EventManager.getInstance().addEventListener(broadcastedSelectionChangedEventListener, SelectionChangedBroadcastEvent.class); + } + } + + /** + * Creates the terminal console tab folder selection listener instance. + * + * @param parent The parent terminal console tab folder manager. Must be not <code>null</code>. + * @return The selection listener instance. + */ + protected TabFolderSelectionListener doCreateTabFolderSelectionListener(TabFolderManager parent) { + Assert.isNotNull(parent); + return new TabFolderSelectionListener(parent); + } + + /** + * Returns the parent terminal consoles view. + * + * @return The terminal consoles view instance. + */ + protected final ITerminalsView getParentView() { + return parentView; + } + + /** + * Returns the tab folder associated with the parent view. + * + * @return The tab folder or <code>null</code>. + */ + protected final CTabFolder getTabFolder() { + return (CTabFolder)getParentView().getAdapter(CTabFolder.class); + } + + /** + * Returns the selection changed listeners currently registered. + * + * @return The registered selection changed listeners or an empty array. + */ + protected final ISelectionChangedListener[] getSelectionChangedListeners() { + return selectionChangedListeners.toArray(new ISelectionChangedListener[selectionChangedListeners.size()]); + } + + /** + * Dispose the tab folder manager instance. + */ + public void dispose() { + // Dispose the selection listener + if (getTabFolder() != null && !getTabFolder().isDisposed()) getTabFolder().removeSelectionListener(selectionListener); + // Remove the broadcasted selection changed event listener from the notification manager + if (broadcastedSelectionChangedEventListener != null) { + EventManager.getInstance().removeEventListener(broadcastedSelectionChangedEventListener); + } + } + + /** + * Creates a new tab item with the given title and connector. + * + * @param title The tab title. Must be not <code>null</code>. + * @param connector The terminal connector. Must be not <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * + * @return The created tab item or <code>null</code> if failed. + */ + @SuppressWarnings("unused") + public CTabItem createTabItem(String title, ITerminalConnector connector, Object data) { + Assert.isNotNull(title); + Assert.isNotNull(connector); + + // The result tab item + CTabItem item = null; + + // Get the tab folder from the parent viewer + CTabFolder tabFolder = getTabFolder(); + if (tabFolder != null) { + // Generate a unique title string for the new tab item (must be called before creating the item itself) + title = makeUniqueTitle(title, tabFolder); + // Create the tab item + item = new CTabItem(tabFolder, SWT.CLOSE); + // Set the tab item title + item.setText(title); + // Set the tab icon + Image image = getTabItemImage(connector, data); + if (image != null) item.setImage(image); + + // Setup the tab item listeners + setupTerminalTabListeners(item); + + // Create the composite to create the terminal control within + Composite composite = new Composite(tabFolder, SWT.NONE); + composite.setLayout(new FillLayout()); + // Associate the composite with the tab item + item.setControl(composite); + + // Refresh the layout + tabFolder.getParent().layout(true); + + // Create the terminal control + ITerminalViewControl terminal = TerminalViewControlFactory.makeControl(doCreateTerminalTabTerminalListener(item), composite, new ITerminalConnector[] { connector }); + // Add the "selection" listener to the terminal control + new TerminalControlSelectionListener(terminal); + // Use the default Eclipse IDE encoding setting to configure the terminals encoding + try { terminal.setEncoding(IDEEncoding.getResourceEncoding()); } catch (UnsupportedEncodingException e) { /* ignored on purpose */ } + // Associated the terminal with the tab item + item.setData(terminal); + // Associated the custom data node with the tab item (if any) + if (data != null) item.setData("customData", data); //$NON-NLS-1$ + + // Overwrite the text canvas help id + String contextHelpId = getParentView().getContextHelpId(); + if (contextHelpId != null) { + PlatformUI.getWorkbench().getHelpSystem().setHelp(terminal.getControl(), contextHelpId); + } + + // Set the context menu + TabFolderMenuHandler menuHandler = (TabFolderMenuHandler)getParentView().getAdapter(TabFolderMenuHandler.class); + if (menuHandler != null) { + Menu menu = (Menu)menuHandler.getAdapter(Menu.class); + if (menu != null) { + // One weird occurrence of IllegalArgumentException: Widget has wrong parent. + // Inspecting the code, this seem extremely unlikely. The terminal is created + // from a composite parent, the composite parent from the tab folder and the menu + // from the tab folder. Means, at the end all should have the same menu shell, shouldn't they? + try { + terminal.getControl().setMenu(menu); + } catch (IllegalArgumentException e) { + // Log exception only if debug mode is set to 1. + if (UIPlugin.getTraceHandler().isSlotEnabled(1, null)) { + e.printStackTrace(); + } + } + } + } + + // Select the created item within the tab folder + tabFolder.setSelection(item); + + // Set the connector + terminal.setConnector(connector); + + // And connect the terminal + terminal.connectTerminal(); + + // Fire selection changed event + fireSelectionChanged(); + } + + // Return the create tab item finally. + return item; + } + + /** + * Generate a unique title string based on the given proposal. + * + * @param proposal The proposal. Must be not <code>null</code>. + * @return The unique title string. + */ + protected String makeUniqueTitle(String proposal, CTabFolder tabFolder) { + Assert.isNotNull(proposal); + Assert.isNotNull(tabFolder); + + String title = proposal; + int index = 0; + + // Loop all existing tab items and check the titles. We have to remember + // all found titles as modifying the proposal might in turn conflict again + // with the title of a tab already checked. + List<String> titles = new ArrayList<String>(); + for (CTabItem item : tabFolder.getItems()) { + // Get the tab item title + titles.add(item.getText()); + // Make the proposal unique be appending (<n>) against all known titles. + while (titles.contains(title)) title = proposal + " (" + index++ + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + return title; + } + + /** + * Setup the terminal console tab item listeners. + * + * @param item The tab item. Must be not <code>null</code>. + */ + protected void setupTerminalTabListeners(CTabItem item) { + Assert.isNotNull(item); + + // Create and associate the disposal listener + item.addDisposeListener(doCreateTerminalTabDisposeListener(this)); + + // Create and register the property change listener + final IPropertyChangeListener propertyChangeListener = doCreateTerminalTabPropertyChangeListener(item); + // Register to the JFace font registry + JFaceResources.getFontRegistry().addListener(propertyChangeListener); + // Remove the listener from the JFace font registry if the tab gets disposed + item.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + JFaceResources.getFontRegistry().removeListener(propertyChangeListener); + } + }); + } + + /** + * Creates a new terminal console tab terminal listener instance. + * + * @param item The tab item. Must be not <code>null</code>. + * @return The terminal listener instance. + */ + protected ITerminalListener doCreateTerminalTabTerminalListener(CTabItem item) { + Assert.isNotNull(item); + return new TabTerminalListener(item); + } + + /** + * Creates a new terminal console tab dispose listener instance. + * + * @param parent The parent terminal console tab folder manager. Must be not <code>null</code>. + * @return The dispose listener instance. + */ + protected DisposeListener doCreateTerminalTabDisposeListener(TabFolderManager parent) { + Assert.isNotNull(parent); + return new TabDisposeListener(parent); + } + + /** + * Creates a new terminal console tab property change listener instance. + * + * @param item The tab item. Must be not <code>null</code>. + * @return The property change listener instance. + */ + protected IPropertyChangeListener doCreateTerminalTabPropertyChangeListener(CTabItem item) { + Assert.isNotNull(item); + return new TabPropertyChangeListener(item); + } + + /** + * Returns the tab item image. + * + * @param connector The terminal connector. Must be not <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * + * @return The tab item image or <code>null</code>. + */ + protected Image getTabItemImage(ITerminalConnector connector, Object data) { + Assert.isNotNull(connector); + return UIPlugin.getImage(ImageConsts.VIEW_Terminals); + } + + /** + * Lookup a tab item with the given title and the given terminal connector. + * <p> + * <b>Note:</b> The method will handle unified tab item titles itself. + * + * @param title The tab item title. Must be not <code>null</code>. + * @param connector The terminal connector. Must be not <code>null</code>. + * @param data The custom terminal data node or <code>null</code>. + * + * @return The corresponding tab item or <code>null</code>. + */ + public CTabItem findTabItem(String title, ITerminalConnector connector, Object data) { + Assert.isNotNull(title); + Assert.isNotNull(connector); + + // Get the tab folder + CTabFolder tabFolder = getTabFolder(); + if (tabFolder == null) return null; + + // Loop all existing tab items and try to find a matching title + for (CTabItem item : tabFolder.getItems()) { + // Disposed items cannot be matched + if (item.isDisposed()) continue; + // Get the title from the current tab item + String itemTitle = item.getText(); + // The terminal console state might be signaled to the user via the + // terminal console tab title. Filter out any prefix "<.*>\s*". + itemTitle = itemTitle.replaceFirst("^<.*>\\s*", ""); //$NON-NLS-1$ //$NON-NLS-2$ + if (itemTitle.startsWith(title)) { + // The title string matches -> double check with the terminal connector + ITerminalViewControl terminal = (ITerminalViewControl)item.getData(); + ITerminalConnector connector2 = terminal.getTerminalConnector(); + // If the connector id and name matches -> check on the settings + if (connector.getId().equals(connector2.getId()) && connector.getName().equals(connector2.getName())) { + if (!connector.isInitialized()) { + // an uninitialized connector does not yield a sensible summary + return item; + } + String summary = connector.getSettingsSummary(); + String summary2 = connector2.getSettingsSummary(); + // If we have matching settings -> we've found the matching item + if (summary.equals(summary2)) return item; + } + } + } + + return null; + } + + /** + * Make the given tab item the active tab and bring the tab to the top. + * + * @param item The tab item. Must be not <code>null</code>. + */ + public void bringToTop(CTabItem item) { + Assert.isNotNull(item); + + // Get the tab folder + CTabFolder tabFolder = getTabFolder(); + if (tabFolder == null) return; + + // Set the given tab item as selection to the tab folder + tabFolder.setSelection(item); + // Fire selection changed event + fireSelectionChanged(); + } + + /** + * Returns the currently active tab. + * + * @return The active tab item or <code>null</code> if none. + */ + public CTabItem getActiveTabItem() { + // Get the tab folder + CTabFolder tabFolder = getTabFolder(); + if (tabFolder == null) return null; + + return tabFolder.getSelection(); + } + + /** + * Remove all terminated tab items. + */ + public void removeTerminatedItems() { + // Get the tab folder + CTabFolder tabFolder = getTabFolder(); + if (tabFolder == null) return; + + // Loop the items and check for terminated status + for (CTabItem item: tabFolder.getItems()) { + // Disposed items cannot be matched + if (item.isDisposed()) continue; + // Check if the item is terminated + if (isTerminatedTabItem(item)) { + // item is terminated -> dispose + item.dispose(); + } + } + } + + /** + * Checks if the given tab item represents a terminated console. Subclasses may + * overwrite this method to extend the definition of terminated. + * + * @param item The tab item or <code>null</code>. + * @return <code>True</code> if the tab item represents a terminated console, <code>false</code> otherwise. + */ + protected boolean isTerminatedTabItem(CTabItem item) { + // Null items or disposed items cannot be matched + if (item == null || item.isDisposed()) return false; + + // First, match the item title. If it contains "<terminated>", the item can be removed + String itemTitle = item.getText(); + if (itemTitle != null && itemTitle.contains("<terminated>")) { //$NON-NLS-1$ + return true; + } + // Second, check if the associated terminal control is closed + // The title string matches -> double check with the terminal connector + ITerminalViewControl terminal = (ITerminalViewControl)item.getData(); + if (terminal != null && terminal.getState() == TerminalState.CLOSED) { + return true; + } + + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + if (listener != null && !selectionChangedListeners.contains(listener)) selectionChangedListeners.add(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + if (listener != null) selectionChangedListeners.remove(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() + */ + @Override + public ISelection getSelection() { + CTabItem activeTabItem = getActiveTabItem(); + return activeTabItem != null ? new StructuredSelection(activeTabItem) : new StructuredSelection(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + @Override + public void setSelection(ISelection selection) { + if (selection instanceof IStructuredSelection && !selection.isEmpty()) { + // The first selection element which is a CTabItem will become the active item + Iterator<?> iterator = ((IStructuredSelection)selection).iterator(); + while (iterator.hasNext()) { + Object candidate = iterator.next(); + if (candidate instanceof CTabItem) { bringToTop((CTabItem)candidate); return; } + } + } + // fire a changed event in any case + fireSelectionChanged(selection); + } + + /** + * Fire the selection changed event to the registered listeners. + */ + protected void fireSelectionChanged() { + fireSelectionChanged(getSelection()); + } + + /** + * Fire the selection changed event to the registered listeners. + */ + protected final void fireSelectionChanged(ISelection selection) { + // Create the selection changed event + SelectionChangedEvent event = new SelectionChangedEvent(TabFolderManager.this, selection); + + // First, invoke the registered listeners and let them do their job + for (ISelectionChangedListener listener : selectionChangedListeners) { + listener.selectionChanged(event); + } + + // Second, broadcast the event if desired + if (isBroadcastSelectionChangedEvent()) onBroadcastSelectionChangedEvent(event); + } + + /** + * Controls if or if not a selection changed event, processed by this tab + * folder manager shall be broadcasted to via the global Workbench notification + * mechanism. + * + * @return <code>True</code> to broadcast the selection changed event, <code>false</code> otherwise. + */ + protected boolean isBroadcastSelectionChangedEvent() { + return false; + } + + /** + * Broadcasts the given selection changed event via the global Workbench notification mechanism. + * + * @param selectionChangedEvent The selection changed event or <code>null</code>. + */ + protected void onBroadcastSelectionChangedEvent(SelectionChangedEvent selectionChangedEvent) { + SelectionChangedBroadcastEvent event = doCreateSelectionChangedBroadcastEvent(this, selectionChangedEvent); + if (event != null) EventManager.getInstance().fireEvent(event); + } + + /** + * Creates the selection changed broadcast event. + * + * @param source The event source. Must not be <code>null</code>. + * @param selectionChangedEvent The selection changed event or <code>null</code>. + * + * @return The selection changed broadcast event or <code>null</code>. + */ + protected SelectionChangedBroadcastEvent doCreateSelectionChangedBroadcastEvent(TabFolderManager source, SelectionChangedEvent selectionChangedEvent) { + return new SelectionChangedBroadcastEvent(source, selectionChangedEvent); + } + + /** + * Returns if or if not this tab folder manager is listening to broadcasted selection + * changed events. Broadcasted events by the same tab folder manager are ignored independent + * of the methods return value. + * + * @return <code>True</code> to listen to broadcasted selection changed events, <code>false</code> to not listen. + */ + protected boolean isListeningToBroadcastedSelectionChangedEvent() { + return false; + } + + /** + * Creates a new broadcasted selection changed event listener instance. + * + * @param parent The parent tab folder manager. Must not be <code>null</code>. + * @return The event listener instance or <code>null</code>. + */ + protected BroadcastedSelectionChangedEventListener doCreateBroadcastedSelectionChangedEventListener(TabFolderManager parent) { + return new BroadcastedSelectionChangedEventListener(parent); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java new file mode 100644 index 000000000..b3e6cc3f8 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java @@ -0,0 +1,297 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.jface.action.IMenuListener2; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.tcf.te.ui.terminals.actions.TabScrollLockAction; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; +import org.eclipse.ui.IWorkbenchActionConstants; + +/** + * Terminals tab folder menu handler. + */ +@SuppressWarnings("restriction") +public class TabFolderMenuHandler extends PlatformObject { + // Reference to the parent terminal console view + private final ITerminalsView parentView; + // Reference to the tab folder context menu manager + private MenuManager contextMenuManager; + // Reference to the tab folder context menu + private Menu contextMenu; + // The list of actions available within the context menu + private final List<AbstractTerminalAction> contextMenuActions = new ArrayList<AbstractTerminalAction>(); + + /** + * Default menu listener implementation. + */ + protected class MenuListener implements IMenuListener2 { + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuListener2#menuAboutToHide(org.eclipse.jface.action.IMenuManager) + */ + @Override + public void menuAboutToHide(IMenuManager manager) { + // CQ:WIND00192293 and CQ:WIND194204 - don't update actions on menuAboutToHide + // See also http://bugs.eclipse.org/296212 + // updateMenuItems(false); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) + */ + @Override + public void menuAboutToShow(IMenuManager manager) { + updateMenuItems(true); + } + + } + + /** + * Constructor. + * + * @param parentView The parent terminal console view. Must not be <code>null</code>. + */ + public TabFolderMenuHandler(ITerminalsView parentView) { + super(); + Assert.isNotNull(parentView); + this.parentView = parentView; + } + + /** + * Returns the parent terminal console view. + * + * @return The parent terminal console view instance. + */ + protected final ITerminalsView getParentView() { + return parentView; + } + + /** + * Returns the tab folder associated with the parent view. + * + * @return The tab folder or <code>null</code>. + */ + protected final CTabFolder getTabFolder() { + return (CTabFolder)getParentView().getAdapter(CTabFolder.class); + } + + /** + * Dispose the tab folder menu handler instance. + */ + public void dispose() { + // Dispose the context menu + if (contextMenu != null) { contextMenu.dispose(); contextMenu = null; } + // Dispose the context menu manager + if (contextMenuManager != null) { contextMenuManager.dispose(); contextMenuManager = null; } + // Clear all actions + contextMenuActions.clear(); + } + + /** + * Setup the context menu for the tab folder. The method will return + * immediately if the menu handler had been initialized before. + * + * @param tabFolder The tab folder control. Must not be <code>null</code>. + */ + public void initialize() { + // Return immediately if the menu manager and menu got initialized already + if (contextMenuManager != null && contextMenu != null) { + return; + } + + // Get the tab folder + CTabFolder tabFolder = getTabFolder(); + if (tabFolder == null) { + return; + } + + // Create the menu manager if not done before + contextMenuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$ + // Create and associated the menu listener + contextMenuManager.addMenuListener(new MenuListener()); + // Create the context menu + contextMenu = contextMenuManager.createContextMenu(tabFolder); + + // Create the context menu action instances + doCreateContextMenuActions(); + + // Fill the context menu + doFillContextMenu(contextMenuManager); + + // Register to the view site to open the menu for contributions + getParentView().getSite().registerContextMenu(contextMenuManager, getParentView().getSite().getSelectionProvider()); + } + + /** + * Adds the given action to the context menu actions list. + * + * @param action The action instance. Must be not <code>null</code>. + */ + protected final void add(AbstractTerminalAction action) { + Assert.isNotNull(action); + contextMenuActions.add(action); + } + + /** + * Create the context menu actions. + */ + protected void doCreateContextMenuActions() { + // Create and add the copy action + add(new TerminalActionCopy() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the paste action + add(new TerminalActionPaste() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the clear all action + add(new TerminalActionClearAll() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the select all action + add(new TerminalActionSelectAll() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the scroll lock action + add (new TabScrollLockAction() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + } + + /** + * Returns the currently active terminal control. + * + * @return The currently active terminal control or <code>null</code>. + */ + protected ITerminalViewControl getActiveTerminalViewControl() { + ITerminalViewControl terminal = null; + + // Get the active tab item from the tab folder manager + TabFolderManager manager = (TabFolderManager)getParentView().getAdapter(TabFolderManager.class); + if (manager != null) { + // If we have the active tab item, we can get the active terminal control + CTabItem activeTabItem = manager.getActiveTabItem(); + if (activeTabItem != null) { + terminal = (ITerminalViewControl)activeTabItem.getData(); + } + } + + return terminal; + } + + /** + * Fill in the context menu content within the given manager. + * + * @param manager The menu manager. Must not be <code>null</code>. + */ + protected void doFillContextMenu(MenuManager manager) { + Assert.isNotNull(manager); + + // Loop all actions and add them to the menu manager + for (AbstractTerminalAction action : contextMenuActions) { + manager.add(action); + // Add a separator after the paste action + if (action instanceof TerminalActionPaste) { + manager.add(new Separator()); + } + // Add a separator after the select all action + if (action instanceof TerminalActionSelectAll) { + manager.add(new Separator()); + } + } + + // Menu contributions will end up here + manager.add(new Separator()); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + /** + * Update the context menu items on showing or hiding the context menu. + * + * @param aboutToShow <code>True</code> if the menu is about to show, <code>false</code> otherwise. + */ + protected void updateMenuItems(boolean aboutToShow) { + // Loop all actions and update the status + for (AbstractTerminalAction action : contextMenuActions) { + action.updateAction(aboutToShow); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (MenuManager.class.isAssignableFrom(adapter)) { + return contextMenuManager; + } else if (Menu.class.isAssignableFrom(adapter)) { + return contextMenu; + } + + // Try the parent view + Object adapted = getParentView().getAdapter(adapter); + if (adapted != null) { + return adapted; + } + + return super.getAdapter(adapter); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderSelectionListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderSelectionListener.java new file mode 100644 index 000000000..e14255319 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderSelectionListener.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; + +/** + * Terminals tab folder default selection listener implementation. + */ +public class TabFolderSelectionListener implements SelectionListener { + private final TabFolderManager parentTabFolderManager; + + /** + * Constructor. + * + * @param parentTabFolderManager The parent tab folder manager. Must be not <code>null</code> + */ + public TabFolderSelectionListener(TabFolderManager parentTabFolderManager) { + Assert.isNotNull(parentTabFolderManager); + this.parentTabFolderManager = parentTabFolderManager; + } + + /** + * Returns the parent terminal console tab folder manager instance. + * + * @return The parent terminal console tab folder manager instance. + */ + protected final TabFolderManager getParentTabFolderManager() { + return parentTabFolderManager; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent e) { + parentTabFolderManager.fireSelectionChanged(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java new file mode 100644 index 000000000..50d6de944 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java @@ -0,0 +1,304 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.ui.terminals.actions.AbstractAction; +import org.eclipse.tcf.te.ui.terminals.actions.TabScrollLockAction; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IWorkbenchActionConstants; + + +/** + * Terminals tab folder toolbar handler. + */ +@SuppressWarnings("restriction") +public class TabFolderToolbarHandler extends PlatformObject { + // Reference to the parent terminal console view + private final ITerminalsView parentView; + // Reference to the toolbar manager + private IToolBarManager toolbarManager; + // Reference to the selection listener + private ToolbarSelectionChangedListener selectionChangedListener; + // The list of actions available within the toolbar + private final List<AbstractTerminalAction> toolbarActions = new ArrayList<AbstractTerminalAction>(); + + /** + * Default selection listener implementation. + */ + protected class ToolbarSelectionChangedListener implements ISelectionChangedListener { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + @Override + public void selectionChanged(SelectionChangedEvent event) { + boolean enable = event != null; + + // The VlmConsoleTabFolderManager is listening to the selection changes of the + // TabFolder and fires selection changed events. + if (enable && event.getSource() instanceof TabFolderManager) { + enable = event.getSelection() instanceof StructuredSelection + && !event.getSelection().isEmpty() + && (((StructuredSelection)event.getSelection()).getFirstElement() instanceof CTabItem + || ((StructuredSelection)event.getSelection()).getFirstElement() instanceof String); + } + + updateToolbarItems(enable); + } + } + + /** + * Constructor. + * + * @param parentView The parent terminal console view. Must not be <code>null</code>. + */ + public TabFolderToolbarHandler(ITerminalsView parentView) { + super(); + Assert.isNotNull(parentView); + this.parentView = parentView; + } + + /** + * Returns the parent terminal console view. + * + * @return The terminal console view instance. + */ + protected final ITerminalsView getParentView() { + return parentView; + } + + /** + * Returns the tab folder associated with the parent view. + * + * @return The tab folder or <code>null</code>. + */ + protected final CTabFolder getTabFolder() { + return (CTabFolder)getParentView().getAdapter(CTabFolder.class); + } + + /** + * Returns the currently active terminal control. + * + * @return The currently active terminal control or <code>null</code>. + */ + public ITerminalViewControl getActiveTerminalViewControl() { + ITerminalViewControl terminal = null; + + // Get the active tab item from the tab folder manager + TabFolderManager manager = (TabFolderManager)getParentView().getAdapter(TabFolderManager.class); + if (manager != null) { + // If we have the active tab item, we can get the active terminal control + CTabItem activeTabItem = manager.getActiveTabItem(); + if (activeTabItem != null && !activeTabItem.isDisposed()) { + terminal = (ITerminalViewControl)activeTabItem.getData(); + } + } + + return terminal; + } + + /** + * Dispose the tab folder menu handler instance. + */ + public void dispose() { + // Dispose the selection changed listener + if (selectionChangedListener != null) { + getParentView().getViewSite().getSelectionProvider().removeSelectionChangedListener(selectionChangedListener); + selectionChangedListener = null; + } + + // Clear all actions + toolbarActions.clear(); + } + + /** + * Setup the context menu for the tab folder. The method will return + * immediately if the toolbar handler had been initialized before. + * + * @param tabFolder The tab folder control. Must not be <code>null</code>. + */ + public void initialize() { + // Return immediately if the toolbar manager got initialized already + if (toolbarManager != null) { + return; + } + + // Register ourself as selection listener to the tab folder + selectionChangedListener = doCreateSelectionChangedListener(); + Assert.isNotNull(selectionChangedListener); + getParentView().getViewSite().getSelectionProvider().addSelectionChangedListener(selectionChangedListener); + + // Get the parent view action bars + IActionBars bars = getParentView().getViewSite().getActionBars(); + + // From the action bars, get the toolbar manager + toolbarManager = bars.getToolBarManager(); + + // Create the toolbar action instances + doCreateToolbarActions(); + + // Fill the toolbar + doFillToolbar(toolbarManager); + + // Update actions + updateToolbarItems(false); + } + + /** + * Creates a new selection changed listener instance. + * + * @return The new selection changed listener instance. + */ + protected ToolbarSelectionChangedListener doCreateSelectionChangedListener() { + return new ToolbarSelectionChangedListener(); + } + + /** + * Adds the given action to the toolbar actions list. + * + * @param action The action instance. Must be not <code>null</code>. + */ + protected final void add(AbstractTerminalAction action) { + Assert.isNotNull(action); + toolbarActions.add(action); + } + + /** + * Create the toolbar actions. + */ + protected void doCreateToolbarActions() { + // Create and add the paste action + add(new TerminalActionPaste() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the copy action + add(new TerminalActionCopy() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the scroll lock action + add (new TabScrollLockAction() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + + // Create and add the clear all action + add(new TerminalActionClearAll() { + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + } + + /** + * Fill in the context menu content within the given manager. + * + * @param manager The menu manager. Must not be <code>null</code>. + */ + protected void doFillToolbar(IToolBarManager manager) { + Assert.isNotNull(manager); + + // Note: For the toolbar, the actions are added from left to right! + // So we start with the additions marker here which is the most + // left contribution item. + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.add(new Separator("anchor")); //$NON-NLS-1$ + + // Loop all actions and add them to the menu manager + for (AbstractTerminalAction action : toolbarActions) { + // Add a separator before the clear all action or if the action is a separator + if (action instanceof TabScrollLockAction + || (action instanceof AbstractAction && ((AbstractAction)action).isSeparator())) { + manager.insertAfter("anchor", new Separator()); //$NON-NLS-1$ + } + // Add the action itself + manager.insertAfter("anchor", action); //$NON-NLS-1$ + } + } + + /** + * Update the toolbar items. + * + * @param enabled <code>True</code> if the items shall be enabled, <code>false</code> otherwise. + */ + protected void updateToolbarItems(boolean enabled) { + // Determine the currently active terminal control + ITerminalViewControl control = getActiveTerminalViewControl(); + // Loop all actions and update the status + for (AbstractTerminalAction action : toolbarActions) { + // If the terminal control is not available, the updateAction + // method of certain actions enable the action (bugzilla #260372). + // Workaround by forcing the action to get disabled with setEnabled. + if (control == null) { + action.setEnabled(false); + } + else { + action.updateAction(enabled); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (IToolBarManager.class.isAssignableFrom(adapter)) { + return toolbarManager; + } + // Try the parent view + Object adapted = getParentView().getAdapter(adapter); + if (adapted != null) { + return adapted; + } + + return super.getAdapter(adapter); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabPropertyChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabPropertyChangeListener.java new file mode 100644 index 000000000..453fb70d6 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabPropertyChangeListener.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.graphics.Font; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.view.TerminalView; + +/** + * Terminals tab default property change listener implementation. + */ +@SuppressWarnings("restriction") +public class TabPropertyChangeListener implements IPropertyChangeListener { + /** + * Default terminal font property key. + * + * @see TerminalView#FONT_DEFINITION + */ + public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$ + + // Reference to the parent tab item + private final CTabItem tabItem; + + /** + * Constructor. + * + * @param tabItem The parent tab item. Must not be <code>null</code>. + */ + public TabPropertyChangeListener(CTabItem tabItem) { + super(); + Assert.isNotNull(tabItem); + this.tabItem = tabItem; + } + + /** + * Returns the associated parent tab item. + * + * @return The parent tab item. + */ + protected final CTabItem getTabItem() { + return tabItem; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + @Override + public void propertyChange(PropertyChangeEvent event) { + // In case we are called once after the tab item got disposed + // --> Do nothing + if (getTabItem() == null || getTabItem().isDisposed()) return; + + // Listen to changes of the Font settings + if (event.getProperty().equals(FONT_DEFINITION)) { + onFontDefinitionProperyChanged(); + } + } + + /** + * Called if a property change event for the terminal font + * definition is received. + */ + protected void onFontDefinitionProperyChanged() { + // Get the current font from JFace + Font font = JFaceResources.getFont(FONT_DEFINITION); + // Get the terminal control from the tab item + if (getTabItem().getData() instanceof ITerminalViewControl) { + ITerminalViewControl terminal = (ITerminalViewControl)getTabItem().getData(); + terminal.setFont(font); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java new file mode 100644 index 000000000..752dc12b1 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.tabs; + +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tm.internal.terminal.control.ITerminalListener; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * Terminals tab default terminal listener implementation. + */ +@SuppressWarnings("restriction") +public class TabTerminalListener implements ITerminalListener { + private final CTabItem tabItem; + + /** + * Constructor. + * + * @param tabItem The parent tab item. Must not be <code>null</code>. + */ + public TabTerminalListener(CTabItem tabItem) { + super(); + Assert.isNotNull(tabItem); + this.tabItem = tabItem; + } + + /** + * Returns the associated parent tab item. + * + * @return The parent tab item. + */ + protected final CTabItem getTabItem() { + return tabItem; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.ITerminalListener#setState(org.eclipse.tcf.internal.terminal.provisional.api.TerminalState) + */ + @Override + public void setState(final TerminalState state) { + // The tab item must have been not yet disposed + final CTabItem item = getTabItem(); + if (item == null || item.isDisposed()) return; + + // Update the tab item title + item.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + String newTitle = getTerminalConsoleTabTitle(state); + if (newTitle != null) item.setText(newTitle); + } + }); + } + + // The pattern will not change over the session life-time + private static final Pattern TERMINAL_TITLE_TERMINATED_PATTERN = Pattern.compile(Messages.TabTerminalListener_consoleTerminated.replaceAll("\\{[0-9]+\\}", ".*")); //$NON-NLS-1$ //$NON-NLS-2$ + + /** + * Returns the title to set to the terminal console tab for the given state. + * <p> + * <b>Note:</b> This method is called from {@link #setState(TerminalState)} and + * is expected to by called within the UI thread. + * + * @param state The terminal state. Must be not <code>null</code>. + * @return The terminal console tab title to set or <code>null</code> to leave the title unchanged. + */ + protected String getTerminalConsoleTabTitle(TerminalState state) { + Assert.isNotNull(state); + Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + + // The tab item must have been not yet disposed + CTabItem item = getTabItem(); + if (item == null || item.isDisposed()) return null; + + // Get the current tab title + String oldTitle = item.getText(); + + // Construct the new title + String newTitle = null; + + if (TerminalState.CLOSED.equals(state)) { + // Avoid multiple decorations of the closed state + if (!TERMINAL_TITLE_TERMINATED_PATTERN.matcher(oldTitle).matches()) { + newTitle = NLS.bind(Messages.TabTerminalListener_consoleTerminated, oldTitle); + } else { + newTitle = oldTitle; + } + } + + return newTitle != null && !newTitle.equals(oldTitle) ? newTitle : null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.internal.terminal.control.ITerminalListener#setTerminalTitle(java.lang.String) + */ + @Override + public void setTerminalTitle(String title) { + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java new file mode 100644 index 000000000..bef1abee9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java @@ -0,0 +1,20 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.types;
+
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+
+/**
+ * Abstract terminal connector type implementation.
+ */
+public abstract class AbstractConnectorType extends ExecutableExtension implements IConnectorType {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java new file mode 100644 index 000000000..156571e05 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java @@ -0,0 +1,102 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.types;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+
+/**
+ * Terminal connector type extension point manager implementation.
+ */
+public class ConnectorManager extends AbstractExtensionPointManager<IConnectorType> {
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstanceHolder {
+ public static ConnectorManager instance = new ConnectorManager();
+ }
+
+ /**
+ * Returns the singleton instance for the terminal connector type extension point manager.
+ */
+ public static ConnectorManager getInstance() {
+ return LazyInstanceHolder.instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ ConnectorManager() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.terminals.connectorTypes"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "connectorType"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the list of all contributed terminal connector types.
+ *
+ * @param unique If <code>true</code>, the method returns new instances for each
+ * contributed terminal connector type.
+ *
+ * @return The list of contributed terminal connector types, or an empty array.
+ */
+ public IConnectorType[] getConnectorTypes(boolean unique) {
+ List<IConnectorType> contributions = new ArrayList<IConnectorType>();
+ Collection<ExecutableExtensionProxy<IConnectorType>> connectorTypes = getExtensions().values();
+ for (ExecutableExtensionProxy<IConnectorType> connectorType : connectorTypes) {
+ IConnectorType instance = unique ? connectorType.newInstance() : connectorType.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+
+ return contributions.toArray(new IConnectorType[contributions.size()]);
+ }
+
+ /**
+ * Returns the terminal connector type identified by its unique id. If no terminal
+ * connector type with the specified id is registered, <code>null</code> is returned.
+ *
+ * @param id The unique id of the terminal connector type or <code>null</code>
+ * @param unique If <code>true</code>, the method returns new instances of the terminal connector type contribution.
+ *
+ * @return The terminal connector type instance or <code>null</code>.
+ */
+ public IConnectorType getConnectorType(String id, boolean unique) {
+ IConnectorType contribution = null;
+ if (getExtensions().containsKey(id)) {
+ ExecutableExtensionProxy<IConnectorType> proxy = getExtensions().get(id);
+ // Get the extension instance
+ contribution = unique ? proxy.newInstance() : proxy.getInstance();
+ }
+
+ return contribution;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/StreamsConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/StreamsConnectorType.java new file mode 100644 index 000000000..b14b07e1d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/StreamsConnectorType.java @@ -0,0 +1,72 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.types;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore;
+import org.eclipse.tcf.te.ui.terminals.streams.StreamsSettings;
+import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
+import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
+
+/**
+ * Streams terminal connector type implementation.
+ */
+@SuppressWarnings("restriction")
+public class StreamsConnectorType extends AbstractConnectorType {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public ITerminalConnector createTerminalConnector(IPropertiesContainer properties) {
+ Assert.isNotNull(properties);
+
+ // Check for the terminal connector id
+ String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
+ if (connectorId == null) connectorId = "org.eclipse.tcf.te.ui.terminals.StreamsConnector"; //$NON-NLS-1$
+
+ // Extract the streams properties
+ OutputStream stdin = (OutputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDIN);
+ InputStream stdout = (InputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT);
+ InputStream stderr = (InputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDERR);
+ boolean localEcho = properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
+ String lineSeparator = properties.getStringProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
+
+ // Construct the terminal settings store
+ ISettingsStore store = new SettingsStore();
+
+ // Construct the streams settings
+ StreamsSettings streamsSettings = new StreamsSettings();
+ streamsSettings.setStdinStream(stdin);
+ streamsSettings.setStdoutStream(stdout);
+ streamsSettings.setStderrStream(stderr);
+ streamsSettings.setLocalEcho(localEcho);
+ streamsSettings.setLineSeparator(lineSeparator);
+ // And save the settings to the store
+ streamsSettings.save(store);
+
+ // Construct the terminal connector instance
+ ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
+ if (connector != null) {
+ // Apply default settings
+ connector.makeSettingsPage();
+ // And load the real settings
+ connector.load(store);
+ }
+
+ return connector;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/TelnetConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/TelnetConnectorType.java new file mode 100644 index 000000000..275f0cb16 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/TelnetConnectorType.java @@ -0,0 +1,101 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.types;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore;
+import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
+import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
+import org.eclipse.tm.internal.terminal.telnet.TelnetSettings;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
+
+/**
+ * Telnet terminal connector type implementation.
+ */
+@SuppressWarnings("restriction")
+public class TelnetConnectorType extends AbstractConnectorType {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public ITerminalConnector createTerminalConnector(IPropertiesContainer properties) {
+ Assert.isNotNull(properties);
+
+ // Check for the terminal connector id
+ String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
+
+ // Extract the telnet properties
+ String host = properties.getStringProperty(ITerminalsConnectorConstants.PROP_IP_HOST);
+ String port = properties.getStringProperty(ITerminalsConnectorConstants.PROP_IP_PORT);
+ String timeout = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TIMEOUT);
+
+ int portOffset = 0;
+ if (properties.getProperty(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) != null) {
+ portOffset = properties.getIntProperty(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET);
+ if (portOffset < 0) portOffset = 0;
+ }
+
+ return host != null && port != null ? createTelnetConnector(connectorId, new String[] { host, port, timeout }, portOffset) : null;
+ }
+
+ /**
+ * Creates a terminal connector object based on the given telnet server attributes.
+ * <p>
+ * The telnet server attributes must contain at least 2 elements:
+ * <ul>
+ * <li>attributes[0] --> telnet server host name</li>
+ * <li>attributes[1] --> telnet port</li>
+ * <li>attributes[2] --> timeout (optional)</li>
+ * </ul>
+ *
+ * @param connectorId The terminal connector id or <code>null</code>.
+ * @param attributes The telnet server attributes. Must not be <code>null</code> and must have at least two elements.
+ * @param portOffset Offset to add to the port.
+ *
+ * @return The terminal connector object instance or <code>null</code>.
+ */
+ protected ITerminalConnector createTelnetConnector(String connectorId, String[] attributes, int portOffset) {
+ Assert.isNotNull(attributes);
+ Assert.isTrue(attributes.length >= 2);
+
+ if (connectorId == null) connectorId = "org.eclipse.tcf.internal.terminal.telnet.TelnetConnector"; //$NON-NLS-1$
+
+ final String serverName = attributes[0];
+ final String serverPort = Integer.toString(Integer.decode(attributes[1]).intValue() + portOffset);
+ final String timeout = attributes.length >= 3 ? attributes[2] : null;
+
+ // Construct the terminal settings store
+ ISettingsStore store = new SettingsStore();
+
+ // Construct the telnet settings
+ TelnetSettings telnetSettings = new TelnetSettings();
+ telnetSettings.setHost(serverName);
+ telnetSettings.setNetworkPort(serverPort);
+ if (timeout != null) {
+ telnetSettings.setTimeout(timeout);
+ }
+ // And save the settings to the store
+ telnetSettings.save(store);
+
+ // Construct the terminal connector instance
+ ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
+ if (connector != null) {
+ // Apply default settings
+ connector.makeSettingsPage();
+ // And load the real settings
+ connector.load(store);
+ }
+
+ return connector;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsView.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsView.java new file mode 100644 index 000000000..abd05e0df --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsView.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.view; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.graphics.Color; +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.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderMenuHandler; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderToolbarHandler; +import org.eclipse.ui.IWorkbenchPreferenceConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.PageBook; +import org.eclipse.ui.part.ViewPart; + +/** + * Terminals view. + */ +public class TerminalsView extends ViewPart implements ITerminalsView { + + // Reference to the main page book control + private PageBook pageBookControl; + // Reference to the tab folder maintaining the consoles + private CTabFolder tabFolderControl; + // Reference to the tab folder manager + private TabFolderManager tabFolderManager; + // Reference to the tab folder menu handler + private TabFolderMenuHandler tabFolderMenuHandler; + // Reference to the tab folder toolbar handler + private TabFolderToolbarHandler tabFolderToolbarHandler; + // Reference to the empty page control (to be show if no console is open) + private Control emptyPageControl; + + /** + * Constructor. + */ + public TerminalsView() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#dispose() + */ + @Override + public void dispose() { + // Dispose the tab folder manager + if (tabFolderManager != null) { tabFolderManager.dispose(); tabFolderManager = null; } + // Dispose the tab folder menu handler + if (tabFolderMenuHandler != null) { tabFolderMenuHandler.dispose(); tabFolderMenuHandler = null; } + // Dispose the tab folder toolbar handler + if (tabFolderToolbarHandler != null) { tabFolderToolbarHandler.dispose(); tabFolderToolbarHandler = null; } + + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + // Create the page book control + pageBookControl = doCreatePageBookControl(parent); + Assert.isNotNull(pageBookControl); + // Configure the page book control + doConfigurePageBookControl(pageBookControl); + + // Create the empty page control + emptyPageControl = doCreateEmptyPageControl(pageBookControl); + Assert.isNotNull(emptyPageControl); + // Configure the empty page control + doConfigureEmptyPageControl(emptyPageControl); + + // Create the tab folder control (empty) + tabFolderControl = doCreateTabFolderControl(pageBookControl); + Assert.isNotNull(tabFolderControl); + // Configure the tab folder control + doConfigureTabFolderControl(tabFolderControl); + + // Create the tab folder manager + tabFolderManager = doCreateTabFolderManager(this); + Assert.isNotNull(tabFolderManager); + // Set the tab folder manager as the selection provider + getSite().setSelectionProvider(tabFolderManager); + + // Setup the tab folder menu handler + tabFolderMenuHandler = doCreateTabFolderMenuHandler(this); + Assert.isNotNull(tabFolderMenuHandler); + doConfigureTabFolderMenuHandler(tabFolderMenuHandler); + + // Setup the tab folder toolbar handler + tabFolderToolbarHandler = doCreateTabFolderToolbarHandler(this); + Assert.isNotNull(tabFolderToolbarHandler); + doConfigureTabFolderToolbarHandler(tabFolderToolbarHandler); + + // Show the empty page control by default + switchToEmptyPageControl(); + } + + /** + * Creates the {@link PageBook} instance. + * + * @param parent The parent composite. Must not be <code>null</code>. + * @return The page book instance. Must never be <code>null</code>. + */ + protected PageBook doCreatePageBookControl(Composite parent) { + return new PageBook(parent, SWT.NONE); + } + + /** + * Configure the given page book control. + * + * @param pagebook The page book control. Must not be <code>null</code>. + */ + protected void doConfigurePageBookControl(PageBook pagebook) { + Assert.isNotNull(pagebook); + + if (getContextHelpId() != null) + PlatformUI.getWorkbench().getHelpSystem().setHelp(pagebook, getContextHelpId()); + } + + /** + * Returns the context help id associated with the terminal console view instance. + * <p> + * <b>Note:</b> The default implementation returns the view id as context help id. + * + * @return The context help id or <code>null</code> if none is associated. + */ + @Override + public String getContextHelpId() { + return getViewSite().getId(); + } + + /** + * Creates the empty page control instance. + * + * @param parent The parent composite. Must not be <code>null</code>. + * @return The empty page control instance. Must never be <code>null</code>. + */ + protected Control doCreateEmptyPageControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + return composite; + } + + /** + * Configures the empty page control. + * + * @param control The empty page control. Must not be <code>null</code>. + */ + protected void doConfigureEmptyPageControl(Control control) { + Assert.isNotNull(control); + } + + /** + * Creates the tab folder control instance. + * + * @param parent The parent composite. Must not be <code>null</code>. + * @return The tab folder control instance. Must never be <code>null</code>. + */ + protected CTabFolder doCreateTabFolderControl(Composite parent) { + return new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT | SWT.BORDER); + } + + /** + * Configures the tab folder control. + * + * @param tabFolder The tab folder control. Must not be <code>null</code>. + */ + protected void doConfigureTabFolderControl(CTabFolder tabFolder) { + Assert.isNotNull(tabFolder); + + // Set the layout data + tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Set the tab gradient coloring from the global preferences + if (useGradientTabBackgroundColor()) { + tabFolder.setSelectionBackground(new Color[] { + JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$ + JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END") //$NON-NLS-1$ + }, + new int[] {100}, true); + } + // Apply the tab folder selection foreground color + tabFolder.setSelectionForeground(JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$ + + // Set the tab style from the global preferences + tabFolder.setSimple(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); + } + + /** + * If <code>True</code> is returned, the inner tabs are colored with + * gradient coloring set in the Eclipse workbench color settings. + * + * @return <code>True</code> to use gradient tab colors, <code>false</code> otherwise. + */ + protected boolean useGradientTabBackgroundColor() { + return false; + } + + /** + * Creates the tab folder manager. + * + * @param parentView The parent view instance. Must be not <code>null</code>. + * @return The tab folder manager. Must never be <code>null</code>. + */ + protected TabFolderManager doCreateTabFolderManager(ITerminalsView parentView) { + Assert.isNotNull(parentView); + return new TabFolderManager(parentView); + } + + /** + * Creates the tab folder menu handler. + * + * @param parentView The parent view instance. Must be not <code>null</code>. + * @return The tab folder menu handler. Must never be <code>null</code>. + */ + protected TabFolderMenuHandler doCreateTabFolderMenuHandler(ITerminalsView parentView) { + Assert.isNotNull(parentView); + return new TabFolderMenuHandler(parentView); + } + + /** + * Configure the tab folder menu handler + * + * @param menuHandler The tab folder menu handler. Must not be <code>null</code>. + */ + protected void doConfigureTabFolderMenuHandler(TabFolderMenuHandler menuHandler) { + Assert.isNotNull(menuHandler); + menuHandler.initialize(); + } + + /** + * Creates the tab folder toolbar handler. + * + * @param parentView The parent view instance. Must be not <code>null</code>. + * @return The tab folder toolbar handler. Must never be <code>null</code>. + */ + protected TabFolderToolbarHandler doCreateTabFolderToolbarHandler(ITerminalsView parentView) { + Assert.isNotNull(parentView); + return new TabFolderToolbarHandler(parentView); + } + + /** + * Configure the tab folder toolbar handler + * + * @param toolbarHandler The tab folder toolbar handler. Must not be <code>null</code>. + */ + protected void doConfigureTabFolderToolbarHandler(TabFolderToolbarHandler toolbarHandler) { + Assert.isNotNull(toolbarHandler); + toolbarHandler.initialize(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + pageBookControl.setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView#switchToEmptyPageControl() + */ + @Override + public void switchToEmptyPageControl() { + if (!pageBookControl.isDisposed() && !emptyPageControl.isDisposed()) pageBookControl.showPage(emptyPageControl); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView#switchToTabFolderControl() + */ + @Override + public void switchToTabFolderControl() { + if (!pageBookControl.isDisposed() && !tabFolderControl.isDisposed()) pageBookControl.showPage(tabFolderControl); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (CTabFolder.class.isAssignableFrom(adapter)) { + return tabFolderControl; + } else if (TabFolderManager.class.isAssignableFrom(adapter)) { + return tabFolderManager; + } else if (TabFolderMenuHandler.class.isAssignableFrom(adapter)) { + return tabFolderMenuHandler; + } else if (TabFolderToolbarHandler.class.isAssignableFrom(adapter)) { + return tabFolderToolbarHandler; + } + + return super.getAdapter(adapter); + } +} |