diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..5aafad20 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,39 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '45 13 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c34d70f5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +name: 'release' + +on: + create: + tags: + +jobs: + release: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Inject JDK + id: inject_jdk + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 11 + +# - name: update mvn version +# id: update_mvn_package +# run: | +# mvn versions:set \ +# -DgroupId=de.applejuicenet.client.gui \ +# -DartifactId=AJCoreGUI \ +# -DgenerateBackupPoms=false \ +# -DoldVersion="*" \ +# -N versions:update-child-modules \ +# -DnewVersion=${{ github.ref_name }} + +# mvn versions:set \ +# -DgroupId=de.applejuicenet.client \ +# -DartifactId=AJClientGUI \ +# -DgenerateBackupPoms=false \ +# -DoldVersion="*" \ +# -N versions:update-child-modules \ +# -DnewVersion=${{ github.ref_name }} + +# - name: commit updated package_version +# id: commit_updated_package_version +# uses: stefanzweifel/git-auto-commit-action@v4 +# with: +# branch: master +# file_pattern: pom.xml +# commit_message: Update mvn Package Version to ${{ github.ref_name }} + + - name: compile and package jar with Maven + id: mvn_package + run: mvn package + + - name: build installable files with Maven + id: mvn_install + run: mvn install + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref_name }} + draft: false + prerelease: false + body: aktuelles Changelog befindet sich [hier](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md#changelog) + + - name: upload .zip + id: upload-release-asset-jar + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/AJCoreGUI.zip + asset_name: AJCoreGUI.zip + asset_content_type: application/zip + + - name: upload windows setup + id: upload-release-asset-setup + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: assets/windows/AJCoreGUI.setup.exe + asset_name: AJCoreGUI.setup.exe + asset_content_type: application/octet-stream + + - name: upload macOS .dmg + id: upload-release-asset-dmg + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/AJCoreGUI_${{github.ref_name}}.dmg + asset_name: AJCoreGUI.dmg + asset_content_type: application/octet-stream diff --git a/.github/workflows/snapcraft.yml b/.github/workflows/snapcraft.yml new file mode 100644 index 00000000..a2c61f51 --- /dev/null +++ b/.github/workflows/snapcraft.yml @@ -0,0 +1,23 @@ +name: 'snapcraft' + +on: + release: + types: [ released ] + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set Snapcraft Version + uses: mikefarah/yq@master + with: + cmd: yq eval -i '.version = "${{ github.ref_name }}"' 'snap/snapcraft.yaml' + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: snap/snapcraft.yaml + branch: master + commit_message: Update snapcraft package to ${{ github.ref_name }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..47dccc50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.idea +target/ +dependency-reduced-pom.xml +*.iml +*.jar +*.zip +*.exc + +pom.xml.versionsBackup diff --git a/.run/ajgui.run.xml b/.run/ajgui.run.xml new file mode 100644 index 00000000..9730cca5 --- /dev/null +++ b/.run/ajgui.run.xml @@ -0,0 +1,26 @@ + + + + \ No newline at end of file diff --git a/AJClientGUI/.classpath b/AJClientGUI/.classpath deleted file mode 100644 index eec03aac..00000000 --- a/AJClientGUI/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/AJClientGUI/.cvsignore b/AJClientGUI/.cvsignore deleted file mode 100644 index be91983b..00000000 --- a/AJClientGUI/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -AJCoreGUI.jar -*.properties -AJCoreGUI_v*.zip diff --git a/AJClientGUI/.project b/AJClientGUI/.project deleted file mode 100644 index ef789a9d..00000000 --- a/AJClientGUI/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - AJClientGUI - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/AJClientGUI/.settings/org.eclipse.jdt.core.prefs b/AJClientGUI/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0a67b997..00000000 --- a/AJClientGUI/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,296 +0,0 @@ -#Fri Feb 18 17:19:19 CET 2005 -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=ignore -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -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_method_declaration=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_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.compiler.debug.localVariable=generate -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_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -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_local_declarations=insert -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=insert -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1 -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not 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_closing_paren_in_enum_constant=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_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -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_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=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_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=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_between_empty_braces_in_array_initializer=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_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=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_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=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.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.lineSplit=80 -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -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_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=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_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 diff --git a/AJClientGUI/.settings/org.eclipse.jdt.ui.prefs b/AJClientGUI/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index c8400e74..00000000 --- a/AJClientGUI/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Fri Feb 18 17:19:19 CET 2005 -comment_format_source_code=true -comment_new_line_for_parameter=true -comment_format_html=true -comment_line_length=80 -comment_format_header=false -eclipse.preferences.version=1 -comment_indent_parameter_description=true -comment_format_comments=true -comment_separate_root_tags=true -comment_clear_blank_lines=false -comment_indent_root_tags=true diff --git a/AJClientGUI/AJCoreGUI.exe b/AJClientGUI/AJCoreGUI.exe deleted file mode 100644 index cbed0dff..00000000 Binary files a/AJClientGUI/AJCoreGUI.exe and /dev/null differ diff --git a/AJClientGUI/AJCoreGUI.jpx b/AJClientGUI/AJCoreGUI.jpx deleted file mode 100644 index 602a9ba2..00000000 --- a/AJClientGUI/AJCoreGUI.jpx +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AJClientGUI/AJLibs.library b/AJClientGUI/AJLibs.library deleted file mode 100644 index 4d788075..00000000 --- a/AJClientGUI/AJLibs.library +++ /dev/null @@ -1,14 +0,0 @@ - - - - AJLibs - - [tools/pack.jar] - [tools/xercesImpl.jar] - [needed_jars/skinlf.jar] - [needed_jars/looks-1.2.1.jar] - [needed_jars/log4j-1.2.8.jar] - [tools/xml-apis.jar] - - 1078938164290 - diff --git a/AJClientGUI/ApplejuiceGUI mit Plugins.launch b/AJClientGUI/ApplejuiceGUI mit Plugins.launch deleted file mode 100644 index 0b1d110d..00000000 --- a/AJClientGUI/ApplejuiceGUI mit Plugins.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/AJClientGUI/ApplejuiceGUI.launch b/AJClientGUI/ApplejuiceGUI.launch deleted file mode 100644 index 5755a45b..00000000 --- a/AJClientGUI/ApplejuiceGUI.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/AJClientGUI/Doku/HowTo_PartList.txt b/AJClientGUI/Doku/HowTo_PartList.txt deleted file mode 100644 index b1acb6fd..00000000 --- a/AJClientGUI/Doku/HowTo_PartList.txt +++ /dev/null @@ -1,55 +0,0 @@ -[10:08:52] (Maj0r|ajGUIen) jo, hast du grad zeit, dass du mir die nochmal kurz in voller epischer breite erklären kannst? -[10:09:16] (muhviehstarr) warte ihc nehm mir dazu die doku her ;) -[10:11:01] (muhviehstarr) k -[10:11:26] (muhviehstarr) du kriegst am anfang erstmal fileinformation -[10:11:31] (muhviehstarr) mit der größe der datei in bytes -[10:11:37] (Maj0r|ajGUIen) ja -[10:12:18] (muhviehstarr) so -[10:12:21] (muhviehstarr) nach fileinformation -[10:12:32] (muhviehstarr) kriegste paar parts -[10:12:42] (Maj0r|ajGUIen) paar tausend -[10:12:47] (muhviehstarr) jop -[10:12:49] (muhviehstarr) je nach file -[10:12:52] (muhviehstarr) da steht dann drin -[10:12:53] (Maj0r|ajGUIen) jop -[10:13:14] (muhviehstarr) -[10:13:15] (muhviehstarr) so -[10:13:25] (muhviehstarr) -[10:13:31] (muhviehstarr) -[10:13:40] (muhviehstarr) das wäre jetzt eine gültige übergabe -[10:13:41] (muhviehstarr) das heißt -[10:13:49] (muhviehstarr) vom byte 0 bis byte 1000 hat man das file (-1) -[10:14:02] (Maj0r|ajGUIen) ok -[10:14:06] (muhviehstarr) dann von 1000 bis 2000 hat man nix, und ist auch nix zu sehen (0) -[10:14:20] (muhviehstarr) von 2000 bis größe aus fileinformation hat man wieder das file (-1) -[10:15:47] (Maj0r|ajGUIen) und die parts sind nicht immer gleich groß, sondern die größe richtet sich nach der anzahl der parts hintereinander mit der gleichen verfügbarkeit? -[10:15:58] (muhviehstarr) nein -[10:16:13] (muhviehstarr) die partgröße gilt von fromposition bis fromposition vom nächsten -[10:16:25] (muhviehstarr) egal wie verfügbar die sind, noch ob man das hat oder nicht -[10:16:38] (muhviehstarr) wenn es kein nachfolger gibt, ist das ende natürlich filegröße -[10:16:43] (muhviehstarr) steht auch so unter der tabelle -[10:17:18] (Maj0r|ajGUIen) klar. aber theoretisch kann jeder part eine andere größe haben, oder? -[10:17:32] (Maj0r|ajGUIen) oder nur der letzte? -[10:17:40] (muhviehstarr) ja jeder -[10:17:46] (muhviehstarr) und nicht nur theoretisch -[10:17:50] (muhviehstarr) das wird eher öfters passieren -[10:18:09] (Maj0r|ajGUIen) ok -[10:18:32] (Maj0r|ajGUIen) kann man sich darauf verlassen, dass in der xml die parts in der richtigen reihenfolge stehen? -[10:18:41] (muhviehstarr) ja -[10:19:46] (Maj0r|ajGUIen) wie hast du deine tabelle gemacht? eine spezielle anzahl von kästchen durch die größe der datei geteilt und diese dann entsprechend ausgewertet? -[10:20:16] (muhviehstarr) ich rechne mir aus -[10:20:26] (muhviehstarr) bei ner reihenhöhe von 16 pixel -[10:20:33] (muhviehstarr) und mein bereich ist 400 pixel breit -[10:20:39] (muhviehstarr) und vielleicht 160 pixel hoch -[10:20:53] (muhviehstarr) krieg ich also 10 reihen à 400 pixel rein -[10:20:59] (muhviehstarr) sprich ich hab 4000 pixel -[10:21:09] (muhviehstarr) dann ist die datei 400000 byte groß -[10:21:21] (muhviehstarr) sprich 1 pixel repräsentiert 100 bytes -[10:21:38] (muhviehstarr) wenn ich jetzt male das ich von 0 bis 2000 die file habe -[10:21:51] (muhviehstarr) male ich von pixel 0 bis 20 in reihe ein den bereich schwarz -[10:22:08] (Maj0r|ajGUIen) ok, jetzt hab ichs gerafft :-) -[10:22:22] (Maj0r|ajGUIen) danke für das epische meisterwerk;) -[10:22:27] (muhviehstarr) lol -[10:22:34] (muhviehstarr) reiner eigennütz -[10:22:45] (Maj0r|ajGUIen) ich glaub, ich werde diese erläuterung mal als doku mit einchecken. -[10:23:06] (muhviehstarr) lol \ No newline at end of file diff --git a/AJClientGUI/Doku/ajclientguicore.pdf b/AJClientGUI/Doku/ajclientguicore.pdf deleted file mode 100644 index 923afba5..00000000 Binary files a/AJClientGUI/Doku/ajclientguicore.pdf and /dev/null differ diff --git a/AJClientGUI/Doku/version.txt b/AJClientGUI/Doku/version.txt deleted file mode 100644 index 20dee5f6..00000000 --- a/AJClientGUI/Doku/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.56.0|http://download.berlios.de/applejuicejava/AJCoreGUI_Win_v0_56_0.zip|http://download.berlios.de/applejuicejava/AJCoreGUI_v0_56_0.zip \ No newline at end of file diff --git a/AJClientGUI/Doku/xml/information.xml b/AJClientGUI/Doku/xml/information.xml deleted file mode 100644 index 6b98df92..00000000 --- a/AJClientGUI/Doku/xml/information.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - 0.28.100.501 - - \ No newline at end of file diff --git a/AJClientGUI/Doku/xml/modified.xml b/AJClientGUI/Doku/xml/modified.xml deleted file mode 100644 index c515ec3a..00000000 --- a/AJClientGUI/Doku/xml/modified.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AJClientGUI/Doku/xml/sessions_modified.xml b/AJClientGUI/Doku/xml/sessions_modified.xml deleted file mode 100644 index f1816e99..00000000 --- a/AJClientGUI/Doku/xml/sessions_modified.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/AJClientGUI/Doku/xml/settings.xml b/AJClientGUI/Doku/xml/settings.xml deleted file mode 100644 index d5d43192..00000000 --- a/AJClientGUI/Doku/xml/settings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - aj with JAVA on linux - 6154 - 9851 - true - 16384 - 0 - 3 - C:\Dokumente und Einstellungen\Torsten\appleJuice\incoming - C:\Dokumente und Einstellungen\Torsten\appleJuice\temp# - - - - \ No newline at end of file diff --git a/AJClientGUI/Doku/xml/share.xml b/AJClientGUI/Doku/xml/share.xml deleted file mode 100644 index d143951a..00000000 --- a/AJClientGUI/Doku/xml/share.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/AJClientGUI/WICHTIG_LESEN.txt b/AJClientGUI/WICHTIG_LESEN.txt deleted file mode 100644 index c7eef93c..00000000 --- a/AJClientGUI/WICHTIG_LESEN.txt +++ /dev/null @@ -1,13 +0,0 @@ -WICHTIG!!! - -Um die Link-Catch-Funktion zu nutzen, muss die .reg-Datei an die eigene Umgebung angepasst und importiert werden. - - -Beispiel: - - -Original: -@="\"C:\\AJClientGUI\\AJCoreGUI.exe\" \"-link=%1\" \"-path=C:\\AJClientGUI\"" - -Wenn Du die exe in "c:\programme\aj" liegen hast, würde die Zeile so aussehen: -@="\"c:\\programme\\aj\\AJCoreGUI.exe\" \"-link=%1\" \"-path=c:\\programme\\aj\"" \ No newline at end of file diff --git a/AJClientGUI/aj_winlinkadapter_nt_2000_xp.reg b/AJClientGUI/aj_winlinkadapter_nt_2000_xp.reg deleted file mode 100644 index e3da9d00..00000000 --- a/AJClientGUI/aj_winlinkadapter_nt_2000_xp.reg +++ /dev/null @@ -1,12 +0,0 @@ -REGEDIT4 - -[HKEY_CLASSES_ROOT\ajfsp] -@="URL: Applejuice Protocol" -"URL Protocol"="" - -[HKEY_CLASSES_ROOT\ajfsp\shell] - -[HKEY_CLASSES_ROOT\ajfsp\shell\open] - -[HKEY_CLASSES_ROOT\ajfsp\shell\open\command] -@="\"C:\\AJClientGUI\\AJCoreGUI.exe\" \"-link=%1\" \"-path=C:\\AJClientGUI\"" diff --git a/AJClientGUI/ajcore.properties b/AJClientGUI/ajcore.properties deleted file mode 100644 index 5e8ae2e4..00000000 --- a/AJClientGUI/ajcore.properties +++ /dev/null @@ -1,2 +0,0 @@ -releaseinfo.host=http://applefiles.cc -releaseinfo.port=80 \ No newline at end of file diff --git a/AJClientGUI/build/MANIFEST.MF b/AJClientGUI/build/MANIFEST.MF deleted file mode 100644 index 18a39d5b..00000000 --- a/AJClientGUI/build/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: ./needed_jars/log4j-1.2.8.jar ./needed_jars/skinlf.jar ./n - eeded_jars/looks-1.2.1.jar -Main-Class: de.applejuicenet.client.AppleJuiceClient - diff --git a/AJClientGUI/build/build.xml b/AJClientGUI/build/build.xml deleted file mode 100644 index b17f6ba7..00000000 --- a/AJClientGUI/build/build.xml +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AJClientGUI/build/readme.first b/AJClientGUI/build/readme.first deleted file mode 100644 index 3cbb6c02..00000000 --- a/AJClientGUI/build/readme.first +++ /dev/null @@ -1,11 +0,0 @@ -Ant-Anleitung: - -1. ant installieren (mindestens ant 1.5.1) -2. in build-Ordner wechseln und "ant complete" starten -3. um andere ant-targets zu starten, "ant help" ausführen - - -Ant-HowTo: -1. install ant (minimum ant version 1.5.1) -2. move to build-directory and execute "ant complete" -3 to execute further ant-targets, see defined ant-targets with "ant-help" \ No newline at end of file diff --git a/AJClientGUI/changelog.htm b/AJClientGUI/changelog.htm deleted file mode 100644 index e240fc8f..00000000 --- a/AJClientGUI/changelog.htm +++ /dev/null @@ -1,910 +0,0 @@ - - - - - - - -

Changelog -

-GUI
-IRC-Plugin
-
-GUI
-
-
Version 0.71.2:
-- [Maj0r] Release-Info auf applefiles.cc umgestellt
-
-
Version 0.71.0:
-- [Maj0r] Sortierung der Tabellen wird gespeichert
-- [Maj0r] Menüpunkt Release-Info in Share, Suche und Download hinzugefügt
-- [Maj0r] Bäume in Suche, Download und Upload durch Tabellen ersetzt
-
-
Version 0.70.5:
-- [Maj0r] Fehler beim Hinzufügen von Share-Ordnern behoben
-- [Maj0r] Priorität der Uploads in der Form 1:2,2 (Priowert) anzeigen
-- [Maj0r] Sortierung im Downloadreiter korrigiert
-
-
Version 0.70.4:
-- [Maj0r] Deadlock beim Start gefixt
-- [Maj0r] Anzeige der Downloadgechwindigkeit und des Gesamtdown- und uploads korrigiert
-- [Maj0r] PwDl der Uploads in der Form 1:2,2 anzeigen
-- [Maj0r] Mit Java6 lassen sich bei lokaler Coreverbindung Sharedateien und laufende Downloads nun mit dem Standardprogramm öffnen
-- [Maj0r] Bug #670 Reiter per Tastaturschnelltaste anwaehlbar
-
-
Version 0.70.2:
-- [Maj0r] Core-Versionsprüfung gefixt
-
-
Version 0.70.1:
- -Java ab 5.0 wird benötigt
-- [Maj0r] TrayIcon von Java6 eingebaut
-     TrayIcon funktioniert nun unter Windows, Mac und Linux (Gnome-Tray und KDE-Tray)
-- [Maj0r] CPU-Last der Suchergebnisdarstellung wesentlich verringert
-     Nun sind auch große Treffermengen gut verwendbar (Test mit 1500 bis 2000 Treffern pro Suche bei 3 Suchen).
-     Lediglich das initiale Laden der Treffer dauert etwas, das Zeug muss halt über die Leitung und einmal geparst werden.
-- [Maj0r] Anzahl aller unterschiedlichen gefundenen Dateien einer Suche wird im Suchergebnisreiter angezeigt
-- [Maj0r] Ist beim Start Loglevel Debug eingestellt, wird ein weiterer Reiter "Debug" angezeigt, der alle Lognachrichten enthält
-- [Maj0r] Featurerequest (Danke an fdh)
-     Gesamtpunkte der gesetzten Priorität wird im Sharebereich ( x/1000 ) angezeigt.
-- [Maj0r] TKLControls eingebaut (www.tkl-soft.de)
-     In den Optionen und im Wizard werden nun Felder mit modifizierten Werten blau umrahmt. Mit Strg+z kann der Ursprungswert wieder hergestellt werden.
-     Ungültige Werte werden rot umrahmt (z.B. im Downloadlinkfeld im Downloadbereich).
-- [Maj0r] Bug #527 gefixt (Danke an fdh)
-     100%-CPU-Bug behoben. Trat immer auf, wenn man die Größe der Partliste veränderte.
-- [Maj0r] Featurerequest #476 (Danke an clickweg)
-     Suchergebnisse, die bereits im Temp oder im Share vorhanden sind, werden grün markiert.
-- [Maj0r] GUI komplett refactored und auf die neue CoreFassade 1.0 umgebaut
-     Infos dazu auf applejuicenet.de
-- [loevenwong] Featurerequest #549 (Danke an xxluckystrikexx)
-     Automatischen Powerdownload komplett überarbeitet.
-
-
Version 0.61.2:
-- [Maj0r] Bug #528 gefixt (Danke an akku)
-     Deadlock bei der Darstellung der Partliste behoben.
-- [Maj0r] Bug #525 gefixt (Danke an akku und apokalypse1982)
-     Das GUI nutzte bei ungünstiger Datenkonstellation 100% CPU-Zeit.
-
-
Version 0.61.1:
-- [Maj0r] Auf vielfachen Wunsch Partlistanzeige wieder auf mehrere Threads aufgeteilt. Braucht wieder etwas mehr Ressourcen, ist aber beim gefühlten Laden schneller.
-- [Maj0r] Bug #524 gefixt (Danke an akku und fdh)
-- [Maj0r] Bug gefixt
-     Nach Benutzung von "Priorität löschen" wurde die View nicht aktualisiert.
-
-
Version 0.61.0:
-Core ab Version 0.30.146.1202 -wird benötigt
-- [Maj0r] Wenn ein Download hinzugefügt wird, gibt es nun, wenn der Core einen Fehler meldet, eine Benachrichtigung.
-- [Maj0r] Bug gefixt (Danke an Up)
-     Coreseitig beendete Suchen werden nun auch im GUI als beendet dargestellt.
-- [Maj0r] skinlf.jar aktualisiert
-- [Maj0r] ajl-Listen können nun direkt mit Angabe eines Zielverzeichnisses importiert werden
-- [Maj0r] Downloads können nun direkt mit Angabe eines Zielverzeichnisses gestartet werden
-- [Maj0r] Anzeige zusätzlicher Information gesharter Dateien (Datum letzter Anfrage, Anzahl Downloadanfragen, Anzahl Suchanfragen)
-- [Maj0r] Bug gefixt
-     Es konnte mit jedem offenen Port eine Verbindung hergestellt werden, das GUI blieb anschließend leer.
-     Unterscheidung zwischen ungültiger Coreadresse und falschem Passwort eingebaut.
-- [Maj0r] Featurerequest #465 (Danke an clickweg)
-     Beim ersten Start des GUIs wird versucht, anhand der Standardeinstellungen zu verbinden.
-- [Maj0r] Die Datei properties.xml wurde durch die Datei ajgui.properties ersetzt.
-- [Maj0r] Einschränkung aufgehoben
-     Im Verbindungsdialog können nun beliebig viele Cores gespeichert werden.
-- [Maj0r] Bug #490 gefixt (Danke an Up)
-     Umlaute sind nun in Verzeichnis- und Dateinamen in den Optionen möglich.
-- [Maj0r] Bug gefixt
-     Im Verbindungsdialog funktionierte die Datenübernahme nicht, wenn im Host- oder Passwortfeld Return betätigt wurde.
-- [Maj0r] Featurerequest #475 (Danke an clickweg)
-     Anzeige der Verfügbarkeit in Prozent der aktuell gezeigten Partliste.
-- [Maj0r] Featurerequest #481 (Danke an johannes8)
-     Firewall-Warnung wird nun zusätzlich als Symbol und als Tooltipp ganz links in der Statusleiste angezeigt.
-- [Maj0r] Bug #494 gefixt (Danke an dsp2004)
-- [Maj0r] Bug #505 gefixt (Danke an rexcorda)
-- [loevenwong] Focus wird auf das Passwort-Feld gesetzt.
-
-Version 0.60.0:

-- [Maj0r] Featurerequest #472 (Danke an clickweg)
-     Downloads, Shares und Suchergebnisse werden -nun mit passenden Icons -dargestellt (vgl. Suche).
-- [loevenwong] Featurerequest #458; Verbindungswizard kann -über Optionen->Verbindungen gestartet werden.
-
- [loevenwong] Featurerequest #414 (Danke an clickweg)
-     Download-Tooltipps können per -Optionen->Ansicht -deaktiviert werden.
-- [loevenwong] Wenn automatisch Verbinden ausgewählt ist, wird -anschliessend noch geprüft, ob die SHIFT-Taste gedrückt wird -(nach Erscheinen des Splash-Screens),
-     falls doch ein anderer Core verwendet -werden soll.
-
- [loevenwong] Tastaturereignisse beim Anmeldedialog um -ENTER/ESCAPE erweitert.
-
-- [Maj0r] Featurerequest
-     Unter Optionen->Ansicht kann ein Programm -ausgewählt werden (z.B. VLC).
-     Wenn der Core auf dem gleichen Rechner wie das -GUI läuft, dann wird in der Downloadtabelle und in der -Sharetabelle im Kontextmenü ein -neuer Menüpunkt aktiviert.
-     Mit diesem wird der Shareeintrag an das -verknüpfte Programm übergeben.
-- [Maj0r] Bug #175 gefixt (Danke an jr17)
-     TrayIcon gefixt.
-- [Maj0r] Bug #413 gefixt (Danke an hirsch.marcel)
-     Leere Suchen werden nicht mehr -ausgeführt. Leerstellen am Anfang und am Ende eines Suchbegriffs -werden entfernt.
-- [Maj0r] Featurerequest #442 (Danke an clickweg)
-     Uploads können nun per Kontextmenü -als Links in die Zwischenablage kopiert werden.
-- [Maj0r] Stats eingebaut. Parameter: -command=getajstats
-- [loevenwong] Versionsanzeige eingebaut. Parameter: -command=getajinfo
-
-Version 0.59.3:
-
-- [Maj0r] Bugfix (Danke an muhviehstarr)
-     Zwei Deadlocks behoben. Einer bewirkte, dass -das GUI beim Start beim Splashscreen hängen bleiben konnte.
-- [Maj0r] \n in der Servernachricht wird nicht mehr beachtet. -Html-Tags verwenden.
-- [Maj0r] Featurerequest
-     Automatischer Powerdownload pausiert nun -standardmäßig nicht mehr die Downloads.
-     Außerdem kann nun ein -Einstellungendialog implementiert werden, um Anpassungen während -des Betriebs des autom. Pwdls vorzunehmen.
-- [Maj0r] Bugfix
-     Bei sehr hohen Maxupload- und/oder -Maxdownloadwerten kam es zu Fehlern im TrayIcon.
-- [Maj0r] Bug #421 gefixt (Danke an Up)
-     Wizard wurde um Standardeinstellungen für -DSL 1000, DSL 2000 und DSL 3000 erweitert.
-- [Maj0r] Bug #423 gefixt (Danke an hirsch.marcel und Up)
-     Aktive, indirekte Uploads werden wieder -angezeigt.
-- [Maj0r] Dreckigen Rest im Uploadbereich entfernt.
-

Version 0.59.2:
-
- [Maj0r] Bug #420 gefixt (Danke an Up)
-     Ganz frischen NullPointer gefixt.
-

-

Version 0.59.1:
-
Core ab Version 0.30.145.610 -wird benötigt -
-- [Maj0r] Wasserstände der einzelnen Uploader werden angezeigt.
-- [Maj0r] Beim Serverwechsel wird nun eine qualifizierte Warnung -ausgegeben, wenn die aktuelle Verbindung noch keine 30 Minuten besteht.
-- [Maj0r] Bugfix
-     Beim Neuerzeigen der properties.xml wurden die -neuen Coredaten nicht für die aktuelle Sitzung übernommen.
-     Folge war ein Verbindungsverlust.
-
-
Version 0.59.0:
-
- [Maj0r] Durch Ändern einer Source-Variable in der -AutomaticPowerdownloadPolicy.java kann das Pausieren von Dateien -verhindert werden.
-- [Maj0r] Bug #392 gefixt (Danke an Up und jr17)
-     Im Zuge der XML-Parser-Umstellung (0.56.1) ist -die Firewallwarnung verschütt gegangen.
-- [Maj0r] Icons für Uploads in der Warteschlange korrigiert.
-- [Maj0r] Downloadadresse für die Updateinfodatei auf Wunsch der -berlios-Crew von berlios.de auf tkl-soft.de geändert.
-- [Maj0r] Uploads, die zwar in der Warteschlange sind, aber keine -aktive -Verbindung halten, werden jetzt im dreckigen Rest angezeigt.
-

-

Version 0.58.0:
-
Core ab Version 0.30.144.522 -wird benötigt
-- [Maj0r] Bug #360 gefixt (Danke an fapu & panterfrau)
-     Beim Linkklicken konnte es passieren, dass -zwei GUIs gestartet werden.
-- [Maj0r] Bug #361 gefixt (Danke an panterfrau)
-     Logfehlermeldung bei überlastetem Core -wird nun nur noch als Debug gelogt.
-- [Maj0r] Featurerequest (Danke an Up)
-     Bei Servern ohne Namen wird nun im -Startbereich IP:Port angezeigt.
-- [Maj0r] Willkommensnachricht des Servers eingebaut.
-- [Maj0r] Anzeige, ob die Warteschlange voll ist, im Uploadbereich -eingebaut.
-- [maj0r] In der Statusspalte eines nicht aktiven Uploads wird nun die -Corezeit -der letzen Aktivität angezeigt.
-

-

Version 0.57.1:
-
-- [Maj0r] Bugfix (Danke an mich ;) )
-     Beim Laden von Plugins konnten Fehler beim -Classloading auftreten. Wenn der Statusbalken bei "Lade Plugins..." -hängen bleibt, bitte updaten.
-- [Maj0r] Change (Danke an hirsch.marcel)
-     Irc-Server im Infodialog angepasst.
-- [Maj0r] Archivdifferenzierung beseitigt (Besonderen Dank an Up -für die -Windows-Starter-Exe !!)
-     Es gibt fortan keine separaten Archive mehr -für Windows und andere Betriebssysteme.
-- [Maj0r] Featurerequest #319 (Danke an tom62)
-     Sortierung im Dateilistenexport eingebaut.
-- [Maj0r] Bugfix (Danke an muhviehstarr)
-     Sortierung nach Zeit in der Serveranzeige -korrigiert.
-- [Maj0r] Bug #322 gefixt (Danke an torsten_altreiter)
-     Der Dateiname wurde per Linkübernahme aus -der Suche nicht korrekt übernommen.
-- [loevenwong] Updateprüfung auch per Menüeintrag -ermöglicht.
-- [Maj0r] Standardaussehen auf JGoodies geändert (weniger -ressourcenlastig)
-     Themes können natürlich weiterhin -verwendet werden.
-

-

Version 0.57.0:
-- [Maj0r] Bugfix (Danke an whitewindow)
-     Die Anzahl der Quellen pro gefundener Datei -wurde bei neuen Ergebnissen nicht korrigiert.
-     Die Anzahl der gefundenen Dateien war korrekt, -jedoch die Anzahl der Quellen pro Datei entsprechend niedrig.
-- [Maj0r] Bug #306 gefixt (Danke an dsp2004)
-     Bei Partlistanfragen an einen -überlasteten Core kam es zu Fehlern.
-- [Maj0r] Fortschrittsbalken in den Splashscreen eingebaut.
-- [Maj0r] Tooltipps in der ersten Spalte der Downloadtabelle eingebaut.
-- [Maj0r] Info-Dialog geändert
-     Credits geändert.
-     Credits lassen sich nun per Mausklick in den -Dialog anhalten bzw. fortsetzen.
-

-

Version 0.56.2:
-- [Maj0r] Bug #293 gefixt (Danke an dsp2004)
-     Bei Partlistanfragen an einen -überlasteten Core kam es zu Fehlern.
-- [Maj0r] Bug #260 gefixt (Danke an computer.ist.org)
-     Buttons im Sharebereich dürfen erst -aktiviert werden, wenn die Einstellungen vom Core geholt wurden.
-- [Maj0r] Bug #282 gefixt (Danke an tnt23)
-     NullPointer behoben, der auftrat, wenn man im -Sharebereich auf "Prioritaet setzen" geklickt hat, ohne vorher einen -Eintrag zu selektieren.
-- [Maj0r] Bug #273 gefixt
-     Es kam zu einem Fehler, wenn die Partliste -nicht den gesamten reservierten Bereich bedeckte und dieser Teil von -der Maus überwandert wurde.
-- [loevenwong] Featurerequest #222 (Danke an hirsch.marcel)
-    
Combobox -zur Auswahl der letzten 3 Verbindungen -eingebaut.
-- [Maj0r] Featurerequest #222 (Danke an johannes8)
-     Download-Umbennen-Dialog bietet nun eine -Auswahl der -gefundenen Namen der Sourcen des Downloads an.
-- [Maj0r] Kontextmenü im Downloadbereich überarbeitet
-     F-Tasten eingebaut.
-     Pausieren und Fortsetzen auf vielfachen Wunsch -getrennt.
-- [Maj0r] Dialog zur Eingabe eines Datei-Incoming-Verzeichnisses kann -jetzt per <RET> bestätigt werden.
-- [Maj0r] Bug behoben, der sich durch die dynamische Generierung -der properties.xml ohne Neustart eingeschlichen hat.
-- [loevenwong] Einfügen per Kontextmenü im Download-Textfeld -eingebaut.
-- [loevenwong] Einstellungen der JGoodies werden jetzt gespeichert.
-- [Maj0r] Installierte Look&Feels werden beim Generieren der -Standard-XML mit aufgenommen.

-

Version 0.56.1:
-
-- [Maj0r] GUI startet nur noch bei unterstützter Coreversion
-    dieses GUI benötigt den Core ab Version -0.29.135.208
-- [loevenwong] GUI muss nicht neugestartet werden, wenn noch kein -Property-File vorhanden ist (wird weiterhin automatisch erzeugt).
-- [Maj0r] Featurerequest #254 gefixt (Danke an te_real_ZeroBANG)
-    Downloadtabelle wird jetzt beim Start -standarmäßig nach Dateiname sortiert.
-- [Maj0r] Featurerequest #274 gefixt (Danke an johannes8)
-    Downloads können per F2 umbenannt werden.
-- [Maj0r] Bug #264 gefixt (Danke an muhviestarr)
-     Verbindungsstatus wird richtig angezeigt.
-- [Maj0r] Modifizierbare und potenziell modifizierbare Dateien bei -Nicht-Windows-System verschoben
-    properties.xml nach ~/appleJuice/gui
-    Plugins nach ~/appleJuice/gui/plugins
-    Logs nach ~/appleJuice/gui/logs
-- [Maj0r] Pluginschnittstelle komplett überarbeitet
-    Alle vorhandenen Plugins müssen an die neue -Schnittstelle angepasst werden.
-    Gründe für die Überarbeitung:
-       1. einfacher
-       2. Eingrenzung der Plugins und -Minimierung der Fehlermöglichkeiten
-       3. Sprachdateien werden -unterstützt (zB language_xml_deutsch.xml im Plugin-Jar)
-- [Maj0r] Suchergebnisse werden nun, wenn möglich mit einem -sprechenden -Icon angezeigt.
-- [Maj0r] Suche um Filter erweitert
-    Die Filter in der Suchergebnistabelle wirken sich -NICHT auf die Suche aus, lediglich die Treffer werden gefiltert.
-- [Maj0r] Status "Warteschlange voll" wird nun auch in "In -Warteschlange" -angezeigt, da diese zB für Pwdl-Änderungen genauso relevant -sind.
-- [Maj0r] TableHeader werden in allen Tabellen gleich dargestellt.
-- [Maj0r] Unterstützung für fremde Look&Feels eingebaut
-    Um Look&Feels zu verwenden, müssen die -Themes deaktiviert werden. -   
-    Ausgeliefert werden nur JGoodies als alternative -Look&Feels.
-    Es können alle konformen Look&Feels -verwendet werden. Dazu einfach ein passendes Jar in /needed_jars legen -und die Look&Feel-Klasse in der propertes.xml eintragen.
-- [Maj0r] Unnützes Passwortfeld unter Optionen->Passwort -entfernt.
-- [Maj0r] Passwortfeld unter Optionen->Proxy ist nun wirklich ein -Passwortfeld und stellt das Passwort nicht mehr im Klartext dar.
-- [Maj0r] Standardthemepack auf Toxic geändert.
-

-

Version 0.56.0:
-meine wahrscheinlich letzte GUI für den Core 0.29.x
-
-- Soundausgabe bei korrektem Login korrigiert.
-- Sound bei fertigem Download eingebaut.
-- Unicode-Verwendung im Umgang mit den Sprachdateien korrigiert. -
-- Kleinere Korrekturen.

-

-Version 0.55.10:
-
-- Bug #246 gefixt (Danke an mail_tom62)
-     Nun können auch bei "voller" -Dateilistetabelle im Sharebereich neue Dateien hinein gezogen werden.
-     Automatische Sortierung nach Dateiname -eingebaut.
-- Featurerequest #244 gefixt (Danke an Homer1Simpson)
-    Standardmäßig ist nun beim automatischen -Powerdownload der Inaktiv-Button selektiert.
-- Bug #243 gefixt (Danke an RoadRunner)
-    GUI stört sich nicht mehr an Nicht-Themes-Zips -im Themes-Verzeichnis.
-- Bug #241 gefixt (Danke an computer.ist.org)
-    Farbgebung war genau umgekehrt. Nun gilt wirklich: -je dunkler, desto mehr Quellen gefunden.
-- Partliste zeigt nun per MausOver-Effekt den Tooltipp zum -ausgewählten Partstück an.
-

-

Version 0.55.9:
-
-- Link zur FAQ im Startbereich hinzugefügt.
-- Bug #242 gefixt (Danke an Kossi-Jaki)
-    Legende für Partliste um "aktive -Übertragung" erweitert.
-- Bug #240 gefixt (Danke an computer.ist.org)
-    Bug behoben, der im VersionChecker zu einer -NoSuchElementException führte.
-- Bug #239 gefixt (Danke an dsp2004)
-    ArrayIndexOutOfBoundsException behoben.
-- Bug #235 gefixt (Danke an Up)
-    Passwortfeld im Logindialog funktioniert wieder -ordentlich.
-

-

Version 0.55.8:
-
-- Bug #234 gefixt (Danke an hirsch.marcel)
-    Tabellen werden beim Ändern von -Spaltengrößen nicht mehr sortiert.
-- Featurerequest #228 realisiert (Danke an Major-Tom)
-    Im Pwdl-Eingabefeld funktionieren nun auch die -Hoch/Runter-Pfeiltasten.
-- Links werden nun bei Übernahme in eine verwertbare Schreibweise -geparst.
-- Bug #226 gefixt (Danke an dsp2004)
-- GUI reagiert ordentlich auf eine coreseitige Passwortänderung.
-- Server werden nun korrekt angezeigt.
-- weitere Speicheroptimierung.
-

-

Version 0.55.7:
-
- Bug #223 und #224 gefixt (Danke an dsp2004, Up und -whitewindow)
-    Das waren noch Bugs in Verbindung mit der -DOM/SAX-Umstellung..
-

-

Version 0.55.6:
-
-- meisten Teile von DOM auf SAX umgebaut
-    RAM-Verbrauch sollte dadurch spürbar gesenkt -werden.
-- Bug #219 gefixt (Danke an Up)
-    100%-CPU bei Eingabe eines falschen Passwortes beim -Anmeldedialog gefixt.
-- Bug #220 gefixt (Danke an dsp2004)
-    OutOfMemoryError behoben.
-

-

Version 0.55.5:
-
-- alten Timestampfehler beseitigt
-    Trotz Sessionumsetzung wurde immer noch der -Timestamp mitgeschleppt.
-- Bug #215 gefixt (Danke an dsp2004)
-    Partliste wird nun auch bei kleinen Dateien korrekt -gezeichnet.
-- Bug #129 gefixt (Danke an dsp2004)
-    WebsiteException durch Überlastung des Cores -sollte nun weitgehend unterbunden sein.
-

-

Version 0.55.4:
-
-- Bug #23 gefixt (Danke an computer.ist.org)
-    Suche abbrechen korrigiert.
-

-

Version 0.55.3:
-
-- Mehr Logging für WebSiteNotFoundException eingebaut.
-- Partliste bearbeitet
-    Hoffentlich den letzten Fehler behoben.
-    Anzeige der Teile, die zurzeit übertragen -werden (hellgelb bis dunkelgelb).
-    Aktualisierungintervall auf 2 Sekunden geändert.
-- Button zum Verwerfen einer abgebrochenen Suche in den Suchreiter -verschoben.
-- Link mit Quellen kann nun auch im Sharebereich erzeugt werden.
-- Bug #195 gefixt (Danke an supermuhkuh)
-    Bug bei Pwdl-Einstellung korrigiert.. -
-- Bug #167 gefixt (Danke an arnoldfake)
-    Sortierung nach Anzahl in der Suchtabelle -korrigiert. -
-- Bug #198 gefixt (Danke an froeschle567)
-    Sortierung nach Downloadstatus korrigiert.

-

Version 0.55.2:
-
-- Max. Anzahl von Quellen pro Datei kann nun begrenzt werden
-    Core ab 0.29.135.208 ist zu verwenden.
-- SplitPane in Sharebereich eingebaut.
-- Sortierung des Sharebaums verbessert.
-- Sortierung in Incoming- / Tempauswahlbaum eingebaut.
-- Partliste überarbeitet.
-- Startbereich scrollbar gemacht, wenn die Darstellung zu klein ist.
-- Rand der JSplitPane im Downloadbereich entfernt (Danke an -muhviestarr).
-- Icons für Upload-DirectStates eingebaut.
-- verwendete Java-Version wird in die Logdatei geschrieben.
-- Wizarddialog korrigiert
-    Nickname wird nun auf Richtigkeit geprüft und -gespeichert wird erst nach Durchlaufen des gesamten Wizards.
-- Bug #94 gefixt (Danke an error666)
-    Zulässige Werte für Core-Port und XML-Port -sind 1024<x<=32000.
-- Bug #185 gefixt (Danke an muhviestarr)
-    Einstellungen des GUIs werden beim Schliessen des -Core gesichert.
-- Downloadlinks können optional mit der eigenen Quelle und ggf. -mit dem verbundenen Server in die Ablage kopiert werden.
-- Serverlinks können in die Ablage kopiert werden.
-

-

Version 0.55.1:
-
-- Kommunikation mit dem Core erfolgt nun komprimiert
-    Core ab Version 0.29.133.201 ist zu verwenden.
-    Ich steuer den Core meist mit dem GUI über das -Internet und konnte eine mehr als deutliche -Geschwindigkeitsverbesserung festellen.
-

-

Version 0.54.7:
-
-- AutomaticPowerdownloadPolicies können nun von Benutzern mit -Java-Erfahrung selbst implementiert werden
-    Dazu muss die Klasse AutomaticPowerdownloadPolicy -abgeleitet und ein Jar gebaut werden.
-    Zum Bauen des jar-Archivs gibt es ein neues Target -in der build.xml.
-    Das GUI erwartet diese Jars im Unterordner -/pwdlpolicies.
-- "Verbindung zum Core verloren" sollte nicht mehr so schnell -kommen (Danke an the_Killerbee).
-- Interne Umbauten um Objekte zu sparen
-    Alle Plugins, die auf globale Objekte mittels -MapSetStringKey zugreifen, müssen angepasst werden, sind in ihrer -alten Version nicht mehr lauffähig und führen zu -ClassNotFoundExceptions im Log.
-    Anstatt eines "new MapSetStringKey(String)" reicht -nun dieser String oder ein "Integer.toString(int)" bei IDs.
-    Die Klasse MapSetStringKey wurde restlos entfernt.
-- Logging verbessert
-    main() in eigene ThreadGroup gepackt, dadurch kann -keine Exception mehr "durchrasseln", alle Exceptions finden sich im Log.
-

-

Version 0.54.6:
-
Nur Frische Bugs beseitigt
-- Bug #155 gefixt (Danke an daa803)
-    Sharebaum wird nun wieder korrekt dargestellt.
-- Bug #154 gefixt (Danke an hirsch.marcel)
-    Alte Objekte werden jetzt wieder korrekt entfernt.
-- Bug #160 gefixt (Danke an octron80)
-    Fertige oder abgebrochene Downloads können nun -wieder entfernt werden.
-- Bug #153 umgesetzt (Danke an jr17)
-    Verbindungsdialog kann nun per Option beim -nächsten GUI-Start erzwungen werden.
-
-Version 0.54.5:
-
- Filter beim Start des GUI eingebaut
-    Die Quellen werden beim ersten Holen der Daten vom -Core nicht abgefragt, so dass Downloads sehr schnell gezeigt werden -können.
-    Nachteil: Da die Quellen anfangs fehlen, stehen die -Geschwindigkeiten aller Downloads auf 0 kb/s. Die Gesamtgeschwindigkeit -wird jedoch angezeigt.
-    Das lange Laden aufgrund von vielen Quellen wird so -folglich nur verschoben und der Benutzer bekommt früh erste -Informationen zu sehen.
-- Icons für Netware und OS/2 eingefügt.
-- Wiederholtes, zeitintensives Laden der gesamten Infos sollte nun -durch ein überarbeitetes Sessionmanagement unterbunden sein.
-- Fehlerhafte Anzeige von Menütexten bei Nicht-Windows-Systemen -gefixt.
-

-

Version 0.54.4:
-
-- Kontextmenüs mit Icons ausgestattet.
-- Optionenmenü überarbeitet.
-- An neue Coreschnittstelle angepasst.
-- TrayIcon-Bug hoffentlich behoben.
-

-

Version 0.54.3:
-
-- Reihenfolge der Spalten der Download- und Uploadtabelle wird -gespeichert
-     Da die properties.xml angefasst werden musste, -wird diese beim ersten Start neu generiert.
-- Bug #74 gefixt (Danke an habkeineMail)
-- ajl-Listen können nun über das Menü importiert werden.
-- Sprachdatei "türkisch" eingebaut (Danke an nurseppel).
-- Upload-Fortschrittsanzeige wird jetzt nur noch bei aktiven Uploads -angezeigt.
-- Laden von Plugins verbessert.
-     Müll oder nicht standardkonforme Plugins -im Plugin-Ordner werden nun korrekt behandelt.
-- Bug #98 gefixt (Danke an twix)
-
-Version 0.54.2:
-
-- Bug #91 umgesetzt (Danke an hirsch.marcel)
-     Maxupload- und Maxdownloadgeschwindigkeit kann -nun über das TrayIcon eingestellt werden (Windowsversion).
-- Bug #82 gefixt (Danke an hirsch.marcel)
-     Sortierung von Downloads innerhalb von -Unterverzeichnissen der Downloadtabelle korrigiert.
-- Sortierung in die Suchergebnistabelle eingebaut.
-- Bug #92 gefixt (Danke an daa803)
-- Bug #77 gefixt (Danke an spam_blocker)
-     Selektionsproblem der Downloadtabelle beim -Entfernen von fertigen Downloads behoben.
-- Tabellenspalten der Download- und Uploadtabelle können nun -über ein -Kontextmenü bei Rechtsklick auf den Tabellenheader -aus/eingeblendet -werden.
-- Im Downloadbereich sind nun der obere (Tabelle) und der untere -Bereich (Powerdownload, Partliste) in der Höhe verstellbar.
-- Bug #83 gefixt (Danke an hirsch.marcel)
-     Tabellenspalten können nun korrekt -verschoben werden..
-- Bug #33 gefixt (Danke an oz_2k)
-     Obwohl ich denke, dass es sich um ein Feature -der Themes handelt, wurde der Vollbildmodus auf Wunsch vieler Benutzer -an Windowsstandard angepasst.
-

-

Version 0.54.1:
-
- Bug #53 gefixt (Danke an o_a_s_e_)
-     98%-CPU-Last Bug durch Suche gefixt.
-- Warnmeldung bezüglich 30-Minuten-Sperre bei manuellem -Serverwechsel eingebaut.
-- Bug #63 umgesetzt (Danke an clickweg)
-     Den Link zum Holen von Servern in einen Button -umgebaut, da der Link wohl von vielen übersehen wurde.
-- Bug #23 gefixt (Danke an computer.ist.org)
-     Suche lässt sich nun korrekt abrechen.
-
-
Version 0.53.2:
-
- Bug #67 gefixt (Danke an dsp2004)
-     Probleme mit der Funktion automatisch -Partliste anzeigen korrigiert.
-

-

Version 0.53.1:
-
-- Wenn die Verbindung zum Core aufgrund von Überlastung des Core -abreisst, wird 2x erneut probiert, bevor das GUI beendet wird.
-- TrayIcon für Windowsplattformen eingebaut
-- Bug #56 gefixt (Danke an MeineR)
-    Das Laden der Plugins beim Start kann über das -Optionenmenü deaktiviert werden.
-- Bug #43 gefixt (Danke an flabeg)
-    Shareverzeichnis wird bei -Prioritätenänderung nicht mehr komplett neu geladen, sondern -nur aktualsiert.
-- Bug #13 umgesetzt (Danke an HabkeineMail)
-    Powerdownload-Werte werden jetzt bei Klick auf einen -Download / Quelle im Powerdownloadfeld angezeigt.
-- Bug #42 umgesetzt (Danke an dsp2004)
-    Partlisten werden nun durch eine Option wahlweise -bei Mausklick auf den Download / Quelle oder über den Button -"Partliste anzeigen" geholt.
-- properties.xml aus den Download-Archiven entfernt
-    Beim Update auf eine neuere Version muss diese nun -nur noch bei einer Formatänderung erneuert werden.
-    Nachteil: Bei einer kompletten Neuinstallation -erhält man beim ersten Start eine Fehlermeldung und muss das GUI -neu starten.
-- Wenn eine neue Version gefunden wird, kann diese nun direkt mit dem -Standardbrowser herunter geladen werden
-    Der Standardbrowser muss in den Optionen -ausgewählt werden.
-- Links im Startbereich sind jetzt anklickbar, sofern ein -Standardbrowser ausgewählt ist.
-- Bug #40 umgesetzt (Danke an hirsch.marcel)
-    Incoming-Verzeichnis kann nun für mehrere -Downloads gleichzeitig geändert werden.
-- PluginOptionenDialog überarbeitet.
-- Dialog bei fehlgeschlagenem Verbindungsversuch überarbeitet.
-- Menüpunkt zum Beenden des Core auf vielfachen Wunsch an separate -Stelle verschoben.
-- Bug #17 gefixt (Danke an HabkeineMail)
-    Partlisten von einigen wenigen DownloadSourcen -wurden bei Bedarf nicht geholt.
-- sonstige Kleinigkeiten.
-

-

Version 0.52.1:
-
-- Plugin-Entwickler können nun ein JPanel für Optionen -implementieren, welches ggf. im Plugin-Reiter der Optionen aufgerufen -werden kann..
-- Plugin-Entwickler können nun Objekte direkt mittels ID vom Core -erfragen (Danke an webhamster).
-- Bug #19 gefixt (Danke an dsp2004)
-    Nullpointer behoben.
-

-

Version 0.51.2:
-
-- Bug #14 umgesetzt (Danke an Dragonne)
-    Es konnte zu einem Fehler kommen, wenn gleichzeitig -zwei Instanzen des GUIs liefen.
-- Der Core kann jetzt übers GUI beendet werden.
-- Downloads können nun umbenannt werden.
-- Das Zielverzeichnis für einen Download -(Incoming-Unterverzeichnis) kann nun geändert werden.
-- Überprüfung auf gültige Javaversion eingebaut
-    Es wird mindestens 1.4 benötigt (empfohlen -1.4.2).
-- Suchanzeige korrigiert
-    Es kann passieren, dass nicht alle gefundenen -Suchergebnisse beim Core ankommen, die Ausgabe wurde entsprechend -korrigiert.
-- Bug #8 umgesetzt (Danke an finn)
-    Downloadlinks kann man nun auch direkt in der -Downloadtabelle per Kontexmenü erzeugen.
-    Ich wollte es eigentlich nicht umsetzen, da ich die -Funktion an dieser Stelle für falsch platziert erachte, doch da -der Wunsch bei vielen Benutzern bestand, hab ich es nun doch eingebaut.
-    In die Uploadtabelle werde ich es definitiv NICHT -einbauen.
-- Bug #10 fixed (Danke an muhviestarr)
-    Wenn man keine Downloads hat, steht nun nicht mehr -"bitte warten" in der Downloadtabelle.
-

-

Version 0.51.1:
-
-- Downloadlinks werden jetzt in ISO-8859-1 an den Core übertragen.
-- Versionupdateinformation geändert
-    Über die Optionen kann nun gewählt werden, -ob man nur bei neuen Versionen (0.51.1), -wichtigen Änderungen (0.51.1) -oder sogar bei kosmetischen Korrekturen (0.51.1) benachrichtigt wird.
-    Standard ist Benachrichtigung bei wichtigen -Änderungen.
-- Bug #1 fixed (Danke an muhviestarr)
-    Look & Feel stimmt nun auch beim -Verbindungsdialog.
-- Bug #2 fixed (Danke an muhviestarr)
-    Taskbareintrag für den Splashscreen und den -Verbindungsdialog eingebaut.
-- Bug #4 fixed (Danke an muhviestarr)
-    Shareanzeige bei Prioritaetenaenderung -gefixt.
-- Dateigrößen in der Sharetabelle -werden nun korrekt ausgegeben (Danke an schnigger und TuxHomer).
-- Nullpointer behoben der auftrat, wenn der -verbundene Server keinen Namen hat (Danke an paderborner).
-

-

Version 0.50:
-
-- Logging kann nun komplett deaktiviert werden (Danke an muhviestarr).
-- Im Verbindungsfenster geht nun ein einfaches -<Enter> (Danke an muhviestarr).
-- Legende für die Servertabelle eingebaut (Danke an muhviestarr).
-- Text von Netzwerk, Neuigkeiten und Nachrichten -ist nun auch schwarz (Danke an muhviestarr).
-- Die Überschrift "Warnungen" auf der -Startseite wird nun ausgeblendet, wenn es keine Warnungen gibt (Danke -an muhviestarr).
-- Gridlines werden nun in der Servertabelle nicht mehr -angezeigt (Danke an muhviestarr).
-- Splashscreen wird nun früher angezeigt (Danke an muhviestarr).
-- Bug in der Partliste behoben.
-- Dau-Button zum Anzeigen der Partliste eingebaut.
-- Bug der Tableheader der Share- und der Uploadtabelle behoben (Danke -an muhviestarr).
-

-

Version 0.49:
-
-- Bug bei der Wiedergabe von Sounds korrigiert (Danke an mrbond).
-    Sounddevice wird nun nach Ausgabe eines Sounds -wieder freigegeben.
-- Es kann nun der Link einer gesharten Datei über das -Popupmenü der Sharetabelle als UBB-Code in die Ablage kopiert -werden.
-- Entwicklercreditsanzeige im Infodialog korrigiert.
-- Bug im Sharebaum behoben.
-- Bug beim Sortieren der Sharetabelle behoben.
-

-

Version 0.48:
-
- Initialen Aufruf des Sharetabs durch einen Initialisierungsthread -beschleunigt.
-- In der Downloadtabelle nun ein Warteicon angezeigt, bis erstmalig -Daten geholt wurden.
-- Verhalten des Popupmenüs der Servertabelle überarbeitet.
-- Partliste wird nun nur noch über das PopupMenü geholt.
-    Wenn der Downloadtab verlassen wird, wird das -Aktualisieren der aktuellen Partliste beendet.
-

-

Version 0.47:
-
- Sharetabelle auf vielfachen Wunsch komplett überarbeitet.
-- Partliste wird erst nach 2 Sekunden Wartezeit geholt (Danke an -muhviestarr).
-    Wenn innerhalb dieser Zeit auf einen anderen -Download.bzw. eine andere Quelle geklickt wird, wird die Wartezeit neu -gestartet.
-- Suche kann nun GUI-seitig abgebrochen werden.
-    Der aktuelle Core (0.29.124.1215) hat an dieser -Stelle noch einen Bug, eine Suche wird jedoch nach einiger Zeit -automatisch beendet.
-- Tabellenspaltenroothandles werden nun in der Downloadtabelle -angezeigt (Danke an muhviestarr).
-    So weiss auch der letzte Benutzer, dass man auf -einen Download klicken kann, um die Quellen zu finden.
-- Neuen Downloadstatus "Fehler beim Fertigstellen" und neuen -Quellenstatus "Eigenes Limit erreicht" eingebaut.
-- Rundungsfehler beim automatischen Powerdownload behoben (Danke an -garnichda).
-

-

Version 0.46:
-
- Bug beim autom. Pwdl behoben, der auftrat, wenn nur eine Datei im -Download war.
-- Bug im Menü behoben, Auswahl eines Menüpunktes geht nun -gewohnt schnell..
-- Kleinere optische Korrekturen (Danke an DBZfan)
-    z.B. Hintergrundfarben aller Scrollbereiche an ihre -Tabelle angepasst.
-- Prozentangabe bei Downloads nun auf zwei Nachkommastellen genau -(Danke an muhviestarr)
-- Parameterübergabe an das GUI geändert
-    Mögliche Parameter können per -help -angezeigt werden.
-    Die reg-Datei muss neu angepasst und importiert -werden, da diese ebenfalls modifiziert werden musste.
-- diverse andere Bugs behoben
-

-

Version 0.45:
-
- Links können nun an das GUI übermittelt werden -(für den INet-Explorer muss die entsprechende reg-Datei angepasst -und importiert und die Windows-Exe verwendet werden).
-- Themes sind nun deaktivierbar

-

Version 0.44:
-
- Themes eingebaut (Danke an LinuxDoc)
-    Passende Themes gibt’s -auf http://javootoo.l2fprod.com/plaf/skinlf/index.php.
-- Automatischen Powerdownload eingebaut
-    Verschiedene Arten des autom. Pwdls können in -Zukunft durch selbst implementierte Klassen per Combobox -ausgewählt werden (nächste Version).
-

-

Version 0.43:
-
- max.RAM-Anzeige in Memory-Monitor eingebaut (Anzeige oben links -nun -"reserviert / max allocated").
-- Soundicons optisch korrigiert.
-- Fehler bei der Soundausgabe bei fehlerhaften Sounddateien (z.B. -falsches -Format) oder fehlendem Sounddevice behoben.

-

Version 0.42:
-
- Memory-Monitor eingebaut (ja, die Anzeige geht richtig und zeigt -den -echten RAM-Verbrauch der Anwendung).
-- manuellen GarbageCollector bei jeder 30. Aktualisierung eingebaut.

-

Version 0.41:
-
- Fehler im Pwdl-Textfeld behoben.
-
- Sortieren der Downloadtabelle nach Status eingefügt.
-
- Speicheroptimierungen.

-

Version 0.40:
-
- Soundeffekte für diverse Ereignisse eingefügt.
-
-Version 0.39:
-
- Standarduploadpriorität ist im Core -noch nicht implementiert und deshalb erstmal wieder aus dem GUI -geflogen (Danke an xcalibur).
-- Buttons zum Ändern der Pwdl-Werte -entsprechend dem Standard vertauscht (Danke an lova).
-- Baum zur Auswahl des Temp- und Incomingordners -korrigiert. Bug hat -sich erst mit v0.38 -eingeschlichen (Danke an lova und akku).

-
-IRC-Plugin
-
-
-
-Version 1.35:
-- [Maj0r] Bug #523 gefixt (Danke an Up)
-     Darstellung von Actions und Notices korrigiert.
-
-Version 1.34:
-
-GUI ab Version 0.61.0 -wird benötigt
-- [Maj0r] Featurerequest #415 (Danke an Up)
-     Links können angeklickt werden.
-- [Maj0r] Userliste wird nun mit Icons für den Userstatus dargestellt.
-- [Maj0r] Bug #416 gefixt (Danke an Up)
-     Verwendung der Userstati korrigiert.
-- [Maj0r] Bug #434 gefixt (Danke an dsp2004)
-
-Version 1.33:
-
- [loevenwong & Maj0r] neues Feature
-     Per /ajstats und /ajversinfo können -aktuelle Verbindungsinfos im Channel ausgegeben werden (alle 60 -Sekunden).
-     /ajoptionsinfo kann nur per Query -ausgeführt werden (soll den Support erleichtern) und gibt die -wesentlichen Einstellungen des Cores aus.
-     Spamming und unaufgeforderte Skriptverwendung -werden in #applejuice mit Kick bestraft!
-

Version 1.32:
-
- [Maj0r] Bug #399 gefixt (Danke an Up)
-     Notices werden jetzt magenta im Channel -angezeigt.
-- [Maj0r] Bug #389 gefixt (Danke an panterfrau)
-- [Maj0r] Bug #391 gefixt (Danke an panterfrau)
-- [Maj0r] Bug #395 gefixt
-     Kein echter Fix, da ich aus dem Log nicht -ersehen kann, was passiert.
-     Ich habe es so umgebaut, dass dieser Fehler im -Channel blau dargestellt wird und nicht mehr stört.
-
-Version 1.31:
-
-- Diverse Verbesserungen.
-- Standardplugin ab GUI 0.58.0
-

-

Version 1.1:
-
-- Plugin an neue ID-Verwendung im GUI angepasst. Voraussetzung ist GUI -ab 0.54.7
-

-

Version 1.0:
-
-- Erstes Release.
-

-
- - - diff --git a/AJClientGUI/classes/de/applejuicenet/client/shared/MultiLineToolTip$1.class b/AJClientGUI/classes/de/applejuicenet/client/shared/MultiLineToolTip$1.class deleted file mode 100644 index b153437a..00000000 Binary files a/AJClientGUI/classes/de/applejuicenet/client/shared/MultiLineToolTip$1.class and /dev/null differ diff --git a/AJClientGUI/icons/abbrechen.gif b/AJClientGUI/icons/abbrechen.gif deleted file mode 100644 index b4a7f4bf..00000000 Binary files a/AJClientGUI/icons/abbrechen.gif and /dev/null differ diff --git a/AJClientGUI/icons/about.gif b/AJClientGUI/icons/about.gif deleted file mode 100644 index 3451071d..00000000 Binary files a/AJClientGUI/icons/about.gif and /dev/null differ diff --git a/AJClientGUI/icons/aelter24h.gif b/AJClientGUI/icons/aelter24h.gif deleted file mode 100644 index 782e4a30..00000000 Binary files a/AJClientGUI/icons/aelter24h.gif and /dev/null differ diff --git a/AJClientGUI/icons/amigaossymbol.gif b/AJClientGUI/icons/amigaossymbol.gif deleted file mode 100644 index 08954121..00000000 Binary files a/AJClientGUI/icons/amigaossymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/applejuice.gif b/AJClientGUI/icons/applejuice.gif deleted file mode 100644 index 431ab074..00000000 Binary files a/AJClientGUI/icons/applejuice.gif and /dev/null differ diff --git a/AJClientGUI/icons/applejuicebanner.gif b/AJClientGUI/icons/applejuicebanner.gif deleted file mode 100644 index de740792..00000000 Binary files a/AJClientGUI/icons/applejuicebanner.gif and /dev/null differ diff --git a/AJClientGUI/icons/applejuiceinfobanner.gif b/AJClientGUI/icons/applejuiceinfobanner.gif deleted file mode 100644 index 375c41ae..00000000 Binary files a/AJClientGUI/icons/applejuiceinfobanner.gif and /dev/null differ diff --git a/AJClientGUI/icons/archive.gif b/AJClientGUI/icons/archive.gif deleted file mode 100644 index 3e520ecd..00000000 Binary files a/AJClientGUI/icons/archive.gif and /dev/null differ diff --git a/AJClientGUI/icons/bereinigen.gif b/AJClientGUI/icons/bereinigen.gif deleted file mode 100644 index 153fbf1b..00000000 Binary files a/AJClientGUI/icons/bereinigen.gif and /dev/null differ diff --git a/AJClientGUI/icons/browsen.gif b/AJClientGUI/icons/browsen.gif deleted file mode 100644 index f7bf5a5f..00000000 Binary files a/AJClientGUI/icons/browsen.gif and /dev/null differ diff --git a/AJClientGUI/icons/chat.gif b/AJClientGUI/icons/chat.gif deleted file mode 100644 index 13c465e6..00000000 Binary files a/AJClientGUI/icons/chat.gif and /dev/null differ diff --git a/AJClientGUI/icons/clipboard.gif b/AJClientGUI/icons/clipboard.gif deleted file mode 100644 index cf47e0d7..00000000 Binary files a/AJClientGUI/icons/clipboard.gif and /dev/null differ diff --git a/AJClientGUI/icons/cool.gif b/AJClientGUI/icons/cool.gif deleted file mode 100644 index b2c0b8c6..00000000 Binary files a/AJClientGUI/icons/cool.gif and /dev/null differ diff --git a/AJClientGUI/icons/debug.gif b/AJClientGUI/icons/debug.gif deleted file mode 100644 index 8ee2d9ae..00000000 Binary files a/AJClientGUI/icons/debug.gif and /dev/null differ diff --git a/AJClientGUI/icons/decrease.gif b/AJClientGUI/icons/decrease.gif deleted file mode 100644 index afda1f96..00000000 Binary files a/AJClientGUI/icons/decrease.gif and /dev/null differ diff --git a/AJClientGUI/icons/diskette.gif b/AJClientGUI/icons/diskette.gif deleted file mode 100644 index 5fe90504..00000000 Binary files a/AJClientGUI/icons/diskette.gif and /dev/null differ diff --git a/AJClientGUI/icons/download.gif b/AJClientGUI/icons/download.gif deleted file mode 100644 index 86defc7b..00000000 Binary files a/AJClientGUI/icons/download.gif and /dev/null differ diff --git a/AJClientGUI/icons/eek.gif b/AJClientGUI/icons/eek.gif deleted file mode 100644 index 1509dfba..00000000 Binary files a/AJClientGUI/icons/eek.gif and /dev/null differ diff --git a/AJClientGUI/icons/erneuern.gif b/AJClientGUI/icons/erneuern.gif deleted file mode 100644 index 008d3933..00000000 Binary files a/AJClientGUI/icons/erneuern.gif and /dev/null differ diff --git a/AJClientGUI/icons/firewall.gif b/AJClientGUI/icons/firewall.gif deleted file mode 100644 index f5f3f73a..00000000 Binary files a/AJClientGUI/icons/firewall.gif and /dev/null differ diff --git a/AJClientGUI/icons/folderopen.gif b/AJClientGUI/icons/folderopen.gif deleted file mode 100644 index 3a4d8f30..00000000 Binary files a/AJClientGUI/icons/folderopen.gif and /dev/null differ diff --git a/AJClientGUI/icons/freebsdsymbol.gif b/AJClientGUI/icons/freebsdsymbol.gif deleted file mode 100644 index 4c5f8db8..00000000 Binary files a/AJClientGUI/icons/freebsdsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/hide.gif b/AJClientGUI/icons/hide.gif deleted file mode 100644 index f506a1a0..00000000 Binary files a/AJClientGUI/icons/hide.gif and /dev/null differ diff --git a/AJClientGUI/icons/hint.gif b/AJClientGUI/icons/hint.gif deleted file mode 100644 index c3542bc6..00000000 Binary files a/AJClientGUI/icons/hint.gif and /dev/null differ diff --git a/AJClientGUI/icons/image.gif b/AJClientGUI/icons/image.gif deleted file mode 100644 index 0c2011be..00000000 Binary files a/AJClientGUI/icons/image.gif and /dev/null differ diff --git a/AJClientGUI/icons/increase.gif b/AJClientGUI/icons/increase.gif deleted file mode 100644 index e40b728e..00000000 Binary files a/AJClientGUI/icons/increase.gif and /dev/null differ diff --git a/AJClientGUI/icons/info.gif b/AJClientGUI/icons/info.gif deleted file mode 100644 index 9b9e98c7..00000000 Binary files a/AJClientGUI/icons/info.gif and /dev/null differ diff --git a/AJClientGUI/icons/irixsymbol.gif b/AJClientGUI/icons/irixsymbol.gif deleted file mode 100644 index 9c3d90c9..00000000 Binary files a/AJClientGUI/icons/irixsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/iso.gif b/AJClientGUI/icons/iso.gif deleted file mode 100644 index 1fd2969b..00000000 Binary files a/AJClientGUI/icons/iso.gif and /dev/null differ diff --git a/AJClientGUI/icons/juenger24h.gif b/AJClientGUI/icons/juenger24h.gif deleted file mode 100644 index 3e0452e0..00000000 Binary files a/AJClientGUI/icons/juenger24h.gif and /dev/null differ diff --git a/AJClientGUI/icons/laufwerk.gif b/AJClientGUI/icons/laufwerk.gif deleted file mode 100644 index 109e6c18..00000000 Binary files a/AJClientGUI/icons/laufwerk.gif and /dev/null differ diff --git a/AJClientGUI/icons/led_gray.gif b/AJClientGUI/icons/led_gray.gif deleted file mode 100644 index 6b16d171..00000000 Binary files a/AJClientGUI/icons/led_gray.gif and /dev/null differ diff --git a/AJClientGUI/icons/led_green.gif b/AJClientGUI/icons/led_green.gif deleted file mode 100644 index 3cc3c6e4..00000000 Binary files a/AJClientGUI/icons/led_green.gif and /dev/null differ diff --git a/AJClientGUI/icons/led_red.gif b/AJClientGUI/icons/led_red.gif deleted file mode 100644 index d8a1bebb..00000000 Binary files a/AJClientGUI/icons/led_red.gif and /dev/null differ diff --git a/AJClientGUI/icons/linuxsymbol.gif b/AJClientGUI/icons/linuxsymbol.gif deleted file mode 100644 index 9b87fd4b..00000000 Binary files a/AJClientGUI/icons/linuxsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/macsymbol.gif b/AJClientGUI/icons/macsymbol.gif deleted file mode 100644 index 76f2d08b..00000000 Binary files a/AJClientGUI/icons/macsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/meinshare.gif b/AJClientGUI/icons/meinshare.gif deleted file mode 100644 index fd7f0906..00000000 Binary files a/AJClientGUI/icons/meinshare.gif and /dev/null differ diff --git a/AJClientGUI/icons/mmonitor.gif b/AJClientGUI/icons/mmonitor.gif deleted file mode 100644 index 60cf1f3b..00000000 Binary files a/AJClientGUI/icons/mmonitor.gif and /dev/null differ diff --git a/AJClientGUI/icons/movie.gif b/AJClientGUI/icons/movie.gif deleted file mode 100644 index 6c6f0dee..00000000 Binary files a/AJClientGUI/icons/movie.gif and /dev/null differ diff --git a/AJClientGUI/icons/netwaresymbol.gif b/AJClientGUI/icons/netwaresymbol.gif deleted file mode 100644 index 507e7bc6..00000000 Binary files a/AJClientGUI/icons/netwaresymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/netzwerk.gif b/AJClientGUI/icons/netzwerk.gif deleted file mode 100644 index 0e029c16..00000000 Binary files a/AJClientGUI/icons/netzwerk.gif and /dev/null differ diff --git a/AJClientGUI/icons/neuedateiliste.gif b/AJClientGUI/icons/neuedateiliste.gif deleted file mode 100644 index acedc5b4..00000000 Binary files a/AJClientGUI/icons/neuedateiliste.gif and /dev/null differ diff --git a/AJClientGUI/icons/notshared.gif b/AJClientGUI/icons/notshared.gif deleted file mode 100644 index 6427cbeb..00000000 Binary files a/AJClientGUI/icons/notshared.gif and /dev/null differ diff --git a/AJClientGUI/icons/openbsdsymbol.gif b/AJClientGUI/icons/openbsdsymbol.gif deleted file mode 100644 index 0153b427..00000000 Binary files a/AJClientGUI/icons/openbsdsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_ansicht.gif b/AJClientGUI/icons/opt_ansicht.gif deleted file mode 100644 index cda3e338..00000000 Binary files a/AJClientGUI/icons/opt_ansicht.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_passwort.gif b/AJClientGUI/icons/opt_passwort.gif deleted file mode 100644 index 63e30a60..00000000 Binary files a/AJClientGUI/icons/opt_passwort.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_plugins.gif b/AJClientGUI/icons/opt_plugins.gif deleted file mode 100644 index b81e9388..00000000 Binary files a/AJClientGUI/icons/opt_plugins.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_proxy.gif b/AJClientGUI/icons/opt_proxy.gif deleted file mode 100644 index d9c1fc26..00000000 Binary files a/AJClientGUI/icons/opt_proxy.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_standard.gif b/AJClientGUI/icons/opt_standard.gif deleted file mode 100644 index 6ac5c390..00000000 Binary files a/AJClientGUI/icons/opt_standard.gif and /dev/null differ diff --git a/AJClientGUI/icons/opt_verbindung.gif b/AJClientGUI/icons/opt_verbindung.gif deleted file mode 100644 index 06d4f99e..00000000 Binary files a/AJClientGUI/icons/opt_verbindung.gif and /dev/null differ diff --git a/AJClientGUI/icons/optionen.gif b/AJClientGUI/icons/optionen.gif deleted file mode 100644 index 571871d6..00000000 Binary files a/AJClientGUI/icons/optionen.gif and /dev/null differ diff --git a/AJClientGUI/icons/os2symbol.gif b/AJClientGUI/icons/os2symbol.gif deleted file mode 100644 index ec01763a..00000000 Binary files a/AJClientGUI/icons/os2symbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/partliste.gif b/AJClientGUI/icons/partliste.gif deleted file mode 100644 index fddef9e4..00000000 Binary files a/AJClientGUI/icons/partliste.gif and /dev/null differ diff --git a/AJClientGUI/icons/pause.gif b/AJClientGUI/icons/pause.gif deleted file mode 100644 index 88e0a84c..00000000 Binary files a/AJClientGUI/icons/pause.gif and /dev/null differ diff --git a/AJClientGUI/icons/pdf.gif b/AJClientGUI/icons/pdf.gif deleted file mode 100644 index 40ba2e71..00000000 Binary files a/AJClientGUI/icons/pdf.gif and /dev/null differ diff --git a/AJClientGUI/icons/server.gif b/AJClientGUI/icons/server.gif deleted file mode 100644 index 9393af74..00000000 Binary files a/AJClientGUI/icons/server.gif and /dev/null differ diff --git a/AJClientGUI/icons/serverloeschen.gif b/AJClientGUI/icons/serverloeschen.gif deleted file mode 100644 index b4a7f4bf..00000000 Binary files a/AJClientGUI/icons/serverloeschen.gif and /dev/null differ diff --git a/AJClientGUI/icons/serverneu.gif b/AJClientGUI/icons/serverneu.gif deleted file mode 100644 index a575f2b8..00000000 Binary files a/AJClientGUI/icons/serverneu.gif and /dev/null differ diff --git a/AJClientGUI/icons/serververbinden.gif b/AJClientGUI/icons/serververbinden.gif deleted file mode 100644 index f64570b1..00000000 Binary files a/AJClientGUI/icons/serververbinden.gif and /dev/null differ diff --git a/AJClientGUI/icons/serververbunden.gif b/AJClientGUI/icons/serververbunden.gif deleted file mode 100644 index 7ae1d253..00000000 Binary files a/AJClientGUI/icons/serververbunden.gif and /dev/null differ diff --git a/AJClientGUI/icons/serverversuche.gif b/AJClientGUI/icons/serverversuche.gif deleted file mode 100644 index 5257cc7e..00000000 Binary files a/AJClientGUI/icons/serverversuche.gif and /dev/null differ diff --git a/AJClientGUI/icons/sharedwosub.gif b/AJClientGUI/icons/sharedwosub.gif deleted file mode 100644 index f7fc929f..00000000 Binary files a/AJClientGUI/icons/sharedwosub.gif and /dev/null differ diff --git a/AJClientGUI/icons/sharedwsub.gif b/AJClientGUI/icons/sharedwsub.gif deleted file mode 100644 index d8116c2c..00000000 Binary files a/AJClientGUI/icons/sharedwsub.gif and /dev/null differ diff --git a/AJClientGUI/icons/skull.gif b/AJClientGUI/icons/skull.gif deleted file mode 100644 index 4ef9f140..00000000 Binary files a/AJClientGUI/icons/skull.gif and /dev/null differ diff --git a/AJClientGUI/icons/somethingshared.gif b/AJClientGUI/icons/somethingshared.gif deleted file mode 100644 index e6fa3f83..00000000 Binary files a/AJClientGUI/icons/somethingshared.gif and /dev/null differ diff --git a/AJClientGUI/icons/sound.gif b/AJClientGUI/icons/sound.gif deleted file mode 100644 index 53a87b97..00000000 Binary files a/AJClientGUI/icons/sound.gif and /dev/null differ diff --git a/AJClientGUI/icons/soundoff.gif b/AJClientGUI/icons/soundoff.gif deleted file mode 100644 index a3a9f0a6..00000000 Binary files a/AJClientGUI/icons/soundoff.gif and /dev/null differ diff --git a/AJClientGUI/icons/soundon.gif b/AJClientGUI/icons/soundon.gif deleted file mode 100644 index f1c3da41..00000000 Binary files a/AJClientGUI/icons/soundon.gif and /dev/null differ diff --git a/AJClientGUI/icons/speichern.gif b/AJClientGUI/icons/speichern.gif deleted file mode 100644 index d992e0a0..00000000 Binary files a/AJClientGUI/icons/speichern.gif and /dev/null differ diff --git a/AJClientGUI/icons/splashscreen.gif b/AJClientGUI/icons/splashscreen.gif deleted file mode 100644 index 77e7f24c..00000000 Binary files a/AJClientGUI/icons/splashscreen.gif and /dev/null differ diff --git a/AJClientGUI/icons/start.gif b/AJClientGUI/icons/start.gif deleted file mode 100644 index 78f486f1..00000000 Binary files a/AJClientGUI/icons/start.gif and /dev/null differ diff --git a/AJClientGUI/icons/suchen.gif b/AJClientGUI/icons/suchen.gif deleted file mode 100644 index e7b8b83a..00000000 Binary files a/AJClientGUI/icons/suchen.gif and /dev/null differ diff --git a/AJClientGUI/icons/sunossymbol.gif b/AJClientGUI/icons/sunossymbol.gif deleted file mode 100644 index 947d16d6..00000000 Binary files a/AJClientGUI/icons/sunossymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/text.gif b/AJClientGUI/icons/text.gif deleted file mode 100644 index dc3bc61c..00000000 Binary files a/AJClientGUI/icons/text.gif and /dev/null differ diff --git a/AJClientGUI/icons/tree.gif b/AJClientGUI/icons/tree.gif deleted file mode 100644 index 29354a88..00000000 Binary files a/AJClientGUI/icons/tree.gif and /dev/null differ diff --git a/AJClientGUI/icons/treeIndirekt.gif b/AJClientGUI/icons/treeIndirekt.gif deleted file mode 100644 index 1f57dd6b..00000000 Binary files a/AJClientGUI/icons/treeIndirekt.gif and /dev/null differ diff --git a/AJClientGUI/icons/treeRoot.gif b/AJClientGUI/icons/treeRoot.gif deleted file mode 100644 index 2b012949..00000000 Binary files a/AJClientGUI/icons/treeRoot.gif and /dev/null differ diff --git a/AJClientGUI/icons/treeUebertrage.gif b/AJClientGUI/icons/treeUebertrage.gif deleted file mode 100644 index 734b238d..00000000 Binary files a/AJClientGUI/icons/treeUebertrage.gif and /dev/null differ diff --git a/AJClientGUI/icons/treeWarteschlange.gif b/AJClientGUI/icons/treeWarteschlange.gif deleted file mode 100644 index 2b9c87a3..00000000 Binary files a/AJClientGUI/icons/treeWarteschlange.gif and /dev/null differ diff --git a/AJClientGUI/icons/umbenennen.gif b/AJClientGUI/icons/umbenennen.gif deleted file mode 100644 index 94b15165..00000000 Binary files a/AJClientGUI/icons/umbenennen.gif and /dev/null differ diff --git a/AJClientGUI/icons/unbekanntsymbol.gif b/AJClientGUI/icons/unbekanntsymbol.gif deleted file mode 100644 index f988f842..00000000 Binary files a/AJClientGUI/icons/unbekanntsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/update.gif b/AJClientGUI/icons/update.gif deleted file mode 100644 index b3f9d4bc..00000000 Binary files a/AJClientGUI/icons/update.gif and /dev/null differ diff --git a/AJClientGUI/icons/upload.gif b/AJClientGUI/icons/upload.gif deleted file mode 100644 index 1a556c45..00000000 Binary files a/AJClientGUI/icons/upload.gif and /dev/null differ diff --git a/AJClientGUI/icons/verbinden.gif b/AJClientGUI/icons/verbinden.gif deleted file mode 100644 index 200cd77a..00000000 Binary files a/AJClientGUI/icons/verbinden.gif and /dev/null differ diff --git a/AJClientGUI/icons/verbindungUnbekannt.gif b/AJClientGUI/icons/verbindungUnbekannt.gif deleted file mode 100644 index 58564c89..00000000 Binary files a/AJClientGUI/icons/verbindungUnbekannt.gif and /dev/null differ diff --git a/AJClientGUI/icons/verzeichnislink.gif b/AJClientGUI/icons/verzeichnislink.gif deleted file mode 100644 index dbf814c3..00000000 Binary files a/AJClientGUI/icons/verzeichnislink.gif and /dev/null differ diff --git a/AJClientGUI/icons/vlc.gif b/AJClientGUI/icons/vlc.gif deleted file mode 100644 index a2e3b613..00000000 Binary files a/AJClientGUI/icons/vlc.gif and /dev/null differ diff --git a/AJClientGUI/icons/warnung.gif b/AJClientGUI/icons/warnung.gif deleted file mode 100644 index a2dcac5f..00000000 Binary files a/AJClientGUI/icons/warnung.gif and /dev/null differ diff --git a/AJClientGUI/icons/warten.gif b/AJClientGUI/icons/warten.gif deleted file mode 100644 index 92e2b639..00000000 Binary files a/AJClientGUI/icons/warten.gif and /dev/null differ diff --git a/AJClientGUI/icons/web.gif b/AJClientGUI/icons/web.gif deleted file mode 100644 index 6820d7ac..00000000 Binary files a/AJClientGUI/icons/web.gif and /dev/null differ diff --git a/AJClientGUI/icons/winsymbol.gif b/AJClientGUI/icons/winsymbol.gif deleted file mode 100644 index e4a54ecd..00000000 Binary files a/AJClientGUI/icons/winsymbol.gif and /dev/null differ diff --git a/AJClientGUI/icons/wizardbanner.gif b/AJClientGUI/icons/wizardbanner.gif deleted file mode 100644 index e7e54f20..00000000 Binary files a/AJClientGUI/icons/wizardbanner.gif and /dev/null differ diff --git a/AJClientGUI/icons/zielordner.gif b/AJClientGUI/icons/zielordner.gif deleted file mode 100644 index 4f432597..00000000 Binary files a/AJClientGUI/icons/zielordner.gif and /dev/null differ diff --git a/AJClientGUI/language/deutsch.gif b/AJClientGUI/language/deutsch.gif deleted file mode 100644 index b32cfb6c..00000000 Binary files a/AJClientGUI/language/deutsch.gif and /dev/null differ diff --git a/AJClientGUI/logs/.cvsignore b/AJClientGUI/logs/.cvsignore deleted file mode 100644 index 2d19fc76..00000000 --- a/AJClientGUI/logs/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.html diff --git a/AJClientGUI/needed_jars/TableLayout-20050920.jar b/AJClientGUI/needed_jars/TableLayout-20050920.jar deleted file mode 100644 index 81c1fc3c..00000000 Binary files a/AJClientGUI/needed_jars/TableLayout-20050920.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/ajcorefassade.jar b/AJClientGUI/needed_jars/ajcorefassade.jar deleted file mode 100644 index 6f6f2792..00000000 Binary files a/AJClientGUI/needed_jars/ajcorefassade.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/ajtray.jar b/AJClientGUI/needed_jars/ajtray.jar deleted file mode 100644 index 95dae56a..00000000 Binary files a/AJClientGUI/needed_jars/ajtray.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/log4j-1.2.15.jar b/AJClientGUI/needed_jars/log4j-1.2.15.jar deleted file mode 100644 index c930a6ab..00000000 Binary files a/AJClientGUI/needed_jars/log4j-1.2.15.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/looks-2.2.1.jar b/AJClientGUI/needed_jars/looks-2.2.1.jar deleted file mode 100644 index 199b267d..00000000 Binary files a/AJClientGUI/needed_jars/looks-2.2.1.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/skinlf.jar b/AJClientGUI/needed_jars/skinlf.jar deleted file mode 100644 index 6d991c4d..00000000 Binary files a/AJClientGUI/needed_jars/skinlf.jar and /dev/null differ diff --git a/AJClientGUI/needed_jars/tklcontrols.jar b/AJClientGUI/needed_jars/tklcontrols.jar deleted file mode 100644 index e940ee85..00000000 Binary files a/AJClientGUI/needed_jars/tklcontrols.jar and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/icon.gif b/AJClientGUI/plugin_src/ircplugin/icons/icon.gif deleted file mode 100644 index ffbb8254..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_blue.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_blue.gif deleted file mode 100644 index bbb7f6d8..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_blue.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_chan.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_chan.gif deleted file mode 100644 index fb87f879..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_chan.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_green.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_green.gif deleted file mode 100644 index e443a544..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_green.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_login.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_login.gif deleted file mode 100644 index bf2caa7d..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_login.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_red.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_red.gif deleted file mode 100644 index 88b57b7d..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_red.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/icons/irc_yellow.gif b/AJClientGUI/plugin_src/ircplugin/icons/irc_yellow.gif deleted file mode 100644 index a00fa88c..00000000 Binary files a/AJClientGUI/plugin_src/ircplugin/icons/irc_yellow.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/ircplugin/language_deutsch.properties b/AJClientGUI/plugin_src/ircplugin/language_deutsch.properties deleted file mode 100644 index 1e1b409e..00000000 --- a/AJClientGUI/plugin_src/ircplugin/language_deutsch.properties +++ /dev/null @@ -1,14 +0,0 @@ -language=deutsch -language.description=Der IRC-Client dient zum Kontakt zur appleJuce-Gemeinschaft und zur Supportvereinfachung. Es wird nur der Server des offiziellen appleJuice-Kanals #applejuice unterstützt. Der Klient unterstützt das Besuchen mehrerer Räume, Queries, usw. Ben?tigt wird ein GUI ab 0.70.4 -language.buttons.connect=Verbinden -language.buttons.disconnect=Trennen -language.buttons.private=Privat sprechen -language.buttons.join=Raum besuchen -language.buttons.nick=Nick ändern -language.buttons.info=Nick Info -language.buttons.cancel=Abbrechen -language.channel.newchannel=Raumnamen eingeben -language.nick.newnick=Nickname -language.title.newconnection=Verbindungsinfo -language.disablerules=Chanregeln anzeigen deaktivieren -language.channel.gesamt=Gesamt diff --git a/AJClientGUI/plugin_src/ircplugin/language_english.properties b/AJClientGUI/plugin_src/ircplugin/language_english.properties deleted file mode 100644 index 95acae5e..00000000 --- a/AJClientGUI/plugin_src/ircplugin/language_english.properties +++ /dev/null @@ -1,14 +0,0 @@ -language=english -language.description=This irc-client supports multiple rooms, queries and much more. GUI 0.70.2 or higher is needed. -language.buttons.connect=Connect -language.buttons.disconnect=Disconnect -language.buttons.private=Talk Private -language.buttons.join=Join a channel -language.buttons.nick=Change nick -language.buttons.info=Nick Info -language.buttons.cancel=Cancel -language.channel.newchannel=Enter channel name -language.nick.newnick=Nickname -language.title.newconnection=Connection Info -language.disablerules=Disable chanrules -language.channel.gesamt=Entire diff --git a/AJClientGUI/plugin_src/ircplugin/plugin.properties b/AJClientGUI/plugin_src/ircplugin/plugin.properties deleted file mode 100644 index c1e53936..00000000 --- a/AJClientGUI/plugin_src/ircplugin/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -general.title=ajIRC -general.version=1.38 -general.author=Maj0r -general.contact=tkrall@tkl-soft.de -general.description=Der IRC-Client dient zum Kontakt zur appleJuce-Gemeinschaft und zur Supportvereinfachung. Es wird nur der Server des offiziellen appleJuice-Kanals #applejuice unterstützt. Der Klient unterstützt das Besuchen mehrerer Räume, Queries, usw. Benötigt wird ein GUI ab 0.70.4 -general.istab=true -general.classname=de.applejuicenet.client.gui.plugins.ircplugin.IrcPlugin \ No newline at end of file diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/ChannelPanel.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/ChannelPanel.java deleted file mode 100644 index 37a47265..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/ChannelPanel.java +++ /dev/null @@ -1,1034 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.AWTKeyStroke; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.KeyboardFocusManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import java.net.URL; - -import java.text.SimpleDateFormat; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.ListSelectionModel; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.MutableAttributeSet; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.start.HyperlinkAdapter; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/ChannelPanel.java,v - * 1.18 2004/12/06 20:55:30 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class ChannelPanel extends JPanel implements ActionListener -{ - public static final String HTTP_IDENTIFIER = "http://"; - public static final String WWW_IDENTIFIER = "www."; - private static final Color JOIN_GREEN = new Color(0, 128, 0); - private String name; - private SortedListModel usernameList = new SortedListModel(); - private JList userList = new JList(usernameList); - private JTextPane textArea = new JTextPane(); - private StyledDocument document = (StyledDocument) textArea.getStyledDocument(); - private JTextField textField; - private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss"); - private ArrayList befehle = new ArrayList(); - private int befehlPos = -1; - private JLabel counter = new JLabel("0 Ops, 0 Gesamt"); - private JTextPane titleArea = new JTextPane(); - private JButton closeButton = new JButton("X"); - private XdccIrc parentPanel; - private boolean selected = false; - private boolean marked = false; - private JTabbedPane tabbedPane; - private Logger logger; - private long lastStatsPrinted = 0; - private long lastVersionPrinted = 0; - private String counterText = "Gesamt"; - - public ChannelPanel(XdccIrc parentPanel, String name, JTabbedPane tabbedPane) - { - logger = Logger.getLogger(getClass()); - this.name = name; - this.parentPanel = parentPanel; - this.tabbedPane = tabbedPane; - makePanel(); - } - - public SortedListModel getUserNameList() - { - return usernameList; - } - - public void selected() - { - selected = true; - marked = false; - } - - public void unselected() - { - selected = false; - } - - private void makePanel() - { - setLayout(new BorderLayout()); - textArea.setEditorKit(new LinkEditorKit()); - textArea.setDocument(document); - textArea.setEditable(false); - textArea.addHyperlinkListener(new HyperlinkAdapter(textArea)); - textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - textArea.setBackground(Color.WHITE); - textField = new JTextField(); - Set set = new HashSet(1); - - set.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_JAPANESE_HIRAGANA, 0)); - textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); - textField.addActionListener(this); - textArea.addKeyListener(new KeyAdapter() - { - public void keyTyped(KeyEvent ke) - { - textField.setText(textField.getText() + ke.getKeyChar()); - textField.requestFocus(); - } - }); - textField.addKeyListener(new KeyAdapter() - { - public void keyReleased(KeyEvent ke) - { - super.keyReleased(ke); - if(ke.getKeyCode() == KeyEvent.VK_TAB) - { - String text = textField.getText(); - - if(text.length() > 0) - { - int index = text.lastIndexOf(' '); - int index2 = text.lastIndexOf(','); - - if(index2 > index) - { - index = index2; - } - - String searchString; - - if(index != -1) - { - searchString = text.substring(index + 1).toLowerCase(); - } - else - { - searchString = text.toLowerCase(); - } - - String treffer = ""; - int count = 0; - - synchronized(usernameList) - { - User[] users = usernameList.getValues(); - String compareValue; - - for(int i = 0; i < users.length; i++) - { - if(users[i].getName().toLowerCase().startsWith(searchString)) - { - treffer += users[i].getName() + " "; - count++; - } - } - } - - if(treffer.length() > 0) - { - treffer = treffer.substring(0, treffer.length() - 1); - if(count == 1) - { - if(index != -1) - { - String newText = text.subSequence(0, index + 1) + treffer; - - textField.setText(newText); - } - else - { - textField.setText(treffer); - } - } - else if(count > 1) - { - updateTextArea("\t" + treffer, false); - } - } - } - } - else if(befehlPos != -1) - { - if(ke.getKeyCode() == KeyEvent.VK_UP) - { - textField.setText(befehle.get(befehlPos)); - if(befehlPos > 0) - { - befehlPos--; - } - } - else if(ke.getKeyCode() == KeyEvent.VK_DOWN) - { - if(befehlPos < befehle.size() - 1) - { - befehlPos++; - } - - textField.setText(befehle.get(befehlPos)); - } - } - } - }); - - userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - userList.addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent me) - { - if(me.getClickCount() == 2) - { - User user = (User) userList.getSelectedValue(); - - if(!user.getName().equalsIgnoreCase(parentPanel.getNickname())) - { - JTabbedPane tabbedPane = parentPanel.getTabbedPane(); - - for(int i = 1; i < tabbedPane.getTabCount(); i++) - { - if(tabbedPane.getTitleAt(i).equalsIgnoreCase(user.getName())) - { - return; - } - } - - parentPanel.addUser(tabbedPane, user.getName()); - tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1); - } - } - } - }); - userList.setCellRenderer(new UserListCellRenderer()); - - JScrollPane sp1 = new JScrollPane(textArea); - JScrollPane sp2 = new JScrollPane(userList); - JPanel panel1 = new JPanel(new BorderLayout()); - - panel1.add(counter, BorderLayout.NORTH); - panel1.add(sp2, BorderLayout.CENTER); - - sp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - sp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, panel1); - - splitPane.setDividerLocation(AppleJuiceDialog.getApp().getSize().width - 200); - add(splitPane, BorderLayout.CENTER); - add(textField, BorderLayout.SOUTH); - add(makeNorth(), BorderLayout.NORTH); - } - - private Box makeNorth() - { - Box northBox = Box.createHorizontalBox(); - - // let's add actions - closeButton.addActionListener(this); - - northBox.add(closeButton); - titleArea.setEditable(false); - northBox.add(titleArea); - - return northBox; - } - - private MutableAttributeSet setLink(String sUrl, SimpleAttributeSet attributeSet) - { - MutableAttributeSet a = new SimpleAttributeSet(attributeSet); - - try - { - if(!sUrl.toLowerCase().startsWith(ChannelPanel.HTTP_IDENTIFIER)) - { - sUrl = ChannelPanel.HTTP_IDENTIFIER + sUrl; - } - - URL url = new URL(sUrl); - - a.addAttribute(LinkEditorKit.LINK, new URL(sUrl)); - } - catch(Exception e) - { - - // nothing to do - } - - a.addAttribute(StyleConstants.Bold, Boolean.TRUE); - a.addAttribute(StyleConstants.Underline, Boolean.TRUE); - return a; - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - - // let's take care of textField - if(source == textField) - { - String message = textField.getText(); - - if(message.length() > 450) - { - message = message.substring(0, 450); - } - - // let's send to server - if(message.startsWith("/")) - { - - // commands that start with "/" - // message = message.substring(1); - if(message.toLowerCase().compareTo("/ajstats") == 0 || message.toLowerCase().compareTo("/ajversinfo") == 0) - { - long currentTime = System.currentTimeMillis(); - - if(message.toLowerCase().compareTo("/ajstats") == 0) - { - if(currentTime > lastStatsPrinted + 60000) - { - lastStatsPrinted = currentTime; - ApplejuiceFassade ajFassade = AppleJuiceClient.getAjFassade(); - Information info = ajFassade.getInformation(); - StringBuffer buf = new StringBuffer(); - - String coreVersion = AppleJuiceClient.getAjFassade().getCoreVersion().getVersion(); - String guiVersion = AppleJuiceDialog.GUI_VERSION; - String ircPluginVersion = parentPanel.getPlugin() - .getGeneralXMLAttributeByTagName(".root.general.version.value"); - - String version = "Java-GUI: " + guiVersion + " / Core: " + coreVersion + " / IRC-Plugin: " + ircPluginVersion; - - buf.append(version + " | "); - String verbindungstatus = null; - - switch(info.getVerbindungsStatus()) - { - - case Information.VERBUNDEN: - { - int serverId = ajFassade.getNetworkInfo().getConnectedWithServerId(); - - try - { - Server curServer = (Server) ajFassade.getObjectById(serverId); - - verbindungstatus = "Server: " + curServer.getName(); - } - catch(IllegalArgumentException e1) - { - verbindungstatus = "Verbindung: verbunden"; - } - - break; - } - - case Information.NICHT_VERBUNDEN: - { - verbindungstatus = "Verbindung: nicht verbunden"; - break; - } - - case Information.VERSUCHE_ZU_VERBINDEN: - { - verbindungstatus = "Verbindung: versuche zu verbinden"; - break; - } - } - - if(null != verbindungstatus) - { - buf.append(verbindungstatus + " | "); - } - - buf.append("Aktueller DL:" + info.getUpDownAsString() + " | "); - buf.append("Gesamt-DL:" + info.getUpDownSessionAsString() + " |"); - buf.append(info.getCreditsAsString() + " | "); - buf.append("offene Verbindungen: " + info.getOpenConnections() + " | "); - - AJSettings ajSettings = ajFassade.getCurrentAJSettings(); - - buf.append("erlaubte Verbindungen: " + ajSettings.getMaxConnections() + " | "); - buf.append("max. neue Verbindungen/10 Seks: " + ajSettings.getMaxNewConnectionsPerTurn() + " | "); - buf.append("max. DL: " + ajSettings.getMaxDownloadInKB() + " KB/s | "); - buf.append("max. UP: " + ajSettings.getMaxUploadInKB() + " KB/s | "); - buf.append("max. Quellen/Datei: " + ajSettings.getMaxSourcesPerFile() + " | "); - buf.append("max. KB/Uploadslot: " + ajSettings.getSpeedPerSlot() + " KB/s"); - - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + buf.toString()); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + buf.toString()); - } - } - else if(message.toLowerCase().compareTo("/ajversinfo") == 0) - { - if(currentTime > lastVersionPrinted + 60000) - { - lastVersionPrinted = currentTime; - String coreVersion = AppleJuiceClient.getAjFassade().getCoreVersion().getVersion(); - String guiVersion = AppleJuiceDialog.GUI_VERSION; - String text = "Java-GUI: " + guiVersion + " / Core: " + coreVersion; - - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + text); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + text); - } - } - } - else - { - parentPanel.analyzeCommand(message); - } - - textField.setText(""); - } - else - { - // A private message to channel! - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + message); - - // let's update textArea - // textArea.append(textField.getText() + "\n"); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + textField.getText()); - textField.setText(""); - } - - if(message != null && message.length() > 0) - { - befehle.add(message); - if(befehle.size() > 40) - { - befehle.remove(0); - } - - befehlPos = befehle.size() - 1; - } - } - else if(source == closeButton) - { - parentPanel.closeChannel(parentPanel.getTabbedPane(), name); - - // Let's send a sensible message - parentPanel.parseSendToCommand("PART " + name); - } - } - - public void setTitleArea(String title) - { - StyledDocument doc = titleArea.getStyledDocument(); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - - StyleConstants.setBackground(attributes, Color.WHITE); - try - { - doc.remove(0, doc.getLength()); - int startIndex = 0; - - for(int i = 0; i < title.length(); i++) - { - if(title.charAt(i) == 3 || i == title.length() - 1) - { - if(title.charAt(i) == 3) - { - String toWrite = title.substring(startIndex, i); - - if(toWrite.length() > 0) - { - attributes = writeString(doc, attributes, toWrite); - } - - startIndex = i + 1; - i++; - } - else - { - String toWrite = title.substring(startIndex); - - if(toWrite.length() > 0) - { - attributes = writeString(doc, attributes, toWrite); - } - } - } - } - } - catch(BadLocationException ex) - { - ex.printStackTrace(); - } - } - - private SimpleAttributeSet writeString(StyledDocument doc, SimpleAttributeSet attributes, String toWrite) - { - boolean istNachkomma = false; - boolean parsEnde = false; - int index = 0; - - if(toWrite.length() > 1) - { - while(!parsEnde) - { - try - { - if(toWrite.charAt(index) == ',') - { - istNachkomma = true; - index++; - continue; - } - - int colorCode = Integer.parseInt(toWrite.substring(index, index + 2)); - - index += 2; - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE) - { - if(toWrite.charAt(index + 1) != ',') - { - parsEnde = true; - } - - try - { - int colorCode = Integer.parseInt(toWrite.substring(index, index + 1)); - - index++; - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE2) - { - parsEnde = true; - StyleConstants.setForeground(attributes, Color.BLACK); - } - } - catch(StringIndexOutOfBoundsException sioobE) - { - parsEnde = true; - try - { - int colorCode = Integer.parseInt(toWrite.substring(index, index + 1)); - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE2) - { - StyleConstants.setForeground(attributes, Color.BLUE); - } - catch(StringIndexOutOfBoundsException nfE2) - { - StyleConstants.setForeground(attributes, Color.BLACK); - } - - return attributes; - } - } - } - - try - { - doc.insertString(doc.getLength(), toWrite.substring(index), attributes); - } - catch(BadLocationException ex) - { - ex.printStackTrace(); - } - - return attributes; - } - - private Color getColor(int code) - { - switch(code) - { - - case 0: - return Color.BLACK; - - case 1: - return Color.BLACK; - - case 2: - return Color.BLUE; - - case 3: - return Color.GREEN; - - case 4: - return Color.RED; - - case 5: - return Color.BLACK; - - case 6: - return Color.PINK; - - case 7: - return Color.ORANGE; - - case 8: - return Color.YELLOW; - - case 9: - return Color.GREEN; - - case 10: - return Color.GREEN; - - case 11: - return Color.CYAN; - - case 12: - return Color.BLUE; - - case 13: - return Color.PINK; - - case 14: - return Color.GRAY; - - case 15: - return Color.LIGHT_GRAY; - - default: - return Color.BLACK; - } - } - - public void updateTextArea(String message, boolean withTimeStamp) - { - Document doc = textArea.getDocument(); - int oldCaretPosition = textArea.getCaretPosition(); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - - StyleConstants.setBackground(attributes, Color.WHITE); - StyleConstants.setForeground(attributes, Color.BLACK); - int index = message.indexOf('>'); - String compareValue; - boolean eigenerName = false; - boolean doMark = false; - - if(index != -1 && message.length() - 1 > index) - { - compareValue = message.substring(index + 1); - } - else - { - compareValue = message; - } - - boolean isAction = false; - - if(compareValue.indexOf(parentPanel.getNickname()) != -1) - { - StyleConstants.setBackground(attributes, Color.ORANGE); - eigenerName = true; - doMark = true; - } - else if(message.indexOf("---> JOIN:") != -1) - { - StyleConstants.setForeground(attributes, JOIN_GREEN); - } - else if(message.indexOf("<--- PART:") != -1) - { - StyleConstants.setForeground(attributes, Color.RED); - } - else if(message.indexOf("<--- QUIT:") != -1) - { - StyleConstants.setForeground(attributes, Color.RED); - } - else if(message.indexOf('>') == 0) - { - StyleConstants.setForeground(attributes, Color.MAGENTA); - } - else if(message.startsWith("* ")) - { - isAction = true; - } - else if(!withTimeStamp || index == -1) - { - StyleConstants.setForeground(attributes, Color.GRAY); - } - else - { - StyleConstants.setForeground(attributes, Color.BLACK); - doMark = true; - } - - try - { - if(withTimeStamp) - { - String zeit = dateFormatter.format(new Date(System.currentTimeMillis())); - - doc.insertString(doc.getLength(), "[" + zeit + "]\t", attributes); - } - - if(isAction) - { - Color color = StyleConstants.getForeground(attributes); - - StyleConstants.setForeground(attributes, Color.MAGENTA); - doc.insertString(doc.getLength(), "\t*", attributes); - StyleConstants.setForeground(attributes, color); - message = message.substring(1).trim(); - } - - parseLinks(attributes, doc, message); - } - catch(BadLocationException blE) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Fehler im IrcPlugin", blE); - } - } - - if(!selected && doMark) - { - if(eigenerName) - { - for(int i = 0; i < tabbedPane.getTabCount(); i++) - { - Object tab = tabbedPane.getComponentAt(i); - - if(tab == this) - { - tabbedPane.setForegroundAt(i, Color.GREEN); - } - } - } - - if(!eigenerName && !marked) - { - for(int i = 0; i < tabbedPane.getTabCount(); i++) - { - Object tab = tabbedPane.getComponentAt(i); - - if(tab == this) - { - tabbedPane.setForegroundAt(i, Color.RED); - } - } - } - - marked = true; - } - - int newCaretPosition = doc.getLength(); - - if(newCaretPosition != oldCaretPosition) - { - textArea.setCaretPosition(newCaretPosition); - } - - usernameList.reorder(); - } - - private void parseLinks(SimpleAttributeSet attributes, Document doc, String message) - throws BadLocationException - { - while(message.toLowerCase().indexOf(HTTP_IDENTIFIER) != -1 || message.toLowerCase().indexOf(WWW_IDENTIFIER) != -1) - { - String httpIdentifier; - int indexHttp = message.toLowerCase().indexOf(HTTP_IDENTIFIER); - int indexWww = message.toLowerCase().indexOf(WWW_IDENTIFIER); - - if(indexHttp == -1) - { - httpIdentifier = WWW_IDENTIFIER; - } - else if(indexWww == -1) - { - httpIdentifier = HTTP_IDENTIFIER; - } - else - { - if(indexWww == indexHttp + HTTP_IDENTIFIER.length()) - { - httpIdentifier = HTTP_IDENTIFIER; - } - else - { - httpIdentifier = WWW_IDENTIFIER; - } - } - - doc.insertString(doc.getLength(), message.substring(0, message.toLowerCase().indexOf(httpIdentifier)), attributes); - message = message.substring(message.toLowerCase().indexOf(httpIdentifier)); - int index = message.indexOf(" "); - int index2 = message.indexOf(">"); - - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf(")"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf("]"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf("}"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - if(index != -1) - { - doc.insertString(doc.getLength(), message.substring(0, index), setLink(message.substring(0, index), attributes)); - message = message.substring(index); - if(message.indexOf(httpIdentifier, index) == -1) - { - break; - } - } - else - { - doc.insertString(doc.getLength(), message, setLink(message, attributes)); - message = ""; - } - } - - doc.insertString(doc.getLength(), message + "\n", attributes); - } - - public void updateTextArea(String message) - { - updateTextArea(message, true); - } - - public void updateUserArea(String username, String command) - { - if(command.equals("add")) - { - User user; - - if(username.indexOf('!') == 0 || username.indexOf('@') == 0 || username.indexOf('%') == 0 || username.indexOf('+') == 0) - { - char mod = username.charAt(0); - - username = username.substring(1); - user = new User(username); - switch(mod) - { - - case '!': - { - user.setAdmin(true); - break; - } - - case '@': - { - user.setOp(true); - break; - } - - case '%': - { - user.setHalfop(true); - break; - } - - case '+': - { - user.setVoice(true); - break; - } - } - } - else - { - user = new User(username); - } - - usernameList.add(user); - } - - else if(command.equals("remove")) - { - if(username.indexOf('!') == 0 || username.indexOf('@') == 0 || username.indexOf('%') == 0 || username.indexOf('+') == 0) - { - username = username.substring(1); - } - - User[] users = usernameList.getValues(); - User user = null; - - for(int i = 0; i < users.length; i++) - { - if(users[i].getName().equalsIgnoreCase(username)) - { - user = users[i]; - break; - } - } - - if(user != null) - { - usernameList.remove(user); - } - } - - updateCounter(); - } - - public void userQuits(String nick, boolean hide) - { - User nickToRemove = null; - - synchronized(usernameList) - { - User[] users = usernameList.getValues(); - - for(int i = 0; i < users.length; i++) - { - if(users[i].getName().equalsIgnoreCase(nick)) - { - nickToRemove = users[i]; - break; - } - } - } - - if(nickToRemove != null) - { - usernameList.remove(nickToRemove); - } - - if(nickToRemove != null && !hide) - { - updateTextArea("<--- QUIT: " + nickToRemove); - } - } - - public void renameUser(String oldNick, String newNick) - { - User searchedNick = null; - - synchronized(usernameList) - { - User[] users = usernameList.getValues(); - String compareValue; - - for(int i = 0; i < users.length; i++) - { - if(users[i].getName().compareToIgnoreCase(oldNick) == 0) - { - searchedNick = users[i]; - break; - } - } - } - - if(searchedNick != null) - { - searchedNick.setName(newNick); - usernameList.reorder(); - updateTextArea(oldNick + " changes nickname to " + newNick); - } - } - - private void updateCounter() - { - counter.setText(usernameList.getOpCount() + " Ops, " + usernameList.getSize() + " " + counterText); - } - - public void fireLanguageChanged() - { - counterText = parentPanel.getPlugin().getLanguageString(".root.language.channel.gesamt"); - updateCounter(); - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/CommandInterpreter.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/CommandInterpreter.java deleted file mode 100644 index 740ea4bf..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/CommandInterpreter.java +++ /dev/null @@ -1,102 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -/* - * @(#) jqIRC 0.4 08/12/2001 - * - * Copyright (c), 2000 by jqIRC, Inc. ^-^ - * - * License: We grant you this piece of source code to play with - * as you wish provided that 1) you buy us a drink when we meet - * somewhere someday. 2) Incase you don't want to fullfill the - * first condition, you just buy something for one of your - * beloved friends. 3) Attach below messages somewhere. ^-^ - * - * To some people, a friend - * is practically anyone they know. - * To me, friendship means - * a much closer relationship, - * one in which you take the time - * to really understand each other. - * A friend is someone you trust enough - * to share a part of yourself - * the rest of the world may never see. - * That kind of friendship - * doesn't come along everyday... - * but that's the way it should be. - * - */ - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/CommandInterpreter.java,v 1.3 2004/10/15 13:34:47 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ - -import java.util.*; - -public class CommandInterpreter { - String lineToServer; - String command = "", - param1 = "", - message = ""; - - public CommandInterpreter(String lineToServer) { - this.lineToServer = lineToServer; - init_all(); - } - - private void init_all() { - if (lineToServer.startsWith("/")) - { - StringTokenizer st = new StringTokenizer(lineToServer, " \r\n"); - int totalTokens = st.countTokens(); - if (totalTokens >= 3) - { - String temp = st.nextToken(); - - temp = temp.toUpperCase(); - temp = temp.substring(1); - command = temp; - - temp = st.nextToken(); - param1 = temp; - - temp = st.nextToken("\n"); - if (temp.startsWith(" ")) - { - temp = temp.substring(1); - - } - message = temp; - } - else if (totalTokens == 2) - { - String temp = st.nextToken(); - - temp = temp.toUpperCase(); - temp = temp.substring(1); - command = temp; - - temp = st.nextToken(); - param1 = temp; - } - } - } - - public String getCommand() { - return command; - } - - public String getParam1() { - return param1; - } - - public String getMessage() { - return message; - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/InitPanel.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/InitPanel.java deleted file mode 100644 index b7bc93c8..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/InitPanel.java +++ /dev/null @@ -1,216 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.text.BadLocationException; -import javax.swing.text.MutableAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.Document; -import javax.swing.text.StyledDocument; - -import java.util.Date; -import java.net.URL; -import java.text.SimpleDateFormat; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.start.HyperlinkAdapter; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/InitPanel.java,v - * 1.6 2004/11/22 16:25:25 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ - -public class InitPanel extends JPanel implements ActionListener { - private final String name = "Init Window"; - - private final JTextPane textArea = new JTextPane(); - private final JTextField textField = new JTextField(); - private StyledDocument document = (StyledDocument) textArea - .getStyledDocument(); - private JTextField titleArea; - private XdccIrc parentPanel; - private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss"); - private Logger logger; - - public InitPanel(XdccIrc parentPanel) { - logger = Logger.getLogger(getClass()); - this.parentPanel = parentPanel; - makePanel(); - } - - private void makePanel() { - textArea.setEditorKit(new LinkEditorKit()); - textArea.setDocument(document); - textArea.setEditable(false); - textArea.addHyperlinkListener(new HyperlinkAdapter(textArea)); - setLayout(new BorderLayout()); - - textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - textArea.setBackground(Color.WHITE); - textField.addActionListener(this); - - JScrollPane sp1 = new JScrollPane(textArea); - - sp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - add(sp1, BorderLayout.CENTER); - add(textField, BorderLayout.SOUTH); - add(makeNorth(), BorderLayout.NORTH); - } - - private MutableAttributeSet setLink(String sUrl, SimpleAttributeSet attributes) { - MutableAttributeSet a = new SimpleAttributeSet(attributes); - try { - if (!sUrl.toLowerCase().startsWith(ChannelPanel.HTTP_IDENTIFIER)){ - sUrl = ChannelPanel.HTTP_IDENTIFIER + sUrl; - } - URL url = new URL(sUrl); - a.addAttribute(LinkEditorKit.LINK, new URL(sUrl)); - } catch (Exception e) { - // nothing to do - } - a.addAttribute(StyleConstants.Bold, Boolean.TRUE); - a.addAttribute(StyleConstants.Underline, Boolean.TRUE); - return a; - } - - private Box makeNorth() { - Box northBox = Box.createHorizontalBox(); - titleArea = new JTextField("Not connected yet"); - titleArea.setEditable(false); - northBox.add(titleArea); - return northBox; - } - - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - - // let's take care of textField - if (source == textField) { - String message = textField.getText(); - - if (message.startsWith("/")) { - // commands that start with "/" - if (message.toLowerCase().indexOf("nickserv identify ") == -1) { - updateTextArea(message); - } - message = message.substring(1); - textField.setText(""); - - parentPanel.parseSendToCommand(message); - } else { - // update textArea - updateTextArea(message); - textField.setText(""); - - parentPanel.parseSendToCommand(message); - } - } - } - - public void resetTextField() { - textField.setText(""); - } - - public void setTitleArea(String message) { - titleArea.setText(message); - } - - public void updateTextArea(String message) { - int oldCaretPosition = textArea.getCaretPosition(); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - StyleConstants.setBackground(attributes, Color.WHITE); - StyleConstants.setForeground(attributes, Color.BLACK); - Document doc = textArea.getDocument(); - String zeit = dateFormatter.format(new Date(System.currentTimeMillis())); - try { - doc.insertString(doc.getLength(), "[" + zeit + "]\t", attributes); - while (message.toLowerCase().indexOf(ChannelPanel.HTTP_IDENTIFIER) != -1 || - message.toLowerCase().indexOf(ChannelPanel.WWW_IDENTIFIER) != -1){ - String httpIdentifier; - int indexHttp = message.toLowerCase().indexOf(ChannelPanel.HTTP_IDENTIFIER); - int indexWww = message.toLowerCase().indexOf(ChannelPanel.WWW_IDENTIFIER); - if (indexHttp == -1){ - httpIdentifier = ChannelPanel.WWW_IDENTIFIER; - } - else if (indexWww == -1){ - httpIdentifier = ChannelPanel.HTTP_IDENTIFIER; - } - else{ - if (indexWww == indexHttp + ChannelPanel.HTTP_IDENTIFIER.length()){ - httpIdentifier = ChannelPanel.HTTP_IDENTIFIER; - } - else{ - httpIdentifier = ChannelPanel.WWW_IDENTIFIER; - } - } - - doc.insertString(doc.getLength(), - message.substring(0, - message.toLowerCase().indexOf(httpIdentifier)), - attributes); - message = message.substring(message.toLowerCase().indexOf(httpIdentifier)); - int index = message.indexOf(" "); - int index2 = message.indexOf(">"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf(")"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf("]"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf("}"); - if (index2 != -1 && index2 < index){ - index = index2; - } - if (index != -1){ - doc.insertString(doc.getLength(), message.substring(0, index), - setLink(message.substring(0, index), attributes)); - message = message.substring(index); - } - else{ - doc.insertString(doc.getLength(), message, setLink(message, attributes)); - message = ""; - } - } - doc.insertString(doc.getLength(), message + "\n", attributes); - } catch (BadLocationException ex) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error("Fehler im IrcPlugin", ex); - } - } - int newCaretPosition = textArea.getDocument().getLength(); - if (newCaretPosition != oldCaretPosition) { - textArea.setCaretPosition(newCaretPosition); - } - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPlugin.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPlugin.java deleted file mode 100644 index b6c55647..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPlugin.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPlugin.java,v 1.3 2009/01/12 10:09:19 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class IrcPlugin extends PluginConnector -{ - private XdccIrc xdccIrc; - private String savePath; - private Properties properties; - - public IrcPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, - Map availableIcons) - { - super(pluginProperties, languageFiles, icon, availableIcons); - init(); - } - - private void init() - { - savePath = AppleJuiceClient.getPropertiesPath(); - int index = savePath.lastIndexOf(File.separator); - - savePath = savePath.substring(0, index) + File.separator + "ircplugin.properties"; - properties = new Properties(); - File tmpFile = new File(savePath); - - if(tmpFile.isFile()) - { - try - { - FileInputStream fiS = new FileInputStream(tmpFile); - - properties.load(fiS); - fiS.close(); - } - catch(IOException ex) - { - ex.printStackTrace(); - } - } - - setLayout(new BorderLayout()); - xdccIrc = new XdccIrc(this); - add(xdccIrc, BorderLayout.CENTER); - } - - public void saveProperties() - { - try - { - properties.store(new FileOutputStream(savePath), "ajIrcPlugin-PropertyFile"); - } - catch(IOException ex) - { - ex.printStackTrace(); - } - } - - public Properties getProperties() - { - return properties; - } - - public void fireLanguageChanged() - { - xdccIrc.fireLanguageChanged(); - } - - /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. - �ber den DataManger k�nnen diese abgerufen werden.*/ - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - } - - public void registerSelected() - { - } - - public JPanel getOptionPanel() - { - JPanel panel1 = new JPanel(new GridBagLayout()); - final JTextField nick = new JTextField(); - - nick.setMinimumSize(new Dimension(200, nick.getPreferredSize().height)); - nick.setPreferredSize(new Dimension(200, nick.getPreferredSize().height)); - final JTextField passwort = new JTextField(); - final JTextField onJoinMessage = new JTextField(); - final JTextField channels = new JTextField(); - final JCheckBox rules = new JCheckBox(); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets = new Insets(5, 0, 0, 0); - constraints.insets.left = 5; - panel1.add(new JLabel("Nickname: "), constraints); - constraints.gridy = 1; - panel1.add(new JLabel("Passwort: "), constraints); - constraints.gridy = 2; - panel1.add(new JLabel("OnJoinMessage: "), constraints); - constraints.gridy = 3; - panel1.add(new JLabel("Channels: "), constraints); - constraints.insets.right = 5; - constraints.gridx = 1; - constraints.gridy = 0; - constraints.weightx = 1; - panel1.add(nick, constraints); - constraints.weightx = 0; - constraints.gridy = 1; - panel1.add(passwort, constraints); - constraints.gridy = 2; - panel1.add(onJoinMessage, constraints); - constraints.gridy = 3; - panel1.add(channels, constraints); - constraints.gridx = 0; - constraints.gridwidth = 2; - constraints.gridy = 4; - rules.setText(getLanguageString("language.disablerules")); - panel1.add(rules, constraints); - String propNick = properties.getProperty("nick"); - - if(propNick != null) - { - nick.setText(propNick); - } - - String propOnJoin = properties.getProperty("onjoin"); - - if(propOnJoin != null) - { - onJoinMessage.setText(propOnJoin); - } - - String propChannels = properties.getProperty("channels"); - - if(propChannels != null) - { - channels.setText(propChannels); - } - - nick.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - properties.put("nick", nick.getText()); - saveProperties(); - } - }); - onJoinMessage.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - properties.put("onjoin", onJoinMessage.getText()); - saveProperties(); - } - }); - channels.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - properties.put("channels", channels.getText()); - saveProperties(); - } - }); - passwort.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - properties.put("passwort", passwort.getText()); - saveProperties(); - } - }); - rules.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - properties.put("norules", new Boolean(rules.isSelected()).toString()); - } - }); - return panel1; - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPluginTestLoader.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPluginTestLoader.java deleted file mode 100644 index 7720990e..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcPluginTestLoader.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class IrcPluginTestLoader extends TestLoader -{ - public IrcPluginTestLoader() - { - super(); - } - - @Override - protected String getPath() - { - return "ircplugin"; - } - - @Override - protected PluginConnector getPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, - Map availableIcons) - { - return new IrcPlugin(pluginProperties, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcUser.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcUser.java deleted file mode 100644 index 84be7f9d..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/IrcUser.java +++ /dev/null @@ -1,89 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -public class IrcUser{ - public static final int MOD_USER = -1; - public static final int MOD_VOICE = 0; - public static final int MOD_HALFOP = 1; - public static final int MOD_OP = 2; - public static final int MOD_ADMIN = 3; - - private String nick; - private int mod; - - public IrcUser(String nick, int mod){ - this.nick = nick; - this.mod = mod; - } - - public String toString(){ - switch (mod){ - case MOD_VOICE: return "+" + nick; - case MOD_HALFOP: return "%" + nick; - case MOD_OP: return "@" + nick; - case MOD_ADMIN: return "!" + nick; - default: return nick; - } - } - - public String getString(){ - return nick; - } - - public int getMod(){ - return mod; - } - - public int compareTo(Object object){ - if (object.getClass() != IrcUser.class) { - return -1; - } - int mod2 = ((IrcUser)object).getMod(); - switch (mod){ - case MOD_ADMIN: { - if (mod2 == MOD_ADMIN) { - return 0; - } - else { - return 1; - } - } - case MOD_OP: { - if (mod2 == MOD_ADMIN) { - return 1; - } - else if (mod2 == MOD_OP) { - return 0; - } - else { - return -1; - } - } - case MOD_HALFOP: { - if (mod2 == MOD_ADMIN || mod2 == MOD_OP) { - return 1; - } - else if (mod2 == MOD_HALFOP) { - return 0; - } - else { - return -1; - } - } - case MOD_VOICE: { - if (mod2 == MOD_ADMIN || mod2 == MOD_OP - || mod2 == MOD_HALFOP) { - return 1; - } - else if (mod2 == MOD_VOICE) { - return 0; - } - else { - return -1; - } - } - default: { - return 0; - } - } - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/LinkEditorKit.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/LinkEditorKit.java deleted file mode 100644 index 68a99716..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/LinkEditorKit.java +++ /dev/null @@ -1,106 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; -import java.net.URL; - -import javax.swing.JEditorPane; -import javax.swing.SwingUtilities; -import javax.swing.event.HyperlinkEvent; -import javax.swing.text.Element; -import javax.swing.text.Position; -import javax.swing.text.StyledDocument; -import javax.swing.text.StyledEditorKit; - -public class LinkEditorKit extends StyledEditorKit { - public static final Object LINK = new StringBuffer("LINK"); - private static LinkHandler linkHandler = new LinkHandler(); - - public LinkEditorKit() {} - - public void install(JEditorPane p) { - super.install(p); - p.addMouseListener(linkHandler); - p.addMouseMotionListener(linkHandler); - } - - public void deinstall(JEditorPane p) { - p.removeMouseListener(linkHandler); - p.removeMouseMotionListener(linkHandler); - super.deinstall(p); - } - - private static class LinkHandler extends MouseAdapter implements - MouseMotionListener { - private Element activeElement; - - private Element characterElementAt(MouseEvent e) { - JEditorPane p = (JEditorPane) e.getComponent(); - Position.Bias[] bias = new Position.Bias[1]; - int position = p.getUI().viewToModel(p, e.getPoint(), bias); - if (bias[0] == Position.Bias.Backward && position != 0){ - --position; - } - Element c = ((StyledDocument) p.getDocument()) - .getCharacterElement(position); - return c; - } - - public void mouseMoved(MouseEvent e) { - JEditorPane p = (JEditorPane) e.getComponent(); - if (!p.isEditable()) { - Element c = characterElementAt(e); - Object target = c.getAttributes().getAttribute(LINK); - if (!(target instanceof URL)) { - target = null; - } - if (target != null) { - p.fireHyperlinkUpdate(new HyperlinkEvent(p, - HyperlinkEvent.EventType.ENTERED, (URL) target, - null, c)); - } else { - p.fireHyperlinkUpdate(new HyperlinkEvent(p, - HyperlinkEvent.EventType.EXITED, (URL) target, - null, c)); - } - } - } - - public void mouseDragged(MouseEvent e) {} - - public void mouseEntered(MouseEvent e) {} - - public void mousePressed(MouseEvent e) { - if (!SwingUtilities.isLeftMouseButton(e)){ - return; - } - JEditorPane p = (JEditorPane) e.getComponent(); - if (p.isEditable()){ - return; - } - Element c = characterElementAt(e); - if (c != null && c.getAttributes().getAttribute(LINK) != null) { - activeElement = c; - } - } - - public void mouseReleased(MouseEvent e) { - if (!SwingUtilities.isLeftMouseButton(e) || activeElement == null){ - return; - } - JEditorPane p = (JEditorPane) e.getComponent(); - Element c = characterElementAt(e); - if (!p.isEditable() && c == activeElement) { - activeElement = null; - Object target = c.getAttributes().getAttribute(LINK); - if (!(target instanceof URL)){ - target = null; - } - p.fireHyperlinkUpdate(new HyperlinkEvent(p, - HyperlinkEvent.EventType.ACTIVATED, (URL) target, null, - c)); - } - } - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/RulesDialog.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/RulesDialog.java deleted file mode 100644 index d57aded3..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/RulesDialog.java +++ /dev/null @@ -1,142 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.ZeichenErsetzer; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; - -public class RulesDialog extends JDialog{ - private Logger logger; - - public RulesDialog(Frame parent, boolean modal){ - super(parent, modal); - logger = Logger.getLogger(getClass()); - try{ - setTitle("#applejuice - Chanrules"); - getContentPane().setLayout(new BorderLayout()); - JTextPane rules = new JTextPane(); - rules.setContentType("text/html"); - rules.setEditable(false); - rules.setText(channelrules); - rules.addHyperlinkListener(new HyperlinkListener() { - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == - HyperlinkEvent.EventType.ACTIVATED) { - if (e.getURL() != null) { - String url = e.getURL().toString(); - if (url.length() != 0) { - executeLink(url); - } - } - } - } - }); - JScrollPane sp = new JScrollPane(rules); - sp.setHorizontalScrollBarPolicy(JScrollPane. - HORIZONTAL_SCROLLBAR_NEVER); - getContentPane().add(sp, BorderLayout.CENTER); - JButton ok = new JButton("OK"); - ok.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - dispose(); - } - }); - getContentPane().add(ok, BorderLayout.SOUTH); - setSize(650, 500); - Dimension size = getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit(). - getScreenSize(); - setBounds( (screenSize.width - size.width) / 2, - (screenSize.height - size.height) / 2, size.width, size.height); - } - catch(Exception e){ - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void executeLink(String link) { - try { - String browser = OptionsManagerImpl.getInstance(). - getStandardBrowser(); - try { - Runtime.getRuntime().exec(new String[] {browser, link}); - } - catch (Exception ex) { - LanguageSelector ls = LanguageSelector. - getInstance(); - String nachricht = ZeichenErsetzer.korrigiereUmlaute(ls. - getFirstAttrbuteByTagName(".root.javagui.startup.updatefehlernachricht")); - String titel = ZeichenErsetzer.korrigiereUmlaute(ls. - getFirstAttrbuteByTagName(".root.mainform.caption")); - JOptionPane.showMessageDialog(this, nachricht, - titel, JOptionPane.INFORMATION_MESSAGE); - } - } - catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private String channelrules = - "

In diesem Channel gibt es Regeln, die zu beachten sind.

" + - "

Regeln

  1. Keine Verbreitung/Unterstützung oder Andeutungen zur Verbreitung zu " + - "illegalen Daten, Inhalten und Links jeglicher Art.
    Dies betrifft ausdrücklich jede " + - "erdenkliche Form, so zB die Nutzung von Nicks wie aj-user^splintercell vor dem offiziellen " + - "Releasetermin, VHosts, Quit-Messages, Chan-Notices und was es noch so alles gibt.

    " + - "
  2. Keine Frage \"ob man fragen darf\". Keine Metafragen. Keine andauernden " + - "Wiederholungen. (=Spamm)
    Dieser Channel ist zu einem guten Teil dazu da" + - ", um den Nutzern Unterstützung anzubieten, und um dem Entwickler Rü" + - "ckmeldungen zu geben, d.h. das Fragen bezüglich Applejuice oder Fehlerreports " + - "ausdrücklich erwünscht sind. Frage dennoch freundlich, denn der Channel " + - "garantiert natürlich keine Support. Fragen der Art \"Ist XYZ besser als " + - "Applejuice?\" oder \"Hast du von XYZ Ahnung?\" sind letzlich immer subjektiv zu " + - "beantworten. Versuche deshalb deine Fragen so exakt und zielgerichtet wie mö" + - "glich zu stellen. Auch das ständige Wechseln des Nickname ist nicht erwünscht. Wozu gibt es /away.

    " + - "
  3. Kein Spamm, keine Werbung, keine Floods, und schon gar kein \"Cracking\" !
    " + - "Jeglicher Spamm ist nicht erwünscht: Mp3-Scripte, Onjoin-Spamm, " + - "Ontext-Spamm usw. Es sind keine Channel-CTCPs erwünscht. Werbung in jeglicher " + - "Form ist nicht erwünscht. Übermässige und sinnlose Nutzung von Farbcodes wird " + - "als Spamm betrachtet. Das Verteilen von viralem/lethalen Code jeglicher Art " + - "ist verboten und wird verfolgt!

    " + - "
  4. Keine Beleidigungen. Verhalte und unterhalte dich wie von Angesicht zu " + - "Angesicht.
    Es gelten die gleichen sozialen Verhaltensgrundregeln wie " + - "im normalem Leben. Das schliesst die demokratische Hierarchie des IRC ein " + - "gelegentlicher Streit kann im Querry ausgetragen werden. Beleidigung und " + - "auschliessliche Nutzung von Fäkalsprache werden nicht toleriert.

    " + - "
  5. Keine Admin/Op/halfOp Betteleien, keine Querries an die Admins/OPs/" + - "halfOPs ohne Einverständnis. Keine Bots ohne Einverständnis.

 

" + - "

Die Anweisungen der Admins, Ops und HalfOPs sind zu " + - "befolgen. Normalerweise macht dich ein netter Mensch auf deinen Regelverstoss " + - "aufmerksam, da du offensichtlich nicht nach Betreten des Channels die " + - "Chanrules gelesen hast. Solltest du dennoch nicht auf die Hinweise achten, " + - "hast du dein Anwesenheitsrecht verwirkt. Auf eingeschaltetes Auto-Rejoin nach " + - "Kick wird mit Ban reagiert, da Auto-Rejoin den Sinn eines Kick untergräbt.

" + - "

Sollte ein \"klärendes Gespräch\" per Query auch nur zu " + - "einem Ban geführt haben, und das bereitet dir schlaflose Nächte, dann " + - "solltest du deinen Umgangston überdenken. Wende dich in diesem Fall ans Forum. Und nun " + - "viel Spass im IRC:)

"+ - "

Diesen Dialog kannst Du über Optionen->Plugins->IrcPlugin deaktivieren.

"; -} \ No newline at end of file diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/SortedListModel.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/SortedListModel.java deleted file mode 100644 index aafca183..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/SortedListModel.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.util.ArrayList; -import java.util.Comparator; - -import javax.swing.AbstractListModel; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/SortedListModel.java,v 1.15 2009/01/12 10:09:19 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class SortedListModel extends AbstractListModel -{ - private ArrayList model = new ArrayList(); - private StringComparator comparator = new StringComparator(); - - public SortedListModel() - { - } - - public int getSize() - { - return model.size(); - } - - public User[] getValues() - { - return (User[]) model.toArray(new User[model.size()]); - } - - public synchronized Object getElementAt(int index) - { - if(index < model.size()) - { - return model.toArray()[index]; - } - else - { - return null; - } - } - - public synchronized void add(User user) - { - if(model.add(user)) - { - fireIntervalAdded(this, 0, getSize()); - } - } - - public synchronized void clear() - { - model.clear(); - fireIntervalRemoved(this, 0, getSize()); - } - - public boolean contains(Object element) - { - return model.contains(element); - } - - public synchronized boolean remove(User user) - { - boolean removed = model.remove(user); - - if(removed) - { - fireIntervalRemoved(this, 0, getSize()); - } - - return removed; - } - - public void fireIntervalAdded(Object source, int index0, int index1) - { - super.fireIntervalAdded(source, index0, index1); - reorder(); - } - - public void fireIntervalRemoved(Object source, int index0, int index1) - { - super.fireIntervalRemoved(source, index0, index1); - reorder(); - } - - public int getOpCount() - { - int ops = 0; - - for(int i = 0; i < model.size(); i++) - { - if((model.get(i)).isAdmin() || (model.get(i)).isOp() || (model.get(i)).isHalfop()) - { - ops++; - } - } - - return ops; - } - - public void reorder() - { - int n = model.size(); - - for(int i = 0; i < n - 1; i++) - { - int k = i; - - for(int j = i + 1; j < n; j++) - { - if(comparator.compare(model.get(j), model.get(k)) < 0) - { - k = j; - } - } - - User tmp = model.get(i); - - model.set(i, model.get(k)); - model.set(k, tmp); - } - - this.fireContentsChanged(this, 0, getSize()); - } - - private class StringComparator implements Comparator - { - public int compare(Object o1, Object o2) - { - if(o1.getClass() == User.class && o2.getClass() == User.class) - { - int mods = 0; - - try - { - mods = compareMods((User) o1, (User) o2); - } - catch(StringIndexOutOfBoundsException saoobE) - { - mods = 0; - } - - if(mods != 0) - { - return mods; - } - else - { - return (((User) o1).getName()).compareToIgnoreCase(((User) o2).getName()); - } - } - else - { - if(o1.hashCode() == o2.hashCode()) - { - return 0; - } - else if(o1.hashCode() <= o2.hashCode()) - { - return -1; - } - else - { - return 1; - } - } - } - - private int compareMods(User mod1, User mod2) - { - if(mod1.getRechteAsInt() == mod2.getRechteAsInt()) - { - return 0; - } - else if(mod1.getRechteAsInt() > mod2.getRechteAsInt()) - { - return -1; - } - else - { - return 1; - } - } - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/User.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/User.java deleted file mode 100644 index 182cf2ad..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/User.java +++ /dev/null @@ -1,81 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -public class User { - public static final int NOTHING = 0; - public static final int VOICE = 1; - public static final int HALFOP = 2; - public static final int OPERATOR = 4; - public static final int ADMINISTRATOR = 8; - - private String name; - - private int status = 0; - private boolean admin = false; - private boolean op = false; - private boolean halfop = false; - private boolean voice = false; - - public User(String name) { - this.name = name; - } - public boolean isAdmin() { - return admin; - } - - public void setAdmin(boolean enable) { - admin = enable; - } - - public boolean isHalfop() { - return halfop; - } - - public void setHalfop(boolean enable) { - halfop = enable; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isOp() { - return op; - } - - public void setOp(boolean enable) { - op = enable; - } - - public boolean isVoice() { - return voice; - } - - public void setVoice(boolean enable) { - voice = enable; - } - - public int getRechteAsInt(){ - int status = 0; - if (admin){ - status += ADMINISTRATOR; - } - if (op){ - status += OPERATOR; - } - if (halfop){ - status += HALFOP; - } - if (voice){ - status += VOICE; - } - return status; - } - - public String toString(){ - return name; - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserListCellRenderer.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserListCellRenderer.java deleted file mode 100644 index fa676d87..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserListCellRenderer.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.Component; - -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -import de.applejuicenet.client.shared.IconManager; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserListCellRenderer.java,v 1.12 2009/01/07 15:21:33 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class UserListCellRenderer extends JLabel implements ListCellRenderer -{ - public UserListCellRenderer() - { - setOpaque(true); - } - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) - { - setFont(list.getFont()); - if(value != null) - { - User user = (User) value; - - setText(user.getName()); - if(isSelected) - { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } - else - { - setForeground(list.getForeground()); - setBackground(list.getBackground()); - } - - if(user.isAdmin()) - { - setIcon(IconManager.getInstance().getIcon("irc_red", true, this.getClass())); - setToolTipText("Administrator"); - } - else if(user.isOp()) - { - setIcon(IconManager.getInstance().getIcon("irc_blue", true, this.getClass())); - setToolTipText("Operator"); - } - else if(user.isHalfop()) - { - setIcon(IconManager.getInstance().getIcon("irc_green", true, this.getClass())); - setToolTipText("Half-Operator"); - } - else if(user.isVoice()) - { - setIcon(IconManager.getInstance().getIcon("irc_yellow", true, this.getClass())); - setToolTipText("Voice"); - } - else - { - setIcon(null); - setToolTipText(null); - } - } - - return this; - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserPanel.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserPanel.java deleted file mode 100644 index ae564bfa..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserPanel.java +++ /dev/null @@ -1,288 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.MutableAttributeSet; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.start.HyperlinkAdapter; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/UserPanel.java,v 1.13 2005/01/21 16:19:42 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ - -public class UserPanel - extends JPanel - implements ActionListener { - private String name; - private final JTextPane textArea = new JTextPane(); - private StyledDocument document = (StyledDocument) textArea - .getStyledDocument(); - - private final JTextField textField = new JTextField(); - private JTextField titleArea = new JTextField(); - private JButton closeButton = new JButton("X"); - private XdccIrc parentPanel; - private boolean selected = false; - private boolean marked = false; - private JTabbedPane tabbedPane; - private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss"); - private Logger logger; - - public UserPanel(XdccIrc parentPanel, String name, JTabbedPane tabbedPane) { - logger = Logger.getLogger(getClass()); - this.name = name; - this.parentPanel = parentPanel; - this.tabbedPane = tabbedPane; - makePanel(); - } - - public void selected(){ - selected = true; - } - - public void unselected(){ - selected = false; - marked = false; - } - - public void setName(String name) { - this.name = name; - } - - public void setTitleArea(String title) { - titleArea.setText(""); - titleArea.setText(title); - } - - private void makePanel() { - setLayout(new BorderLayout()); - - textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - textField.addActionListener(this); - textArea.setEditorKit(new LinkEditorKit()); - textArea.setDocument(document); - textArea.setEditable(false); - textArea.addHyperlinkListener(new HyperlinkAdapter(textArea)); - - titleArea.setEditable(false); - - JScrollPane sp1 = new JScrollPane(textArea); - - sp1.setVerticalScrollBarPolicy(JScrollPane. - VERTICAL_SCROLLBAR_ALWAYS); - - add(sp1, BorderLayout.CENTER); - add(textField, BorderLayout.SOUTH); - add(makeNorth(), BorderLayout.NORTH); - } - - private MutableAttributeSet setLink(String sUrl, SimpleAttributeSet attributes) { - MutableAttributeSet a = new SimpleAttributeSet(attributes); - try { - if (!sUrl.toLowerCase().startsWith(ChannelPanel.HTTP_IDENTIFIER)){ - sUrl = ChannelPanel.HTTP_IDENTIFIER + sUrl; - } - URL url = new URL(sUrl); - a.addAttribute(LinkEditorKit.LINK, new URL(sUrl)); - } catch (Exception e) { - // nothing to do - } - a.addAttribute(StyleConstants.Bold, Boolean.TRUE); - a.addAttribute(StyleConstants.Underline, Boolean.TRUE); - return a; - } - - private Box makeNorth() { - Box northBox = Box.createHorizontalBox(); - // let's add actions - closeButton.addActionListener(this); - northBox.add(closeButton); - northBox.add(titleArea); - return northBox; - } - - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - - // let's take care of textField - if (source == textField) { - String message = textField.getText(); - - // let's send to the server - if (message.startsWith("/")) { - // A command - if (message.toLowerCase().compareTo("/ajstats") == 0 || message.toLowerCase().compareTo("/ajversinfo") == 0 - || message.toLowerCase().compareTo("/ajoptionsinfo") == 0) { - // todo - /* - long currentTime = System.currentTimeMillis(); - if (message.toLowerCase().compareTo("/ajstats") == 0){ - String text = AppleJuiceClient.getAjFassade().getInstance().getStats().substring(3); - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + text); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + - text); - } - else if (message.toLowerCase().compareTo("/ajversinfo") == 0) { - String text = ApplejuiceFassade.getInstance().getVersionInformation().substring(3); - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + text); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + - text); - } - else if (message.toLowerCase().compareTo("/ajoptionsinfo") == 0) { - String text = ApplejuiceFassade.getInstance().getOptionsInformation().substring(3); - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + text); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + - text); - } - */ - } - else if(message.toLowerCase().startsWith("/ajform=")){ - // todo - /* - String text = ApplejuiceFassade.getInstance().getFormatedStats(message.substring(8)).substring(3); - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + text); - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + - text); - */ - } - else{ - parentPanel.analyzeCommand(message); - } - textField.setText(""); - } - else { - // A normal private message to send to the user - parentPanel.parseSendToCommand("PRIVMSG " + name + " :" + message); - - // let's update textArea - updateTextArea(parentPanel.formatNickname("<" + parentPanel.getNickname() + "> ") + - textField.getText()); - resetTextField(); - } - } - else if (source == closeButton) { - parentPanel.closeChannel(parentPanel.getTabbedPane(), name); - } - } - - public void resetTextField() { - textField.setText(""); - } - - public void updateTextArea(String message) { - int oldCaretPosition = textArea.getCaretPosition(); - String zeit = dateFormatter.format(new Date(System. - currentTimeMillis())); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - StyleConstants.setBackground(attributes, Color.WHITE); - StyleConstants.setForeground(attributes, Color.BLACK); - Document doc = textArea.getDocument(); - try { - doc.insertString(doc.getLength(), "[" + zeit + "]\t", attributes); - while (message.toLowerCase().indexOf(ChannelPanel.HTTP_IDENTIFIER) != -1 || - message.toLowerCase().indexOf(ChannelPanel.WWW_IDENTIFIER) != -1){ - String httpIdentifier; - int indexHttp = message.toLowerCase().indexOf(ChannelPanel.HTTP_IDENTIFIER); - int indexWww = message.toLowerCase().indexOf(ChannelPanel.WWW_IDENTIFIER); - if (indexHttp == -1){ - httpIdentifier = ChannelPanel.WWW_IDENTIFIER; - } - else if (indexWww == -1){ - httpIdentifier = ChannelPanel.HTTP_IDENTIFIER; - } - else{ - if (indexWww == indexHttp + ChannelPanel.HTTP_IDENTIFIER.length()){ - httpIdentifier = ChannelPanel.HTTP_IDENTIFIER; - } - else{ - httpIdentifier = ChannelPanel.WWW_IDENTIFIER; - } - } - - doc.insertString(doc.getLength(), - message.substring(0, - message.toLowerCase().indexOf(httpIdentifier)), - attributes); - message = message.substring(message.toLowerCase().indexOf(httpIdentifier)); - int index = message.indexOf(" "); - int index2 = message.indexOf(">"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf(")"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf("]"); - if (index2 != -1 && index2 < index){ - index = index2; - } - index2 = message.indexOf("}"); - if (index2 != -1 && index2 < index){ - index = index2; - } - if (index != -1){ - doc.insertString(doc.getLength(), message.substring(0, index), - setLink(message.substring(0, index), attributes)); - message = message.substring(index); - } - else{ - doc.insertString(doc.getLength(), message, setLink(message, attributes)); - message = ""; - } - } - doc.insertString(doc.getLength(), message + "\n", attributes); - } - catch (BadLocationException ex) { - if (logger.isEnabledFor(Level.ERROR)){ - logger.error("Fehler im IrcPlugin", ex); - } - } - if (!selected && !marked){ - marked = true; - for (int i = 0; i < tabbedPane.getTabCount(); i++) { - Object tab = tabbedPane.getComponentAt(i); - if (tab == this) { - tabbedPane.setForegroundAt(i, Color.GREEN); - } - } - } - int newCaretPosition = textArea.getDocument().getLength(); - if (newCaretPosition != oldCaretPosition) { - textArea.setCaretPosition(newCaretPosition); - } - } - - public void userQuits(String nick){ - updateTextArea("<--- QUIT: " + nick); - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/XdccIrc.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/XdccIrc.java deleted file mode 100644 index 1cbc9bd6..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/XdccIrc.java +++ /dev/null @@ -1,1725 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.InterruptedIOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -import java.net.Socket; -import java.net.SocketException; - -import java.util.Random; -import java.util.StringTokenizer; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.shared.IconManager; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/XdccIrc.java,v 1.37 2009/01/12 10:09:19 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class XdccIrc extends JPanel -{ - private JButton connectButton; - private JButton cancelButton; - private Logger logger; - private Thread ircWorker; - private String host = "irc.devStaff.net"; - private int port = 6667; - private final String STANDARD_CHANNEL = "#applejuice"; - private JTabbedPane tabbedPane; - private String nickname; - private String realname; - - // Action to join a Channel - private JButton joinChannelAction; - private JButton createConnection; - private JButton changeNickAction; - private JButton newUserAction; - private String connectionInfo = "Connection Info"; - private String nicknameString = "Enter nickname"; - private String channelNameString = "Enter nickname"; - private String verbinden; - private String trennen; - private IrcPlugin parent; - private JDialog dialog; - private JTextField nickJTextField1; - private Socket chatSocket; - private BufferedReader fromServer; - private PrintWriter toServer; - private AppleJuiceDialog theApp = AppleJuiceDialog.getApp(); - private DisconnectActionListener disconnectActionListener = new DisconnectActionListener(); - private ConnectActionListener connectActionListener = new ConnectActionListener(); - private boolean doJoin = false; - private boolean first = true; - - public XdccIrc(IrcPlugin parent) - { - this.parent = parent; - logger = Logger.getLogger(getClass()); - try - { - setLayout(new BorderLayout()); - IconManager im = IconManager.getInstance(); - - createConnection = new JButton("Connect"); - createConnection.setIcon(im.getIcon("irc_login", true, this.getClass())); - createConnection.addActionListener(connectActionListener); - newUserAction = new JButton("Talk Private"); - newUserAction.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - newUser(); - } - }); - joinChannelAction = new JButton("Join a Channel"); - joinChannelAction.setIcon(im.getIcon("irc_chan", true, this.getClass())); - joinChannelAction.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - joinChan(); - } - }); - changeNickAction = new JButton("Change nick"); - changeNickAction.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - changeNick(); - } - }); - - connectButton = new JButton("Connect"); - cancelButton = new JButton("Cancel"); - - tabbedPane = createTabbedPane(); - tabbedPane.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - Object selected = tabbedPane.getSelectedComponent(); - - for(int i = 0; i < tabbedPane.getTabCount(); i++) - { - Object tab = tabbedPane.getComponentAt(i); - - if(tab == selected) - { - tabbedPane.setForegroundAt(i, Color.BLACK); - if(tab.getClass() == UserPanel.class) - { - ((UserPanel) tab).selected(); - } - else if(tab.getClass() == ChannelPanel.class) - { - ((ChannelPanel) tab).selected(); - } - } - else - { - if(tab.getClass() == UserPanel.class) - { - ((UserPanel) tab).unselected(); - } - else if(tab.getClass() == ChannelPanel.class) - { - ((ChannelPanel) tab).unselected(); - } - } - } - } - }); - - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - - // Let's create a ToolBar - panel1.add(createConnection); - panel1.add(newUserAction); - panel1.add(joinChannelAction); - panel1.add(changeNickAction); - - add(panel1, BorderLayout.NORTH); - add(tabbedPane, BorderLayout.CENTER); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - public IrcPlugin getPlugin() - { - return parent; - } - - public JTabbedPane getTabbedPane() - { - return tabbedPane; - } - - public void fireLanguageChanged() - { - verbinden = parent.getLanguageString("language.buttons.connect"); - trennen = parent.getLanguageString("language.buttons.disconnect"); - createConnection.removeActionListener(disconnectActionListener); - ActionListener[] listener = createConnection.getActionListeners(); - boolean found = false; - - for(int i = 0; i < listener.length; i++) - { - if(listener[i] == connectActionListener) - { - found = true; - createConnection.setText(verbinden); - break; - } - } - - if(!found) - { - createConnection.setText(trennen); - } - - newUserAction.setText(parent.getLanguageString("language.buttons.private")); - joinChannelAction.setText(parent.getLanguageString("language.buttons.join")); - changeNickAction.setText(parent.getLanguageString("language.buttons.nick")); - connectButton.setText(parent.getLanguageString("language.buttons.connect")); - cancelButton.setText(parent.getLanguageString("language.buttons.cancel")); - connectionInfo = parent.getLanguageString("language.title.newconnection"); - nicknameString = parent.getLanguageString("language.nick.newnick"); - channelNameString = parent.getLanguageString("language.channel.newchannel"); - for(int i = 0; i < tabbedPane.getComponentCount(); i++) - { - Object obj = tabbedPane.getComponent(i); - - if(obj.getClass() == ChannelPanel.class) - { - ((ChannelPanel) obj).fireLanguageChanged(); - } - } - } - - public void connectStartRegister() - { - try - { - connect(); - start(); - register(); - } - catch(IOException e) - { - tabUpdate("Init Window", "Connection refused to: " + host + ":" + port); - } - } - - private void makeConnectionInfo() - { - dialog = new JDialog(AppleJuiceDialog.getApp(), connectionInfo, true); - Container dialogContentPane = dialog.getContentPane(); - - // Ok, let's make the UserInfo - JPanel userInfo = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JLabel label1 = new JLabel("Nickname: "); - - nickJTextField1 = new JTextField(25); - nickJTextField1.addKeyListener(new KeyAdapter() - { - public void keyReleased(KeyEvent ke) - { - super.keyReleased(ke); - if(nickJTextField1.getText().length() != 0) - { - connectButton.setEnabled(true); - if(ke.getKeyChar() == KeyEvent.VK_ENTER) - { - connectButton.doClick(); - } - } - else - { - connectButton.setEnabled(false); - } - } - }); - userInfo.add(label1); - userInfo.add(nickJTextField1); - String nick = parent.getProperties().getProperty("nick"); - - if(nick != null) - { - nickname = nick; - } - - if(nickname != null && nickname.length() > 0) - { - nickJTextField1.setText(nickname); - } - else - { - Random random = new Random(); - - nickJTextField1.setText("ajPluginUser" + Integer.toString(random.nextInt(99999))); - } - - connectButton.setEnabled(true); - - JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - - // Action Listener - connectButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - - // OK, let's set the nickname if user has mentioned it - if(nickJTextField1.getText().length() == 0) - { - dialog.dispose(); - return; - } - - if(nickJTextField1.getText() != null) - { - setNickname(nickJTextField1.getText()); - } - - if(nickJTextField1.getText() == null) - { - Random random = new Random(); - - setNickname("ajPlugin" + Integer.toString(random.nextInt(99999))); - } - - connectButton.setEnabled(false); - createConnection.setEnabled(false); - connectStartRegister(); - createConnection.setText(trennen); - createConnection.removeActionListener(connectActionListener); - createConnection.addActionListener(disconnectActionListener); - createConnection.setEnabled(true); - dialog.dispose(); - } - }); - cancelButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if(dialog != null) - { - dialog.dispose(); - dialog = null; - } - } - }); - - buttonPanel.add(connectButton); - buttonPanel.add(cancelButton); - - dialogContentPane.add("North", userInfo); - dialogContentPane.add("South", buttonPanel); - - dialog.pack(); - dialog.setLocationRelativeTo(this); - dialog.setVisible(true); - } - - private void connect() throws IOException - { - doJoin = false; - first = true; - String propHost = parent.getProperties().getProperty("host"); - - if(propHost != null && propHost.length() > 0) - { - host = propHost; - } - - tabUpdate("Init Window", " Connecting to: " + host); - String propPort = parent.getProperties().getProperty("port"); - - if(propPort != null && propPort.length() > 0) - { - try - { - int tmpPort = Integer.parseInt(propPort); - - port = tmpPort; - } - catch(NumberFormatException nfE) - { - - //ungueltiger Port - } - } - - chatSocket = new Socket(host, port); - fromServer = new BufferedReader(new InputStreamReader(chatSocket.getInputStream())); - toServer = new PrintWriter(new OutputStreamWriter(chatSocket.getOutputStream())); - Component aComponent = tabbedPane.getComponentAt(0); - - ((InitPanel) aComponent).setTitleArea(nickname + " connected to: " + host + ":" + port); - } - - private void register() - { - realname = nickname; - - String propPass = parent.getProperties().getProperty("passwort"); - - if(propPass != null && propPass.length() > 0) - { - parseSendToCommand("PASS " + propPass); - } - - parseSendToCommand("NICK " + nickname); - parseSendToCommand("USER " + nickname + " 0 * :" + realname); - - new Thread() - { - public void run() - { - int count = 0; - - while(!isInterrupted() && count < 60) - { - try - { - sleep(500); - } - catch(InterruptedException ex) - { - interrupt(); - } - - if(doJoin) - { - if(toServer != null) - { - joinChannel(STANDARD_CHANNEL); - String onJoin = parent.getProperties().getProperty("onjoin"); - - if(onJoin != null && onJoin.length() > 0) - { - if(onJoin.charAt(0) == '/') - { - onJoin = onJoin.substring(1); - } - - parseSendToCommand(onJoin); - } - - String onJoinChannels = parent.getProperties().getProperty("channels"); - - if(onJoinChannels != null && onJoinChannels.length() > 0) - { - onJoinChannels(onJoinChannels); - } - } - - doJoin = false; - break; - } - - count++; - } - } - }.start(); - } - - private void onJoinChannels(String onJoinChannels) - { - String[] channels = onJoinChannels.split(","); - - for(int i = 0; i < channels.length; i++) - { - parseSendToCommand("JOIN " + channels[i]); - } - } - - // sends back your current nickname - public String getNickname() - { - return nickname; - } - - // setNickname sets your current nickname - public void setNickname(String nickname) - { - this.nickname = nickname; - } - - public void changeNickname(String oldNickname, String newNickname) - { - int totalTabs = tabbedPane.getTabCount(); - - for(int i = 0; i < totalTabs; i++) - { - Component aComponent = tabbedPane.getComponentAt(i); - - if(aComponent instanceof ChannelPanel) - { - - // Do channel processing - // At first remove the old nickname from the userNameBox - ((ChannelPanel) aComponent).renameUser(oldNickname, newNickname); - } - else if(aComponent instanceof UserPanel) - { - ; - - // Do UserPanel processing - // Actually this process was done in the NICK handling part.... - } - } - } - - public String formatNickname(String nickname) - { - return formatNickname(nickname, true); - } - - public String formatNickname(String nickname, boolean allignLeft) - { - int maxLength = 20; - String blank = ""; - int len = nickname.length(); - - if(len >= maxLength) - { - nickname = nickname.substring(0, maxLength); - } - else - { - for(int i = len; i < maxLength; i++) - { - nickname += " "; - } - } - - if(allignLeft) - { - return nickname + "\t"; - } - else - { - return "\t" + nickname; - } - } - - public String getRealname() - { - return realname; - } - - public void start() - { - if(ircWorker != null) - { - ircWorker.interrupt(); - ircWorker = null; - } - - ircWorker = new Thread() - { - public void run() - { - try - { - while(!isInterrupted()) - { - if(fromServer == null) - { - try - { - sleep(5000); - continue; - } - catch(InterruptedException e) - { - interrupt(); - } - } - - String line = null; - - try - { - line = fromServer.readLine(); - } - catch(InterruptedIOException se) - { - - // Timeout vom Socket - try - { - sleep(1500); - continue; - } - catch(InterruptedException e) - { - // nothing to do - line = null; - } - } - catch(SocketException se) - { - line = null; - } - - if(line != null) - { - parseFromServer(line); - } - else - { - // a null line indicates that our server has - // closed the connection - tabUpdate("Init Window", "Server closed the connection or network is fucked."); - closeAll(); - createConnection.setText(verbinden); - createConnection.removeActionListener(disconnectActionListener); - createConnection.addActionListener(connectActionListener); - createConnection.setEnabled(true); - break; - } - } - } - - catch(IOException e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - }; - ircWorker.start(); - } - - public void closeAll() - { - try - { - chatSocket.close(); - fromServer.close(); - toServer.close(); - } - catch(Exception e) - { - - //egal, weg ist weg... - } - - chatSocket = null; - fromServer = null; - toServer = null; - closeAllChannels(); - } - - public synchronized void parseFromServer(String lineFromServer) - throws IOException - { - myParser parser = new myParser(lineFromServer); - String command = parser.getCommand(); - - if(command.equals("PING") && first) - { - first = false; - parseSendToCommand("PONG :" + parser.getTrailing()); - doJoin = true; - } - else if(command.equals("MODE") && first) - { - doJoin = true; - first = false; - } - else if(command.equals("JOIN")) - { - String channelName = parser.getTrailing(); - - if(channelName.startsWith("#")) - { - channelName = channelName.substring(1); - int indexOfChannel = findTab(tabbedPane, "#" + channelName); - - if(indexOfChannel == -1) - { // Channel Tab doesn't exist - ChannelPanel channel = addChannel(tabbedPane, channelName); - - indexOfChannel = findTab(tabbedPane, "#" + channelName); - tabbedPane.setSelectedIndex(indexOfChannel); - channel.updateTextArea("*** Now talking in: " + parser.getTrailing()); - } - else - { // channelName tab exists! - ChannelPanel channel = (ChannelPanel) tabbedPane.getComponentAt(indexOfChannel); - - channel.updateTextArea("---> JOIN: " + parser.getNick() + " (" + parser.getUser() + "@" + parser.getHost() + ")"); - channel.updateUserArea(parser.getNick(), "add"); - } - } - } - else if(command.equals("PRIVMSG")) - { - - // handle PRIVMSG - String destination = parser.getMiddle(); - - if(destination.startsWith("#")) - { - - // it's a channel! - String channelName = destination.substring(1); - - // MSG Received....! - int indexOfChannel = findTab(tabbedPane, destination); - - if(indexOfChannel != -1) - { // A connection/tab already exists! - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - String trailing; - String nick; - - nick = parser.getNick(); - trailing = parser.getTrailing(); - if(trailing.indexOf(1) != -1) - { //is this a CTCP - //remove \001 from Beginning and End of CTCP msg - trailing = trailing.substring(1, trailing.length() - 1); - String message = trailing.replaceFirst("ACTION", nick); - - ((ChannelPanel) aComponent).updateTextArea("* " + message); - } - else if(nick.equals(nickname)) - { - - //((ChannelPanel)aComponent).textArea.setDisabledTextColor(new Color(255,0,0)); - ((ChannelPanel) aComponent).updateTextArea(formatNickname("<" + nick + "> ") + trailing); - } - else - { - - //((ChannelPanel)aComponent).textArea.setDisabledTextColor(new Color(0,0,255)); - ((ChannelPanel) aComponent).updateTextArea(formatNickname("<" + nick + "> ") + trailing); - } - } - } - else - { // A connection/tab doesn't exists, so create one! - ChannelPanel channel = addChannel(tabbedPane, channelName); - - channel.updateTextArea(formatNickname("<" + parser.getNick() + "> ") + "> " + parser.getTrailing()); - } - } //if (destination.startsWith("#")) - else - { //if (!destination.equalsIgnoreCase(getNickname())) - // it's from a user - int indexOfUser = findTab(tabbedPane, parser.getNick()); - - if(indexOfUser == -1) - { - UserPanel userPanel = addUser(tabbedPane, parser.getNick()); //if tab doesnt exist - // Add the real username@hostname in title of tabbedPane - - userPanel.setTitleArea(parser.getNick() + "!" + parser.getUser() + "@" + parser.getHost()); - } - - indexOfUser = findTab(tabbedPane, parser.getNick()); - - if(indexOfUser != -1) - { // A user connection/tab already exists! - Component aComponent = tabbedPane.getComponentAt(indexOfUser); - UserPanel userPanel = (UserPanel) aComponent; - - if(aComponent instanceof UserPanel) - { - String ctcpCommand; - String trailing; - char firstOne = 1; - - trailing = parser.getTrailing(); - if(trailing.indexOf(1) != -1) - { //is this a CTCP - if(trailing.indexOf(" ") != -1) - { - ctcpCommand = trailing.substring(1, trailing.indexOf(" ")); - } - else - { - ctcpCommand = trailing.substring(1, trailing.indexOf(1, 2)); - } - - if(ctcpCommand.equalsIgnoreCase("PING")) - { - parseSendToCommand("NOTICE " + parser.getNick() + " " + trailing); - } - - else if(ctcpCommand.equalsIgnoreCase("VERSION")) - { - String versionReply = "NOTICE " + parser.getNick() + " " + firstOne + ctcpCommand + - " Using ajPlugin IRC:v" + parent.getVersion() + ":Java" + firstOne; - - parseSendToCommand(versionReply); - - } - - userPanel.updateTextArea(formatNickname("��� � CTCP " + ctcpCommand + " received from " + - parser.getNick())); - } // if (trailing.indexOf(1) != -1) //is this a CTCP - - else - { // regular privmsg - userPanel.updateTextArea(formatNickname("<" + parser.getNick() + "> ") + trailing); - } - } //if (aComponent instanceof UserPanel) - } // if (indexOfUser != -1) - } // else (Msg from a user..) - } //else if (command.equals("PRIVMSG")) - - else if(command.equals("PART")) - { - - // Let's grab the channel name - String channelName = parser.getParams(); - int index = channelName.indexOf("#"); - int index2 = channelName.indexOf(":"); - - if(index2 != -1) - { - channelName = channelName.substring(index, index2 - 1); - } - else - { - channelName = channelName.substring(index); - } - - if(channelName.startsWith("#")) - { - channelName = channelName.substring(1); - - int indexOfChannel = findTab(tabbedPane, "#" + channelName); - - if(indexOfChannel != -1) - { // Tab doesn't exist. Do nothing - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - ((ChannelPanel) aComponent).updateTextArea("<--- PART: " + parser.getNick()); - ((ChannelPanel) aComponent).updateUserArea(parser.getNick(), "remove"); - } - - // Ok, let's remove the tab if the user who left the channel is you - if(parser.getNick().equals(getNickname())) - { - tabbedPane.removeTabAt(indexOfChannel); - } - } - } - } - else if(command.equals("QUIT")) - { - - //Find what channel user is on and direct Quit msg to correct channel(s) - boolean hide = parser.getTrailing().toLowerCase().indexOf("z:lined") != -1; - int index = findTab(tabbedPane, parser.getNick()); - - if(index != -1) - { - Object tab = tabbedPane.getComponentAt(index); - - if(tab.getClass() == UserPanel.class) - { - ((UserPanel) tab).userQuits(parser.getNick()); - } - } - - for(int i = 1; i < tabbedPane.getTabCount(); i++) - { - Object tab = tabbedPane.getComponentAt(i); - - if(tab.getClass() == ChannelPanel.class) - { - ((ChannelPanel) tab).userQuits(parser.getNick(), hide); - } - } - - if(hide) - { - tabUpdate("Init Window", parser.getNick() + " has quit (" + parser.getTrailing() + ")"); - } - } - else if(command.equals("NICK")) - { - - // handle NICK --- When a user changes its nickname - int index = findTab(tabbedPane, parser.getNick()); - - if(index != -1) - { - // setting the user tab title to changed nickname - tabbedPane.setTitleAt(index, parser.getTrailing()); - - // Let's change the name of the UserPanel alsow - UserPanel temp = (UserPanel) tabbedPane.getComponentAt(index); - - temp.setName(parser.getTrailing()); - } - - if(parser.getNick().equalsIgnoreCase(getNickname())) - { - setNickname(parser.getTrailing()); - } - - // When a user changes his/her name, his name in every - // UserPanel or ChannelPanel should be changed too. - // So, we are doing it now --- here - String oldNickname = parser.getNick(); - String newNickname = parser.getTrailing(); - - changeNickname(oldNickname, newNickname); - } - else if(command.equals("NOTICE")) - { - tabUpdate("Init Window", "NOTICE FROM: " + parser.getNick() + " ---> " + parser.getTrailing()); - Object reiter; - - for(int i = 1; i < tabbedPane.getTabCount(); i++) - { - reiter = tabbedPane.getComponentAt(i); - if(reiter.getClass() == ChannelPanel.class) - { - ((ChannelPanel) reiter).updateTextArea(formatNickname(">" + parser.getNick() + "< ") + parser.getTrailing()); - } - } - } - else if(command.equals("KICK")) - { - - // handle KICK - String kickedNick; - String kickedChannel; - String temp; - - temp = parser.getMiddle(); - kickedChannel = temp.substring(0, temp.indexOf(" ")); - kickedNick = temp.substring(temp.indexOf(" ") + 1, temp.length()); - int indexOfChannel = findTab(tabbedPane, kickedChannel); - ChannelPanel channel = (ChannelPanel) tabbedPane.getComponentAt(indexOfChannel); - - if(!(kickedNick.equals(getNickname()))) - { - channel.updateTextArea("<- KICK: " + kickedNick + " by " + parser.getNick() + " (" + parser.getTrailing() + ")"); - channel.updateUserArea(kickedNick, "remove"); - } - else - { // You have been kicked... - tabbedPane.removeTabAt(indexOfChannel); - tabUpdate("Init Window", - "You have been kicked from " + kickedChannel + " by " + parser.getNick() + " because " + - parser.getTrailing()); - } - } - else if(command.equals("001") || // RPL_WELCOME - command.equals("002") || // RPL_YOURHOST - command.equals("003") || // RPL_CREATED - command.equals("004")) - { // RPL_MYINFO - // successful registration - tabUpdate("Init Window", parser.getTrailing()); - } - else if(command.equals("250") || command.equals("251") || command.equals("253") || command.equals("255") || - command.equals("256") || command.equals("257") || command.equals("258") || command.equals("259") || - command.equals("265") || command.equals("266")) - { - tabUpdate("Init Window", parser.getTrailing()); - } - - //252 & 254 = num IRCOP and Total Channels - else if(command.equals("252")) - { - String numThing; - - numThing = lineFromServer.substring(lineFromServer.indexOf("252") + 5 + nickname.length(), lineFromServer.indexOf(":", 2)); - tabUpdate("Init Window", numThing + " " + parser.getTrailing()); - } - - else if(command.equals("254")) - { - String numThing; - - numThing = lineFromServer.substring(lineFromServer.indexOf("254") + 5 + nickname.length(), lineFromServer.indexOf(":", 2)); - tabUpdate("Init Window", numThing + " " + parser.getTrailing()); - } - - //channel full, invite only or need a key - else if(command.equals("471") || command.equals("473") || command.equals("475")) - { - String channel; - - channel = lineFromServer.substring(lineFromServer.indexOf("#"), lineFromServer.indexOf(":", 2)); - tabUpdate("Init Window", parser.getTrailing() + " (" + channel + ")"); - } - - /* else if (command.equals("371") || - command.equals("372") || - command.equals("374") || - command.equals("375") || - command.equals("376") - ) - { - tabUpdate("Init Window", "371-376 " + parser.getTrailing()); - tabUpdate("Init Window", "Skipping MOTD!"); - }*/ - else if(command.equals("311") // RPL_WHOISUSER - ) - { - - // Ok, let's see how we can process PROCESS - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - - //StringTokenizer st = new StringTokenizer(parser.getParams(), " "); - String whoNick = ""; - - //StringTokenizer st = new StringTokenizer(parser.getParams(), " "); - String whoUser = ""; - - //StringTokenizer st = new StringTokenizer(parser.getParams(), " "); - String whoHost = ""; - - //StringTokenizer st = new StringTokenizer(parser.getParams(), " "); - String whoMode = ""; - - //StringTokenizer st = new StringTokenizer(parser.getParams(), " "); - String whoRealName = ""; - - for(int i = 0; st.hasMoreTokens();) - { - String aToken = st.nextToken(); - - if(i == 1) - { - whoNick = aToken; - } - else if(i == 2) - { - whoUser = aToken; - } - else if(i == 3) - { - whoHost = aToken; - } - else if(i == 4) - { - whoMode = aToken; - } - else if(i == 5) - { - - //� v�rifier!!!!!!!!!!!!!! - String paramsWhois = parser.getParams(); - - whoRealName = paramsWhois.substring(paramsWhois.indexOf(aToken) + 1, paramsWhois.length()); - - //whoRealName = aToken.substring(1); - } - - i++; - } - - // Let's show the messages in the Init Window - tabUpdate("Init Window", "Whois info for " + whoNick); - tabUpdate("Init Window", " " + whoNick + "!" + whoUser + "@" + whoHost + " " + whoRealName); - } - else if(command.equals("312")) - { - String whoNick = ""; - String whoServer = ""; - String whoServerInfo = ""; - - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - - for(int i = 0; st.hasMoreTokens();) - { - String aToken = st.nextToken(); - - if(i == 1) - { - whoNick = aToken; - } - else if(i == 2) - { - whoServer = aToken; - } - else if(i == 3) - { - - //� v�rifier!!!!!!!!!!!!!! ainsi que whois realname - String paramsWhois = parser.getParams(); - - whoServerInfo = paramsWhois.substring(paramsWhois.indexOf(aToken) + 1, paramsWhois.length()); - - //whoServerInfo = aToken.substring(aToken.length()); - } - - i++; - } - - // Let's update the Init Window - tabUpdate("Init Window", " Server: " + whoServer + " " + whoServerInfo); - } - else if(command.equals("313")) - { - tabUpdate("Init Window", " Operator: " + lineFromServer); - } - else if(command.equals("317")) - { - String seconds = ""; - String trailing = ""; - - trailing = parser.getTrailing(); - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - - for(int i = 0; st.hasMoreTokens();) - { - String aToken = st.nextToken(); - - if(i == 2) - { - seconds = aToken; - break; - } - - i++; - } - - tabUpdate("Init Window", " Idle time: " + seconds + " " + trailing); - } - else if(command.equals("318")) - { - tabUpdate("Init Window", parser.getTrailing()); - } - else if(command.equals("319")) - { - tabUpdate("Init Window", " Channels: " + parser.getTrailing()); - } - else if(command.equals("301")) - { // RPL_AWAY - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - String awayNickname = ""; - - for(int i = 0; st.hasMoreTokens();) - { - String aToken = st.nextToken(); - - if(i == 1) - { - awayNickname = aToken; - break; - } - - i++; - } - - tabUpdate("Init Window", awayNickname + " is away for \"" + parser.getTrailing() + "\""); - } - else if(command.equals("305")) - { // RPL_UNAWAY - ; - } - - else if(command.equals("333")) - { // RPL_UNAWAY - ; - } - - // used or not ??????? - else if(command.equals("332") // RPL_TOPIC - ) - { - String topicChannelName = ""; - - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - - for(int i = 0; st.hasMoreTokens();) - { - String aToken = st.nextToken(); - - if(i == 1) - { - topicChannelName = aToken; - break; - } - - i++; - } - - int indexOfChannel = findTab(tabbedPane, topicChannelName); - - if(indexOfChannel != -1) - { - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - ((ChannelPanel) aComponent).setTitleArea(parser.getTrailing()); - } - } - } - else if(command.equals("TOPIC")) - { - String topicChannelName = ""; - - StringTokenizer st = new StringTokenizer(parser.getParams(), " \r\n"); - - if(st.hasMoreTokens()) - { - topicChannelName = st.nextToken(); - - } - - int indexOfChannel = findTab(tabbedPane, topicChannelName); - - if(indexOfChannel != -1) - { - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - ((ChannelPanel) aComponent).setTitleArea(parser.getTrailing()); - ((ChannelPanel) aComponent).updateTextArea("TOPIC: " + parser.getTrailing() + "(" + parser.getNick() + ")"); - } - } - } - else if(command.equals("353") // - ) - { - String channelName = parser.getMiddle(); - int index = channelName.lastIndexOf("#"); - - channelName = channelName.substring(index); - - // Find the tab of channelName - int indexOfChannel = findTab(tabbedPane, channelName); - - // If the channelName tab exists! - if(indexOfChannel != -1) - { - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - - // All the usernames are in trailing! - String trailing = parser.getTrailing(); - - // let's split those usernames with StringTokenizer - StringTokenizer st = new StringTokenizer(trailing, " \r\n"); - - // How many users are there? - int totalTokens = st.countTokens(); - - for(int i = 0; i < totalTokens; i++) - { - - // a username/nickname - String tempnickname = st.nextToken(); - - // Add that username to channelPanel's usernameBox - ((ChannelPanel) aComponent).updateUserArea(tempnickname, "add"); - } - } - } - else - { // channelName tab doesn't exist! - ; - } - } - - else if(command.equals("404")) - { - tabUpdate("Init Window", "ERROR: Cannot send msg to channel! " + lineFromServer); - } - - else if(command.equals("421")) - { - tabUpdate("Init Window", "ERROR: Command not found! " + lineFromServer); - } - - else if(command.equals("442")) - { - tabUpdate("Init Window", "ERROR: You're not on that channel! " + lineFromServer); - } - - else if(command.equals("443")) - { - tabUpdate("Init Window", "ERROR: User is already on that channel! " + lineFromServer); - } - - else if(command.equals("461")) - { - tabUpdate("Init Window", "ERROR: Need more params for this command! " + lineFromServer); - } - - else if(command.equals("482")) - { - tabUpdate("Init Window", "ERROR: You must be channel operator for this! " + lineFromServer); - } - - else if(command.equals("433")) - { - tabUpdate("Init Window", nickname + " already in use " + parser.getTrailing()); - - String newNickname; - - newNickname = JOptionPane.showInputDialog(nicknameString, nickname); - - if(newNickname != null) - { - nickname = newNickname; - Component aComponent = tabbedPane.getComponentAt(0); - - ((InitPanel) aComponent).setTitleArea(newNickname + " connected to: " + host + ":" + port); - parseSendToCommand("NICK " + newNickname); - } - } - else - { - if(lineFromServer.indexOf("MODE") != -1) - { - String nickCommand; - String modeReceiver; - String modeReceived; - String temp; - String channelsMode; - - //:UP^!UP@phpaj.de.vu MODE #applejuice +vvv ajPluginUser27667 ajPluginUser6848 ajPluginUser89142 - temp = lineFromServer.substring(1, lineFromServer.indexOf(" ")); - nickCommand = temp; - if(temp.indexOf("!") != -1) - { - nickCommand = temp.substring(0, temp.indexOf("!")); - } - - temp = lineFromServer.substring(lineFromServer.indexOf(" ", lineFromServer.indexOf(" ") + 1)); - temp = temp.substring(temp.indexOf(" ")); - - // User mode - if(temp.indexOf(":") != -1) - { - modeReceiver = temp.substring(0, temp.indexOf(":") - 1); - modeReceived = temp.substring(temp.indexOf(":") + 1); - tabUpdate("Init Window", nickCommand + " sets MODE: " + modeReceived + " " + modeReceiver); - } - - // Channel mode - else - { - channelsMode = temp.substring(1, temp.indexOf(" ", 1)); - modeReceived = temp.substring(temp.indexOf(" ", 1) + 1, temp.length()); - int indexOfChannel = findTab(tabbedPane, channelsMode); - - if(indexOfChannel != -1) - { - Component aComponent = tabbedPane.getComponentAt(indexOfChannel); - - if(aComponent instanceof ChannelPanel) - { - ChannelPanel channel = (ChannelPanel) aComponent; - - //MeineR sets MODE: +vvv bluna Biggestking ajPluginUser23249 - char plusMinus = modeReceived.charAt(0); - String tmp = modeReceived.substring(1, modeReceived.indexOf(" ")); - String names = modeReceived.substring(modeReceived.indexOf(" ") + 1); - String[] splits = names.split(" "); - - if((plusMinus == '-' || plusMinus == '+')) - { - char mode = modeReceived.charAt(1); - - if(mode == 'v' || mode == 'a' || mode == 'o' || mode == 'h') - { - for(int i = 0; i < splits.length; i++) - { - String name = splits[i]; - User[] users = channel.getUserNameList().getValues(); - - for(int x = 0; x < users.length; x++) - { - if(users[x].getName().equalsIgnoreCase(name)) - { - if(mode == 'v') - { - users[x].setVoice(plusMinus == '+'); - } - else if(mode == 'a') - { - users[x].setAdmin(plusMinus == '+'); - } - else if(mode == 'o') - { - users[x].setOp(plusMinus == '+'); - } - else if(mode == 'h') - { - users[x].setHalfop(plusMinus == '+'); - } - - channel.getUserNameList().reorder(); - break; - } - } - } - } - } - - channel.updateTextArea(nickCommand + " sets MODE: " + modeReceived); - } - } - } - } - else if(lineFromServer.indexOf(" 366 ") != -1) - { - ; - } - else - { - tabUpdate("Init Window", lineFromServer); - } - } - } - - private int findTab(final JTabbedPane tabbedPane, String title) - { - int totalTabs = tabbedPane.getTabCount(); - - for(int i = 0; i < totalTabs; i++) - { - String tabTitle = tabbedPane.getTitleAt(i); - - // Let's see whether tabbedPane title and title matches! - if(tabTitle.equalsIgnoreCase(title)) - { - return i; - } - } - - // Not found anything? Return -1 - return -1; - } - - private int tabUpdate(String tabTitle, String message) - { - int indexOfTab = findTab(tabbedPane, tabTitle); - - if(indexOfTab != -1) - { - Component aComponent = tabbedPane.getComponentAt(indexOfTab); - - if(aComponent.getClass() == ChannelPanel.class) - { - ((ChannelPanel) aComponent).updateTextArea(message); - } - else if(aComponent.getClass() == UserPanel.class) - { - ((UserPanel) aComponent).updateTextArea(message); - } - else if(aComponent.getClass() == InitPanel.class) - { - ((InitPanel) aComponent).updateTextArea(message); - } - } - - return indexOfTab; - } - - public void parseSendToCommand(String lineToServer) - { - - // At first let's see whether the connection is still alive or - // not. - if(toServer != null) - { - toServer.print(lineToServer + "\r\n"); - toServer.flush(); - if(lineToServer.toLowerCase().indexOf("join #" + STANDARD_CHANNEL) != -1) - { - String norules = parent.getProperties().getProperty("norules"); - - if(norules == null || norules.compareToIgnoreCase("true") != 0) - { - RulesDialog rulesDialog = new RulesDialog(AppleJuiceDialog.getApp(), true); - - rulesDialog.setVisible(true); - } - } - } - } - - private JTabbedPane createTabbedPane() - { - JTabbedPane tabbedPane = new JTabbedPane(); - - // Adding the init window - tabbedPane.add(new InitPanel(this), "Init Window"); - return tabbedPane; - } - - private void newUser() - { - String userName; - - userName = JOptionPane.showInputDialog(theApp, nicknameString, nickname); - - if(userName != null) - { - addUser(tabbedPane, userName); - } - } - - private void joinChan() - { - String channelName; - - channelName = JOptionPane.showInputDialog(theApp, channelNameString); - joinChannel(channelName); - } - - private void joinChannel(String channel) - { - if(channel != null) - { - if(channel.startsWith("#")) - { - tabUpdate("Init Window", "Trying to join: " + channel); - if(toServer != null) - { - parseSendToCommand("JOIN " + channel); - } - } - else - { - tabUpdate("Init Window", "Trying to join: #" + channel); - if(toServer != null) - { - parseSendToCommand("JOIN #" + channel); - } - } - } - else - { - tabUpdate("Init Window", "No channel name specified."); - } - } - - private void changeNick() - { - String newNickname; - - newNickname = JOptionPane.showInputDialog(theApp, nicknameString, nickname); - - if(newNickname != null) - { - if(newNickname.length() > 30) - { - newNickname = newNickname.substring(0, 30); - } - - if(toServer != null) - { - Component aComponent = tabbedPane.getComponentAt(0); - - ((InitPanel) aComponent).setTitleArea(newNickname + " connected to: " + host + ":" + port); - parseSendToCommand("NICK " + newNickname); - nickname = newNickname; - } - } - } - - private void whois() - { - String whoisNickname; - - whoisNickname = JOptionPane.showInputDialog(theApp, nicknameString); - - if(whoisNickname != null && toServer != null) - { - parseSendToCommand("WHOIS " + whoisNickname); - } - } - - public UserPanel addUser(final JTabbedPane tabbedPane, String name) - { - UserPanel userPanel = new UserPanel(this, name, tabbedPane); - - tabbedPane.add(userPanel, name); - tabbedPane.revalidate(); - - return userPanel; - } - - private ChannelPanel addChannel(final JTabbedPane tabbedPane, String name) - { - ChannelPanel channel; - - if(name.startsWith("#")) - { - channel = new ChannelPanel(this, name, tabbedPane); - tabbedPane.add(channel, name); - } - else - { - channel = new ChannelPanel(this, "#" + name, tabbedPane); - tabbedPane.add(channel, "#" + name); - } - - tabbedPane.revalidate(); - - return channel; - } - - public JTabbedPane closeChannel(final JTabbedPane tabbedPane, String name) - { - int index; - - index = tabbedPane.indexOfTab(name); - - if(index != -1 && index >= 0) - { - tabbedPane.removeTabAt(index); - } - - tabbedPane.revalidate(); - return tabbedPane; - } - - public JTabbedPane closeAllChannels() - { - int count = tabbedPane.getTabCount(); - - for(int i = count - 1; i > 0; i--) - { - tabbedPane.removeTabAt(i); - } - - tabbedPane.revalidate(); - return tabbedPane; - } - - public void analyzeCommand(String message) - { - CommandInterpreter cmdI = new CommandInterpreter(message); - - if(cmdI.getCommand().equals("JOIN")) - { - parseSendToCommand(cmdI.getCommand() + " " + cmdI.getParam1() + " " + cmdI.getMessage()); - } - else if(cmdI.getCommand().equals("PART") || cmdI.getCommand().equals("LEAVE")) - { - parseSendToCommand("PART " + cmdI.getParam1() + " :" + cmdI.getMessage()); - } - else if(cmdI.getCommand().equals("QUIT")) - { - parseSendToCommand("QUIT :" + cmdI.getParam1() + " " + cmdI.getMessage()); - } - else if(cmdI.getCommand().equals("WHOIS")) - { - parseSendToCommand("WHOIS " + cmdI.getParam1() + " " + cmdI.getMessage()); - } - else if(cmdI.getCommand().equals("MSG")) - { - parseSendToCommand("PRIVMSG " + cmdI.getParam1() + " :" + cmdI.getMessage()); - } - else if(cmdI.getCommand().equals("CTCP")) - { - parseSendToCommand("PRIVMSG " + cmdI.getParam1() + " :" + 1 + cmdI.getMessage() + 1); - } - else if(cmdI.getCommand().equals("NICK")) - { - parseSendToCommand("NICK " + cmdI.getParam1()); - } - else if(cmdI.getCommand().equals("TOPIC")) - { - if(cmdI.getMessage().equals("")) - { - parseSendToCommand(cmdI.getCommand() + " " + cmdI.getParam1() + " :"); - } - else - { - parseSendToCommand(cmdI.getCommand() + " " + cmdI.getParam1() + " :" + cmdI.getMessage()); - } - } - else - { - parseSendToCommand(cmdI.getCommand() + " :" + cmdI.getParam1() + " " + cmdI.getMessage()); - } - } - - private class ConnectActionListener implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - makeConnectionInfo(); - } - } - - - private class DisconnectActionListener implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - createConnection.setEnabled(false); - createConnection.setText(verbinden); - createConnection.removeActionListener(disconnectActionListener); - createConnection.addActionListener(connectActionListener); - closeAll(); - createConnection.setEnabled(true); - tabUpdate("Init Window", "Disconnected from: " + host + ":" + port); - } - } -} diff --git a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/myParser.java b/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/myParser.java deleted file mode 100644 index 00a30d90..00000000 --- a/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/myParser.java +++ /dev/null @@ -1,152 +0,0 @@ -package de.applejuicenet.client.gui.plugins.ircplugin; - -import java.util.*; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/ircplugin/src/de/applejuicenet/client/gui/plugins/ircplugin/myParser.java,v 1.4 2004/10/15 13:34:47 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ - -public class myParser { - String line; - String prefix = "", - command = "", - params = "", - middle = "", - trailing = "", - servername = "", - nick = "", - user = "", - host = ""; - - public myParser(String line) { - this.line = line; - initTags(); - } - - private void initTags() { - StringTokenizer st = new StringTokenizer(line, " \r\n"); - int totalTokens = st.countTokens(); - - if (line.startsWith(":") && totalTokens >= 3) - { - String temp = st.nextToken(); - int index = temp.indexOf(":"); - if (index != -1){ - prefix = temp.substring(index + 1); - } - - temp = st.nextToken(); - command = temp; - - temp = st.nextToken("\n"); - params = temp; - } - else if (!line.startsWith(":") && totalTokens >= 2) - { - String temp = st.nextToken(); - command = temp; - while (st.hasMoreTokens()){ - params = params + st.nextToken(); - } - } - } - - public String getPrefix() { - return prefix; - } - - public String getCommand() { - return command; - } - - public String getParams() { - return params; - } - - public String getServer() { - if (!prefix.equals("")) - { - int index = prefix.indexOf("!"); - if (index != -1) - { - String temp = prefix.substring(0, index); - servername = temp; - } - } - return servername; - } - - public String getNick() { - if (!prefix.equals("")) - { - int index = prefix.indexOf("!"); - if (index != -1) - { - String temp = prefix.substring(0, index); - nick = temp; - } - } - return nick; - } - - public String getUser() { - if (!prefix.equals("")) - { - int exMark = prefix.indexOf("!"); - int adMark = prefix.indexOf("@"); - if (exMark != -1 && adMark != -1 && (adMark > exMark)) - { - user = prefix.substring(exMark + 1, adMark); - } - } - return user; - } - - public String getHost() { - if (!prefix.equals("")) - { - int adMark = prefix.indexOf("@"); - if (adMark != -1 && adMark >= 0) - { - host = prefix.substring(adMark + 1); - } - } - return host; - } - - public String getTrailing() { - if (!params.equals("")) - { - int index = params.indexOf(":"); - if (index != -1 && index >= 0) - { - trailing = params.substring(index + 1); - } - } - return trailing; - } - - public String getMiddle() { - if (!params.equals("")) - { - int index = params.indexOf(":"); - if (index != -1 && index >= 0) - { - if (params.startsWith(" ") && index - 1 >= 1){ - middle = params.substring(1, index - 1); - } - else{ - middle = params.substring(0, index - 1); - } - } - } - return middle; - } -} diff --git a/AJClientGUI/plugin_src/jabber/icons/available.gif b/AJClientGUI/plugin_src/jabber/icons/available.gif deleted file mode 100644 index 7ae1d253..00000000 Binary files a/AJClientGUI/plugin_src/jabber/icons/available.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/icons/awk.gif b/AJClientGUI/plugin_src/jabber/icons/awk.gif deleted file mode 100644 index 3e0452e0..00000000 Binary files a/AJClientGUI/plugin_src/jabber/icons/awk.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/icons/icon.gif b/AJClientGUI/plugin_src/jabber/icons/icon.gif deleted file mode 100644 index f9d61f89..00000000 Binary files a/AJClientGUI/plugin_src/jabber/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/icons/offline.gif b/AJClientGUI/plugin_src/jabber/icons/offline.gif deleted file mode 100644 index 5257cc7e..00000000 Binary files a/AJClientGUI/plugin_src/jabber/icons/offline.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/lib/smack.jar b/AJClientGUI/plugin_src/jabber/lib/smack.jar deleted file mode 100644 index dfe9d842..00000000 Binary files a/AJClientGUI/plugin_src/jabber/lib/smack.jar and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/lib/smackx.jar b/AJClientGUI/plugin_src/jabber/lib/smackx.jar deleted file mode 100644 index 00eeeaeb..00000000 Binary files a/AJClientGUI/plugin_src/jabber/lib/smackx.jar and /dev/null differ diff --git a/AJClientGUI/plugin_src/jabber/plugin_properties.xml b/AJClientGUI/plugin_src/jabber/plugin_properties.xml deleted file mode 100644 index 692f5372..00000000 --- a/AJClientGUI/plugin_src/jabber/plugin_properties.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - <version value="1.0"/> - <author value="Maj0r"/> - <contact value="tkrall@tkl-soft.de"/> - <description value="Jabber-Plugin"/> - <istab value="true"/> - <classname value="de.applejuicenet.client.gui.plugins.jabber.JabberPlugin"/> - </general> -</root> diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberPlugin.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberPlugin.java deleted file mode 100644 index 2f404190..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberPlugin.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Map; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.SmackConfiguration; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.muc.MultiUserChat; - -import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; -import de.applejuicenet.client.gui.plugins.PluginConnector; -import de.applejuicenet.client.gui.plugins.jabber.control.IdentityController; -import de.applejuicenet.client.gui.plugins.jabber.control.MultiUserChatController; -import de.applejuicenet.client.gui.plugins.jabber.view.IdentityPanel; -import de.applejuicenet.client.gui.plugins.jabber.view.MultiUserChatListCellRenderer; -import de.applejuicenet.client.gui.plugins.jabber.view.RosterUserTreeCellRenderer; -import de.tklsoft.gui.controls.InvalidRule; -import de.tklsoft.gui.controls.ModifyableComponent; -import de.tklsoft.gui.controls.TKLPasswordField; -import de.tklsoft.gui.controls.TKLTextField; -import de.tklsoft.gui.controls.StatusHolder.STATUSFLAG; - -public class JabberPlugin extends PluginConnector -{ - private final String CMD_VERBINDEN = "Verbinden"; - private final String CMD_TRENNEN = "Trennen"; - private Logger logger; - private JButton connectButton = new JButton(CMD_VERBINDEN); - private TKLTextField user = new TKLTextField(15); - private TKLPasswordField passwort = new TKLPasswordField(); - private TKLTextField nickname = new TKLTextField(15); - private JTabbedPane tabbedPane = new JTabbedPane(); - private CardLayout registerLayout = new CardLayout(); - private JPanel registerPanel = new JPanel(registerLayout); - private XMPPConnection connection = null; - - public JabberPlugin(XMLValueHolder pluginsPropertiesXMLHolder, Map<String, XMLValueHolder> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - super(pluginsPropertiesXMLHolder, languageFiles, icon, availableIcons); - SmackConfiguration.setPacketReplyTimeout(20000); - RosterUserTreeCellRenderer.available = getAvailableIcon("available"); - RosterUserTreeCellRenderer.offline = getAvailableIcon("offline"); - RosterUserTreeCellRenderer.awk = getAvailableIcon("awk"); - - MultiUserChatListCellRenderer.moderator = getAvailableIcon("available"); - MultiUserChatListCellRenderer.voice = getAvailableIcon("offline"); - MultiUserChatListCellRenderer.owner = getAvailableIcon("awk"); - MultiUserChatListCellRenderer.member = getAvailableIcon("awk"); - - logger = Logger.getLogger(getClass()); - initGUI(); - } - - private void initGUI() - { - user.addInvalidRule(InvalidRule.EmptyInvalidRule.getInstance()); - user.addInvalidRule(new InvalidRule() - { - public boolean isInvalid(ModifyableComponent comp) - { - String text = user.getText().trim(); - - if(text.length() <= 2) - { - return true; - } - - if(text.indexOf("@") == -1) - { - return true; - } - - if(text.indexOf(".") == -1 || text.endsWith(".")) - { - return true; - } - - return false; - } - }); - - passwort.setColumns(15); - // passwort.addInvalidRule(InvalidRule.EmptyInvalidRule.getInstance()); - nickname.addInvalidRule(InvalidRule.EmptyInvalidRule.getInstance()); - - user.ignoreInvalidRules(false); - nickname.ignoreInvalidRules(false); - - user.ignoreStatus(STATUSFLAG.MODIFIED, true); - // passwort.ignoreStatus(STATUSFLAG.MODIFIED, true); - nickname.ignoreStatus(STATUSFLAG.MODIFIED, true); - - user.fireCheckRules(); - nickname.fireCheckRules(); - - setLayout(new BorderLayout()); - JPanel buttonpanel = new JPanel(new FlowLayout()); - - buttonpanel.add(new JLabel("Benutzer:")); - buttonpanel.add(user); - buttonpanel.add(new JLabel("Passwort:")); - buttonpanel.add(passwort); - buttonpanel.add(new JLabel("Nickname:")); - buttonpanel.add(nickname); - buttonpanel.add(connectButton); - add(buttonpanel, BorderLayout.NORTH); - - if(System.getProperty("Debug") != null) - { - initForTest(); - } - - connectButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - doConnect(); - } - }); - - IdentityPanel identityPanel = IdentityController.getInstance().getPanel(); - - JSplitPane eastSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, identityPanel, registerPanel); - - eastSplitPane.setOneTouchExpandable(true); - - JSplitPane centerSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabbedPane, eastSplitPane); - - centerSplitPane.setOneTouchExpandable(true); - centerSplitPane.setResizeWeight(1); - add(centerSplitPane, BorderLayout.CENTER); - } - - private boolean isInputValid() - { - user.fireCheckRules(); - nickname.fireCheckRules(); - - // password.fireCheckRules(); - if(user.isInvalid()) - { - return false; - } - - if(nickname.isInvalid()) - { - return false; - } - - return true; - } - - protected void doConnect() - { - if(!isInputValid()) - { - return; - } - - connectButton.setEnabled(false); - if(CMD_VERBINDEN.equals(connectButton.getText())) - { - user.setEnabled(false); - passwort.setEnabled(false); - nickname.setEnabled(false); - - // neue Verbindung aufbauen - String tmp = user.getText().trim(); - int index = tmp.indexOf("@"); - final String server = tmp.substring(index + 1); - - final String username = tmp.substring(0, index); - final String nick = nickname.getText().trim(); - - new Thread(new Runnable() - { - public void run() - { - try - { - connection = new XMPPConnection(server); - String password = new String(passwort.getPassword()); - - connection.login(username, password); - IdentityController.getInstance().setConnection(connection); - joinMultiUserChat("applejuice@conference.jabber.org", nick); - connectButton.setText(CMD_TRENNEN); - connectButton.setEnabled(true); - } - catch(XMPPException e) - { - e.printStackTrace(); - connectButton.setEnabled(true); - } - } - }).start(); - } - else - { - - // neue Verbindung trennen - if(null != connection) - { - new Thread(new Runnable() - { - public void run() - { - connection.close(); - connection = null; - IdentityController.getInstance().setConnection(null); - connectButton.setText(CMD_VERBINDEN); - user.setEnabled(true); - passwort.setEnabled(true); - nickname.setEnabled(true); - connectButton.setEnabled(true); - } - }).start(); - } - } - } - - private void initForTest() - { - user.setText("ajtest2@jabber.org"); - nickname.setText("ajtest2"); - user.fireCheckRules(); - nickname.fireCheckRules(); - } - - @Override - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - } - - @Override - public void fireLanguageChanged() - { - } - - @Override - public void registerSelected() - { - } - - private void joinMultiUserChat(final String room, String nick) - throws XMPPException - { - MultiUserChat muc = new MultiUserChat(connection, room); - final MultiUserChatController multiUserChatController = new MultiUserChatController(muc, nick); - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - tabbedPane.addTab(room, multiUserChatController.getMultiUserChatPanel()); - registerPanel.add(multiUserChatController.getRoomName(), multiUserChatController.getUserListPane()); - } - }); - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberTestLoader.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberTestLoader.java deleted file mode 100644 index e0d5b083..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/JabberTestLoader.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.applejuicenet.client.gui.plugins.jabber; - -import java.util.Map; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class JabberTestLoader extends TestLoader -{ - @Override - protected String getPath() - { - return "jabber"; - } - - @Override - protected PluginConnector getPlugin(XMLValueHolder pluginsPropertiesXMLHolder, Map<String, XMLValueHolder> languageFiles, - ImageIcon icon, Map<String, ImageIcon> availableIcons) - { - return new JabberPlugin(pluginsPropertiesXMLHolder, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/IdentityController.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/IdentityController.java deleted file mode 100644 index db769019..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/IdentityController.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; - -import javax.swing.SwingUtilities; - -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterGroup; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.packet.Presence; - -import de.applejuicenet.client.gui.plugins.jabber.control.rostertree.RosterTreeNode; -import de.applejuicenet.client.gui.plugins.jabber.view.IdentityPanel; -import de.applejuicenet.client.gui.plugins.jabber.view.RosterUserTreeCellRenderer; - -public class IdentityController -{ - private static IdentityController instance = null; - private XMPPConnection connection; - private IdentityPanel identityPanel = null; - private KnownUsersTreeModel knownUsersTreeModel = null; - - private IdentityController() - { - } - - public static synchronized IdentityController getInstance() - { - if(null == instance) - { - instance = new IdentityController(); - } - - return instance; - } - - public void setConnection(XMPPConnection aConnection) - { - connection = aConnection; - if(null == connection) - { - getKnownUsersTreeModel().getRootNode().removeAllChildren(); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getPanel().getKnownUsersTree().updateUI(); - } - }); - } - else - { - final Roster roster = connection.getRoster(); - - new MyRosterListener(roster); - new Thread(new Runnable() - { - public void run() - { - RosterTreeNode rootNode = getKnownUsersTreeModel().getRootNode(); - - rootNode.setText(connection.getUser()); - rootNode.removeAllChildren(); - RosterGroup curGroup; - RosterEntry curRosterEntry; - RosterTreeNode groupNode; - RosterTreeNode rosterEntryNode; - String name; - - HashSet<String> allUsers = new HashSet<String>(); - Iterator it = roster.getEntries(); - - while(it.hasNext()) - { - curRosterEntry = (RosterEntry) it.next(); - allUsers.add(curRosterEntry.getName()); - } - - it = roster.getGroups(); - while(it.hasNext()) - { - curGroup = (RosterGroup) it.next(); - groupNode = new RosterTreeNode(curGroup.getName()); - - rootNode.insert(groupNode, 0); - Iterator it2 = curGroup.getEntries(); - - while(it2.hasNext()) - { - curRosterEntry = (RosterEntry) it2.next(); - name = curRosterEntry.getName(); - rosterEntryNode = new RosterTreeNode(name); - allUsers.remove(name); - groupNode.insert(rosterEntryNode, 0); - } - } - - if(allUsers.size() > 0) - { - groupNode = new RosterTreeNode("Sonstige"); - rootNode.insert(groupNode, rootNode.getChildCount()); - for(String curUser : allUsers) - { - rosterEntryNode = new RosterTreeNode(curUser); - - groupNode.insert(rosterEntryNode, 0); - } - } - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getPanel().getKnownUsersTree().updateUI(); - int count = getKnownUsersTreeModel().getRootNode().getChildCount(); - - for(int i = count - 1; i >= 0; i--) - { - getPanel().getKnownUsersTree().expandRow(i); - } - } - }); - } - }).start(); - } - } - - public IdentityPanel getPanel() - { - if(null == identityPanel) - { - identityPanel = new IdentityPanel(); - identityPanel.getKnownUsersTree().setModel(getKnownUsersTreeModel()); - - identityPanel.getKnownUsersTree().setCellRenderer(new RosterUserTreeCellRenderer()); - } - - return identityPanel; - } - - public KnownUsersTreeModel getKnownUsersTreeModel() - { - if(null == knownUsersTreeModel) - { - knownUsersTreeModel = new KnownUsersTreeModel(); - } - - return knownUsersTreeModel; - } - - private class MyRosterListener implements RosterListener - { - private final Roster roster; - - public MyRosterListener(Roster roster) - { - this.roster = roster; - roster.addRosterListener(this); - } - - public void entriesAdded(Collection arg0) - { - } - - public void entriesDeleted(Collection arg0) - { - } - - public void entriesUpdated(Collection arg0) - { - - // nichts zu tun - ; - } - - public void presenceChanged(String nick) - { - Presence presence = roster.getPresence(nick); - - nick = nick.substring(0, nick.indexOf("@")); - RosterTreeNode rootNode = getKnownUsersTreeModel().getRootNode(); - int count = rootNode.getChildCount(); - boolean found = false; - - for(int i = 0; i < count; i++) - { - RosterTreeNode child = (RosterTreeNode) rootNode.getChildAt(i); - - if(child.isLeaf()) - { - if(child.getText().equalsIgnoreCase(nick)) - { - child.setPresence(presence); - found = true; - } - } - else - { - int count2 = child.getChildCount(); - - for(int x = 0; x < count2; x++) - { - RosterTreeNode subChild = (RosterTreeNode) child.getChildAt(x); - - if(subChild.getText().equalsIgnoreCase(nick)) - { - subChild.setPresence(presence); - found = true; - break; - } - } - } - - if(found) - { - break; - } - } - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - identityPanel.getKnownUsersTree().updateUI(); - } - }); - } - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/KnownUsersTreeModel.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/KnownUsersTreeModel.java deleted file mode 100644 index 657d6fc5..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/KnownUsersTreeModel.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.applejuicenet.client.gui.plugins.jabber.control; - -import javax.swing.tree.DefaultTreeModel; - -import de.applejuicenet.client.gui.plugins.jabber.control.rostertree.RosterTreeNode; - -public class KnownUsersTreeModel extends DefaultTreeModel -{ - public KnownUsersTreeModel() - { - super(new RosterTreeNode()); - } - - public RosterTreeNode getRootNode() - { - return (RosterTreeNode) getRoot(); - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/LinkEditorKit.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/LinkEditorKit.java deleted file mode 100644 index 18b160ce..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/LinkEditorKit.java +++ /dev/null @@ -1,139 +0,0 @@ -package de.applejuicenet.client.gui.plugins.jabber.control; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; - -import java.net.URL; - -import javax.swing.JEditorPane; -import javax.swing.SwingUtilities; -import javax.swing.event.HyperlinkEvent; -import javax.swing.text.Element; -import javax.swing.text.Position; -import javax.swing.text.StyledDocument; -import javax.swing.text.StyledEditorKit; - -public class LinkEditorKit extends StyledEditorKit -{ - public static final Object LINK = new StringBuffer("LINK"); - private static LinkHandler linkHandler = new LinkHandler(); - - public LinkEditorKit() - { - } - - public void install(JEditorPane p) - { - super.install(p); - p.addMouseListener(linkHandler); - p.addMouseMotionListener(linkHandler); - } - - public void deinstall(JEditorPane p) - { - p.removeMouseListener(linkHandler); - p.removeMouseMotionListener(linkHandler); - super.deinstall(p); - } - - private static class LinkHandler extends MouseAdapter implements MouseMotionListener - { - private Element activeElement; - - private Element characterElementAt(MouseEvent e) - { - JEditorPane p = (JEditorPane) e.getComponent(); - Position.Bias[] bias = new Position.Bias[1]; - int position = p.getUI().viewToModel(p, e.getPoint(), bias); - - if(bias[0] == Position.Bias.Backward && position != 0) - { - --position; - } - - Element c = ((StyledDocument) p.getDocument()).getCharacterElement(position); - - return c; - } - - public void mouseMoved(MouseEvent e) - { - JEditorPane p = (JEditorPane) e.getComponent(); - - if(!p.isEditable()) - { - Element c = characterElementAt(e); - Object target = c.getAttributes().getAttribute(LINK); - - if(!(target instanceof URL)) - { - target = null; - } - - if(target != null) - { - p.fireHyperlinkUpdate(new HyperlinkEvent(p, HyperlinkEvent.EventType.ENTERED, (URL) target, null, c)); - } - else - { - p.fireHyperlinkUpdate(new HyperlinkEvent(p, HyperlinkEvent.EventType.EXITED, (URL) target, null, c)); - } - } - } - - public void mouseDragged(MouseEvent e) - { - } - - public void mouseEntered(MouseEvent e) - { - } - - public void mousePressed(MouseEvent e) - { - if(!SwingUtilities.isLeftMouseButton(e)) - { - return; - } - - JEditorPane p = (JEditorPane) e.getComponent(); - - if(p.isEditable()) - { - return; - } - - Element c = characterElementAt(e); - - if(c != null && c.getAttributes().getAttribute(LINK) != null) - { - activeElement = c; - } - } - - public void mouseReleased(MouseEvent e) - { - if(!SwingUtilities.isLeftMouseButton(e) || activeElement == null) - { - return; - } - - JEditorPane p = (JEditorPane) e.getComponent(); - Element c = characterElementAt(e); - - if(!p.isEditable() && c == activeElement) - { - activeElement = null; - Object target = c.getAttributes().getAttribute(LINK); - - if(!(target instanceof URL)) - { - target = null; - } - - p.fireHyperlinkUpdate(new HyperlinkEvent(p, HyperlinkEvent.EventType.ACTIVATED, (URL) target, null, c)); - } - } - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiChatUserMode.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiChatUserMode.java deleted file mode 100644 index e836d66f..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiChatUserMode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control; - -public enum MultiChatUserMode -{OWNER(0), MODERATOR(1), MEMBER(2), VOICE(3), NOTHING(4);private int value; - - MultiChatUserMode(int aValue) - { - value = aValue; - } - - public Integer getValue() - { - return value; - } - - public static MultiChatUserMode getByRole(String role) - { - if(role.equalsIgnoreCase("moderator")) - { - return MODERATOR; - } - else if(role.equalsIgnoreCase("member")) - { - return MEMBER; - } - else if(role.equalsIgnoreCase("participant")) - { - return VOICE; - } - else - { - return NOTHING; - } - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatController.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatController.java deleted file mode 100644 index 87401195..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatController.java +++ /dev/null @@ -1,900 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -import java.net.URL; - -import java.text.SimpleDateFormat; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.Iterator; - -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.MutableAttributeSet; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; - -import org.apache.log4j.Logger; - -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.SmackConfiguration; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smackx.muc.DefaultParticipantStatusListener; -import org.jivesoftware.smackx.muc.DiscussionHistory; -import org.jivesoftware.smackx.muc.MultiUserChat; -import org.jivesoftware.smackx.muc.SubjectUpdatedListener; -import org.jivesoftware.smackx.packet.DelayInformation; -import org.jivesoftware.smackx.packet.MUCUser; - -import de.applejuicenet.client.gui.plugins.jabber.view.MultiUserChatListCellRenderer; -import de.applejuicenet.client.gui.plugins.jabber.view.MultiUserChatPanel; - -public class MultiUserChatController implements SubjectUpdatedListener, ActionListener -{ - private static final Color JOIN_GREEN = new Color(0, 128, 0); - public static final String HTTP_IDENTIFIER = "http://"; - public static final String WWW_IDENTIFIER = "www."; - private final MultiUserChat muc; - private MultiUserChatPanel multiUserChatPanel = null; - private boolean selected = false; - private boolean marked = false; - private Logger logger = Logger.getLogger(MultiUserChatController.class); - private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss"); - private ArrayList<String> befehle = new ArrayList<String>(); - private int befehlPos = -1; - private JScrollPane userScrollPane = null; - private MultiUserChatUserListModel multiUserChatUserListModel; - private JList userList; - private String nick; - private MyMessageListener myMessageListener; - private MyParticipantListener myParticipantListener; - - public MultiUserChatController(MultiUserChat multiUserChat, String nick) - throws XMPPException - { - this.nick = nick; - muc = multiUserChat; - Calendar cal = Calendar.getInstance(); - - // Historie der letzten 2 Tage holen (wenns der Server zulaesst) - cal.add(Calendar.DATE, -2); - DiscussionHistory history = new DiscussionHistory(); - - history.setSince(cal.getTime()); - myMessageListener = new MyMessageListener(muc); - myParticipantListener = new MyParticipantListener(muc); - muc.addParticipantListener(new PacketListener() - { - public void processPacket(Packet packet) - { - Presence presence = (Presence) packet; - Iterator it = presence.getExtensions(); - - while(it.hasNext()) - { - Object obj = it.next(); - - if(obj instanceof MUCUser) - { - MUCUser user = (MUCUser) obj; - String nick = user.getItem().getJid(); - - if(null != nick && nick.indexOf("@") != -1) - { - String role = user.getItem().getRole(); - String affilation = user.getItem().getAffiliation(); - - nick = nick.substring(0, nick.indexOf("@")); - System.out.println(role); - MultiChatUserMode mode = MultiChatUserMode.getByRole(role); - MutliUserChatUser multiUser = getMultiUserChatUserListModel().getMutliUserChatUserByName(nick); - - if(null == multiUser) - { - multiUser = new MutliUserChatUser(nick); - getMultiUserChatUserListModel().addParticipant(multiUser); - } - - multiUser.setMode(mode); - updateUserList(); - } - } - } - } - }); - muc.addSubjectUpdatedListener(this); - muc.join(nick, null, history, SmackConfiguration.getPacketReplyTimeout()); - getMultiUserChatUserListModel().addParticipant(new MutliUserChatUser(nick)); - updateUserList(); - } - - public String getRoomName() - { - return muc.getRoom(); - } - - public synchronized MultiUserChatPanel getMultiUserChatPanel() - { - if(null == multiUserChatPanel) - { - multiUserChatPanel = new MultiUserChatPanel(); - getMultiUserChatPanel().getTextArea().addKeyListener(new KeyAdapter() - { - public void keyTyped(KeyEvent ke) - { - getMultiUserChatPanel().getTextField().setText(getMultiUserChatPanel().getTextField().getText() + - ke.getKeyChar()); - getMultiUserChatPanel().getTextField().requestFocus(); - } - }); - getMultiUserChatPanel().getTextField().addKeyListener(new KeyAdapter() - { - public void keyReleased(KeyEvent ke) - { - super.keyReleased(ke); - - // if(ke.getKeyCode() == KeyEvent.VK_TAB) - // { - // String text = textField.getText(); - // - // if(text.length() > 0) - // { - // int index = text.lastIndexOf(' '); - // int index2 = text.lastIndexOf(','); - // - // if(index2 > index) - // { - // index = index2; - // } - // - // String searchString; - // - // if(index != -1) - // { - // searchString = text.substring(index + 1).toLowerCase(); - // } - // else - // { - // searchString = text.toLowerCase(); - // } - // - // String treffer = ""; - // int count = 0; - // - // synchronized(usernameList) - // { - // User[] users = usernameList.getValues(); - // String compareValue; - // - // for(int i = 0; i < users.length; i++) - // { - // if(users[i].getName().toLowerCase().startsWith(searchString)) - // { - // treffer += users[i].getName() + " "; - // count++; - // } - // } - // } - // - // if(treffer.length() > 0) - // { - // treffer = treffer.substring(0, treffer.length() - 1); - // if(count == 1) - // { - // if(index != -1) - // { - // String newText = text.subSequence(0, index + 1) + treffer; - // - // textField.setText(newText); - // } - // else - // { - // textField.setText(treffer); - // } - // } - // else if(count > 1) - // { - // updateTextArea("\t" + treffer, false); - // } - // } - // } - // } - if(befehlPos != -1) - { - if(ke.getKeyCode() == KeyEvent.VK_UP) - { - getMultiUserChatPanel().getTextField().setText(befehle.get(befehlPos)); - if(befehlPos > 0) - { - befehlPos--; - } - } - else if(ke.getKeyCode() == KeyEvent.VK_DOWN) - { - if(befehlPos < befehle.size() - 1) - { - befehlPos++; - } - - getMultiUserChatPanel().getTextField().setText(befehle.get(befehlPos)); - } - } - } - }); - getMultiUserChatPanel().getCloseButton().addActionListener(this); - getMultiUserChatPanel().getTextField().addActionListener(this); - } - - return multiUserChatPanel; - } - - public synchronized void updateTextArea(String message, boolean withTimeStamp, Date stamp) - { - Document doc = getMultiUserChatPanel().getTextArea().getDocument(); - int oldCaretPosition = getMultiUserChatPanel().getTextArea().getCaretPosition(); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - - StyleConstants.setBackground(attributes, Color.WHITE); - StyleConstants.setForeground(attributes, Color.BLACK); - int index = message.indexOf('>'); - String compareValue; - boolean eigenerName = false; - boolean doMark = false; - - if(index != -1 && message.length() - 1 > index) - { - compareValue = message.substring(index + 1); - } - else - { - compareValue = message; - } - - boolean isAction = false; - - // if(compareValue.indexOf(parentPanel.getNickname()) != -1) - // { - // StyleConstants.setBackground(attributes, Color.ORANGE); - // eigenerName = true; - // doMark = true; - // } - // if(message.indexOf("---> JOIN:") != -1) - // { - // StyleConstants.setForeground(attributes, JOIN_GREEN); - // } - // else if(message.indexOf("<--- PART:") != -1) - // { - // StyleConstants.setForeground(attributes, Color.RED); - // } - // else if(message.indexOf("<--- QUIT:") != -1) - // { - // StyleConstants.setForeground(attributes, Color.RED); - // } - // else if(message.indexOf('>') == 0) - // { - // StyleConstants.setForeground(attributes, Color.MAGENTA); - // } - // else if(message.startsWith("* ")) - // { - // isAction = true; - // } - // else if(!withTimeStamp || index == -1) - // { - // StyleConstants.setForeground(attributes, Color.GRAY); - // } - if(withTimeStamp) - { - StyleConstants.setForeground(attributes, Color.BLACK); - doMark = true; - } - else - { - StyleConstants.setForeground(attributes, Color.GRAY); - } - - try - { - if(withTimeStamp) - { - String zeit; - - if(null != stamp) - { - zeit = dateFormatter.format(stamp); - } - else - { - zeit = dateFormatter.format(new Date(System.currentTimeMillis())); - } - - doc.insertString(doc.getLength(), "[" + zeit + "]\t", attributes); - } - - if(isAction) - { - Color color = StyleConstants.getForeground(attributes); - - StyleConstants.setForeground(attributes, Color.MAGENTA); - doc.insertString(doc.getLength(), "\t*", attributes); - StyleConstants.setForeground(attributes, color); - message = message.substring(1).trim(); - } - - parseLinks(attributes, doc, message); - } - catch(BadLocationException blE) - { - logger.error("Fehler im JabberPlugin", blE); - } - - if(!selected && doMark) - { - if(eigenerName) - { - - // for(int i = 0; i < tabbedPane.getTabCount(); i++) - // { - // Object tab = tabbedPane.getComponentAt(i); - // - // if(tab == this) - // { - // tabbedPane.setForegroundAt(i, Color.GREEN); - // } - // } - } - - if(!eigenerName && !marked) - { - - // for(int i = 0; i < tabbedPane.getTabCount(); i++) - // { - // Object tab = tabbedPane.getComponentAt(i); - // - // if(tab == this) - // { - // tabbedPane.setForegroundAt(i, Color.RED); - // } - // } - } - - marked = true; - } - - final int newCaretPosition = doc.getLength(); - - if(newCaretPosition != oldCaretPosition) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getMultiUserChatPanel().getTextArea().setCaretPosition(newCaretPosition); - } - }); - } - } - - public void updateTextArea(String message) - { - updateTextArea(message, true, null); - } - - private void parseLinks(SimpleAttributeSet attributes, Document doc, String message) - throws BadLocationException - { - while(message.toLowerCase().indexOf(MultiUserChatController.HTTP_IDENTIFIER) != -1 || - message.toLowerCase().indexOf(MultiUserChatController.WWW_IDENTIFIER) != -1) - { - String httpIdentifier; - int indexHttp = message.toLowerCase().indexOf(HTTP_IDENTIFIER); - int indexWww = message.toLowerCase().indexOf(WWW_IDENTIFIER); - - if(indexHttp == -1) - { - httpIdentifier = WWW_IDENTIFIER; - } - else if(indexWww == -1) - { - httpIdentifier = HTTP_IDENTIFIER; - } - else - { - if(indexWww == indexHttp + HTTP_IDENTIFIER.length()) - { - httpIdentifier = HTTP_IDENTIFIER; - } - else - { - httpIdentifier = WWW_IDENTIFIER; - } - } - - doc.insertString(doc.getLength(), message.substring(0, message.toLowerCase().indexOf(httpIdentifier)), attributes); - message = message.substring(message.toLowerCase().indexOf(httpIdentifier)); - int index = message.indexOf(" "); - int index2 = message.indexOf(">"); - - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf(")"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf("]"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - index2 = message.indexOf("}"); - if(index2 != -1 && index2 < index) - { - index = index2; - } - - if(index != -1) - { - doc.insertString(doc.getLength(), message.substring(0, index), setLink(message.substring(0, index), attributes)); - message = message.substring(index); - if(message.indexOf(httpIdentifier, index) == -1) - { - break; - } - } - else - { - doc.insertString(doc.getLength(), message, setLink(message, attributes)); - message = ""; - } - } - - doc.insertString(doc.getLength(), message + "\n", attributes); - } - - private MutableAttributeSet setLink(String sUrl, SimpleAttributeSet attributeSet) - { - MutableAttributeSet a = new SimpleAttributeSet(attributeSet); - - try - { - if(!sUrl.toLowerCase().startsWith(MultiUserChatController.HTTP_IDENTIFIER)) - { - sUrl = MultiUserChatController.HTTP_IDENTIFIER + sUrl; - } - - URL url = new URL(sUrl); - - a.addAttribute(LinkEditorKit.LINK, new URL(sUrl)); - } - catch(Exception e) - { - ; - - // nothing to do - } - - a.addAttribute(StyleConstants.Bold, Boolean.TRUE); - a.addAttribute(StyleConstants.Underline, Boolean.TRUE); - return a; - } - - private synchronized void setTitle(final String title) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - StyledDocument doc = getMultiUserChatPanel().getTitleArea().getStyledDocument(); - SimpleAttributeSet attributes = new SimpleAttributeSet(); - - StyleConstants.setBackground(attributes, Color.WHITE); - try - { - doc.remove(0, doc.getLength()); - int startIndex = 0; - - for(int i = 0; i < title.length(); i++) - { - if(title.charAt(i) == 3 || i == title.length() - 1) - { - if(title.charAt(i) == 3) - { - String toWrite = title.substring(startIndex, i); - - if(toWrite.length() > 0) - { - attributes = writeString(doc, attributes, toWrite); - } - - startIndex = i + 1; - i++; - } - else - { - String toWrite = title.substring(startIndex); - - if(toWrite.length() > 0) - { - attributes = writeString(doc, attributes, toWrite); - } - } - } - } - } - catch(BadLocationException ex) - { - ex.printStackTrace(); - } - } - }); - } - - private SimpleAttributeSet writeString(StyledDocument doc, SimpleAttributeSet attributes, String toWrite) - { - boolean istNachkomma = false; - boolean parsEnde = false; - int index = 0; - - if(toWrite.length() > 1) - { - while(!parsEnde) - { - try - { - if(toWrite.charAt(index) == ',') - { - istNachkomma = true; - index++; - continue; - } - - int colorCode = Integer.parseInt(toWrite.substring(index, index + 2)); - - index += 2; - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE) - { - if(toWrite.charAt(index + 1) != ',') - { - parsEnde = true; - } - - try - { - int colorCode = Integer.parseInt(toWrite.substring(index, index + 1)); - - index++; - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE2) - { - parsEnde = true; - StyleConstants.setForeground(attributes, Color.BLACK); - } - } - catch(StringIndexOutOfBoundsException sioobE) - { - parsEnde = true; - try - { - int colorCode = Integer.parseInt(toWrite.substring(index, index + 1)); - Color color = getColor(colorCode); - - if(!istNachkomma) - { - StyleConstants.setForeground(attributes, color); - } - } - catch(NumberFormatException nfE2) - { - StyleConstants.setForeground(attributes, Color.BLUE); - } - catch(StringIndexOutOfBoundsException nfE2) - { - StyleConstants.setForeground(attributes, Color.BLACK); - } - - return attributes; - } - } - } - - try - { - doc.insertString(doc.getLength(), toWrite.substring(index), attributes); - } - catch(BadLocationException ex) - { - ex.printStackTrace(); - } - - return attributes; - } - - private Color getColor(int code) - { - switch(code) - { - - case 0: - return Color.BLACK; - - case 1: - return Color.BLACK; - - case 2: - return Color.BLUE; - - case 3: - return Color.GREEN; - - case 4: - return Color.RED; - - case 5: - return Color.BLACK; - - case 6: - return Color.PINK; - - case 7: - return Color.ORANGE; - - case 8: - return Color.YELLOW; - - case 9: - return Color.GREEN; - - case 10: - return Color.GREEN; - - case 11: - return Color.CYAN; - - case 12: - return Color.BLUE; - - case 13: - return Color.PINK; - - case 14: - return Color.GRAY; - - case 15: - return Color.LIGHT_GRAY; - - default: - return Color.BLACK; - } - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - - if(source == getMultiUserChatPanel().getTextField()) - { - final String messageText = getMultiUserChatPanel().getTextField().getText(); - - getMultiUserChatPanel().getTextField().setText(""); - - if(null != messageText && messageText.length() > 0) - { - befehle.add(messageText); - if(befehle.size() > 40) - { - befehle.remove(0); - } - - befehlPos = befehle.size() - 1; - } - - new Thread(new Runnable() - { - public void run() - { - - // Message message = muc.createMessage(); - // message.setBody(messageText); - try - { - muc.sendMessage(messageText); - } - catch(XMPPException e) - { - e.printStackTrace(); - } - } - }).start(); - } - else if(source == getMultiUserChatPanel().getCloseButton()) - { - logger.debug("todo: close room"); - } - } - - public void subjectUpdated(final String subject, String from) - { - setTitle(subject); - } - - public JScrollPane getUserListPane() - { - if(null == userScrollPane) - { - userScrollPane = new JScrollPane(getUserList()); - } - - return userScrollPane; - } - - private MultiUserChatUserListModel getMultiUserChatUserListModel() - { - if(null == multiUserChatUserListModel) - { - multiUserChatUserListModel = new MultiUserChatUserListModel(); - - } - - return multiUserChatUserListModel; - } - - private JList getUserList() - { - if(null == userList) - { - userList = new JList(getMultiUserChatUserListModel()); - userList.setCellRenderer(new MultiUserChatListCellRenderer()); - - } - - return userList; - } - - private void updateUserList() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getUserList().updateUI(); - } - }); - } - - private class MyParticipantListener extends DefaultParticipantStatusListener - { - public MyParticipantListener(MultiUserChat muc) - { - muc.addParticipantStatusListener(this); - } - - public void banned(String arg0, String arg1, String arg2) - { - } - - public void joined(String participant) - { - participant = participant.substring(participant.indexOf("/") + 1); - getMultiUserChatUserListModel().addParticipant(new MutliUserChatUser(participant)); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getUserList().updateUI(); - } - }); - } - - public void kicked(String participant, String arg1, String arg2) - { - removeParticipant(participant); - } - - private void removeParticipant(String participant) - { - participant = participant.substring(participant.indexOf("/") + 1); - MutliUserChatUser user = getMultiUserChatUserListModel().getMutliUserChatUserByName(participant); - - if(null == user) - { - return; - } - - getMultiUserChatUserListModel().removeParticipant(user); - updateUserList(); - } - - public void left(String participant) - { - removeParticipant(participant); - } - - public void nicknameChanged(String arg0, String arg1) - { - } - } - - - private class MyMessageListener implements PacketListener - { - public MyMessageListener(MultiUserChat muc) - { - muc.addMessageListener(this); - } - - public void processPacket(Packet packet) - { - final Message message = (Message) packet; - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - String from = message.getFrom(); - int index = message.getFrom().indexOf("/"); - - if(index != -1) - { - from = from.substring(index + 1); - Iterator it = message.getExtensions(); - Date stamp = null; - - while(it.hasNext()) - { - PacketExtension ext = (PacketExtension) it.next(); - - if(ext instanceof DelayInformation) - { - stamp = ((DelayInformation) ext).getStamp(); - break; - } - } - - updateTextArea(from + ": " + message.getBody(), true, stamp); - } - else - { - updateTextArea(message.getBody(), false, null); - } - } - }); - } - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatUserListModel.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatUserListModel.java deleted file mode 100644 index 6c7d5b93..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MultiUserChatUserListModel.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control; - -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; - -public class MultiUserChatUserListModel extends AbstractListModel -{ - private List<MutliUserChatUser> users = new ArrayList<MutliUserChatUser>(); - - public Object getElementAt(int index) - { - return users.get(index); - } - - public int getSize() - { - return users.size(); - } - - public void addParticipant(MutliUserChatUser participant) - { - users.add(participant); - } - - public MutliUserChatUser getMutliUserChatUserByName(String name) - { - for(MutliUserChatUser curMutliUserChatUser : users) - { - if(curMutliUserChatUser.getName().equals(name)) - { - return curMutliUserChatUser; - } - } - - return null; - } - - public void removeParticipant(MutliUserChatUser participant) - { - users.remove(participant); - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MutliUserChatUser.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MutliUserChatUser.java deleted file mode 100644 index dd6f0bcc..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/MutliUserChatUser.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control; - -public class MutliUserChatUser -{ - private String name; - private MultiChatUserMode mode = MultiChatUserMode.NOTHING; - - public MutliUserChatUser(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - @Override - public boolean equals(Object obj) - { - return name.equals(obj.toString()); - } - - @Override - public String toString() - { - return name; - } - - public void setMode(MultiChatUserMode mode) - { - this.mode = mode; - } - - public MultiChatUserMode getHighestMode() - { - return mode; - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/rostertree/RosterTreeNode.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/rostertree/RosterTreeNode.java deleted file mode 100644 index 3c1f81d1..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/control/rostertree/RosterTreeNode.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.control.rostertree; - -import java.util.Comparator; -import java.util.Enumeration; -import java.util.Set; -import java.util.TreeSet; - -import javax.swing.tree.MutableTreeNode; -import javax.swing.tree.TreeNode; - -import org.jivesoftware.smack.packet.Presence; - -public class RosterTreeNode implements MutableTreeNode -{ - private Set<RosterTreeNode> users = new TreeSet<RosterTreeNode>(new Comparator<RosterTreeNode>() - { - public int compare(RosterTreeNode o1, RosterTreeNode o2) - { - return o1.getText().compareToIgnoreCase(o2.getText()); - } - }); - private RosterTreeNode parent = null; - private String text = ""; - private Presence presence = null; - - public RosterTreeNode(String text) - { - this.text = text; - } - - public RosterTreeNode() - { - this(""); - } - - public void removeAllChildren() - { - for(int i = users.size() - 1; i >= 0; i--) - { - remove(i); - } - } - - public void insert(MutableTreeNode child, int index) - { - users.add((RosterTreeNode) child); - child.setParent(this); - } - - public void remove(int index) - { - remove(users.toArray(new RosterTreeNode[users.size()])[index]); - } - - public void remove(MutableTreeNode node) - { - users.remove(node); - node.setParent(null); - } - - public void removeFromParent() - { - if(null != parent) - { - parent.remove(this); - parent = null; - } - } - - public void setParent(MutableTreeNode newParent) - { - parent = (RosterTreeNode) newParent; - } - - public void setUserObject(Object object) - { - - // ?? - } - - public Enumeration children() - { - return new Enumeration() - { - private int index = 0; - - public boolean hasMoreElements() - { - return users.size() > index; - } - - public Object nextElement() - { - index++; - return users.toArray(new RosterTreeNode[users.size()])[index]; - } - }; - } - - public boolean getAllowsChildren() - { - return true; - } - - public TreeNode getChildAt(int childIndex) - { - return users.toArray(new RosterTreeNode[users.size()])[childIndex]; - } - - public int getChildCount() - { - return users.size(); - } - - public int getIndex(TreeNode node) - { - RosterTreeNode[] allNodes = users.toArray(new RosterTreeNode[users.size()]); - - for(int i = 0; i < allNodes.length; i++) - { - if(allNodes[i] == node) - { - return i; - } - } - - return -1; - } - - public TreeNode getParent() - { - return parent; - } - - public boolean isLeaf() - { - return users.size() == 0; - } - - @Override - public String toString() - { - return getText(); - } - - public String getText() - { - return text; - } - - public void setText(String text) - { - this.text = text; - } - - public Presence getPresence() - { - return presence; - } - - public void setPresence(Presence presence) - { - this.presence = presence; - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/IdentityPanel.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/IdentityPanel.java deleted file mode 100644 index 47195ae7..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/IdentityPanel.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.applejuicenet.client.gui.plugins.jabber.view; - -import java.awt.Dimension; - -import javax.swing.BorderFactory; -import javax.swing.JScrollPane; -import javax.swing.JTree; - -public class IdentityPanel extends JScrollPane -{ - private JTree knownUsersTree = null; - - public IdentityPanel() - { - setViewportView(getKnownUsersTree()); - setBorder(BorderFactory.createTitledBorder("Kontakte")); - setMinimumSize(new Dimension(140, 10)); - } - - public JTree getKnownUsersTree() - { - if(null == knownUsersTree) - { - knownUsersTree = new JTree(); - knownUsersTree.setRootVisible(false); - } - - return knownUsersTree; - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatListCellRenderer.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatListCellRenderer.java deleted file mode 100644 index bf3ecd8a..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatListCellRenderer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.view; - -import java.awt.Component; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JList; - -import de.applejuicenet.client.gui.plugins.jabber.control.MultiChatUserMode; -import de.applejuicenet.client.gui.plugins.jabber.control.MutliUserChatUser; - -public class MultiUserChatListCellRenderer extends DefaultListCellRenderer -{ - public static ImageIcon owner; - public static ImageIcon moderator; - public static ImageIcon member; - public static ImageIcon voice; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) - { - MultiChatUserMode mode = ((MutliUserChatUser) value).getHighestMode(); - JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if(mode == MultiChatUserMode.MODERATOR) - { - comp.setIcon(moderator); - } - else if(mode == MultiChatUserMode.OWNER) - { - comp.setIcon(owner); - } - else if(mode == MultiChatUserMode.MEMBER) - { - comp.setIcon(member); - } - else if(mode == MultiChatUserMode.VOICE) - { - comp.setIcon(voice); - } - else if(mode == MultiChatUserMode.NOTHING) - { - comp.setIcon(null); - } - - return comp; - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatPanel.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatPanel.java deleted file mode 100644 index af8d5aaa..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/MultiUserChatPanel.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.view; - -import java.awt.AWTKeyStroke; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.KeyboardFocusManager; -import java.awt.event.KeyEvent; - -import java.util.HashSet; -import java.util.Set; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.text.StyledDocument; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.plugins.jabber.control.LinkEditorKit; -import de.applejuicenet.client.gui.start.HyperlinkAdapter; - -import de.tklsoft.gui.controls.TKLPanel; - -public class MultiUserChatPanel extends TKLPanel -{ - private JTextPane textArea = new JTextPane(); - private StyledDocument document = (StyledDocument) textArea.getStyledDocument(); - private JTextField textField; - private JTextPane titleArea = new JTextPane(); - private JButton closeButton = new JButton("X"); - private Logger logger = Logger.getLogger(MultiUserChatPanel.class); - - public MultiUserChatPanel() - { - initGUI(); - } - - private void initGUI() - { - setLayout(new BorderLayout()); - textArea.setEditorKit(new LinkEditorKit()); - textArea.setDocument(document); - textArea.setEditable(false); - textArea.addHyperlinkListener(new HyperlinkAdapter(textArea)); - textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - textArea.setBackground(Color.WHITE); - textField = new JTextField(); - Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(1); - - set.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_JAPANESE_HIRAGANA, 0)); - textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); - - JScrollPane sp1 = new JScrollPane(textArea); - JPanel panel1 = new JPanel(new BorderLayout()); - - sp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - add(sp1, BorderLayout.CENTER); - add(textField, BorderLayout.SOUTH); - add(makeNorth(), BorderLayout.NORTH); - } - - private Box makeNorth() - { - Box northBox = Box.createHorizontalBox(); - - northBox.add(closeButton); - titleArea.setEditable(false); - northBox.add(titleArea); - - return northBox; - } - - public JTextPane getTextArea() - { - return textArea; - } - - public JTextField getTextField() - { - return textField; - } - - public JTextPane getTitleArea() - { - return titleArea; - } - - public JButton getCloseButton() - { - return closeButton; - } -} diff --git a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/RosterUserTreeCellRenderer.java b/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/RosterUserTreeCellRenderer.java deleted file mode 100644 index dd7b8e89..00000000 --- a/AJClientGUI/plugin_src/jabber/src/de/applejuicenet/client/gui/plugins/jabber/view/RosterUserTreeCellRenderer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.jabber.view; - -import java.awt.Component; - -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; - -import org.jivesoftware.smack.packet.Presence; - -import de.applejuicenet.client.gui.plugins.jabber.control.rostertree.RosterTreeNode; - -public class RosterUserTreeCellRenderer extends DefaultTreeCellRenderer -{ - public static ImageIcon available; - public static ImageIcon offline; - public static ImageIcon awk; - - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, - int row, boolean hasFocus) - { - Component comp = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); - RosterTreeNode node = (RosterTreeNode) value; - - if(null == node.getParent()) - { - - // rootnode - return comp; - } - - if(leaf) - { - ImageIcon icon; - - Presence presence = node.getPresence(); - String toolTipText; - - if(null == presence) - { - icon = offline; - toolTipText = "offline"; - } - else if(presence.getMode() == Presence.Mode.AVAILABLE) - { - icon = available; - toolTipText = presence.getMode().toString(); - } - else - { - icon = awk; - toolTipText = presence.getMode().toString(); - } - - ((JLabel) comp).setIcon(icon); - ((JLabel) comp).setToolTipText(toolTipText); - return comp; - } - - return comp; - } -} diff --git a/AJClientGUI/plugin_src/logviewer/icons/icon.gif b/AJClientGUI/plugin_src/logviewer/icons/icon.gif deleted file mode 100644 index bc856661..00000000 Binary files a/AJClientGUI/plugin_src/logviewer/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java b/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java deleted file mode 100644 index 61fc10ee..00000000 --- a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.logviewer; - -import java.awt.BorderLayout; -import java.io.File; -import java.io.FilenameFilter; -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTextPane; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java,v 1.4 2009/01/23 09:58:24 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: GPL</p> - * - * @author: loevenwong <timo@loevenwong.de> - * - */ -public class LogViewerPlugin extends PluginConnector -{ - private static Logger logger; - private static String path = AppleJuiceClient.getPath() + File.separator + "logs"; - private JSplitPane splitPane = null; - private JTextPane logPane = new JTextPane(); - private SortedStringListModel listModel = new SortedStringListModel(); - private JList list = new JList(listModel); - - public LogViewerPlugin(Properties pluginsProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - super(pluginsProperties, languageFiles, icon, availableIcons); - logger = Logger.getLogger(getClass()); - try - { - setLayout(new BorderLayout()); - logPane.setBackground(getBackground()); - logPane.setContentType("text/html"); - logPane.setEditable(false); - logPane.setBorder(null); - list.setCellRenderer(new FileNameListCellRenderer()); - splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(list), new JScrollPane(logPane)); - add(splitPane, BorderLayout.CENTER); - readLogDir(); - list.addListSelectionListener(new ListSelectionListener() - { - public void valueChanged(ListSelectionEvent e) - { - if(!e.getValueIsAdjusting()) - { - doDisplayLogfile(); - } - } - }); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - private void doDisplayLogfile() - { - try - { - File selectedLog = (File) list.getSelectedValue(); - - logPane.setPage("file://localhost/" + selectedLog.getAbsolutePath()); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - private void readLogDir() - { - File logPath = new File(path); - - if(!logPath.isDirectory()) - { - return; - } - - File[] htmlFiles = logPath.listFiles(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - return name.endsWith(".html"); - } - }); - - listModel.setData(htmlFiles); - } - - public void fireLanguageChanged() - { - } - - public void registerSelected() - { - } - - public void fireContentChanged(de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE arg0, Object arg1) - { - } -} diff --git a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerTestLoader.java b/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerTestLoader.java deleted file mode 100644 index 62e99aea..00000000 --- a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerTestLoader.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.logviewer; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class LogViewerTestLoader extends TestLoader -{ - @Override - protected String getPath() - { - return "logviewer"; - } - - @Override - protected PluginConnector getPlugin(Properties pluginsProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - return new LogViewerPlugin(pluginsProperties, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/serverwatcher/icons/icon.gif b/AJClientGUI/plugin_src/serverwatcher/icons/icon.gif deleted file mode 100644 index ffbb8254..00000000 Binary files a/AJClientGUI/plugin_src/serverwatcher/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/serverwatcher/plugin.properties b/AJClientGUI/plugin_src/serverwatcher/plugin.properties deleted file mode 100644 index 74bce7bc..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -general.title=ServerWatcher -general.version=1.5 -general.author=Maj0r -general.contact=tkrall@tkl-soft.de -general.description=Mit dem Serverwatcher kann der Status von Servern angezeigt werden. Benötigt wird ein GUI ab 0.70.4 -general.istab=true -general.classname=de.applejuicenet.client.gui.plugins.serverwatcher.ServerWatcherPlugin \ No newline at end of file diff --git a/AJClientGUI/plugin_src/serverwatcher/serverwatcher.xml b/AJClientGUI/plugin_src/serverwatcher/serverwatcher.xml deleted file mode 100644 index c3d20beb..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/serverwatcher.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<root> - <server> - </server> -</root> diff --git a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerConfig.java b/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerConfig.java deleted file mode 100644 index 82b35fe3..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.serverwatcher; - - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerConfig.java,v 1.3 2009/01/12 10:19:56 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ServerConfig -{ - private String bezeichnung; - private String dyn; - private String port; - private String userpass; - - public ServerConfig(String bezeichnung, String dyn, String port, String userpass) - { - this.bezeichnung = bezeichnung; - this.dyn = dyn; - this.port = port; - this.userpass = userpass; - } - - public ServerConfig(String dyn, String port, String userpass) - { - this.dyn = dyn; - bezeichnung = "a"; - int value; - - for(int i = 0; i < dyn.length(); i++) - { - value = (int) dyn.charAt(i); - if(value > 96 && value < 123) - { - bezeichnung += dyn.charAt(i); - } - } - - this.port = port; - this.userpass = new sun.misc.BASE64Encoder().encode(userpass.getBytes()); - } - - public String getBezeichnung() - { - return bezeichnung; - } - - public String getDyn() - { - return dyn; - } - - public String getPort() - { - return port; - } - - public String getUserPass() - { - return userpass; - } - - public String toString() - { - return dyn + ":" + port; - } -} diff --git a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherPlugin.java b/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherPlugin.java deleted file mode 100644 index 823653ef..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherPlugin.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.serverwatcher; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherPlugin.java,v 1.3 2009/01/12 10:19:56 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: GPL</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ServerWatcherPlugin extends PluginConnector -{ - private static Logger logger; - private JPanel topPanel = new JPanel(new GridBagLayout()); - private JEditorPane editorPane = new JEditorPane(); - private JComboBox ip = new JComboBox(); - private JButton status = new JButton("Status"); - private JButton serverliste = new JButton("Serverliste"); - private JButton neu = new JButton("Neu"); - private JButton entfernen = new JButton("Entfernen"); - private JLabel statusText = new JLabel(); - - public ServerWatcherPlugin(Properties pluginsProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - super(pluginsProperties, languageFiles, icon, availableIcons); - logger = Logger.getLogger(getClass()); - try - { - setLayout(new BorderLayout()); - initServerList(); - int height = ip.getPreferredSize().height; - - status.setPreferredSize(new Dimension(status.getPreferredSize().width, height)); - serverliste.setPreferredSize(new Dimension(serverliste.getPreferredSize().width, height)); - statusText.setPreferredSize(new Dimension(statusText.getPreferredSize().width, height)); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - - panel1.add(new JLabel("Server ")); - panel1.add(ip); - panel1.add(new JLabel(" ")); - panel1.add(neu); - panel1.add(entfernen); - JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - - panel2.add(status); - panel2.add(serverliste); - topPanel.add(panel1, constraints); - constraints.gridy = 1; - topPanel.add(panel2, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - topPanel.add(new JLabel(), constraints); - - status.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(ip.getSelectedIndex() != -1) - { - getHtmlContent(false); - } - } - }); - serverliste.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(ip.getSelectedIndex() != -1) - { - getHtmlContent(true); - } - } - }); - neu.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - NewServerDialog newServerDialog = new NewServerDialog(AppleJuiceDialog.getApp(), true); - Dimension appDimension = newServerDialog.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - newServerDialog.setLocation((screenSize.width - appDimension.width) / 2, - (screenSize.height - appDimension.height) / 2); - newServerDialog.setVisible(true); - if(newServerDialog.isSave()) - { - ServerXML.addServer(newServerDialog.getServerConfig()); - } - - initServerList(); - } - }); - entfernen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(ip.getSelectedIndex() != -1) - { - ServerXML.removeServer((ServerConfig) ip.getSelectedItem()); - initServerList(); - } - } - }); - add(topPanel, BorderLayout.NORTH); - editorPane.setEditable(false); - editorPane.setContentType("text/html"); - add(new JScrollPane(editorPane), BorderLayout.CENTER); - add(statusText, BorderLayout.SOUTH); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - private void initServerList() - { - ip.removeAllItems(); - ServerConfig[] server = ServerXML.getServer(); - - for(int i = 0; i < server.length; i++) - { - ip.addItem(server[i]); - } - } - - private void getHtmlContent(final boolean serverList) - { - Thread serverWatcherWorker = new Thread() - { - public void run() - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("ServerWatcherWorkerthread gestartet. " + this); - } - - serverliste.setEnabled(false); - status.setEnabled(false); - StringBuffer htmlContent = new StringBuffer(); - - try - { - ServerConfig server = (ServerConfig) ip.getSelectedItem(); - String tmpUrl = "http://" + server.getDyn() + ":" + server.getPort(); - - if(serverList) - { - tmpUrl += "/serverlist.htm"; - } - else - { - tmpUrl += "/status.htm"; - } - - URL url = new URL(tmpUrl); - ProxySettings proxySettings = ProxyManagerImpl.getInstance().getProxySettings(); - - if(proxySettings.isUse()) - { - System.getProperties().put("proxyHost", proxySettings.getHost()); - System.getProperties().put("proxyPort", Integer.toString(proxySettings.getPort())); - } - - URLConnection uc = url.openConnection(); - - if(proxySettings.isUse()) - { - uc.setRequestProperty("Proxy-Authorization", "Basic " + proxySettings.getUserpass()); - } - - uc.setRequestProperty("Authorization", "Basic " + server.getUserPass()); - InputStream content = uc.getInputStream(); - BufferedReader in = new BufferedReader(new InputStreamReader(content)); - String line; - - while((line = in.readLine()) != null) - { - htmlContent.append(line); - } - - if(proxySettings.isUse()) - { - System.getProperties().remove("proxyHost"); - System.getProperties().remove("proxyPort"); - } - - statusText.setText(""); - } - catch(MalformedURLException e) - { - editorPane.setText(""); - statusText.setText("Ungueltige URL"); - } - catch(IOException e) - { - editorPane.setText(""); - statusText.setText("Zugang verweigert"); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - - editorPane.setText(htmlContent.toString()); - serverliste.setEnabled(true); - status.setEnabled(true); - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("ServerWatcherWorkerthread beendet. " + this); - } - } - }; - - serverWatcherWorker.start(); - } - - public void fireLanguageChanged() - { - } - - /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. - ueber den DataManger koennen diese abgerufen werden.*/ - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - } - - public void registerSelected() - { - } -} diff --git a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherTestLoader.java b/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherTestLoader.java deleted file mode 100644 index f794e52b..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerWatcherTestLoader.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.serverwatcher; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class ServerWatcherTestLoader extends TestLoader -{ - @Override - protected String getPath() - { - return "serverwatcher"; - } - - @Override - protected PluginConnector getPlugin(Properties pluginsProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - return new ServerWatcherPlugin(pluginsProperties, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerXML.java b/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerXML.java deleted file mode 100644 index 5fb69a9e..00000000 --- a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerXML.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.serverwatcher; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import java.util.ArrayList; - -import com.sun.org.apache.xml.internal.serialize.OutputFormat; -import com.sun.org.apache.xml.internal.serialize.XMLSerializer; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import de.applejuicenet.client.fassade.shared.XMLDecoder; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/ServerXML.java,v 1.8 2009/01/12 10:19:56 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: GPL</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ServerXML extends XMLDecoder -{ - private static Logger logger; - private static String path; - - private ServerXML(String path) - { - super(); - File aFile = new File(path); - - if(!aFile.isFile()) - { - try - { - StringBuffer xmlData = new StringBuffer(); - - xmlData.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); - xmlData.append("<root>\r\n"); - xmlData.append(" <server>\r\n"); - xmlData.append(" </server>\r\n"); - xmlData.append("</root>\r\n"); - FileWriter fileWriter = new FileWriter(path); - - fileWriter.write(xmlData.toString()); - fileWriter.close(); - } - catch(IOException ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Fehler beim Anlegen der serverwatcher.xml", ex); - } - } - } - - reload(path); - logger = Logger.getLogger(getClass()); - } - - public static ServerConfig[] getServer() - { - try - { - path = getXMLPath(); - ServerXML connectionXML = new ServerXML(path); - Element e = null; - ArrayList<ServerConfig> serverConfigs = new ArrayList<ServerConfig>(); - String bezeichnung; - String dyn; - String port; - String userpass; - NodeList nodes = connectionXML.document.getElementsByTagName("server"); - - nodes = nodes.item(0).getChildNodes(); - int nodesSize = nodes.getLength(); - - for(int y = 0; y < nodesSize; y++) - { - if(nodes.item(y).getNodeType() == Node.ELEMENT_NODE) - { - e = (Element) nodes.item(y); - bezeichnung = e.getNodeName(); - dyn = e.getAttribute("dyn"); - port = e.getAttribute("port"); - userpass = e.getAttribute("userpass"); - serverConfigs.add(new ServerConfig(bezeichnung, dyn, port, userpass)); - } - } - - return (ServerConfig[]) serverConfigs.toArray(new ServerConfig[serverConfigs.size()]); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - - return null; - } - } - - public static String getXMLPath() - { - String path; - - if(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) - { - path = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui" + File.separator + - "plugins" + File.separator + "serverwatcher.xml"; - } - else - { - path = System.getProperty("user.dir") + File.separator + "plugins" + File.separator + "serverwatcher.xml"; - } - - return path; - } - - public static void addServer(ServerConfig serverConfig) - { - try - { - String path = getXMLPath(); - ServerXML connectionXML = new ServerXML(path); - - Element e = null; - NodeList nodes = connectionXML.document.getElementsByTagName(serverConfig.getBezeichnung()); - - if(nodes.getLength() > 0) - { - e = (Element) nodes.item(0); - e.setAttribute("dyn", serverConfig.getDyn()); - e.setAttribute("port", serverConfig.getPort()); - e.setAttribute("userpass", serverConfig.getUserPass()); - } - else - { - nodes = connectionXML.document.getElementsByTagName("server"); - e = (Element) nodes.item(0); - Node node = connectionXML.document.createElement(serverConfig.getBezeichnung()); - Element newNode = (Element) e.appendChild(node); - Attr attr1 = connectionXML.document.createAttribute("dyn"); - - attr1.setValue(serverConfig.getDyn()); - newNode.setAttributeNode(attr1); - Attr attr2 = connectionXML.document.createAttribute("port"); - - attr2.setValue(serverConfig.getPort()); - newNode.setAttributeNode(attr2); - Attr attr3 = connectionXML.document.createAttribute("userpass"); - - attr3.setValue(serverConfig.getUserPass()); - newNode.setAttributeNode(attr3); - } - - connectionXML.save(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - private void save() - { - try - { - XMLSerializer xs = new XMLSerializer(new FileWriter(path), new OutputFormat(document, "UTF-8", true)); - - xs.serialize(document); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - public static void removeServer(ServerConfig serverConfig) - { - try - { - String path = getXMLPath(); - ServerXML connectionXML = new ServerXML(path); - - Element e = null; - NodeList nodes = connectionXML.document.getElementsByTagName(serverConfig.getBezeichnung()); - - e = (Element) nodes.item(0); - Node parent = e.getParentNode(); - - parent.removeChild(e); - connectionXML.save(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } -} diff --git a/AJClientGUI/plugin_src/speedgraph/icons/icon.gif b/AJClientGUI/plugin_src/speedgraph/icons/icon.gif deleted file mode 100644 index 60cf1f3b..00000000 Binary files a/AJClientGUI/plugin_src/speedgraph/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/speedgraph/plugin.properties b/AJClientGUI/plugin_src/speedgraph/plugin.properties deleted file mode 100644 index 27fcd3ab..00000000 --- a/AJClientGUI/plugin_src/speedgraph/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -general.title=SpeedGraph -general.version=1.4 -general.author=Maj0r -general.contact=tkrall@tkl-soft.de -general.description=Der SpeedGraph zeigt die Historie der Download- und Uploadgeschwindigkeit an. Benötigt wird ein GUI ab 0.70.2 -general.istab=true -general.classname=de.applejuicenet.client.gui.plugins.speedgraph.SpeedGraphPlugin \ No newline at end of file diff --git a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/GraphPanel.java b/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/GraphPanel.java deleted file mode 100644 index 4b45e095..00000000 --- a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/GraphPanel.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.speedgraph; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.image.BufferedImage; - -import java.text.SimpleDateFormat; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import de.applejuicenet.client.AppleJuiceClient; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/GraphPanel.java,v 1.8 2009/01/12 11:59:59 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class GraphPanel extends JPanel -{ - private String uploadSpeedKey = "uploadspeed"; - private String downloadSpeedKey = "downloadspeed"; - private int leftBorder = 33; - private int width; - private int imageHeight; - private int bottomHeight = 30; - private int topHeight = 30; - private int minImageHeight = bottomHeight + 280; - private long time; - private SimpleDateFormat formatter = new SimpleDateFormat("HH:mm"); - private Font timeFont; - private Image image = null; - private UpdateThread updateThread; - private Map<Integer, Integer> pendingDownloadSpeeds = new HashMap<Integer, Integer>(); - private Map<Integer, Integer> pendingUploadSpeeds = new HashMap<Integer, Integer>(); - private double pxPerKb; - private int lastUploadY; - private int lastDownloadY; - private Integer curX = 0; - - public GraphPanel() - { - updateThread = new UpdateThread(); - updateThread.start(); - } - - @Override - protected void paintComponent(Graphics g) - { - if(null != image) - { - Dimension size = getSize(); - - // wird ggf. skaliert - g.drawImage(image, 0, 0, size.width, size.height, null); - } - else - { - super.paintComponent(g); - } - } - - @SuppressWarnings("unchecked") - public synchronized void update(HashMap speeds) - { - curX++; - synchronized(pendingDownloadSpeeds) - { - pendingDownloadSpeeds.put(curX, ((Long) speeds.get(downloadSpeedKey)).intValue()); - } - - synchronized(pendingDownloadSpeeds) - { - pendingUploadSpeeds.put(curX, ((Long) speeds.get(uploadSpeedKey)).intValue()); - } - } - - private class UpdateThread extends Thread - { - public UpdateThread() - { - super("SpeedGraphPaintThread"); - setDaemon(true); - } - - @Override - public void run() - { - while(true) - { - try - { - sleep(2000); - } - catch(InterruptedException e) - { - - // nix zu tun - ; - } - - if(null == image) - { - width = getWidth(); - if(getHeight() < minImageHeight) - { - imageHeight = minImageHeight; - } - else - { - imageHeight = getHeight(); - } - - if(width == 0 || imageHeight == 0) - { - - /* - Da kamen schneller Daten rein, als das Plugin angezeigt werden konnte. - Wir nehmen folglich erst den naechsten Durchgang. - */ - continue; - } - - long maxDownKb = AppleJuiceClient.getAjFassade().getCurrentAJSettings().getMaxDownloadInKB(); - - int remainingHeight = imageHeight - bottomHeight - topHeight; - - pxPerKb = ((double) remainingHeight) / (maxDownKb + 10); - - int yAbstaende = 30; - int anzahlMarks = (remainingHeight / yAbstaende); - - image = new BufferedImage(width, imageHeight, BufferedImage.TYPE_INT_ARGB); - Graphics g = image.getGraphics(); - - // erstmal schwaerzen - g.setColor(Color.BLACK); - g.fillRect(0, 0, width, imageHeight); - - g.setColor(Color.WHITE); - // senkrechte Linie - g.drawLine(leftBorder, imageHeight - bottomHeight, leftBorder, topHeight); - FontMetrics fm = g.getFontMetrics(); - String markText; - int strWidth; - int strHeight = fm.getHeight(); - - for(int i = 0; i <= anzahlMarks; i++) - { - markText = "" + (int) (((double) (maxDownKb + 10)) / anzahlMarks * i); - strWidth = fm.stringWidth(markText); - - g.drawString(markText, leftBorder - strWidth - 4, imageHeight - bottomHeight - i * yAbstaende); - g.drawLine(leftBorder - 2, imageHeight - bottomHeight - i * yAbstaende, width, - imageHeight - bottomHeight - i * yAbstaende); - } - - strWidth = fm.stringWidth("kb/s"); - g.drawString("kb/s", leftBorder - (strWidth / 2), topHeight / 2); - g.setColor(Color.GREEN); - g.drawLine(70, topHeight / 2, 85, topHeight / 2); - g.setColor(Color.WHITE); - g.drawString("Download", 92, topHeight / 4 * 3); - - g.setColor(Color.YELLOW); - g.drawLine(170, topHeight / 2, 185, topHeight / 2); - g.setColor(Color.WHITE); - g.drawString("Upload", 192, topHeight / 4 * 3); - - Font gFont = g.getFont(); - - timeFont = new Font(gFont.getName(), gFont.getStyle(), 9); - g.setFont(timeFont); - fm = g.getFontMetrics(); - time = System.currentTimeMillis(); - String actualTime = formatter.format(new Date(time)); - - strWidth = fm.stringWidth(actualTime); - g.drawString(actualTime, leftBorder - strWidth / 2, imageHeight - (bottomHeight / 2)); - } - - Map<Integer, Integer> copyPendingDownloadSpeeds = new HashMap<Integer, Integer>(); - Map<Integer, Integer> copyPendingUploadSpeeds = new HashMap<Integer, Integer>(); - - synchronized(pendingDownloadSpeeds) - { - copyPendingDownloadSpeeds.putAll(pendingDownloadSpeeds); - pendingDownloadSpeeds.clear(); - } - - synchronized(pendingDownloadSpeeds) - { - copyPendingUploadSpeeds.putAll(pendingUploadSpeeds); - pendingUploadSpeeds.clear(); - } - - Graphics g = image.getGraphics(); - - g.setColor(Color.GREEN); - Integer speed; - - int curLastX = -1; - - for(Integer actualX : copyPendingDownloadSpeeds.keySet()) - { - speed = copyPendingDownloadSpeeds.get(actualX); - int curY = (int) (speed * pxPerKb); - - if(actualX > 0) - { - g.drawLine(leftBorder + actualX - 1, imageHeight - bottomHeight - lastDownloadY, leftBorder + actualX, - imageHeight - bottomHeight - curY); - } - - lastDownloadY = curY; - curLastX = actualX; - } - - g.setColor(Color.YELLOW); - for(Integer actualX : copyPendingUploadSpeeds.keySet()) - { - speed = copyPendingUploadSpeeds.get(actualX); - int curY = (int) (speed * pxPerKb); - - if(actualX > 0) - { - g.drawLine(leftBorder + actualX - 1, imageHeight - bottomHeight - lastUploadY, leftBorder + actualX, - imageHeight - bottomHeight - curY); - } - - lastUploadY = curY; - curLastX = actualX; - } - - long curTime = System.currentTimeMillis(); - - if(curLastX != -1 && time - curTime > 300000) - { - g.setColor(Color.WHITE); - Font gFont = g.getFont(); - - timeFont = new Font(gFont.getName(), gFont.getStyle(), 9); - g.setFont(timeFont); - FontMetrics fm = g.getFontMetrics(); - - fm = g.getFontMetrics(); - String actualTime = formatter.format(new Date(curTime)); - - int strWidth = fm.stringWidth(actualTime); - - g.drawString(actualTime, leftBorder + curLastX - strWidth / 2, imageHeight - (bottomHeight / 2)); - time = curTime; - } - - if(SpeedGraphPlugin.doPaint) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - repaint(); - } - }); - } - } - } - } -} diff --git a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPlugin.java b/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPlugin.java deleted file mode 100644 index 626b8116..00000000 --- a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPlugin.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.speedgraph; - -import java.awt.BorderLayout; -import java.awt.Color; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; -import javax.swing.JScrollPane; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPlugin.java,v 1.4 2009/01/12 11:59:59 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class SpeedGraphPlugin extends PluginConnector -{ - private static Logger logger; - private GraphPanel graphPanel = new GraphPanel(); - public static boolean doPaint = false; - - public SpeedGraphPlugin(Properties properties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - super(properties, languageFiles, icon, availableIcons); - logger = Logger.getLogger(getClass()); - try - { - setLayout(new BorderLayout()); - graphPanel.setBackground(Color.BLACK); - add(new JScrollPane(graphPanel), BorderLayout.CENTER); - setBackground(Color.BLACK); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.SPEED_CHANGED); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - public void fireLanguageChanged() - { - } - - /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. - Über den DataManger können diese abgerufen werden.*/ - @SuppressWarnings("unchecked") - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - if(type == DATALISTENER_TYPE.SPEED_CHANGED) - { - graphPanel.update((HashMap) content); - } - } - - public void registerSelected() - { - doPaint = true; - } - - @Override - public void lostSelection() - { - doPaint = false; - } -} diff --git a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPluginTestLoader.java b/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPluginTestLoader.java deleted file mode 100644 index 29e1c230..00000000 --- a/AJClientGUI/plugin_src/speedgraph/src/de/applejuicenet/client/gui/plugins/speedgraph/SpeedGraphPluginTestLoader.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.speedgraph; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class SpeedGraphPluginTestLoader extends TestLoader -{ - public SpeedGraphPluginTestLoader() - { - super(); - } - - @Override - protected String getPath() - { - return "speedgraph"; - } - - @Override - protected PluginConnector getPlugin(Properties properties, Map<String, Properties> languageFiles, - ImageIcon icon, Map<String, ImageIcon> availableIcons) - { - return new SpeedGraphPlugin(properties, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/versionchecker/icons/icon.gif b/AJClientGUI/plugin_src/versionchecker/icons/icon.gif deleted file mode 100644 index ffbb8254..00000000 Binary files a/AJClientGUI/plugin_src/versionchecker/icons/icon.gif and /dev/null differ diff --git a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersionChecker.java b/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersionChecker.java deleted file mode 100644 index f5033f2e..00000000 --- a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersionChecker.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.versionchecker; - -import java.awt.BorderLayout; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.Upload; -import de.applejuicenet.client.gui.plugins.PluginConnector; -import de.applejuicenet.client.gui.plugins.versionchecker.panels.MainPanel; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersionChecker.java,v 1.5 2009/01/12 10:18:00 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: GPL</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class VersionChecker extends PluginConnector -{ - private MainPanel mainPanel; - private Logger logger; - - public VersionChecker(Properties pluginProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - super(pluginProperties, languageFiles, icon, availableIcons); - logger = Logger.getLogger(getClass()); - try - { - setLayout(new BorderLayout()); - mainPanel = new MainPanel(); - add(mainPanel, BorderLayout.CENTER); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.UPLOAD_CHANGED); - } - catch(Exception e) - { - logger.error("Unbehandelte Exception", e); - } - } - - public void fireLanguageChanged() - { - } - - /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. - ueber den DataManger koennen diese abgerufen werden.*/ - @SuppressWarnings("unchecked") - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - try - { - if(type == DATALISTENER_TYPE.DOWNLOAD_CHANGED) - { - HashMap<String, Download> downloads = (HashMap<String, Download>) content; - - mainPanel.updateByDownload(downloads); - } - else if(type == DATALISTENER_TYPE.UPLOAD_CHANGED) - { - HashMap<String, Upload> uploads = (HashMap<String, Upload>) content; - - mainPanel.updateByUploads(uploads); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error("Unbehandelte Exception", e); - } - } - } - - public void registerSelected() - { - } -} diff --git a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerTestLoader.java b/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerTestLoader.java deleted file mode 100644 index 004c4337..00000000 --- a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerTestLoader.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugins.versionchecker; - -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import de.applejuicenet.client.gui.plugincontrol.TestLoader; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -public class VersioncheckerTestLoader extends TestLoader -{ - @Override - protected String getPath() - { - return "versionchecker"; - } - - @Override - protected PluginConnector getPlugin(Properties pluginProperties, Map<String, Properties> languageFiles, ImageIcon icon, - Map<String, ImageIcon> availableIcons) - { - return new VersionChecker(pluginProperties, languageFiles, icon, availableIcons); - } -} diff --git a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java b/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java deleted file mode 100644 index 484d02c3..00000000 --- a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java +++ /dev/null @@ -1,374 +0,0 @@ -package de.applejuicenet.client.gui.plugins.versionchecker.panels; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; - -import java.text.DecimalFormat; - -import java.util.HashMap; -import java.util.HashSet; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableCellRenderer; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Upload; -import de.applejuicenet.client.fassade.entity.Version; -import de.applejuicenet.client.shared.IconManager; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java,v 1.1 2006/05/04 14:15:17 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class MainPanel extends JPanel -{ - private Logger logger; - private HashMap<String, VersionHolder> versions = new HashMap<String, VersionHolder>(); - private HashSet<String> ids = new HashSet<String>(); - private VersionTableModel versionTableModel = new VersionTableModel(); - private JTable versionTable; - private DecimalFormat formatter = new DecimalFormat("###,##0.00"); - - public MainPanel() - { - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - logger.error("Unbehandelte Exception", e); - } - } - - private void init() - { - setLayout(new BorderLayout()); - versionTableModel = new VersionTableModel(); - versionTable = new JTable(); - versionTable.setModel(versionTableModel); - for(int i = 0; i < versionTable.getColumnCount(); i++) - { - versionTable.getTableHeader().getColumnModel().getColumn(i).setHeaderRenderer(new TableHeaderCellRenderer()); - if(i > 0) - { - versionTable.getColumnModel().getColumn(i).setCellRenderer(new TableValueCellRenderer()); - } - } - - add(new JScrollPane(versionTable), BorderLayout.CENTER); - } - - public void updateByDownload(HashMap<String, Download> downloads) - { - String versionsNr; - String key; - String key2; - VersionHolder versionHolder; - boolean updateView = false; - - try - { - synchronized(downloads) - { - for(Download curDownload : downloads.values()) - { - if(curDownload == null) - { - continue; - } - - for(DownloadSource curSource : curDownload.getSources()) - { - if(curSource == null || curSource.getVersion() == null) - { - continue; - } - - key = Integer.toString(curSource.getId()); - if(!ids.contains(key)) - { - updateView = true; - ids.add(key); - versionsNr = curSource.getVersion().getVersion(); - key2 = versionsNr; - if(versions.containsKey(key2)) - { - versionHolder = versions.get(key2); - } - else - { - versionHolder = new VersionHolder(versionsNr); - versions.put(key2, versionHolder); - } - - versionHolder.addUser(curSource.getVersion().getBetriebsSystem()); - } - } - } - } - - if(updateView) - { - versionTableModel.setTable(versions); - updateTableHeader(); - } - } - catch(Exception e) - { - logger.error("Unbehandelte Exception", e); - } - } - - private void updateTableHeader() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - versionTable.getTableHeader().updateUI(); - } - }); - } - - public void updateByUploads(HashMap<String, Upload> uploads) - { - String versionsNr; - String key; - String key2; - VersionHolder versionHolder; - boolean updateView = false; - - try - { - synchronized(uploads) - { - for(Upload curUpload : uploads.values()) - { - if(curUpload == null || curUpload.getVersion() == null) - { - continue; - } - - key = Integer.toString(curUpload.getId()); - if(!ids.contains(key)) - { - updateView = true; - ids.add(key); - versionsNr = curUpload.getVersion().getVersion(); - key2 = versionsNr; - if(versions.containsKey(key2)) - { - versionHolder = versions.get(key2); - } - else - { - versionHolder = new VersionHolder(versionsNr); - versions.put(key2, versionHolder); - } - - versionHolder.addUser(curUpload.getVersion().getBetriebsSystem()); - } - } - } - - if(updateView) - { - versionTableModel.setTable(versions); - updateTableHeader(); - } - } - catch(Exception e) - { - logger.error("Unbehandelte Exception", e); - } - } - - class TableHeaderCellRenderer extends JLabel implements TableCellRenderer - { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, - int column) - { - switch(column) - { - - case 1: - { - setIcon(getVersionIcon(Version.WIN32)); - setText(value.toString() + getPercent(Version.WIN32)); - break; - } - - case 2: - { - setIcon(getVersionIcon(Version.LINUX)); - setText(value.toString() + getPercent(Version.LINUX)); - break; - } - - case 3: - { - setIcon(getVersionIcon(Version.MACINTOSH)); - setText(value.toString() + getPercent(Version.MACINTOSH)); - break; - } - - case 4: - { - setIcon(getVersionIcon(Version.SOLARIS)); - setText(value.toString() + getPercent(Version.SOLARIS)); - break; - } - - case 5: - { - setIcon(getVersionIcon(Version.OS2)); - setText(value.toString() + getPercent(Version.OS2)); - break; - } - - case 6: - { - setIcon(getVersionIcon(Version.FREEBSD)); - setText(value.toString() + getPercent(Version.FREEBSD)); - break; - } - - case 7: - { - setIcon(getVersionIcon(Version.NETWARE)); - setText(value.toString() + getPercent(Version.NETWARE)); - break; - } - - case 8: - { - setIcon(getVersionIcon(-11 /*unbekannt*/)); - setText(value.toString() + getPercent(-11)); - break; - } - - default: - - //setText(value.toString()); - break; - } - - setBackground(table.getBackground()); - setForeground(table.getForeground()); - setEnabled(table.isEnabled()); - setFont(table.getFont()); - setOpaque(true); - return this; - } - } - - private String getPercent(int os) - { - if(VersionHolder.countAll == 0) - { - return ""; - } - - int gesamt = 0; - - for(VersionHolder curHolder : versions.values()) - { - gesamt += curHolder.getUser(os); - } - - if(gesamt == 0) - { - return ""; - } - - double percent = (double) gesamt / VersionHolder.countAll * 100; - - return " ( " + formatter.format(percent) + "% )"; - } - - private Icon getVersionIcon(int version) - { - switch(version) - { - - case Version.WIN32: - return IconManager.getInstance().getIcon("winsymbol"); - - case Version.LINUX: - return IconManager.getInstance().getIcon("linuxsymbol"); - - case Version.FREEBSD: - return IconManager.getInstance().getIcon("freebsdsymbol"); - - case Version.MACINTOSH: - return IconManager.getInstance().getIcon("macsymbol"); - - case Version.SOLARIS: - return IconManager.getInstance().getIcon("sunossymbol"); - - case Version.NETWARE: - return IconManager.getInstance().getIcon("netwaresymbol"); - - case Version.OS2: - return IconManager.getInstance().getIcon("os2symbol"); - - default: - return IconManager.getInstance().getIcon("unbekanntsymbol"); - } - } - - class TableValueCellRenderer extends JLabel implements TableCellRenderer - { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, - int column) - { - setText(value.toString()); - if(isSelected) - { - setForeground(table.getSelectionForeground()); - setBackground(table.getSelectionBackground()); - } - else - { - setBackground(table.getBackground()); - try - { - if(Integer.parseInt(value.toString()) > 0) - { - setForeground(Color.BLUE); - } - else - { - setForeground(table.getForeground()); - } - } - catch(Exception e) - { - setForeground(table.getForeground()); - } - } - - setEnabled(table.isEnabled()); - setFont(table.getFont()); - setOpaque(true); - return this; - } - } -} diff --git a/AJClientGUI/plugins/ircplugin.jar b/AJClientGUI/plugins/ircplugin.jar deleted file mode 100644 index c29318af..00000000 Binary files a/AJClientGUI/plugins/ircplugin.jar and /dev/null differ diff --git a/AJClientGUI/plugins/logviewerplugin.jar b/AJClientGUI/plugins/logviewerplugin.jar deleted file mode 100644 index 9a77dd0b..00000000 Binary files a/AJClientGUI/plugins/logviewerplugin.jar and /dev/null differ diff --git a/AJClientGUI/plugins/readme.txt b/AJClientGUI/plugins/readme.txt deleted file mode 100644 index 7c10be6b..00000000 --- a/AJClientGUI/plugins/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -In dieses Verzeichnis kommen die Plugins als jar-Archive rein. -Falls Du Linux verwendest, wird dieses Verzeichnis nicht beachtet. Dann gehören Plugins ins Verzeichnis ~/appleJuice/gui/plugins . \ No newline at end of file diff --git a/AJClientGUI/plugins/serverwatcher.jar b/AJClientGUI/plugins/serverwatcher.jar deleted file mode 100644 index a8b6655e..00000000 Binary files a/AJClientGUI/plugins/serverwatcher.jar and /dev/null differ diff --git a/AJClientGUI/plugins/versioncheckerplugin.jar b/AJClientGUI/plugins/versioncheckerplugin.jar deleted file mode 100644 index 5d7f033d..00000000 Binary files a/AJClientGUI/plugins/versioncheckerplugin.jar and /dev/null differ diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/ApplejuiceFassadeDummy.java b/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/ApplejuiceFassadeDummy.java deleted file mode 100644 index d238cd1c..00000000 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/ApplejuiceFassadeDummy.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Created on 14.02.2005 - */ -package test.de.applejuicenet.client.gui.powerdownload; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import junit.framework.Assert; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; - -/** - * @author loevenit - */ -public class ApplejuiceFassadeDummy extends ApplejuiceFassade -{ - private Map<String, Download> snapshot = null; - private List<DownloadDummy> expected = new Vector<DownloadDummy>(); - - public ApplejuiceFassadeDummy(Map<String, Download> downloads) throws IllegalArgumentException - { - super(new CoreConnectionSettingsHolder("localhost", new Integer(80), "", true)); - snapshot = downloads; - } - - public ApplejuiceFassadeDummy() throws IllegalArgumentException - { - super(new CoreConnectionSettingsHolder("localhost", new Integer(80), "", true)); - snapshot = new HashMap<String,Download>(); - } - - public Map<String, Download> getDownloadsSnapshot() - { - return snapshot; - } - - public void pauseDownload(List<Download> downloads) - throws IllegalArgumentException - { - for (Download cur : downloads) { - ((DownloadDummy)cur).setStatus(Download.PAUSIERT); - snapshot.put(Integer.toString(cur.getId()), cur); - } - } - - public void resumeDownload(List<Download> downloads) - throws IllegalArgumentException - { - for (Download cur : downloads) { - ((DownloadDummy)cur).setStatus(Download.SUCHEN_LADEN); - snapshot.put(Integer.toString(cur.getId()), cur); - } - } - public void setPowerDownload(List<Download> downloads, Integer powerDownload) - throws IllegalArgumentException - { - for (Download cur : downloads) { - ((DownloadDummy)cur).setPowerdownload(powerDownload); - snapshot.put(Integer.toString(cur.getId()), cur); - } - } - - public void addDownload(Download download) - { - this.snapshot.put(Integer.toString(download.getId()), download); - } - - public void addExpectedDownload(DownloadDummy dummy) - { - this.expected.add(dummy); - } - - public void clearExpectedDownload() - { - this.expected.clear(); - } - - public void verify() { - Assert.assertEquals("expected.size() != snapshot.size()", expected.size(), snapshot.size()); - for (DownloadDummy cur : expected) { - Download download = snapshot.get(Integer.toString(cur.getId())); - Assert.assertNotNull(download); - Assert.assertEquals("Filename nicht gleich", cur.getFilename(), download.getFilename()); - Assert.assertEquals("Status nicht gleich", cur.getStatus(), download.getStatus()); - Assert.assertEquals("BereitsGeladen nicht gleich", cur.getProzentGeladen(), download.getProzentGeladen(), 0.00); - Assert.assertEquals("Powerdownload nicht gleich", cur.getPowerDownload(), download.getPowerDownload()); - Assert.assertEquals("Groesse nicht gleich", cur.getGroesse(), download.getGroesse()); - Assert.assertEquals("quellen nicht gleich", cur.getSources(), download.getSources()); - } - } -} diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadDummy.java b/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadDummy.java deleted file mode 100644 index 363a1606..00000000 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadDummy.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Created on 14.02.2005 - */ -package test.de.applejuicenet.client.gui.powerdownload; - -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; - -/** - * @author loevenit - */ -public class DownloadDummy implements Download -{ - private Integer id; - private String bezeichnung; - private double prozentGeladen; - private int status; - private int powerdwl; - private long groesse; - private DownloadSource[] quellen; - - public DownloadDummy(Integer id, String bezeichnung, double prozentGeladen, int status, int powerdwl, long groesse, DownloadSource[] quellen) - { - super(); - this.id = id; - this.bezeichnung = bezeichnung; - this.prozentGeladen = prozentGeladen; - this.status = status; - this.powerdwl = powerdwl; - this.groesse = groesse; - this.quellen = quellen; - } - - public DownloadDummy(Integer id, String bezeichnung, double prozentGeladen, int status, int powerdwl) - { - this(id, bezeichnung, prozentGeladen, status, powerdwl, 0, null); - } - - public DownloadDummy(int id, String bezeichnung, double prozentGeladen, int status, int powerdwl) - { - this(new Integer(id), bezeichnung, prozentGeladen, status, powerdwl); - } - - public DownloadDummy(int id, double prozentGeladen, int status, int powerdwl, int groesse, DownloadSource[] quellen) - { - this(new Integer(id), "", prozentGeladen, status, powerdwl, groesse, quellen); - } - - public DownloadDummy(int id, double prozentGeladen, int status, int powerdwl, int groesse) - { - this(new Integer(id), "", prozentGeladen, status, powerdwl, groesse, null); - } - - public DownloadDummy(int id, double prozentGeladen, int status, int powerdwl) - { - this(id, prozentGeladen, status, powerdwl, 0); - } - - public DownloadDummy(int id, int status, int powerdwl, int groesse) - { - this(id, 1.0, status, powerdwl, groesse); - } - - public String getProzentGeladenAsString() - { - return Double.toString(prozentGeladen); - } - - public double getProzentGeladen() - { - return prozentGeladen; - } - - public DownloadSource getSourceById(int sourceId) - { - // TODO Auto-generated method stub - return null; - } - - public DownloadSource[] getSources() - { - return quellen; - } - - public int getShareId() - { - // TODO Auto-generated method stub - return 0; - } - - public String getHash() - { - // TODO Auto-generated method stub - return null; - } - - public long getGroesse() - { - return groesse; - } - - public int getStatus() - { - return status; - } - - public String getFilename() - { - return bezeichnung; - } - - public String getTargetDirectory() - { - // TODO Auto-generated method stub - return null; - } - - public int getPowerDownload() - { - return powerdwl; - } - - public int getId() - { - return id.intValue(); - } - - public int getTemporaryFileNumber() - { - // TODO Auto-generated method stub - return 0; - } - - public long getReady() - { - // TODO Auto-generated method stub - return 0; - } - - public long getRestZeit() - { - // TODO Auto-generated method stub - return 0; - } - - public String getRestZeitAsString() - { - // TODO Auto-generated method stub - return null; - } - - public long getSpeedInBytes() - { - // TODO Auto-generated method stub - return 0; - } - - public long getBereitsGeladen() - { - return 0; - } - - public void setStatus(int status) - { - this.status = status; - } - - public void setPowerdownload(Integer powerDownload) - { - this.powerdwl = powerDownload.intValue(); - } -} \ No newline at end of file diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadSourceDummy.java b/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadSourceDummy.java deleted file mode 100644 index 9c5c5563..00000000 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/DownloadSourceDummy.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Created on 17.02.2005 - */ -package test.de.applejuicenet.client.gui.powerdownload; - -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Version; - -/** - * @author loevenit - */ -public class DownloadSourceDummy extends DownloadSource -{ - - public int getStatus() - { - // TODO Auto-generated method stub - return 0; - } - - public int getSize() - { - // TODO Auto-generated method stub - return 0; - } - - public int getHerkunft() - { - // TODO Auto-generated method stub - return 0; - } - - public int getDirectstate() - { - // TODO Auto-generated method stub - return 0; - } - - public int getDownloadFrom() - { - // TODO Auto-generated method stub - return 0; - } - - public int getDownloadTo() - { - // TODO Auto-generated method stub - return 0; - } - - public int getActualDownloadPosition() - { - // TODO Auto-generated method stub - return 0; - } - - public int getSpeed() - { - // TODO Auto-generated method stub - return 0; - } - - public Version getVersion() - { - // TODO Auto-generated method stub - return null; - } - - public int getQueuePosition() - { - // TODO Auto-generated method stub - return 0; - } - - public int getPowerDownload() - { - // TODO Auto-generated method stub - return 0; - } - - public String getFilename() - { - // TODO Auto-generated method stub - return null; - } - - public String getNickname() - { - // TODO Auto-generated method stub - return null; - } - - public int getId() - { - // TODO Auto-generated method stub - return 0; - } - - public int getDownloadId() - { - // TODO Auto-generated method stub - return 0; - } - -} diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/TestStandardAutomaticPwdlPolicy.java b/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/TestStandardAutomaticPwdlPolicy.java deleted file mode 100644 index f845e1e1..00000000 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/test/de/applejuicenet/client/gui/powerdownload/TestStandardAutomaticPwdlPolicy.java +++ /dev/null @@ -1,288 +0,0 @@ - -package test.de.applejuicenet.client.gui.powerdownload; - -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.gui.powerdownload.StandardAutomaticPwdlPolicy; -import de.applejuicenet.client.gui.powerdownload.StandardAutomaticPwdlPolicy.Reihenfolge; - -public class TestStandardAutomaticPwdlPolicy extends TestCase -{ - private ApplejuiceFassadeDummy fassade = null; - private StandardAutomaticPwdlPolicy policy = null; - private DownloadSourceDummy DUMMY = new DownloadSourceDummy(); - private DownloadSource[] EINE_QUELLE = new DownloadSource[]{DUMMY}; - private DownloadSource[] ZWEI_QUELLEN = new DownloadSource[]{DUMMY,DUMMY}; - private DownloadSource[] DREI_QUELLEN = new DownloadSource[]{DUMMY,DUMMY,DUMMY}; - private DownloadSource[] VIER_QUELLEN = new DownloadSource[]{DUMMY,DUMMY,DUMMY,DUMMY}; - private static Reihenfolge[] SOURCEN_PROZENT_GROESSE = - new Reihenfolge[]{ - Reihenfolge.SOURCEN, - Reihenfolge.PROZENT_GELADEN, - Reihenfolge.GROESSE, - Reihenfolge.ID - }; - private static Reihenfolge[] PROZENT_SOURCEN_GROESSE = - new Reihenfolge[]{ - Reihenfolge.PROZENT_GELADEN, - Reihenfolge.SOURCEN, - Reihenfolge.GROESSE, - Reihenfolge.ID - }; - private static Reihenfolge[] GROESSE_PROZENT_SOURCEN = - new Reihenfolge[]{ - Reihenfolge.GROESSE, - Reihenfolge.PROZENT_GELADEN, - Reihenfolge.SOURCEN, - Reihenfolge.ID - }; - - protected void setUp() throws Exception - { - super.setUp(); - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - } - - protected void tearDown() throws Exception - { - super.tearDown(); - fassade = null; - policy = null; - } - - public void testDoSimpleAction() throws IllegalArgumentException - { - try - { - policy.doAction(); - } - catch (Exception e) - { - fail("Fehler: " + e.getMessage()); - e.printStackTrace(); - } - fassade.verify(); - } - - public void testDoOneAction() throws IllegalArgumentException - { - Map<String,Download> downloads = new HashMap<String,Download>(); - downloads.put(Integer.toString(1), new DownloadDummy(new Integer(1), "bla1", 1.1, Download.SUCHEN_LADEN, 1)); - fassade = new ApplejuiceFassadeDummy(downloads); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addExpectedDownload(new DownloadDummy(new Integer(1), "bla1", 1.1, Download.SUCHEN_LADEN, 3)); - try - { - policy.doAction(); - } - catch (Exception e) - { - fail("Fehler: " + e.getMessage()); - e.printStackTrace(); - } - fassade.verify(); - } - - public void testDoFourAction() throws Exception - { - fassade = new ApplejuiceFassadeDummy(new HashMap<String,Download>()); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addDownload(new DownloadDummy(1, 0.0, Download.SUCHEN_LADEN, 1)); - fassade.addDownload(new DownloadDummy(2, 0.0, Download.SUCHEN_LADEN, 1)); - fassade.addDownload(new DownloadDummy(3, 1.3, Download.SUCHEN_LADEN, 1)); - fassade.addDownload(new DownloadDummy(4, 1.4, Download.SUCHEN_LADEN, 1)); - fassade.addExpectedDownload(new DownloadDummy(1, 0.0, Download.PAUSIERT, 1)); - fassade.addExpectedDownload(new DownloadDummy(2, 0.0, Download.PAUSIERT, 1)); - fassade.addExpectedDownload(new DownloadDummy(3, 1.3, Download.PAUSIERT, 1)); - fassade.addExpectedDownload(new DownloadDummy(4, 1.4, Download.SUCHEN_LADEN, 3)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoActionGroesse() throws Exception - { - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addDownload(new DownloadDummy(1, 10.0, Download.SUCHEN_LADEN, 1, 10)); - fassade.addDownload(new DownloadDummy(2, 10.0, Download.SUCHEN_LADEN, 1, 20)); - fassade.addDownload(new DownloadDummy(3, 1.3, Download.SUCHEN_LADEN, 1, 30)); - fassade.addDownload(new DownloadDummy(4, 1.4, Download.SUCHEN_LADEN, 1, 40)); - fassade.addDownload(new DownloadDummy(5, 10.0, Download.SUCHEN_LADEN, 1, 15)); - fassade.addExpectedDownload(new DownloadDummy(1, 10.0, Download.PAUSIERT, 1, 10)); - fassade.addExpectedDownload(new DownloadDummy(2, 10.0, Download.SUCHEN_LADEN, 3, 20)); - fassade.addExpectedDownload(new DownloadDummy(3, 1.3, Download.PAUSIERT, 1, 30)); - fassade.addExpectedDownload(new DownloadDummy(4, 1.4, Download.PAUSIERT, 1, 40)); - fassade.addExpectedDownload(new DownloadDummy(5, 10.0, Download.PAUSIERT, 1, 15)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoActionGroesseProzentSourcen() throws Exception - { - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 3, 3, GROESSE_PROZENT_SOURCEN); - - fassade.addDownload(new DownloadDummy(1, 20.0, Download.SUCHEN_LADEN, 1, 30, EINE_QUELLE)); - fassade.addDownload(new DownloadDummy(2, 99.0, Download.SUCHEN_LADEN, 1, 30, EINE_QUELLE)); - fassade.addDownload(new DownloadDummy(3, 20.0, Download.SUCHEN_LADEN, 1, 30, ZWEI_QUELLEN)); - fassade.addDownload(new DownloadDummy(4, 20.0, Download.SUCHEN_LADEN, 1, 40, EINE_QUELLE)); - fassade.addDownload(new DownloadDummy(5, 20.0, Download.SUCHEN_LADEN, 1, 30, EINE_QUELLE)); - - fassade.addExpectedDownload(new DownloadDummy(1, 20.0, Download.PAUSIERT, 1, 30, EINE_QUELLE)); - fassade.addExpectedDownload(new DownloadDummy(2, 99.0, Download.SUCHEN_LADEN, 3, 30, EINE_QUELLE)); - fassade.addExpectedDownload(new DownloadDummy(3, 20.0, Download.SUCHEN_LADEN, 3, 30, ZWEI_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(4, 20.0, Download.SUCHEN_LADEN, 3, 40, EINE_QUELLE)); - fassade.addExpectedDownload(new DownloadDummy(5, 20.0, Download.PAUSIERT, 1, 30, EINE_QUELLE)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoActionProzentUndSourcen() throws Exception - { - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addDownload(new DownloadDummy(1, 10.0, Download.SUCHEN_LADEN, 1, 100, EINE_QUELLE)); - fassade.addDownload(new DownloadDummy(2, 10.0, Download.SUCHEN_LADEN, 1, 20, VIER_QUELLEN)); - fassade.addDownload(new DownloadDummy(3, 1.3, Download.SUCHEN_LADEN, 1, 30, ZWEI_QUELLEN)); - fassade.addDownload(new DownloadDummy(4, 1.4, Download.SUCHEN_LADEN, 1, 40, DREI_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(1, 10.0, Download.PAUSIERT, 1, 100, EINE_QUELLE)); - fassade.addExpectedDownload(new DownloadDummy(2, 10.0, Download.SUCHEN_LADEN, 3, 20, VIER_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(3, 1.3, Download.PAUSIERT, 1, 30, ZWEI_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(4, 1.4, Download.PAUSIERT, 1, 40, DREI_QUELLEN)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoActionQuellen() throws Exception - { - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 2, 3, SOURCEN_PROZENT_GROESSE); - - fassade.addDownload(new DownloadDummy(1, 90.0, Download.SUCHEN_LADEN, 1, 30, ZWEI_QUELLEN)); - fassade.addDownload(new DownloadDummy(2, 90.0, Download.SUCHEN_LADEN, 1, 30, EINE_QUELLE)); - fassade.addDownload(new DownloadDummy(3, 30.0, Download.SUCHEN_LADEN, 1, 10, VIER_QUELLEN)); - fassade.addDownload(new DownloadDummy(4, 40.0, Download.SUCHEN_LADEN, 1, 10, DREI_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(1, 90.0, Download.PAUSIERT, 1, 30, ZWEI_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(2, 90.0, Download.PAUSIERT, 1, 30, EINE_QUELLE)); - fassade.addExpectedDownload(new DownloadDummy(3, 30.0, Download.SUCHEN_LADEN, 3, 10, VIER_QUELLEN)); - fassade.addExpectedDownload(new DownloadDummy(4, 40.0, Download.SUCHEN_LADEN, 3, 10, DREI_QUELLEN)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoAction() throws Exception - { - fassade = new ApplejuiceFassadeDummy(); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addDownload(new DownloadDummy(1, Download.SUCHEN_LADEN, 1, 10)); - fassade.addDownload(new DownloadDummy(2, Download.SUCHEN_LADEN, 1, 20)); - fassade.addExpectedDownload(new DownloadDummy(1, Download.PAUSIERT, 1, 10)); - fassade.addExpectedDownload(new DownloadDummy(2, Download.SUCHEN_LADEN, 3, 20)); - - policy.doAction(); - fassade.verify(); - - fassade.addDownload(new DownloadDummy(3, 0.0, Download.SUCHEN_LADEN, 1)); - fassade.addExpectedDownload(new DownloadDummy(3, 0.0, Download.PAUSIERT, 1)); - - policy.doAction(); - fassade.verify(); - } - - public void testDoNextAction() throws Exception - { - Map<String,Download> downloads = new HashMap<String,Download>(); - downloads.put(Integer.toString(1), new DownloadDummy(new Integer(1), "bla1", 1.1, Download.SUCHEN_LADEN, 1)); - downloads.put(Integer.toString(2), new DownloadDummy(new Integer(2), "bla2", 1.2, Download.SUCHEN_LADEN, 1)); - downloads.put(Integer.toString(3), new DownloadDummy(new Integer(3), "bla3", 1.3, Download.PAUSIERT, 3)); - downloads.put(Integer.toString(4), new DownloadDummy(new Integer(4), "bla4", 1.4, Download.FERTIG, 1)); - - fassade = new ApplejuiceFassadeDummy(downloads); - policy = new StandardAutomaticPwdlPolicy(fassade, 2, 3, PROZENT_SOURCEN_GROESSE); - - policy.doAction(); - - fassade.addExpectedDownload(new DownloadDummy(new Integer(1), "bla1", 1.1, Download.PAUSIERT, 1)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(2), "bla2", 1.2, Download.SUCHEN_LADEN, 3)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(3), "bla3", 1.3, Download.SUCHEN_LADEN, 3)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(4), "bla4", 1.4, Download.FERTIG, 1)); - - fassade.verify(); - } - - public void testDoEndeAction() throws Exception - { - Map<String,Download> downloads = new HashMap<String,Download>(); - downloads.put(Integer.toString(1), new DownloadDummy(new Integer(1), "bla1", 1.1, Download.FERTIG, 1)); - downloads.put(Integer.toString(2), new DownloadDummy(new Integer(2), "bla2", 1.2, Download.FERTIG, 1)); - downloads.put(Integer.toString(3), new DownloadDummy(new Integer(3), "bla3", 1.3, Download.FERTIG, 3)); - downloads.put(Integer.toString(4), new DownloadDummy(new Integer(4), "bla4", 1.4, Download.FERTIG, 1)); - - fassade = new ApplejuiceFassadeDummy(downloads); - policy = new StandardAutomaticPwdlPolicy(fassade, 2, 3, PROZENT_SOURCEN_GROESSE); - - policy.doAction(); - - fassade.addExpectedDownload(new DownloadDummy(new Integer(1), "bla1", 1.1, Download.FERTIG, 1)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(2), "bla2", 1.2, Download.FERTIG, 1)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(3), "bla3", 1.3, Download.FERTIG, 3)); - fassade.addExpectedDownload(new DownloadDummy(new Integer(4), "bla4", 1.4, Download.FERTIG, 1)); - - fassade.verify(); - } - - public void testDoActionOneAdded() throws Exception - { - fassade = new ApplejuiceFassadeDummy(new HashMap<String,Download>()); - policy = new StandardAutomaticPwdlPolicy(fassade, 1, 3, PROZENT_SOURCEN_GROESSE); - - fassade.addDownload(new DownloadDummy(1, 10.0, Download.SUCHEN_LADEN, 1)); - fassade.addDownload(new DownloadDummy(2, 10.0, Download.SUCHEN_LADEN, 1)); - fassade.addExpectedDownload(new DownloadDummy(1, 10.0, Download.SUCHEN_LADEN, 3)); - fassade.addExpectedDownload(new DownloadDummy(2, 10.0, Download.PAUSIERT, 1)); - - policy.doAction(); - fassade.verify(); - - fassade.addDownload(new DownloadDummy(3, 0.0, Download.SUCHEN_LADEN, 1)); - fassade.addExpectedDownload(new DownloadDummy(3, 0.0, Download.PAUSIERT, 1)); - - policy.doAction(); - fassade.verify(); - } - - public void testGetVersion() - { - assertNotNull("Version ist nicht gesetzt!", policy.getVersion()); - assertTrue("Version ist \"\"!", policy.getVersion().length()>0); - } - - public void testGetDescription() - { - assertNotNull("Description ist nicht gesetzt!", policy.getDescription()); - assertTrue("Description ist \"\"!", policy.getDescription().length()>0); - } - - public void testGetAuthor() - { - assertNotNull("Autor ist nicht gesetzt!", policy.getAuthor()); - assertTrue("Autor ist \"\"!", policy.getAuthor().length()>0); - } - -} diff --git a/AJClientGUI/pwdlpolicies/.cvsignore b/AJClientGUI/pwdlpolicies/.cvsignore deleted file mode 100644 index 8b137891..00000000 --- a/AJClientGUI/pwdlpolicies/.cvsignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/AJClientGUI/pwdlpolicies/StandardPwdlPolicy.jar b/AJClientGUI/pwdlpolicies/StandardPwdlPolicy.jar deleted file mode 100644 index 103c4b31..00000000 Binary files a/AJClientGUI/pwdlpolicies/StandardPwdlPolicy.jar and /dev/null differ diff --git a/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClient.java b/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClient.java deleted file mode 100644 index a23a06c2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClient.java +++ /dev/null @@ -1,742 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client; - -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.HeadlessException; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.event.KeyEvent; - -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; - -import java.net.Socket; - -import java.text.SimpleDateFormat; - -import java.util.Date; -import java.util.StringTokenizer; - -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; - -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.FileAppender; -import org.apache.log4j.HTMLLayout; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.UpdateInformationDialog; -import de.applejuicenet.client.gui.components.listener.KeyStates; -import de.applejuicenet.client.gui.connect.ConnectFrame; -import de.applejuicenet.client.gui.connect.QuickConnectionSettingsDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.LinkListener; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; -import de.applejuicenet.client.gui.wizard.WizardDialog; -import de.applejuicenet.client.shared.ConnectionSettings; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.SoundPlayer; -import de.applejuicenet.client.shared.Splash; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClient.java,v 1.109 2009/02/12 13:11:40 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class AppleJuiceClient -{ - public static Splash splash = null; - private static Logger logger = Logger.getLogger(AppleJuiceClient.class); - private static String fileAppenderPath; - private static HTMLLayout layout; - private static ApplejuiceFassade ajFassade = null; - private static CoreConnectionSettingsHolder conn = null; - private static String rootDirectory = null; - - /** - * @return Returns the path of the Client-GUI. - */ - public static String getPath() - { - return getRootDirectory(); - } - - public static synchronized ApplejuiceFassade getAjFassade() - { - if(ajFassade == null) - { - ConnectionSettings rm = OptionsManagerImpl.getInstance().getRemoteSettings(); - - try - { - conn = new CoreConnectionSettingsHolder(rm.getHost(), new Integer(rm.getXmlPort()), rm.getOldPassword(), false); - ajFassade = new ApplejuiceFassade(conn); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - - return ajFassade; - } - - public static CoreConnectionSettingsHolder getCoreConnectionSettingsHolder() - { - return conn; - } - - public static HTMLLayout getLoggerHtmlLayout() - { - return layout; - } - - public static String getLoggerFileAppenderPath() - { - return fileAppenderPath; - } - - public static void main(String[] args) - { - AppleJuiceClientTG tg = new AppleJuiceClientTG(); - final String[] myargs = args; - Runnable runnable = new Runnable() - { - public void run() - { - AppleJuiceClient.runmain(myargs); - } - }; - - Thread t = new Thread(tg, runnable, "appleJuiceCoreGUI"); - - t.start(); - } - - public static void runmain(String[] args) - { - StringBuffer version = new StringBuffer(System.getProperty("java.version")); - - for(int i = version.length() - 1; i >= 0; i--) - { - if(version.charAt(i) == '.') - { - version.deleteCharAt(i); - } - } - - boolean gueltig = false; - - try - { - int versionsNr = Integer.parseInt(version.toString().substring(0, 2)); - - if(versionsNr >= 15) - { - gueltig = true; - } - } - catch(Exception e) - { - ; - - //nix zu tun - } - - if(!gueltig) - { - JOptionPane.showMessageDialog(new Frame(), "Es wird mindestens JRE 5 benoetigt!", "appleJuice Client", - JOptionPane.ERROR_MESSAGE); - System.exit(-1); - } - - boolean processLink = false; - String link = ""; - boolean doubleInstance = false; - LinkListener linkListener = null; - - if(args != null && args.length > 0) - { - try - { - for(String curArg : args) - { - if(curArg.indexOf("-path=") != -1) - { - System.setProperty("user.dir", curArg.substring(6)); - break; - } - } - - boolean hilfeAusgegeben = false; - - for(String curArg : args) - { - if(curArg.compareTo("-help") == 0) - { - if(hilfeAusgegeben) - { - continue; - } - - System.out.println(); - System.out.println(" -help Diese Uebersicht."); - System.out.println(" -path=<pfad> Ausfuehrpfad setzen. Alles im GUI ist relativ zu diesem."); - System.out.println(" -link=<md5Passwort|link> ajfsp-Link ans GUI uebergeben. " + - " Das GUI wird ggf gestartet."); - System.out.println(); - hilfeAusgegeben = true; - } - else if(curArg.indexOf("-command=") != -1) - { - if(linkListener == null) - { - try - { - linkListener = new LinkListener(); - } - catch(IOException ex) - { - //bereits ein GUI vorhanden, also GUI schliessen - doubleInstance = true; - } - } - - if(doubleInstance) - { - int PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); - String passwort = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); - Socket socket = new Socket("localhost", PORT); - PrintStream out = new PrintStream(socket.getOutputStream()); - DataInputStream in = new DataInputStream(socket.getInputStream()); - - out.println(passwort + "|" + curArg); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - String line = reader.readLine(); - - System.out.println(line); - socket.close(); - System.exit(1); - } - else - { - System.out.println("appleJuice-JavaGUI nicht gestartet"); - System.exit(1); - } - } - else if(curArg.indexOf("-link=") != -1 && curArg.length() > "-link=".length() + 1) - { - link = curArg.substring(curArg.indexOf("-link=") + "-link=".length()); - if(linkListener == null) - { - try - { - linkListener = new LinkListener(); - } - catch(IOException ex) - { - //bereits ein GUI vorhanden, also GUI schliessen - doubleInstance = true; - } - } - - if(doubleInstance) - { - int PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); - String passwort = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); - Socket socket = new Socket("localhost", PORT); - PrintStream out = new PrintStream(socket.getOutputStream()); - - out.println(passwort + "|" + curArg); - socket.close(); - //war nur Linkprocessing, also GUI schliessen - System.exit(1); - } - else - { - linkListener.processLink(link, ""); - } - } - } - } - catch(IOException ioE) - { - //Keine bisherige GUI-Instanz vorhanden, also GUI oeffnen - processLink = true; - } - catch(Exception e) - { - System.exit(1); - } - } - - if(linkListener == null) - { - try - { - linkListener = new LinkListener(); - } - catch(IOException ex) - { - //bereits ein GUI vorhanden, also GUI schliessen - doubleInstance = true; - } - } - - if(doubleInstance) - { - //bereits ein GUI vorhanden, also GUI schliessen - JOptionPane.showMessageDialog(new Frame(), "Eine Instanz des GUIs ist bereits in Verwendung.", "appleJuice Client", - JOptionPane.ERROR_MESSAGE); - System.exit(1); - } - - if(processLink) - { - linkListener.processLink(link, ""); - } - - boolean isDebug = System.getProperty("Debug") != null; - - if(isDebug) - { - ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%d [%t] %-5p %c - %m%n")); - - Logger.getRootLogger().addAppender(consoleAppender); - Logger.getRootLogger().setLevel(Level.DEBUG); - } - else - { - Logger rootLogger = Logger.getRootLogger(); - - String datum = new SimpleDateFormat("ddMMyyyy_HHmmss").format(new Date(System.currentTimeMillis())); - String dateiName; - - dateiName = datum + ".html"; - layout = new HTMLLayout(); - layout.setTitle("appleJuice-GUI-Log " + datum); - layout.setLocationInfo(true); - Level logLevel = OptionsManagerImpl.getInstance().getLogLevel(); - - try - { - String path = getRootDirectory() + File.separator + "logs"; - File aFile = new File(path); - - if(!aFile.exists()) - { - aFile.mkdir(); - } - - fileAppenderPath = path + File.separator + dateiName; - if(logLevel != Level.OFF) - { - FileAppender fileAppender = new FileAppender(layout, fileAppenderPath); - - rootLogger.removeAllAppenders(); - rootLogger.addAppender(fileAppender); - } - } - catch(IOException ioe) - { - ioe.printStackTrace(); - } - - rootLogger.setLevel(logLevel); - } - - try - { - String nachricht = "appleJuice-GUI " + AppleJuiceDialog.GUI_VERSION + "/" + ApplejuiceFassade.FASSADE_VERSION + - " wird gestartet..."; - ConnectFrame connectFrame = new ConnectFrame(); - - splash = new Splash(connectFrame, ((ImageIcon) IconManager.getInstance().getIcon("splashscreen")).getImage(), 0, 100); - KeyStates ks = new KeyStates(); - - splash.addKeyListener(ks); - splash.setVisible(true); - try - { - if(OptionsManagerImpl.getInstance().isThemesSupported()) - { - java.lang.reflect.Method method = JFrame.class.getMethod("setDefaultLookAndFeelDecorated", - new Class[] {boolean.class}); - - method.invoke(null, new Object[] {Boolean.TRUE}); - - method = JDialog.class.getMethod("setDefaultLookAndFeelDecorated", new Class[] {boolean.class}); - method.invoke(null, new Object[] {Boolean.TRUE}); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.FATAL)) - { - logger.fatal("Programmabbruch", e); - } - } - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - - System.out.println(nachricht); - if(logger.isEnabledFor(Level.INFO)) - { - nachricht = "erkanntes GUI-OS: " + System.getProperty("os.name"); - logger.info(nachricht); - nachricht = "erkannte Java-Version: " + System.getProperty("java.version"); - logger.info(nachricht); - } - - String titel = null; - LanguageSelector languageSelector = LanguageSelector.getInstance(); - QuickConnectionSettingsDialog remoteDialog = null; - - splash.setProgress(5, "Lade Themes..."); - AppleJuiceDialog.initThemes(); - splash.setProgress(10, "Teste Verbindung..."); - boolean showDialog = OptionsManagerImpl.getInstance().shouldShowConnectionDialogOnStartup(); - boolean keyDown = ks.isKeyDown(KeyEvent.VK_SHIFT); - - if(!showDialog) - { - showDialog = keyDown; - } - - boolean firstTry = keyDown ? false : true; - int erreichbarkeit = 2; - - if(ajFassade == null) - { - getAjFassade(); - } - while(showDialog || (erreichbarkeit = ajFassade.isCoreAvailable()) != 0) - { - splash.setVisible(false); - if(!showDialog) - { - if(erreichbarkeit == 2) - { - titel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.fehlversuch"); - SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); - JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.ERROR_MESSAGE); - } - else - { - titel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - nachricht = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext3"); - SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); - JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.ERROR_MESSAGE); - } - } - - showDialog = false; - remoteDialog = new QuickConnectionSettingsDialog(connectFrame); - if(firstTry && OptionsManagerImpl.getInstance().isErsterStart()) - { - firstTry = false; - remoteDialog.setNieWiederAnzeigen(); - remoteDialog.pressOK(); - } - else - { - remoteDialog.setVisible(true); - if(remoteDialog.getResult() == QuickConnectionSettingsDialog.ABGEBROCHEN) - { - nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.verbindungsfehler"); - nachricht = nachricht.replaceFirst("%s", OptionsManagerImpl.getInstance().getRemoteSettings().getHost()); - JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.OK_OPTION); - logger.fatal(nachricht); - System.out.println("Fehler: " + nachricht); - System.exit(-1); - } - } - - splash.setVisible(true); - } - - SoundPlayer.getInstance().playSound(SoundPlayer.ZUGANG_GEWAEHRT); - - splash.setProgress(20, "Lade Hauptdialog..."); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - final AppleJuiceDialog theApp = new AppleJuiceDialog(); - - splash.setProgress(100, "GUI geladen..."); - PositionManager lm = PositionManagerImpl.getInstance(); - - if(lm.isLegal()) - { - theApp.setLocation(lm.getMainXY()); - theApp.setSize(lm.getMainDimension()); - } - else - { - Toolkit tk = Toolkit.getDefaultToolkit(); - Dimension screenSize = tk.getScreenSize(); - Dimension appScreenSize = new Dimension(screenSize.width, screenSize.height); - Insets insets = tk.getScreenInsets(theApp.getGraphicsConfiguration()); - - appScreenSize.width -= (insets.left + insets.right); - appScreenSize.width = appScreenSize.width / 5 * 4; - appScreenSize.height -= (insets.top + insets.bottom); - appScreenSize.height = appScreenSize.height / 5 * 4; - Point location = new Point((screenSize.width - appScreenSize.width) / 2, - (screenSize.height - appScreenSize.height) / 2); - - lm.setMainXY(location); - lm.setMainDimension(appScreenSize); - theApp.setSize(appScreenSize); - theApp.setLocation(location); - } - - theApp.setVisible(true); - String nachricht = "appleJuice-GUI gestartet..."; - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - - System.out.println(nachricht); - splash.dispose(); - if(OptionsManagerImpl.getInstance().isErsterStart()) - { - showConnectionWizard(theApp); - } - - Thread versionWorker = new Thread() - { - public void run() - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("VersionWorkerThread gestartet. " + this); - } - - try - { - ProxySettings proxy = ProxyManagerImpl.getInstance().getProxySettings(); - String downloadData = WebsiteContentLoader.getWebsiteContent(proxy, "http://www.tkl-soft.de", 80, - "/applejuice/version.txt"); - - if(downloadData.length() > 0) - { - int pos1 = downloadData.indexOf("|"); - final String aktuellsteVersion = downloadData.substring(0, pos1); - StringTokenizer token1 = new StringTokenizer(aktuellsteVersion, "."); - String guiVersion = AppleJuiceDialog.GUI_VERSION; - - if(guiVersion.indexOf('-') != -1) - { - guiVersion = guiVersion.substring(0, guiVersion.indexOf('-')); - } - - StringTokenizer token2 = new StringTokenizer(guiVersion, "."); - - if(token1.countTokens() != 3 || token2.countTokens() != 3) - { - return; - } - - String[] versionInternet = new String[3]; - String[] aktuelleVersion = new String[3]; - - for(int i = 0; i < 3; i++) - { - versionInternet[i] = token1.nextToken(); - aktuelleVersion[i] = token2.nextToken(); - } - - int versionsInfoModus = OptionsManagerImpl.getInstance().getVersionsinfoModus(); - boolean showInfo = false; - boolean versionUpdate = false; - boolean importantUpdate = false; - boolean cosmeticUpdate = false; - - if(Integer.parseInt(versionInternet[0]) > Integer.parseInt(aktuelleVersion[0])) - { - versionUpdate = true; - } - else if(Integer.parseInt(versionInternet[1]) > Integer.parseInt(aktuelleVersion[1])) - { - importantUpdate = true; - } - else if(Integer.parseInt(versionInternet[2]) > Integer.parseInt(aktuelleVersion[2])) - { - cosmeticUpdate = true; - } - - if(versionsInfoModus == 2 && (cosmeticUpdate || importantUpdate || versionUpdate)) - { - showInfo = true; - } - else if(versionsInfoModus == 1 && (importantUpdate || versionUpdate)) - { - showInfo = true; - } - else if(versionsInfoModus == 0 && versionUpdate) - { - showInfo = true; - } - - if(showInfo) - { - int pos2 = downloadData.lastIndexOf("|"); - final String winLink = downloadData.substring(pos1 + 1, pos2); - final String sonstigeLink = downloadData.substring(pos2 + 1); - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - UpdateInformationDialog updateInformationDialog = new UpdateInformationDialog(theApp, - aktuellsteVersion, - winLink, - sonstigeLink); - - updateInformationDialog.setVisible(true); - } - }); - } - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Aktualisierungsinformationen konnten nicht geladen werden. Server down?"); - } - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("VersionWorkerThread beendet. " + this); - } - } - }; - - versionWorker.start(); - } - }); - - /** - * erstmal raus mit dem Mobile-Client - */ - - // MobileProxy.getInstance(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.FATAL)) - { - logger.fatal("Programmabbruch", e); - } - - System.exit(-1); - } - } - - private static String getRootDirectory() - { - if(rootDirectory == null) - { - if(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) - { - rootDirectory = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui"; - } - else - { - rootDirectory = System.getProperty("user.dir"); - } - } - - return rootDirectory; - } - - public static void showConnectionWizard(JFrame frame) - throws HeadlessException - { - WizardDialog wizardDialog = new WizardDialog(frame, true); - Dimension appDimension = wizardDialog.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - wizardDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - wizardDialog.setVisible(true); - } - - public static boolean showConnectionWizard(JDialog dialog, AJSettings ajSettings) - throws HeadlessException - { - WizardDialog wizardDialog = new WizardDialog(dialog, true, ajSettings); - Dimension appDimension = wizardDialog.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - wizardDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - wizardDialog.setVisible(true); - return wizardDialog.isRegularClosed(); - } - - public static String getPropertiesPath() - { - if(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) - { - String dir = System.getProperty("user.home") + File.separator + "appleJuice"; - File directory = new File(dir); - - if(!directory.isDirectory()) - { - directory.mkdir(); - } - - dir += File.separator + "gui"; - directory = new File(dir); - if(!directory.isDirectory()) - { - directory.mkdir(); - } - - dir += File.separator + "ajgui.properties"; - return dir; - } - else - { - return System.getProperty("user.dir") + File.separator + "ajgui.properties"; - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClientTG.java b/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClientTG.java deleted file mode 100644 index 7e7c7474..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClientTG.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client; - -import java.awt.Frame; - -import javax.swing.JFrame; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.exception.CoreLostException; -import de.applejuicenet.client.fassade.exception.WrongPasswordException; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClientTG.java,v 1.12 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class AppleJuiceClientTG extends ThreadGroup -{ - private Logger logger; - - public AppleJuiceClientTG() - { - super("AppleJuiceClientThreadGroup"); - logger = Logger.getLogger(getClass()); - } - - public void uncaughtException(Thread t, Throwable e) - { - if(e.getClass() == ClassCastException.class && - e.getMessage().equals("java.awt.TrayIcon cannot be cast to java.awt.Component")) - { - - /** - * "insignificantly error in java6 -> ignoring" - */ - } - else if(e.getClass() == ArrayIndexOutOfBoundsException.class) - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - else if(e.getClass() == WrongPasswordException.class) - { - AppleJuiceDialog.getApp().informWrongPassword(); - } - else if(e.getClass() == CoreLostException.class) - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.verbindungsfehler"); - - nachricht = nachricht.replaceFirst("%s", OptionsManagerImpl.getInstance().getRemoteSettings().getHost()); - AppleJuiceDialog.closeWithErrormessage(nachricht, true); - } - else - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - private Frame findActiveFrame() - { - Frame[] frames = JFrame.getFrames(); - - for(int i = 0; i < frames.length; i++) - { - Frame frame = frames[i]; - - if(frame.isVisible()) - { - return frame; - } - } - - return null; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/AppleJuiceDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/AppleJuiceDialog.java deleted file mode 100644 index 8499de08..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/AppleJuiceDialog.java +++ /dev/null @@ -1,1851 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ -package de.applejuicenet.client.gui; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.InputEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; - -import java.net.URL; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.swing.AbstractAction; -import javax.swing.ButtonGroup; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.JSlider; -import javax.swing.JTextPane; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.ToolTipManager; -import javax.swing.UIManager; -import javax.swing.border.BevelBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.filechooser.FileFilter; - -import com.l2fprod.gui.plaf.skin.Skin; -import com.l2fprod.gui.plaf.skin.SkinLookAndFeel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.fassade.shared.NetworkInfo; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; -import de.applejuicenet.client.gui.about.AboutDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManager; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.controller.PropertiesManager; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; -import de.applejuicenet.client.gui.download.DownloadController; -import de.applejuicenet.client.gui.download.DownloadPanel; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.gui.memorymonitor.MemoryMonitorDialog; -import de.applejuicenet.client.gui.options.IncomingDirSelectionDialog; -import de.applejuicenet.client.gui.options.OptionsDialog; -import de.applejuicenet.client.gui.server.ServerPanel; -import de.applejuicenet.client.gui.share.ShareController; -import de.applejuicenet.client.gui.share.SharePanel; -import de.applejuicenet.client.gui.tray.TrayIF; -import de.applejuicenet.client.gui.upload.UploadController; -import de.applejuicenet.client.gui.upload.UploadPanel; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.LookAFeel; -import de.applejuicenet.client.shared.SoundPlayer; - -import de.tklsoft.gui.controls.TKLButton; -import de.tklsoft.gui.controls.TKLFrame; -import de.tklsoft.gui.controls.TKLLabel; -import de.tklsoft.gui.controls.TKLPanel; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/AppleJuiceDialog.java,v - * 1.125 2004/06/23 14:56:12 maj0r Exp $ - * - * <p> - * Titel: AppleJuice Client-GUI - * </p> - * <p> - * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - * </p> - * <p> - * Copyright: General Public License - * </p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class AppleJuiceDialog extends TKLFrame implements LanguageListener, DataUpdateListener -{ - - //CVS-Beispiel 0.60.0-1-CVS - public static final String GUI_VERSION = "0.71.2"; - private static Logger logger = Logger.getLogger(AppleJuiceDialog.class); - private static Map<String, Skin> themes = null; - public static boolean rewriteProperties = false; - private static AppleJuiceDialog theApp; - private static boolean themesInitialized = false; - private static boolean useTrayIcon = false; - private static TrayIF trayLoader = null; - private Information information = null; - private RegisterPanel registerPane; - private TKLLabel[] statusbar = new TKLLabel[6]; - private JMenu sprachMenu; - private JMenu optionenMenu; - private JMenu themesMenu = null; - private JMenu coreMenu; - private JMenuItem menuItemOptionen = new JMenuItem(); - private JMenuItem menuItemDateiliste = new JMenuItem(); - private JMenuItem menuItemCheckUpdate = new JMenuItem(); - private JMenuItem menuItemCoreBeenden = new JMenuItem(); - private JMenuItem menuItemUeber = new JMenuItem(); - private JMenuItem menuItemDeaktivieren = new JMenuItem(); - private JMenuItem menuItemAktivieren = new JMenuItem(); - private JMenuItem popupOptionenMenuItem = new JMenuItem(); - private JMenuItem popupAboutMenuItem = new JMenuItem(); - private JMenuItem popupShowHideMenuItem = new JMenuItem(); - private JMenuItem popupCheckUpdateMenuItem = new JMenuItem(); - private TKLButton sound = new TKLButton(); - private TKLButton memory = new TKLButton(); - private String keinServer; - private boolean firstChange = true; - private MemoryMonitorDialog memoryMonitorDialog; - private String themeSupportTitel; - private String themeSupportNachricht; - private boolean automaticPwdlEnabled = false; - private String titel; - private String bestaetigung; - private int desktopHeight; - private int desktopWidth; - private boolean maximized = false; - private Dimension lastFrameSize; - private Point lastFrameLocation; - private Icon versteckenIcon = null; - private Icon zeigenIcon = null; - private boolean firewalled = false; - private String firewallWarning; - private String alreadyLoaded; - private String invalidLink; - private String linkFailure; - private String dialogTitel; - private String verbunden; - private String verbinden; - private String nichtVerbunden; - private ImageIcon firewallIcon; - private ImageIcon verbundenIcon; - private ImageIcon nichtVerbundenIcon; - private JPopupMenu popup; - private DownloadlinkPanel linkPane = new DownloadlinkPanel(); - - public AppleJuiceDialog() - { - super(); - try - { - enableCloseWindowListener(false); - theApp = this; - init(); - pack(); - LanguageSelector.getInstance().addLanguageListener(this); - initKeyStrokes(); - - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - private void initKeyStrokes() - { - int tabCount = registerPane.getTabCount(); - - for(int i = 0; i < tabCount; i++) - { - int event = i < 9 ? KeyEvent.VK_1 + i : KeyEvent.VK_A + i - 9; - KeyStroke stroke = KeyStroke.getKeyStroke(event, InputEvent.CTRL_DOWN_MASK); - final int index = i; - AbstractAction action = new AbstractAction() - { - public void actionPerformed(ActionEvent e) - { - registerPane.setSelectedIndex(index); - } - }; - - String commandName = "ctrl_" + ((char) event); - - ((JComponent) getContentPane()).getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, commandName); - ((JComponent) getContentPane()).getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(stroke, commandName); - ((JComponent) getContentPane()).getActionMap().put(commandName, action); - } - } - - @SuppressWarnings("deprecation") - public static void initThemes() - { - try - { - themesInitialized = true; - if(OptionsManagerImpl.getInstance().isThemesSupported()) - { - HashSet<URL> themesDateien = new HashSet<URL>(); - File themesPath = new File(System.getProperty("user.dir") + File.separator + "themes"); - - if(!themesPath.isDirectory()) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Der Ordner" + " fuer die Themes zip-Dateien ist nicht vorhanden." + "\r\nappleJuice wird beendet."); - } - - closeWithErrormessage("Der Ordner" + " fuer die Themes zip-Dateien ist nicht vorhanden." + - "\r\nappleJuice wird beendet.", false); - } - - File[] themeFiles = themesPath.listFiles(); - - for(int i = 0; i < themeFiles.length; i++) - { - if(themeFiles[i].isFile() && themeFiles[i].getName().indexOf(".zip") != -1) - { - - //testen, ob es wirklich ein skinfile ist - ZipFile jf = new ZipFile(themeFiles[i]); - ZipEntry entry = jf.getEntry("skinlf-themepack.xml"); - - if(entry != null) - { - themesDateien.add(themeFiles[i].toURL()); - } - } - } - - Skin standardSkin = null; - Skin aSkin = null; - String temp; - String shortName = ""; - String defaultTheme = OptionsManagerImpl.getInstance().getDefaultTheme(); - - themes = new HashMap<String, Skin>(); - for(URL curSkinURL : themesDateien) - { - temp = curSkinURL.getFile(); - int index1 = temp.lastIndexOf('/'); - int index2 = temp.lastIndexOf(".zip"); - - if(index1 == -1 || index2 == -1) - { - continue; - } - - shortName = temp.substring(index1 + 1, index2); - aSkin = SkinLookAndFeel.loadThemePack(curSkinURL); - themes.put(shortName, aSkin); - if(shortName.compareToIgnoreCase(defaultTheme) == 0) - { - standardSkin = aSkin; - } - } - - if(standardSkin == null) - { - standardSkin = aSkin; - } - - SkinLookAndFeel.setSkin(standardSkin); - SkinLookAndFeel.enable(); - } - else - { - LookAFeel defaultlookandfeel = OptionsManagerImpl.getInstance().getDefaultLookAndFeel(); - - if(defaultlookandfeel != null) - { - UIManager.setLookAndFeel(defaultlookandfeel.getClassName()); - } - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public static AppleJuiceDialog getApp() - { - return theApp; - } - - @SuppressWarnings("unchecked") - private void init() throws Exception - { - titel = "appleJuice Client (GUI " + AppleJuiceDialog.GUI_VERSION + "/" + ApplejuiceFassade.FASSADE_VERSION + ")"; - IconManager im = IconManager.getInstance(); - - firewallIcon = im.getIcon("firewall"); - verbundenIcon = im.getIcon("serververbunden"); - nichtVerbundenIcon = im.getIcon("serverversuche"); - - Image image = im.getIcon("applejuice").getImage(); - - setTitle(titel); - String osName = System.getProperty("os.name"); - - setIconImage(image); - menuItemOptionen.setIcon(im.getIcon("optionen")); - menuItemUeber.setIcon(im.getIcon("info")); - menuItemCoreBeenden.setIcon(im.getIcon("skull")); - menuItemDateiliste.setIcon(im.getIcon("speichern")); - menuItemCheckUpdate.setIcon(im.getIcon("update")); - - setJMenuBar(createMenuBar()); - if(OptionsManagerImpl.getInstance().isThemesSupported()) - { - SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); - } - - String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; - String sprache = OptionsManagerImpl.getInstance().getSprache(); - - if(null == sprache || sprache.trim().length() == 0) - { - sprache = "deutsch"; - } - - path += sprache + ".properties"; - if(AppleJuiceClient.splash != null) - { - AppleJuiceClient.splash.setProgress(25, "Initialisiere Sprache..."); - } - - LanguageSelector languageSelector = LanguageSelector.getInstance(path); - - if(AppleJuiceClient.splash != null) - { - AppleJuiceClient.splash.setProgress(30, "Erstelle Register..."); - } - - registerPane = new RegisterPanel(this); - languageSelector.fireLanguageChanged(); - if(AppleJuiceClient.splash != null) - { - AppleJuiceClient.splash.setProgress(95, "Register erstellt.."); - } - - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - closeDialog(evt); - } - }); - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - desktopWidth = screenSize.width; - desktopHeight = screenSize.height; - addComponentListener(new ComponentAdapter() - { - public void componentResized(ComponentEvent e) - { - int x = getWidth(); - int y = getHeight(); - - if(x == desktopWidth && y == desktopHeight) - { - if(maximized) - { - demaximize(); - } - else - { - maximize(); - } - } - else - { - if(!maximized) - { - lastFrameSize = getSize(); - lastFrameLocation = getLocation(); - } - - super.componentResized(e); - } - } - - public void componentMoved(ComponentEvent e) - { - if(!maximized) - { - lastFrameLocation = getLocation(); - } - - super.componentMoved(e); - } - }); - useTrayIcon = true; - popup = makeSwingPopup(); - try - { - Class trayLoaderClass = Class.forName("de.applejuicenet.client.gui.tray.TrayLoader"); - - trayLoader = (TrayIF) trayLoaderClass.newInstance(); - - useTrayIcon = trayLoader.makeTray(image, titel, this, popupShowHideMenuItem, zeigenIcon, versteckenIcon, popup); - AppleJuiceClient.getAjFassade().addDataUpdateListener(new DataUpdateListener() - { - private Map<Integer, Integer> stati = new HashMap<Integer, Integer>(); - private List<Integer> alreadyNotified = new ArrayList<Integer>(); - - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - Map<Integer, Download> downloads = (Map<Integer, Download>) content; - - for(Download curDownload : downloads.values()) - { - Integer oldDownloadStatus = stati.get(curDownload.getId()); - - if(null == oldDownloadStatus) - { - // neu - stati.put(curDownload.getId(), curDownload.getStatus()); - } - else if(curDownload.getStatus() == Download.FERTIG && oldDownloadStatus != Download.FERTIG && - !alreadyNotified.contains(curDownload.getId())) - { - // fertiggestellt und noch nicht benachrichtigt - alreadyNotified.add(curDownload.getId()); - showMessage("Download fertig", curDownload.getFilename() + " abgeschlossen!"); - } - } - - ArrayList<Integer> toRemove = new ArrayList<Integer>(); - - for(Integer curKey : stati.keySet()) - { - if(!downloads.containsKey(curKey)) - { - // download wurde entfernt - toRemove.add(curKey); - } - } - - for(Integer curKey : toRemove) - { - stati.remove(curKey); - } - } - }, DATALISTENER_TYPE.DOWNLOAD_CHANGED); - } - catch(Throwable e) - { - useTrayIcon = false; - } - - getContentPane().setLayout(new BorderLayout()); - linkPane.getBtnStartDownload().addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - uebernehmeLink(); - } - }); - - getContentPane().add(linkPane, BorderLayout.NORTH); - getContentPane().add(registerPane, BorderLayout.CENTER); - - TKLPanel panel = new TKLPanel(new GridBagLayout()); - - for(int i = 0; i < statusbar.length; i++) - { - statusbar[i] = new TKLLabel(" "); - statusbar[i].setHorizontalAlignment(TKLLabel.RIGHT); - statusbar[i].setBorder(new BevelBorder(BevelBorder.LOWERED)); - statusbar[i].setFont(new java.awt.Font("SansSerif", 0, 11)); - } - - memory.setIcon(IconManager.getInstance().getIcon("mmonitor")); - memory.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(memoryMonitorDialog == null) - { - memoryMonitorDialog = new MemoryMonitorDialog(AppleJuiceDialog.this); - Point loc = memory.getLocationOnScreen(); - - loc.setLocation(loc.getX() - memoryMonitorDialog.getWidth(), loc.getY() - memoryMonitorDialog.getHeight()); - memoryMonitorDialog.setLocation(loc); - } - - if(!memoryMonitorDialog.isVisible()) - { - memoryMonitorDialog.setVisible(true); - } - } - }); - - sound.addActionListener(new ActionListener() - { - - { - if(OptionsManagerImpl.getInstance().isSoundEnabled()) - { - sound.setIcon(IconManager.getInstance().getIcon("soundon")); - } - else - { - sound.setIcon(IconManager.getInstance().getIcon("soundoff")); - } - } - - public void actionPerformed(ActionEvent ae) - { - OptionsManager om = OptionsManagerImpl.getInstance(); - - om.enableSound(!om.isSoundEnabled()); - if(om.isSoundEnabled()) - { - sound.setIcon(IconManager.getInstance().getIcon("soundon")); - } - else - { - sound.setIcon(IconManager.getInstance().getIcon("soundoff")); - } - } - }); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - panel.add(statusbar[0], constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel.add(statusbar[1], constraints); - constraints.weightx = 0; - constraints.gridx = 2; - panel.add(statusbar[2], constraints); - constraints.gridx = 3; - panel.add(statusbar[3], constraints); - constraints.gridx = 4; - panel.add(statusbar[4], constraints); - constraints.gridx = 5; - panel.add(statusbar[5], constraints); - constraints.gridx = 6; - panel.add(memory, constraints); - constraints.gridx = 7; - panel.add(sound, constraints); - getContentPane().add(panel, BorderLayout.SOUTH); - - //Tooltipps einstellen - ToolTipManager.sharedInstance().setInitialDelay(1); - ToolTipManager.sharedInstance().setDismissDelay(50000); - LanguageSelector.getInstance().addLanguageListener(linkPane); - fireLanguageChanged(); - ApplejuiceFassade dm = AppleJuiceClient.getAjFassade(); - - dm.addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); - dm.addDataUpdateListener(this, DATALISTENER_TYPE.NETINFO_CHANGED); - dm.startXMLCheck(); - } - - public static synchronized void showMessage(String caption, String message) - { - if(null != trayLoader) - { - trayLoader.showBallon(caption, message); - } - } - - protected void uebernehmeLink() - { - if(linkPane.getTxtDownloadLink().isInvalid()) - { - return; - } - - final String link = linkPane.getTxtDownloadLink().getText(); - Object sel = linkPane.getCmbTargetDir().getSelectedItem(); - String tmp; - - if(sel != null) - { - tmp = (String) sel; - } - else - { - tmp = ""; - } - - final String targetDir = tmp; - - if(link.length() != 0) - { - linkPane.getTxtDownloadLink().setText(""); - Thread linkThread = new Thread() - { - public void run() - { - try - { - final String result = AppleJuiceClient.getAjFassade().processLink(link, targetDir); - - SoundPlayer.getInstance().playSound(SoundPlayer.LADEN); - if(result.indexOf("ok") != 0) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - String message = null; - - if(result.indexOf("already downloaded") != -1) - { - message = alreadyLoaded.replaceAll("%s", link); - } - else if(result.indexOf("incorrect link") != -1) - { - message = invalidLink.replaceAll("%s", link); - } - else if(result.indexOf("failure") != -1) - { - message = linkFailure; - } - - if(message != null) - { - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message, dialogTitel, - JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); - } - } - }); - } - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }; - - linkThread.start(); - } - } - - private void demaximize() - { - setSize(lastFrameSize); - setLocation(lastFrameLocation); - maximized = false; - } - - private void maximize() - { - Toolkit tk = Toolkit.getDefaultToolkit(); - Dimension screenSize = tk.getScreenSize(); - Insets insets = tk.getScreenInsets(getGraphicsConfiguration()); - - screenSize.width -= (insets.left + insets.right); - screenSize.height -= (insets.top + insets.bottom); - setSize(screenSize); - setLocation(insets.left, insets.top); - maximized = true; - } - - private static void einstellungenSpeichern() - { - try - { - String sprachText = LanguageSelector.getInstance().getFirstAttrbuteByTagName("Languageinfo.name"); - - OptionsManagerImpl.getInstance().setSprache(sprachText); - int[] downloadWidths = ((DownloadPanel) DownloadController.getInstance().getComponent()).getDownloadColumnWidths(); - int[] downloadSourcesWidths = ((DownloadPanel) DownloadController.getInstance().getComponent()).getDownloadSourcesColumnWidths(); - int[] uploadWidths = ((UploadPanel) UploadController.getInstance().getComponent()).getColumnActiveWidths(); - int[] uploadWaitingWidths = ((UploadPanel) UploadController.getInstance().getComponent()).getColumnWaitingWidths(); - int[] serverWidths = ServerPanel.getInstance().getColumnWidths(); - int[] shareWidths = ((SharePanel) ShareController.getInstance().getComponent()).getColumnWidths(); - Dimension dim = AppleJuiceDialog.getApp().getSize(); - Point p = AppleJuiceDialog.getApp().getLocationOnScreen(); - PositionManager pm = PositionManagerImpl.getInstance(); - - pm.setMainXY(p); - pm.setMainDimension(dim); - pm.setDownloadWidths(downloadWidths); - pm.setDownloadSourcesWidths(downloadSourcesWidths); - pm.setUploadWidths(uploadWidths); - pm.setUploadWaitingWidths(uploadWaitingWidths); - pm.setServerWidths(serverWidths); - pm.setShareWidths(shareWidths); - pm.save(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void informAutomaticPwdlEnabled(boolean enabled) - { - if(enabled != automaticPwdlEnabled) - { - automaticPwdlEnabled = enabled; - setTitle(titel); - repaint(); - } - } - - private void closeDialog(WindowEvent evt) - { - AppleJuiceClient.getAjFassade().stopXMLCheck(); - if(rewriteProperties) - { - PropertiesManager.restoreProperties(); - } - - String nachricht = "appleJuice-GUI wird beendet..."; - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - - System.out.println(nachricht); - if(!rewriteProperties) - { - einstellungenSpeichern(); - } - - setVisible(false); - - System.exit(0); - } - - public static void closeWithErrormessage(String error, boolean speichereEinstellungen) - { - JOptionPane.showMessageDialog(theApp, error, "appleJuice Client", JOptionPane.OK_OPTION); - if(rewriteProperties) - { - PropertiesManager.restoreProperties(); - } - else - { - AppleJuiceClient.getAjFassade().stopXMLCheck(); - } - - String nachricht = "appleJuice-GUI wird beendet..."; - Logger aLogger = Logger.getLogger(AppleJuiceDialog.class.getName()); - - if(aLogger.isEnabledFor(Level.INFO)) - { - aLogger.info(nachricht); - } - - System.out.println(nachricht); - if(speichereEinstellungen && !rewriteProperties) - { - einstellungenSpeichern(); - } - - System.out.println("Fehler: " + error); - - System.exit(-1); - } - - protected JMenuBar createMenuBar() - { - try - { - if(!themesInitialized) - { - AppleJuiceDialog.initThemes(); - } - - String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; - File languagePath = new File(path); - - if(!languagePath.isDirectory()) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Der Ordner " + path + " fuer die Sprachauswahl properties-Dateien ist nicht vorhanden." + - "\r\nappleJuice wird beendet."); - } - - closeWithErrormessage("Der Ordner " + path + " fuer die Sprachauswahl properties-Dateien ist nicht vorhanden." + - "\r\nappleJuice wird beendet.", false); - } - - String[] tempListe = languagePath.list(); - HashSet<String> sprachDateien = new HashSet<String>(); - - for(int i = 0; i < tempListe.length; i++) - { - if(tempListe[i].indexOf(".properties") != -1) - { - sprachDateien.add(tempListe[i]); - } - } - - if(sprachDateien.size() == 0) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Es sind keine properties-Dateien fuer die Sprachauswahl im Ordner " + path + " vorhanden." + - "\r\nappleJuice wird beendet."); - } - - closeWithErrormessage("Es sind keine properties-Dateien fuer die Sprachauswahl im Ordner " + path + " vorhanden." + - "\r\nappleJuice wird beendet.", false); - } - - JMenuBar menuBar = new JMenuBar(); - - optionenMenu = new JMenu(); - menuItemOptionen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showOptionsDialog(); - } - }); - menuItemDateiliste.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dateiListeImportieren(); - } - }); - menuItemCheckUpdate.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - checkAndDisplayUpdate(); - } - }); - menuItemCoreBeenden.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), bestaetigung, "appleJuice Client", - JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); - - if(result == JOptionPane.YES_OPTION) - { - AppleJuiceClient.getAjFassade().shutdownCore(); - } - } - }); - menuItemUeber.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showAboutDialog(); - } - }); - optionenMenu.add(menuItemOptionen); - optionenMenu.add(menuItemDateiliste); - optionenMenu.add(menuItemCheckUpdate); - optionenMenu.add(menuItemUeber); - menuBar.add(optionenMenu); - - sprachMenu = new JMenu(); - menuBar.add(sprachMenu); - ButtonGroup lafGroup = new ButtonGroup(); - - for(String curSprachDatei : sprachDateien) - { - String sprachText = LanguageSelector.getInstance(path + curSprachDatei) - .getFirstAttrbuteByTagName("Languageinfo.name"); - JCheckBoxMenuItem rb = new JCheckBoxMenuItem(sprachText); - - if(OptionsManagerImpl.getInstance().getSprache().equalsIgnoreCase(sprachText)) - { - rb.setSelected(true); - } - - Image img = Toolkit.getDefaultToolkit().getImage(path + sprachText.toLowerCase() + ".gif"); - ImageIcon result = new ImageIcon(); - - result.setImage(img); - rb.setIcon(result); - - sprachMenu.add(rb); - rb.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent ae) - { - JCheckBoxMenuItem rb2 = (JCheckBoxMenuItem) ae.getSource(); - - if(rb2.isSelected()) - { - String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; - String dateiName = path + rb2.getText().toLowerCase() + ".properties"; - - LanguageSelector.getInstance(dateiName); - } - } - }); - lafGroup.add(rb); - } - - themesMenu = new JMenu(); - if(OptionsManagerImpl.getInstance().isThemesSupported()) - { - HashSet<URL> themesDateien = new HashSet<URL>(); - File themesPath = new File(System.getProperty("user.dir") + File.separator + "themes"); - - if(!themesPath.isDirectory()) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Der Ordner " + path + " fuer die Themes zip-Dateien ist nicht vorhanden." + - "\r\nappleJuice wird beendet."); - } - - closeWithErrormessage("Der Ordner " + path + " fuer die Themes zip-Dateien ist nicht vorhanden." + - "\r\nappleJuice wird beendet.", false); - } - - File[] themeFiles = themesPath.listFiles(); - - for(int i = 0; i < themeFiles.length; i++) - { - if(themeFiles[i].isFile() && themeFiles[i].getName().indexOf(".zip") != -1) - { - - //testen, ob es wirklich ein skinfile ist - ZipFile jf = new ZipFile(themeFiles[i]); - ZipEntry entry = jf.getEntry("skinlf-themepack.xml"); - - if(entry != null) - { - themesDateien.add(themeFiles[i].toURL()); - } - } - } - - ButtonGroup lafGroup2 = new ButtonGroup(); - String temp; - String shortName; - String defaultTheme = OptionsManagerImpl.getInstance().getDefaultTheme(); - - for(URL curSkinURL : themesDateien) - { - temp = curSkinURL.getFile(); - int index1 = temp.lastIndexOf('/'); - int index2 = temp.lastIndexOf(".zip"); - - if(index1 == -1 || index2 == -1) - { - continue; - } - - shortName = temp.substring(index1 + 1, index2); - final JCheckBoxMenuItem rb = new JCheckBoxMenuItem(shortName); - - if(shortName.compareToIgnoreCase(defaultTheme) == 0) - { - rb.setSelected(true); - } - - rb.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent ae) - { - if(rb.isSelected()) - { - activateLaF(rb.getText()); - } - } - }); - lafGroup2.add(rb); - themesMenu.add(rb); - } - - themesMenu.add(new JSeparator()); - menuItemDeaktivieren.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ce) - { - activateThemeSupport(false); - } - }); - themesMenu.add(menuItemDeaktivieren); - } - else - { - final LookAFeel[] feels = OptionsManagerImpl.getInstance().getLookAndFeels(); - LookAFeel defaultlookandfeel = OptionsManagerImpl.getInstance().getDefaultLookAndFeel(); - ButtonGroup lafGroup2 = new ButtonGroup(); - - for(int i = 0; i < feels.length; i++) - { - final JCheckBoxLookAndFeelMenuItem lookAndFeelMenuItem = new JCheckBoxLookAndFeelMenuItem(feels[i]); - - lafGroup2.add(lookAndFeelMenuItem); - themesMenu.add(lookAndFeelMenuItem); - if(defaultlookandfeel != null && feels[i].getName().equals(defaultlookandfeel.getName())) - { - lookAndFeelMenuItem.setSelected(true); - } - else - { - lookAndFeelMenuItem.setSelected(false); - } - - lookAndFeelMenuItem.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent ae) - { - if(lookAndFeelMenuItem.isSelected()) - { - activateLaF(lookAndFeelMenuItem.getText()); - } - } - }); - } - - menuItemAktivieren.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ce) - { - activateThemeSupport(true); - } - }); - themesMenu.add(new JSeparator()); - themesMenu.add(menuItemAktivieren); - } - - menuBar.add(themesMenu); - coreMenu = new JMenu(); - coreMenu.add(menuItemCoreBeenden); - menuBar.add(coreMenu); - coreMenu.setText("Core"); - return menuBar; - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - return null; - } - } - - private void showOptionsDialog() - { - OptionsDialog od = new OptionsDialog(getApp()); - Dimension optDimension = od.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - od.setLocation((screenSize.width - optDimension.width) / 2, (screenSize.height - optDimension.height) / 2); - od.setVisible(true); - } - - private void showAboutDialog() - { - AboutDialog aboutDialog = new AboutDialog(getApp(), true); - Dimension appDimension = aboutDialog.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - aboutDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - aboutDialog.setVisible(true); - } - - private void activateThemeSupport(boolean enable) - { - int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.this, themeSupportNachricht, themeSupportTitel, - JOptionPane.YES_NO_OPTION); - - if(result == JOptionPane.YES_OPTION) - { - OptionsManagerImpl.getInstance().enableThemeSupport(enable); - closeDialog(null); - } - } - - private void activateLaF(String laf) - { - try - { - - // theme??? - if(themes != null) - { - Skin aSkin = (Skin) themes.get(laf); - - if(aSkin != null) - { - SkinLookAndFeel.setSkin(aSkin); - SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); - OptionsManagerImpl.getInstance().setDefaultTheme(laf); - return; - } - } - - // laf??? - final LookAFeel[] feels = OptionsManagerImpl.getInstance().getLookAndFeels(); - - if(feels != null && laf != null) - { - for(int i = 0; i < feels.length; i++) - { - if(laf.equals(feels[i].getName())) - { - OptionsManagerImpl.getInstance().setDefaultLookAndFeel(feels[i]); - return; - } - } - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void setTitle(String newTitle) - { - if(!automaticPwdlEnabled) - { - super.setTitle(newTitle); - } - else - { - super.setTitle(newTitle + " - Autopilot"); - } - - titel = newTitle; - } - - private void dateiListeImportieren() - { - JFileChooser fileChooser = new JFileChooser(); - - fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); - fileChooser.setFileFilter(new TxtFileFilter()); - fileChooser.setDialogTitle(menuItemDateiliste.getText()); - fileChooser.setMultiSelectionEnabled(false); - int i = fileChooser.showOpenDialog(this); - - if(i == JFileChooser.APPROVE_OPTION) - { - final File file = fileChooser.getSelectedFile(); - - if(file.isFile()) - { - String[] dirs = AppleJuiceClient.getAjFassade().getCurrentIncomingDirs(); - IncomingDirSelectionDialog incomingDirSelectionDialog = new IncomingDirSelectionDialog(AppleJuiceDialog.getApp(), dirs, - null); - - incomingDirSelectionDialog.setVisible(true); - String directory = incomingDirSelectionDialog.getSelectedIncomingDir(); - - if(directory != null) - { - directory = directory.trim(); - if(directory.indexOf(File.separator) == 0 || directory.indexOf(ApplejuiceFassade.separator) == 0) - { - directory = directory.substring(1); - } - } - else - { - directory = ""; - } - - final String targetDir = directory; - - new Thread() - { - public void run() - { - BufferedReader reader = null; - - try - { - reader = new BufferedReader(new FileReader(file)); - String line = ""; - - while((line = reader.readLine()) != null) - { - if(line.compareTo("100") == 0) - { - break; - } - } - - String size = ""; - String filename = ""; - String checksum = ""; - String link = ""; - ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); - final StringBuffer returnValues = new StringBuffer(); - boolean somethingAdded = false; - - while((line = reader.readLine()) != null) - { - filename = line; - checksum = reader.readLine(); - size = reader.readLine(); - if(size != null && checksum != null) - { - link = "ajfsp://file|" + filename + "|" + checksum + "|" + size + "/"; - String result; - - try - { - result = af.processLink(link, targetDir); - } - catch(IllegalArgumentException e) - { - logger.error(e); - return; - } - - if(result.indexOf("ok") == 0) - { - returnValues.append("'" + link + "' OK\n"); - somethingAdded = true; - } - else if(result.indexOf("already downloaded") != -1) - { - returnValues.append(alreadyLoaded.replaceAll("%s", link) + "\n"); - somethingAdded = true; - } - else if(result.indexOf("incorrect link") != -1) - { - returnValues.append(invalidLink.replaceAll("%s", link) + "\n"); - somethingAdded = true; - } - else if(result.indexOf("failure") != -1) - { - returnValues.append(linkFailure + "\n"); - somethingAdded = true; - } - } - } - - if(somethingAdded) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - JTextPane textArea = new JTextPane(); - - textArea.setPreferredSize(new Dimension(550, 300)); - textArea.setMaximumSize(new Dimension(550, 300)); - textArea.setEditable(false); - textArea.setBackground(new TKLLabel().getBackground()); - textArea.setText(returnValues.toString()); - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), new JScrollPane(textArea), - dialogTitel, - JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); - } - }); - } - } - catch(FileNotFoundException ex) - { - ; - - //nix zu tun - } - catch(IOException ex1) - { - ; - - //nix zu tun - } - } - }.start(); - } - } - } - - public void fireLanguageChanged() - { - try - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - verbunden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.verbunden"); - verbinden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.verbinden"); - nichtVerbunden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.nichtverbunden"); - keinServer = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.keinserver"); - themeSupportTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - themeSupportNachricht = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.themesupportnachricht"); - sprachMenu.setText(languageSelector.getFirstAttrbuteByTagName("einstform.languagesheet.caption")); - menuItemOptionen.setText(languageSelector.getFirstAttrbuteByTagName("mainform.optbtn.caption")); - menuItemOptionen.setToolTipText(languageSelector.getFirstAttrbuteByTagName("mainform.optbtn.hint")); - menuItemCoreBeenden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.corebeenden")); - menuItemCoreBeenden.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.corebeendenhint")); - menuItemUeber.setText(languageSelector.getFirstAttrbuteByTagName("mainform.aboutbtn.caption")); - menuItemCheckUpdate.setText(languageSelector.getFirstAttrbuteByTagName("mainform.checkupdate.caption")); - menuItemCheckUpdate.setToolTipText(languageSelector.getFirstAttrbuteByTagName("mainform.checkupdate.hint")); - menuItemDeaktivieren.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.deaktivieren")); - optionenMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.extras")); - menuItemDateiliste.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.dateiliste")); - menuItemDateiliste.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.dateilistehint")); - themesMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.themes")); - bestaetigung = languageSelector.getFirstAttrbuteByTagName("javagui.menu.bestaetigung"); - menuItemAktivieren.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.aktivieren")); - menuItemDeaktivieren.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.deaktivieren")); - - firewallWarning = languageSelector.getFirstAttrbuteByTagName("mainform.firewallwarning.caption"); - alreadyLoaded = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.bereitsgeladen"); - invalidLink = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.falscherlink"); - linkFailure = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.sonstigerlinkfehlerkurz"); - dialogTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - if(firewalled) - { - statusbar[0].setToolTipText(firewallWarning); - } - - if(useTrayIcon && null != trayLoader) - { - trayLoader.setTextVerstecken(languageSelector.getFirstAttrbuteByTagName("javagui.menu.verstecken")); - trayLoader.setTextZeigen(languageSelector.getFirstAttrbuteByTagName("javagui.menu.zeigen")); - popupAboutMenuItem.setText(menuItemUeber.getText()); - popupAboutMenuItem.setToolTipText(menuItemUeber.getToolTipText()); - popupOptionenMenuItem.setText(menuItemOptionen.getText()); - popupOptionenMenuItem.setToolTipText(menuItemOptionen.getToolTipText()); - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void fireContentChanged(DATALISTENER_TYPE type, final Object content) - { - if(type == DATALISTENER_TYPE.NETINFO_CHANGED) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - try - { - NetworkInfo netInfo = (NetworkInfo) content; - - if(netInfo.isFirewalled() != firewalled) - { - firewalled = !firewalled; - updateFirewall(); - if(firewalled) - { - statusbar[0].setToolTipText(firewallWarning); - } - else - { - statusbar[0].setToolTipText(null); - } - - updateFirewall(); - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - }); - } - else if(type == DATALISTENER_TYPE.INFORMATION_CHANGED) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - try - { - if(firstChange) - { - firstChange = false; - SoundPlayer.getInstance().playSound(SoundPlayer.GESTARTET); - String versionsNr = AppleJuiceClient.getAjFassade().getCoreVersion().getVersion(); - - titel = LanguageSelector.getInstance().getFirstAttrbuteByTagName("mainform.caption") + " (Core " + - versionsNr + " - GUI " + AppleJuiceDialog.GUI_VERSION + "/" + ApplejuiceFassade.FASSADE_VERSION + - ")"; - setTitle(titel); - repaint(); - } - - information = (Information) content; - statusbar[0].setText(getVerbindungsStatusAsString(information)); - if(information.getVerbindungsStatus() == Information.NICHT_VERBUNDEN) - { - statusbar[1].setText(keinServer); - } - else - { - String tmp = information.getServerName(); - - if(tmp == null || tmp.length() == 0) - { - Server server = information.getServer(); - - if(server != null) - { - tmp = server.getHost() + ":" + server.getPort(); - } - } - - statusbar[1].setText(tmp); - } - - statusbar[2].setText(information.getUpDownAsString()); - statusbar[3].setText(information.getUpDownSessionAsString()); - statusbar[4].setText(information.getExterneIP()); - statusbar[5].setText(information.getCreditsAsString()); - updateFirewall(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - }); - } - } - - protected void updateFirewall() - { - if(information != null && information.getVerbindungsStatus() != Information.VERBUNDEN) - { - statusbar[0].setIcon(nichtVerbundenIcon); - } - else - { - if(firewalled) - { - statusbar[0].setIcon(firewallIcon); - } - else - { - statusbar[0].setIcon(verbundenIcon); - } - } - } - - public JPopupMenu makeSwingPopup() - { - final JPopupMenu popup = new JPopupMenu(); - - popupShowHideMenuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(!isVisible()) - { - setVisible(true); - setAlwaysOnTop(true); - setAlwaysOnTop(false); - requestFocus(); - } - else - { - if(popup.isVisible()) - { - popup.setVisible(false); - } - - setVisible(false); - } - } - }); - popup.add(popupShowHideMenuItem); - popupOptionenMenuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - showOptionsDialog(); - } - }); - - popup.add(popupOptionenMenuItem); - IconManager im = IconManager.getInstance(); - - versteckenIcon = im.getIcon("hide"); - zeigenIcon = im.getIcon("applejuice"); - Icon aboutIcon = im.getIcon("about"); - - popupOptionenMenuItem.setIcon(im.getIcon("optionen")); - popupAboutMenuItem.setIcon(aboutIcon); - popupAboutMenuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - showAboutDialog(); - } - }); - popup.add(popupAboutMenuItem); - new Thread() - { - public void run() - { - final AJSettings ajSettings = AppleJuiceClient.getAjFassade().getAJSettings(); - - if(ajSettings != null) - { - long maxUpload = 50; - - if(ajSettings.getMaxUploadInKB() > maxUpload) - { - maxUpload = ajSettings.getMaxUploadInKB() + 20; - } - - final JSlider uploadSlider = new JSlider(JSlider.VERTICAL, 0, (int) maxUpload, (int) ajSettings.getMaxUploadInKB()); - long maxDownload = 300; - - if(ajSettings.getMaxDownloadInKB() > maxDownload) - { - maxDownload = ajSettings.getMaxDownloadInKB() + 20; - } - - final JSlider downloadSlider = new JSlider(JSlider.VERTICAL, 0, (int) maxDownload, - (int) ajSettings.getMaxDownloadInKB()); - - uploadSlider.setPaintLabels(true); - uploadSlider.setPaintTicks(true); - uploadSlider.setPaintTrack(true); - uploadSlider.setSnapToTicks(true); - downloadSlider.setPaintLabels(true); - downloadSlider.setPaintTicks(true); - downloadSlider.setPaintTrack(true); - downloadSlider.setSnapToTicks(true); - final JMenu uploadMenu = new JMenu("Upload"); - final JMenu downloadMenu = new JMenu("Download"); - TKLPanel uploadPanel = new TKLPanel(new BorderLayout()); - TKLPanel downloadPanel = new TKLPanel(new BorderLayout()); - final TKLLabel label1 = new TKLLabel("50 kb/s"); - final TKLLabel label2 = new TKLLabel("50 kb/s"); - - label1.setText(Long.toString(ajSettings.getMaxUploadInKB()) + " kb/s"); - label2.setText(Long.toString(ajSettings.getMaxDownloadInKB()) + " kb/s"); - uploadPanel.add(label1, BorderLayout.NORTH); - uploadPanel.add(uploadSlider, BorderLayout.SOUTH); - uploadMenu.add(uploadPanel); - downloadPanel.add(label2, BorderLayout.NORTH); - downloadPanel.add(downloadSlider, BorderLayout.SOUTH); - downloadMenu.add(downloadPanel); - uploadSlider.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - JSlider slider = (JSlider) e.getSource(); - - label1.setText(Integer.toString(slider.getValue()) + " kb/s"); - } - }); - downloadSlider.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - JSlider slider = (JSlider) e.getSource(); - - label2.setText(Integer.toString(slider.getValue()) + " kb/s"); - } - }); - uploadSlider.addMouseListener(new MouseAdapter() - { - public void mouseReleased(MouseEvent e) - { - if(uploadSlider.getValue() < uploadSlider.getMaximum() && uploadSlider.getValue() > 0) - { - Long down = new Long(downloadSlider.getValue() * 1024); - Long up = new Long(uploadSlider.getValue() * 1024); - - try - { - AppleJuiceClient.getAjFassade().setMaxUpAndDown(up, down); - } - catch(IllegalArgumentException e1) - { - logger.error(e1); - } - } - else - { - uploadSlider.setValue((int) ajSettings.getMaxUploadInKB()); - } - } - }); - downloadSlider.addMouseListener(new MouseAdapter() - { - public void mouseReleased(MouseEvent e) - { - if(downloadSlider.getValue() < downloadSlider.getMaximum() && downloadSlider.getValue() > 0) - { - Long down = new Long(downloadSlider.getValue() * 1024); - Long up = new Long(uploadSlider.getValue() * 1024); - - try - { - AppleJuiceClient.getAjFassade().setMaxUpAndDown(up, down); - } - catch(IllegalArgumentException e1) - { - logger.error(e1); - } - } - else - { - downloadSlider.setValue((int) ajSettings.getMaxDownloadInKB()); - } - } - }); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - popup.add(uploadMenu); - popup.add(downloadMenu); - } - }); - } - } - }.start(); - return popup; - } - - public static void showInformation(String information) - { - JOptionPane.showMessageDialog(theApp, information, "appleJuice Client", JOptionPane.OK_OPTION); - } - - private String getVerbindungsStatusAsString(Information information) - { - switch(information.getVerbindungsStatus()) - { - - case Information.VERBUNDEN: - return verbunden; - - case Information.NICHT_VERBUNDEN: - return nichtVerbunden; - - case Information.VERSUCHE_ZU_VERBINDEN: - return verbinden; - - default: - return ""; - } - } - - private void checkAndDisplayUpdate() - { - Thread versionWorker = new Thread() - { - public void run() - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("VersionWorkerThread gestartet. " + this); - } - - try - { - ProxySettings proxy = ProxyManagerImpl.getInstance().getProxySettings(); - String downloadData = WebsiteContentLoader.getWebsiteContent(proxy, "http://www.tkl-soft.de", 80, - "/applejuice/version.txt"); - - if(downloadData.length() > 0) - { - int pos1 = downloadData.indexOf("|"); - String aktuellsteVersion = downloadData.substring(0, pos1); - StringTokenizer token1 = new StringTokenizer(aktuellsteVersion, "."); - String guiVersion = AppleJuiceDialog.GUI_VERSION; - - if(guiVersion.indexOf('-') != -1) - { - guiVersion = guiVersion.substring(0, guiVersion.indexOf('-')); - } - - StringTokenizer token2 = new StringTokenizer(guiVersion, "."); - - if(token1.countTokens() != 3 || token2.countTokens() != 3) - { - return; - } - - String[] versionInternet = new String[3]; - String[] aktuelleVersion = new String[3]; - - for(int i = 0; i < 3; i++) - { - versionInternet[i] = token1.nextToken(); - aktuelleVersion[i] = token2.nextToken(); - } - - if((versionInternet[0].compareTo(aktuelleVersion[0]) > 0) || - (versionInternet[0].compareTo(aktuelleVersion[0]) == 0 && - versionInternet[1].compareTo(aktuelleVersion[1]) > 0) || - (versionInternet[0].compareTo(aktuelleVersion[0]) == 0 && - versionInternet[1].compareTo(aktuelleVersion[1]) == 0) && - versionInternet[2].compareTo(aktuelleVersion[2]) > 0) - { - int pos2 = downloadData.lastIndexOf("|"); - String winLink = downloadData.substring(pos1 + 1, pos2); - String sonstigeLink = downloadData.substring(pos2 + 1); - UpdateInformationDialog updateInformationDialog = new UpdateInformationDialog(AppleJuiceDialog.getApp(), - aktuellsteVersion, winLink, - sonstigeLink); - - updateInformationDialog.setVisible(true); - } - else - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String fehlerTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - - String fehlerNachricht = languageSelector.getFirstAttrbuteByTagName("javagui.checkupdate.keineNeueVersion"); - - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), fehlerNachricht, fehlerTitel, - JOptionPane.INFORMATION_MESSAGE); - } - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Aktualisierungsinformationen konnten nicht geladen werden. Server down?"); - } - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("VersionWorkerThread beendet. " + this); - } - } - }; - - versionWorker.start(); - } - - public void informWrongPassword() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String nachricht = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext3"); - - SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); - closeWithErrormessage(nachricht, true); - } - - private class TxtFileFilter extends FileFilter - { - public boolean accept(File file) - { - if(!file.isFile()) - { - return true; - } - else - { - String name = file.getName(); - - return (name.toLowerCase().endsWith(".ajl")); - } - } - - public String getDescription() - { - return "AJL-Dateien"; - } - } - - - private class JCheckBoxLookAndFeelMenuItem extends JCheckBoxMenuItem - { - private final LookAFeel lookAFeel; - - public JCheckBoxLookAndFeelMenuItem(LookAFeel lookAFeelToUse) - { - super(lookAFeelToUse.getName()); - this.lookAFeel = lookAFeelToUse; - addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent ae) - { - if(isSelected()) - { - try - { - UIManager.setLookAndFeel(lookAFeel.getClassName()); - SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - }); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/UpdateInformationDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/UpdateInformationDialog.java deleted file mode 100644 index 711a815b..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/UpdateInformationDialog.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/UpdateInformationDialog.java,v 1.11 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class UpdateInformationDialog extends JDialog -{ - private String aktuellsteVersion; - private JButton schliessen = new JButton(); - private String windowsLink = ""; - private String sonstigeLink = ""; - private Logger logger; - - public UpdateInformationDialog(JFrame parentFrame, String aktuellsteVersion, String winLink, String sonstigeLink) - { - super(parentFrame, true); - logger = Logger.getLogger(getClass()); - try - { - this.aktuellsteVersion = aktuellsteVersion; - this.windowsLink = winLink; - this.sonstigeLink = sonstigeLink; - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - LanguageSelector ls = LanguageSelector.getInstance(); - - schliessen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - UpdateInformationDialog.this.dispose(); - } - }); - - String titel = ls.getFirstAttrbuteByTagName("javagui.startup.newversiontitel"); - String nachricht = ls.getFirstAttrbuteByTagName("javagui.startup.newversionnachricht"); - - nachricht = nachricht.replaceFirst("%s", aktuellsteVersion); - schliessen.setText(ls.getFirstAttrbuteByTagName("javagui.options.plugins.schliessen")); - setTitle(titel); - JPanel panel1 = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.gridwidth = 3; - constraints.insets.left = 5; - constraints.insets.top = 5; - constraints.insets.right = 5; - panel1.add(new JLabel(nachricht), constraints); - constraints.insets.right = 0; - constraints.gridwidth = 1; - constraints.gridy = 1; - JLabel label1 = new JLabel(); - - label1.setText(ls.getFirstAttrbuteByTagName("javagui.startup.windowsversion") + ": "); - JLabel linkWin = new JLabel("<html><font><u>" + windowsLink + "</u></font></html>"); - - panel1.add(label1, constraints); - constraints.gridx = 1; - panel1.add(linkWin, constraints); - constraints.gridx = 2; - constraints.weightx = 1; - constraints.insets.right = 5; - panel1.add(new JLabel(), constraints); - constraints.insets.right = 0; - constraints.weightx = 0; - constraints.gridx = 0; - constraints.gridy = 2; - constraints.insets.bottom = 5; - JLabel label2 = new JLabel(); - - label2.setText(ls.getFirstAttrbuteByTagName("javagui.startup.sonstigeversionen") + ": "); - JLabel linkSonstige = new JLabel("<html><font><u>" + sonstigeLink + "</u></font></html>"); - - panel1.add(label2, constraints); - constraints.gridx = 1; - panel1.add(linkSonstige, constraints); - constraints.gridx = 2; - constraints.weightx = 1; - constraints.insets.right = 5; - panel1.add(new JLabel(), constraints); - constraints.insets.right = 0; - constraints.weightx = 0; - - linkWin.setForeground(Color.blue); - linkWin.addMouseListener(new MouseAdapter() - { - public void mouseExited(MouseEvent e) - { - setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - - public void mouseEntered(MouseEvent e) - { - setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - - public void mouseClicked(MouseEvent e) - { - executeLink(windowsLink); - } - }); - - linkSonstige.setForeground(Color.blue); - linkSonstige.addMouseListener(new MouseAdapter() - { - public void mouseExited(MouseEvent e) - { - setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - - public void mouseEntered(MouseEvent e) - { - setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - - public void mouseClicked(MouseEvent e) - { - executeLink(sonstigeLink); - } - }); - - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(panel1, BorderLayout.CENTER); - JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - - southPanel.add(schliessen); - getContentPane().add(southPanel, BorderLayout.SOUTH); - pack(); - Dimension appDimension = getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - } - - private void executeLink(String link) - { - try - { - String browser = OptionsManagerImpl.getInstance().getStandardBrowser(); - - try - { - Runtime.getRuntime().exec(new String[] {browser, link}); - } - catch(Exception ex) - { - LanguageSelector ls = LanguageSelector.getInstance(); - String nachricht = ls.getFirstAttrbuteByTagName("javagui.startup.updatefehlernachricht"); - String titel = ls.getFirstAttrbuteByTagName("mainform.caption"); - - setVisible(false); - JOptionPane.showMessageDialog(this, nachricht, titel, JOptionPane.INFORMATION_MESSAGE); - setVisible(true); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/about/AboutDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/about/AboutDialog.java deleted file mode 100644 index 0d0c0f58..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/about/AboutDialog.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.about; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.MediaTracker; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.CropImageFilter; -import java.awt.image.FilteredImageSource; -import java.awt.image.ImageFilter; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JDialog; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.shared.IconManager; -import de.tklsoft.gui.controls.TKLLabel; -import de.tklsoft.gui.controls.TKLPanel; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/about/AboutDialog.java,v 1.14 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class AboutDialog extends JDialog -{ - private Logger logger; - private WorkerThread worker = null; - private BackPanel backPanel = new BackPanel(); - - public AboutDialog(Frame parent, boolean modal) - { - super(parent, modal); - logger = Logger.getLogger(getClass()); - try - { - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - if(worker != null) - { - worker.interrupt(); - worker = null; - } - } - }); - init(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public Dimension getPreferredSize() - { - if(backPanel != null) - { - return backPanel.getPreferredSize(); - } - else - { - return super.getPreferredSize(); - } - } - - private void init() - { - setResizable(false); - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - setTitle(languageSelector.getFirstAttrbuteByTagName("mainform.aboutbtn.caption")); - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(backPanel, BorderLayout.CENTER); - pack(); - } - - class BackPanel extends TKLPanel - { - private Image backgroundImage; - private Image flagge; - private TKLLabel version = new TKLLabel(); - private List<CreditsEntry> credits = new ArrayList<CreditsEntry>(); - private Logger logger; - - public BackPanel() - { - super(); - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - worker = new WorkerThread(backgroundImage, this, credits); - worker.start(); - addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent me) - { - if(worker != null) - { - worker.toggleRunStatus(); - } - } - }); - } - - private void init() - { - credits.add(new CreditsEntry(true, "Programmierung")); - credits.add(new CreditsEntry(false, "Maj0r")); - credits.add(new CreditsEntry(false, "(tkrall@tkl-soft.de)")); - credits.add(new CreditsEntry(false, "loevenwong")); - credits.add(new CreditsEntry(false, "(tloevenich@tkl-soft.de)")); - credits.add(new CreditsEntry(true, "Besonderen Dank an")); - credits.add(new CreditsEntry(false, "muhviehstarr")); - credits.add(new CreditsEntry(true, "Banner & Bilder")); - credits.add(new CreditsEntry(false, "saschxd")); - credits.add(new CreditsEntry(true, "Übersetzung")); - credits.add(new CreditsEntry(false, "BlueTiger")); - credits.add(new CreditsEntry(false, "nurseppel")); - credits.add(new CreditsEntry(true, "Kontakt")); - credits.add(new CreditsEntry(false, "irc.devStaff.net:6667")); - credits.add(new CreditsEntry(false, "#applejuice")); - credits.add(new CreditsEntry(false, "www.applejuicenet.de")); - - backgroundImage = IconManager.getInstance().getIcon("applejuiceinfobanner").getImage(); - flagge = IconManager.getInstance().getIcon("deutsch").getImage(); - MediaTracker mt = new MediaTracker(this); - - mt.addImage(backgroundImage, 0); - try - { - mt.waitForAll(); - } - catch(InterruptedException x) - { - - //kein Bild da, dann kack drauf ;-) - } - - version.setText("Version " + AppleJuiceDialog.GUI_VERSION + "/" + ApplejuiceFassade.FASSADE_VERSION); - Font font = version.getFont(); - - font = new Font(font.getName(), Font.PLAIN, font.getSize()); - version.setFont(font); - setLayout(new BorderLayout()); - TKLPanel panel1 = new TKLPanel(new FlowLayout(FlowLayout.RIGHT)); - - panel1.add(version); - panel1.setOpaque(false); - add(panel1, BorderLayout.SOUTH); - } - - public void paintComponent(Graphics g) - { - super.paintComponent(g); - - Color saved = g.getColor(); - - g.setColor(getBackground()); - g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(saved); - - if(backgroundImage != null) - { - int imageX = (getWidth() - backgroundImage.getWidth(this)) / 2; - int imageY = (getHeight() - backgroundImage.getHeight(this)) / 2; - - g.drawImage(backgroundImage, imageX, imageY, this); - if(flagge != null) - { - g.drawImage(flagge, backgroundImage.getWidth(this) - flagge.getWidth(this), 0, this); - } - } - } - - public Dimension getPreferredSize() - { - if(backgroundImage != null) - { - int width = backgroundImage.getWidth(this) + 3; - int height = backgroundImage.getHeight(this) + 3; - - return new Dimension(width, height); - } - else - { - return super.getPreferredSize(); - } - } - } - - - class CreditsEntry - { - private boolean ueberschrift; - private String ausgabetext; - - public CreditsEntry(boolean ueberschrift, String ausgabetext) - { - this.ueberschrift = ueberschrift; - this.ausgabetext = ausgabetext; - } - - public boolean isUeberschrift() - { - return ueberschrift; - } - - public void setUeberschrift(boolean ueberschrift) - { - this.ueberschrift = ueberschrift; - } - - public String getAusgabetext() - { - return ausgabetext; - } - - public void setAusgabetext(String ausgabetext) - { - this.ausgabetext = ausgabetext; - } - } - - - private class WorkerThread extends Thread - { - private Image backgroundImage; - private BackPanel backPanel; - private List<CreditsEntry> credits; - private boolean run = true; - private Logger logger; - - public WorkerThread(Image backgroundImage, BackPanel backPanel, List<CreditsEntry> credits) - { - logger = Logger.getLogger(getClass()); - this.backgroundImage = backgroundImage; - this.backPanel = backPanel; - this.credits = credits; - } - - public void toggleRunStatus() - { - run = !run; - } - - public void run() - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("About-Workerthread gestartet. " + this); - } - - Image new_img; - Image toDraw; - ImageFilter filter = new ImageFilter(); - int creditsHoehe = 60; - int creditsBreite = 135; - int imageX = backgroundImage.getWidth(backPanel) / 2 + 20; - int imageY = backgroundImage.getHeight(backPanel) / 2 - 15; - - filter = new CropImageFilter(imageX, imageY, creditsBreite, creditsHoehe); - new_img = createImage(new FilteredImageSource(backgroundImage.getSource(), filter)); - filter = new CropImageFilter(0, 0, creditsBreite, creditsHoehe); - int y = creditsHoehe; - - try - { - sleep(1000); - Graphics g = backPanel.getGraphics(); - - g.setColor(Color.BLACK); - Graphics toDrawGraphics; - FontMetrics fm; - int strWidth; - Font fontBold = new Font("Arial", Font.BOLD, 12); - Font fontPlain = new Font("Arial", Font.PLAIN, 12); - boolean draw = false; - - while(!isInterrupted()) - { - if(run) - { - toDraw = createImage(creditsBreite, creditsHoehe); - toDrawGraphics = toDraw.getGraphics(); - toDrawGraphics.drawImage(new_img, 0, 0, backPanel); - y--; - int abstand = -15; - - for(CreditsEntry curEntry : credits) - { - if(curEntry.isUeberschrift()) - { - abstand += 20; - toDrawGraphics.setFont(fontBold); - toDrawGraphics.setColor(Color.BLUE); - } - else - { - abstand += 15; - toDrawGraphics.setFont(fontPlain); - toDrawGraphics.setColor(Color.BLACK); - } - - fm = toDrawGraphics.getFontMetrics(); - strWidth = fm.stringWidth(curEntry.getAusgabetext()); - toDrawGraphics.drawString(curEntry.getAusgabetext(), (creditsBreite - strWidth) / 2, y + abstand); - } - - if(draw) - { - g.drawImage(toDraw, imageX - 1, imageY - 11, backPanel); - } - else - { - draw = true; - } - - if(y == -5 - credits.size() * 15) - { - y = creditsHoehe; - } - } - - try - { - sleep(100); - } - catch(InterruptedException iE) - { - interrupt(); - } - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("About-Workerthread beendet. " + this); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiController.java b/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiController.java deleted file mode 100644 index 310face2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiController.java +++ /dev/null @@ -1,68 +0,0 @@ -package de.applejuicenet.client.gui.components; - -import javax.swing.JComponent; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.gui.components.util.Value; -import de.applejuicenet.client.gui.listener.LanguageListener; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiController.java,v 1.8 2005/01/19 16:22:19 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ - -public abstract class GuiController implements LanguageListener, DataUpdateListener{ - protected final Logger logger; - - public GuiController(){ - logger = Logger.getLogger(getClass()); - } - - public abstract void fireAction(int actionId, Object source); - - public abstract JComponent getComponent(); - - public abstract void componentSelected(); - - public abstract void componentLostSelection(); - - public abstract Value[] getCustomizedValues(); - - public final String getName(){ - return getClass().getName(); - } - - public final void fireLanguageChanged() { - try{ - languageChanged(); - } catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public final void fireContentChanged(DATALISTENER_TYPE type, Object content) { - try{ - contentChanged(type, content); - } catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - protected abstract void languageChanged(); - - protected abstract void contentChanged(DATALISTENER_TYPE type, Object content); -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/LanguageSelector.java b/AJClientGUI/src/de/applejuicenet/client/gui/controller/LanguageSelector.java deleted file mode 100644 index 381fe088..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/LanguageSelector.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.controller; - -import java.io.CharArrayWriter; -import java.io.File; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/LanguageSelector.java,v 1.30 2009/01/12 09:02:56 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI f\uFFFDr den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class LanguageSelector extends XMLValueHolder -{ - private static LanguageSelector instance = null; - private static Logger logger = Logger.getLogger(LanguageSelector.class); - private Set<LanguageListener> languageListener = new HashSet<LanguageListener>(); - private CharArrayWriter contents = new CharArrayWriter(); - private StringBuffer key = new StringBuffer(); - @SuppressWarnings("unchecked") - private Set pluginsToWatch = null; - - private LanguageSelector(String path) - { - super(); - try - { - parseProperties(new File(path)); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - public static LanguageSelector getInstance() - { - if(instance == null) - { - String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; - OptionsManager om = OptionsManagerImpl.getInstance(); - String datei = om.getSprache(); - - if(null == datei || datei.length() == 0) - { - datei = "deutsch"; - } - - path += datei + ".properties"; - - //zZ werden die Header der TableModel nicht aktualisiert, deshalb hier schon - return new LanguageSelector(path); - } - - return instance; - } - - @SuppressWarnings("unchecked") - public void addPluginsToWatch(Set plugins) - { - pluginsToWatch = plugins; - } - - private void init(File languageFile) - { - try - { - if(key.length() > 0) - { - key.delete(0, key.length() - 1); - } - - parseProperties(languageFile); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public static LanguageSelector getInstance(String path) - { - if(instance == null) - { - instance = new LanguageSelector(path); - } - else - { - File sprachDatei = new File(path); - - if(!sprachDatei.isFile()) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Die in der ajgui.properties hinterlegte Sprachdatei wurde nicht gefunden." + - "\r\nappleJuice wird beendet."); - } - - AppleJuiceDialog.closeWithErrormessage("Die in der ajgui.properties hinterlegte Sprachdatei wurde nicht gefunden." + - "\r\nappleJuice wird beendet.", false); - } - - instance.init(sprachDatei); - instance.informLanguageListener(); - } - - return instance; - } - - public void fireLanguageChanged() - { - informLanguageListener(); - } - - public void addLanguageListener(LanguageListener listener) - { - if(!(languageListener.contains(listener))) - { - languageListener.add(listener); - } - } - - public void removeLanguageListener(LanguageListener listener) - { - if(languageListener.contains(listener)) - { - languageListener.remove(listener); - } - } - - public String getFirstAttrbuteByTagName(String[] pathToValue) - { - StringBuffer path = new StringBuffer(); - - path.append("."); - path.append("root"); - for(int i = 0; i < pathToValue.length; i++) - { - path.append("."); - path.append(pathToValue[i]); - } - - return getFirstAttrbuteByTagName(path.toString()); - } - - public String getFirstAttrbuteByTagName(String identifier) - { - if(values.containsKey(identifier)) - { - return values.getProperty(identifier); - } - else - { - return ""; - } - } - - @SuppressWarnings("unchecked") - private void informLanguageListener() - { - Iterator it = languageListener.iterator(); - - while(it.hasNext()) - { - ((LanguageListener) it.next()).fireLanguageChanged(); - } - - if(pluginsToWatch != null) - { - it = pluginsToWatch.iterator(); - String language = getFirstAttrbuteByTagName("Languageinfo.name").toLowerCase(); - - while(it.hasNext()) - { - ((PluginConnector) it.next()).setLanguage(language); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/LinkListener.java b/AJClientGUI/src/de/applejuicenet/client/gui/controller/LinkListener.java deleted file mode 100644 index b09769b8..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/LinkListener.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.controller; - -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; - -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; - -import java.util.HashSet; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.listener.CoreStatusListener; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/LinkListener.java,v 1.15 2009/01/12 14:53:08 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class LinkListener extends Thread implements CoreStatusListener -{ - private static Logger logger; - private final int PORT; - private ServerSocket listen; - private ApplejuiceFassade applejuiceFassade = null; - private HashSet<Link> linkCache = null; - - public LinkListener() throws IOException - { - PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); - logger = Logger.getLogger(getClass()); - try - { - listen = new ServerSocket(PORT); - setName("LinkListenerThread"); - setDaemon(true); - start(); - ApplejuiceFassade.addCoreStatusListener(this); - } - catch(IOException ioE) - { - throw ioE; - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void run() - { - try - { - while(true) - { - Socket client = listen.accept(); - - if(client.getInetAddress().getHostAddress().compareTo(InetAddress.getByName("localhost").getHostAddress()) == 0) - { - try - { - DataInputStream in = new DataInputStream(client.getInputStream()); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - String line = reader.readLine(); - - if(line.indexOf("-link=") != -1) - { - String link = getLinkFromReadLine(line); - - if(link != null) - { - Link aLink = new Link(link, ""); - - if(applejuiceFassade != null) - { - processLink(aLink); - } - else - { - if(linkCache == null) - { - linkCache = new HashSet<Link>(); - } - - linkCache.add(aLink); - } - } - } - - //todo - /* else if (line.indexOf("-command=") != -1) { - String command = line.substring(line.indexOf( - "-command=") + 9).toLowerCase(); - if (command.startsWith("getajstats")) { - PrintStream out = new PrintStream(client. - getOutputStream()); - out.println(AppleJuiceClient.getAjFassade(). - getStats()); - } - else if (command.startsWith("getajinfo")) { - PrintStream out = new PrintStream(client. - getOutputStream()); - out.println(ApplejuiceFassade.getInstance().getVersionInformation()); - } - }*/ - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - client.close(); - return; - } - } - else - { - DataInputStream in = new DataInputStream(client.getInputStream()); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - - reader.readLine(); - PrintStream out = new PrintStream(client.getOutputStream()); - - out.println("Fuck you, little bastard !!!"); - } - - client.close(); - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - private boolean isValidAjLink(String line) - { - try - { - if(line == null) - { - return false; - } - - String password = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); - - if(line.substring(0, password.length()).compareTo(password) != 0) - { - return false; - } - - if(line.indexOf("ajfsp://") == -1) - { - return false; - } - } - catch(Exception e) - { - return false; - } - - return true; - } - - private String getLinkFromReadLine(String line) - { - if(!isValidAjLink(line)) - { - return null; - } - else - { - return line.substring(line.indexOf("ajfsp://")); - } - } - - public void fireStatusChanged(STATUS newStatus) - { - if(newStatus == STATUS.STARTED) - { - ApplejuiceFassade.removeCoreStatusListener(this); - applejuiceFassade = AppleJuiceClient.getAjFassade(); - processCache(); - } - } - - private void processCache() - { - if(linkCache == null) - { - return; - } - - for(Link curLink : linkCache) - { - processLink(curLink); - } - - linkCache.clear(); - linkCache = null; - } - - public void processLink(String link, String directory) - { - Link aLink = new Link(link, ""); - - if(applejuiceFassade == null) - { - if(linkCache == null) - { - linkCache = new HashSet<Link>(); - } - - linkCache.add(aLink); - } - else - { - processLink(aLink); - } - } - - private void processLink(Link aLink) - { - try - { - applejuiceFassade.processLink(aLink.getLink(), aLink.getDirectory()); - } - catch(IllegalArgumentException e) - { - // an dieser Stelle unterbuttern - logger.warn(e); - } - } - - private class Link - { - private final String link; - private final String directory; - - public Link(String link, String directory) - { - this.link = link; - this.directory = directory; - } - - public String getDirectory() - { - return directory; - } - - public String getLink() - { - return link; - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertiesManager.java b/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertiesManager.java deleted file mode 100644 index 61cb536a..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertiesManager.java +++ /dev/null @@ -1,1566 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.controller; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Point; - -import java.io.IOException; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import javax.swing.LookAndFeel; -import javax.swing.UIManager; -import javax.swing.UIManager.LookAndFeelInfo; - -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.download.table.DownloadSourcesTableModel; -import de.applejuicenet.client.gui.download.table.DownloadsTableModel; -import de.applejuicenet.client.gui.search.table.SearchTableModel; -import de.applejuicenet.client.gui.server.table.ServerTableModel; -import de.applejuicenet.client.gui.share.table.ShareTableModel; -import de.applejuicenet.client.gui.upload.table.UploadActiveTableModel; -import de.applejuicenet.client.gui.upload.table.UploadWaitingTableModel; -import de.applejuicenet.client.shared.ConnectionSettings; -import de.applejuicenet.client.shared.LookAFeel; -import de.applejuicenet.client.shared.Settings; -import de.applejuicenet.client.shared.exception.InvalidPasswordException; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertiesManager.java,v - * 1.49 2004/07/09 11:34:00 loevenwong Exp $ - * - * <p> - * Titel: AppleJuice Client-GUI - * </p> - * <p> - * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - * </p> - * <p> - * Copyright: General Public License - * </p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class PropertiesManager implements OptionsManager, PositionManager, ProxyManager -{ - private static PropertiesManager instance = null; - private static final String PROPERTIES_ERROR = "Fehler beim Zugriff auf die ajgui.properties. " + - "Die Datei wird neu erstellt."; - private static final String PROPERTIES_ERROR_MESSAGE = "ajgui.properties neu erstellt"; - private static Logger logger; - private static String path; - private static final int DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH = 90; - private static final int DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH = 90; - private static final int DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH = 80; - private static final int DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH = 80; - private static final int DEFAULT_SHARE_TABLE_COLUMN_WIDTH = 194; - private static final int DEFAULT_SERVER_TABLE_COLUMN_WIDTH = 175; - private static final int DEFAULT_SEARCH_TABLE_COLUMN_WIDTH = 103; - private Set<DataUpdateListener> settingsListener = new HashSet<DataUpdateListener>(); - private Set<DataUpdateListener> connectionSettingsListener = new HashSet<DataUpdateListener>(); - private Point mainXY; - private Dimension mainDimension; - private ProxySettings proxySettings; - private ConnectionSettings connectionSettings = null; - private int[] downloadWidths; - private int[] downloadSourcesWidths; - private int[] uploadWidths; - private int[] serverWidths; - private int[] shareWidths; - private boolean[] downloadVisibilities; - private boolean[] downloadSourcesVisibilities; - private boolean[] uploadVisibilities; - private boolean[] uploadWaitingVisibilities; - private int[] downloadIndex; - private int[] downloadSourcesIndex; - private int[] uploadIndex; - private int[] uploadWaitingIndex; - private Settings settings = null; - private boolean firstReadError = true; - private boolean legal = false; - private PropertyHandler propertyHandler; - private int[] uploadWaitingWidths; - private int[] downloadSort; - private int[] uploadSort; - private int[] searchSort; - private int[] downloadSourcesSort; - private int[] uploadWaitingSort; - private int[] serverSort; - - private PropertiesManager(String propertiesPath) - { - PropertiesManager.path = propertiesPath; - logger = Logger.getLogger(getClass()); - init(); - } - - static PropertiesManager getInstance() - { - if(instance == null) - { - instance = new PropertiesManager(AppleJuiceClient.getPropertiesPath()); - } - - return instance; - } - - static PositionManager getPositionManager() - { - if(instance == null) - { - instance = new PropertiesManager(AppleJuiceClient.getPropertiesPath()); - } - - return instance; - } - - private void saveFile() - { - try - { - propertyHandler.save(); - } - catch(IllegalArgumentException e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(e.getMessage(), e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - } - - //ProxyManager-Interface - public ProxySettings getProxySettings() - { - return proxySettings; - } - - public void saveProxySettings(ProxySettings proxySettings) - { - this.proxySettings = proxySettings; - propertyHandler.put("options_proxy_use", proxySettings.isUse()); - propertyHandler.put("options_proxy_host", proxySettings.getHost()); - propertyHandler.put("options_proxy_port", proxySettings.getPort()); - propertyHandler.put("options_proxy_userpass", proxySettings.getUserpass()); - saveFile(); - } - - //OptionsManager-Interface - public void addSettingsListener(DataUpdateListener listener) - { - if(!(settingsListener.contains(listener))) - { - settingsListener.add(listener); - } - } - - public void addConnectionSettingsListener(DataUpdateListener listener) - { - if(!(connectionSettingsListener.contains(listener))) - { - connectionSettingsListener.add(listener); - } - } - - @SuppressWarnings("unchecked") - private void informSettingsListener(Settings settings) - { - Iterator it = settingsListener.iterator(); - - while(it.hasNext()) - { - ((DataUpdateListener) it.next()).fireContentChanged(DATALISTENER_TYPE.SETTINGS_CHANGED, settings); - } - } - - @SuppressWarnings("unchecked") - private void informConnectionSettingsListener(ConnectionSettings settings) - { - Iterator it = connectionSettingsListener.iterator(); - - while(it.hasNext()) - { - ((DataUpdateListener) it.next()).fireContentChanged(DATALISTENER_TYPE.CONNECTION_SETTINGS_CHANGED, settings); - } - } - - public String getSprache() - { - try - { - return propertyHandler.get("options_sprache", "deutsch"); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return null; - } - } - - public String getDefaultTheme() - { - try - { - String temp = propertyHandler.get("options_defaulttheme", "toxicthemepack"); - - if(temp.length() == 0) - { - throw new Exception("Kein Defaulttheme vorhanden."); - } - - return temp; - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return ""; - } - } - - public void setDefaultTheme(String themeShortName) - { - propertyHandler.put("options_defaulttheme", themeShortName); - } - - public LookAFeel[] getLookAndFeels() - { - try - { - ArrayList<LookAFeel> lookAndFeels = new ArrayList<LookAFeel>(); - String temp = "."; - String temp2; - int i = 1; - - String test = propertyHandler.get("options_lookandfeels_laf" + 1 + "_value", null); - - if(null == test) - { - initLookAndFeels(propertyHandler); - } - while(temp != null && temp.length() > 0) - { - temp = propertyHandler.get("options_lookandfeels_laf" + i + "_value", ""); - if(temp.length() > 0) - { - temp2 = propertyHandler.get("options_lookandfeels_laf" + i + "_name", ""); - lookAndFeels.add(new LookAFeel(temp2, temp)); - } - - i++; - } - - return (LookAFeel[]) lookAndFeels.toArray(new LookAFeel[lookAndFeels.size()]); - - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - - return null; - } - - private static void initLookAndFeels(PropertyHandler propertyHandler2) - { - propertyHandler2.put("options_lookandfeels_laf1_name", "JGoodies Plastic"); - propertyHandler2.put("options_lookandfeels_laf1_value", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); - int index = 2; - - if(System.getProperty("os.name").toLowerCase().indexOf("win") != -1) - { - propertyHandler2.put("options_lookandfeels_laf" + index + "_name", "JGoodies Windows"); - propertyHandler2.put("options_lookandfeels_laf" + index + "_value", "com.jgoodies.looks.windows.WindowsLookAndFeel"); - index++; - } - - LookAndFeelInfo[] feels = UIManager.getInstalledLookAndFeels(); - LookAndFeel currentFeel = UIManager.getLookAndFeel(); - - for(int i = 0; i < feels.length; i++) - { - try - { - UIManager.setLookAndFeel(feels[i].getClassName()); - propertyHandler2.put("options_lookandfeels_laf" + index + "_name", feels[i].getName()); - propertyHandler2.put("options_lookandfeels_laf" + index + "_value", feels[i].getClassName()); - index++; - } - catch(Exception e) - { - - //unsupported - } - } - - try - { - UIManager.setLookAndFeel(currentFeel); - } - catch(Exception ex) - { - - //muss klappen - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - public LookAFeel getDefaultLookAndFeel() - { - try - { - LookAFeel[] looks = this.getLookAndFeels(); - String temp = propertyHandler.get("options_lookandfeels_default_name", "JGoodies Plastic"); - - for(int i = 0; i < looks.length; i++) - { - if(temp.equals(looks[i].getName())) - { - return looks[i]; - } - } - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - - return null; - } - - public void setDefaultLookAndFeel(LookAFeel lookAFeel) - { - propertyHandler.put("options_lookandfeels_default_name", lookAFeel.getName()); - } - - public void setOpenProgram(String path) - { - if(path == null || path.length() == 0) - { - path = "-1"; - } - - propertyHandler.put("options_program_file", path); - String temp = getOpenProgram(); - - if(temp.compareTo(path) != 0) - { - AppleJuiceDialog.rewriteProperties = true; - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - } - - public String getOpenProgram() - { - try - { - String temp = propertyHandler.get("options_program_file", "-1"); - - if(temp.compareTo("-1") == 0) - { - return ""; - } - else if(temp.length() == 0) - { - return null; - } - else - { - return temp; - } - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return ""; - } - } - - public String getStandardBrowser() - { - try - { - return propertyHandler.get("options_browser_file", ""); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return ""; - } - } - - public void setStandardBrowser(String browser) - { - propertyHandler.put("options_browser_file", browser); - String temp = getStandardBrowser(); - - if(temp.compareTo(browser) != 0) - { - AppleJuiceDialog.rewriteProperties = true; - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - } - - public boolean isErsterStart() - { - try - { - return propertyHandler.getAsBoolean("options_firststart", true); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return false; - } - } - - public void setErsterStart(boolean ersterStart) - { - propertyHandler.put("options_firststart", ersterStart); - } - - public boolean shouldLoadPluginsOnStartup() - { - try - { - return propertyHandler.getAsBoolean("options_loadplugins", true); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return false; - } - } - - public void loadPluginsOnStartup(boolean loadPluginsOnStartup) - { - propertyHandler.put("options_loadplugins", loadPluginsOnStartup); - shouldLoadPluginsOnStartup(); - } - - public boolean isThemesSupported() - { - try - { - return propertyHandler.getAsBoolean("options_themes", false); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return false; - } - } - - public void enableThemeSupport(boolean enable) - { - propertyHandler.put("options_themes", enable); - } - - public int getVersionsinfoModus() - { - return propertyHandler.getAsInt("options_versionsinfo", 1); - } - - public void setVersionsinfoModus(int versionsinfoModus) - { - if(versionsinfoModus < 0 || versionsinfoModus > 2) - { - versionsinfoModus = 1; - } - - propertyHandler.put("options_versionsinfo", versionsinfoModus); - } - - public int getLinkListenerPort() - { - return propertyHandler.getAsInt("options_linklistenerport", 8768); - } - - public void setLinkListenerPort(int port) - { - propertyHandler.put("options_linklistenerport", port); - } - - public boolean isSoundEnabled() - { - try - { - return propertyHandler.getAsBoolean("options_sound", true); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return false; - } - } - - public void enableSound(boolean enable) - { - propertyHandler.put("options_sound", enable); - } - - public void setSprache(String sprache) - { - propertyHandler.put("options_sprache", sprache.toLowerCase()); - } - - public boolean shouldShowConnectionDialogOnStartup() - { - try - { - return propertyHandler.getAsBoolean("options_dialogzeigen", true); - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return false; - } - } - - public void showConnectionDialogOnStartup(boolean show) - { - propertyHandler.put("options_dialogzeigen", show); - } - - public Level getLogLevel() - { - try - { - String temp = propertyHandler.get("options_logging_level", "INFO"); - Level result = Level.OFF; - - if(temp.compareToIgnoreCase("INFO") == 0) - { - return Level.INFO; - } - else if(temp.compareToIgnoreCase("DEBUG") == 0) - { - return Level.DEBUG; - } - else if(temp.compareToIgnoreCase("WARN") == 0) - { - return Level.WARN; - } - else if(temp.compareToIgnoreCase("FATAL") == 0) - { - return Level.FATAL; - } - else if(temp.compareToIgnoreCase("ALL") == 0) - { - return Level.ALL; - } - else if(temp.compareToIgnoreCase("OFF") == 0) - { - return Level.OFF; - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("Aktueller Loglevel: " + result.toString()); - } - - return result; - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return null; - } - } - - public void setLogLevel(Level level) - { - if(level == null) - { - level = Level.OFF; - } - - String temp = "OFF"; - - if(level == Level.ALL) - { - temp = "ALL"; - } - else if(level == Level.INFO) - { - temp = "INFO"; - } - else if(level == Level.DEBUG) - { - temp = "DEBUG"; - } - else if(level == Level.WARN) - { - temp = "WARN"; - } - else if(level == Level.FATAL) - { - temp = "FATAL"; - } - - propertyHandler.put("options_logging_level", temp); - Logger rootLogger = Logger.getRootLogger(); - - rootLogger.setLevel(level); - rootLogger.removeAllAppenders(); - if(level != Level.OFF) - { - try - { - FileAppender fileAppender = new FileAppender(AppleJuiceClient.getLoggerHtmlLayout(), - AppleJuiceClient.getLoggerFileAppenderPath()); - - rootLogger.addAppender(fileAppender); - } - catch(IOException ioe) - { - rootLogger.addAppender(new ConsoleAppender()); - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ioe); - } - } - else - { - rootLogger.addAppender(new ConsoleAppender()); - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("Loglevel geaendert in " + level.toString()); - } - } - - public Settings getSettings() - { - try - { - if(settings == null) - { - settings = new Settings(); - } - - Color downloadFertigHintergrundColor = null; - Color quelleHintergrundColor = null; - boolean farbenAktiv; - boolean downloadUebersicht; - boolean loadPlugins; - boolean enableToolTip; - String temp; - - farbenAktiv = propertyHandler.get("options_farben_aktiv", "true").equals("true"); - temp = propertyHandler.get("options_farben_hintergrund_downloadFertig", "-13382656"); - if(temp.length() != 0) - { - downloadFertigHintergrundColor = new Color(Integer.parseInt(temp)); - } - - temp = propertyHandler.get("options_farben_hintergrund_quelle", "-205"); - if(temp.length() != 0) - { - quelleHintergrundColor = new Color(Integer.parseInt(temp)); - } - - downloadUebersicht = propertyHandler.getAsBoolean("options_download_uebersicht", true); - loadPlugins = propertyHandler.getAsBoolean("options_loadplugins", true); - enableToolTip = propertyHandler.getAsBoolean("options_enableToolTip", true); - settings.setFarbenAktiv(farbenAktiv); - settings.setDownloadFertigHintergrundColor(downloadFertigHintergrundColor); - settings.setQuelleHintergrundColor(quelleHintergrundColor); - settings.loadPluginsOnStartup(loadPlugins); - settings.enableToolTipEnabled(enableToolTip); - settings.setDownloadUebersicht(downloadUebersicht); - return settings; - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return null; - } - } - - public void saveSettings(Settings settings) - { - propertyHandler.put("options_farben_aktiv", settings.isFarbenAktiv()); - propertyHandler.put("options_farben_hintergrund_downloadFertig", settings.getDownloadFertigHintergrundColor().getRGB()); - propertyHandler.put("options_farben_hintergrund_quelle", settings.getQuelleHintergrundColor().getRGB()); - propertyHandler.put("options_loadplugins", settings.shouldLoadPluginsOnStartup()); - propertyHandler.put("options_enableToolTip", settings.isToolTipEnabled()); - propertyHandler.put("options_download_uebersicht", settings.isDownloadUebersicht()); - propertyHandler.save(); - informSettingsListener(settings); - } - - public ConnectionSettings getRemoteSettings() - { - try - { - if(connectionSettings == null) - { - connectionSettings = new ConnectionSettings(); - } - - String host = "localhost"; - String passwort = ""; - int xmlPort = 9851; - - host = propertyHandler.get("options_remote_host", "localhost"); - passwort = propertyHandler.get("options_remote_passwort", ""); - xmlPort = Integer.parseInt(propertyHandler.get("options_remote_port", "9851")); - connectionSettings.setHost(host); - if(passwort.length() == 0) - { - connectionSettings.setOldPassword(""); - } - else - { - connectionSettings.setOldMD5Password(passwort); - } - - connectionSettings.setXmlPort(xmlPort); - return connectionSettings; - } - catch(Exception e) - { - AppleJuiceDialog.rewriteProperties = true; - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - return null; - } - } - - public void saveRemote(ConnectionSettings remote) throws InvalidPasswordException - { - propertyHandler.put("options_remote_host", remote.getHost()); - try - { - AppleJuiceClient.getAjFassade().setPassword(remote.getNewPassword(), false); - } - catch(de.applejuicenet.client.fassade.exception.IllegalArgumentException e) - { - logger.error(e); - } - - propertyHandler.put("options_remote_passwort", remote.getNewPassword()); - propertyHandler.put("options_remote_port", remote.getXmlPort()); - informConnectionSettingsListener(getRemoteSettings()); - } - - public void onlySaveRemote(ConnectionSettings remote) - { - propertyHandler.put("options_remote_host", remote.getHost()); - propertyHandler.put("options_remote_passwort", remote.getNewPassword()); - propertyHandler.put("options_remote_port", remote.getXmlPort()); - connectionSettings = remote; - } - - public void saveAJSettings(AJSettings ajSettings) - { - AppleJuiceClient.getAjFassade().saveAJSettings(ajSettings); - } - - private boolean isVeraltet() - { - return false; - } - - public static void restoreProperties() - { - PropertyHandler aPropertyHandler = null; - - try - { - aPropertyHandler = new PropertyHandler(AppleJuiceClient.getPropertiesPath(), "appleJuice-Java-GUI Propertyfile", false); - aPropertyHandler.put("options_dialogzeigen", true); - aPropertyHandler.put("options_firststart", true); - aPropertyHandler.put("options_sound", true); - aPropertyHandler.put("options_sprache", "deutsch"); - aPropertyHandler.put("options_themes", false); - aPropertyHandler.put("options_defaulttheme", "toxicthemepack"); - aPropertyHandler.put("options_loadplugins", true); - aPropertyHandler.put("options_enableToolTip", true); - aPropertyHandler.put("options_linklistenerport", 8768); - aPropertyHandler.put("options_versionsinfo", 1); - aPropertyHandler.put("options_remote_host", "localhost"); - aPropertyHandler.put("options_remote_passwort", ""); - aPropertyHandler.put("options_remote_port", 9851); - - aPropertyHandler.put("options_logging_level", "INFO"); - aPropertyHandler.put("options_download_uebersicht", true); - aPropertyHandler.put("options_farben_aktiv", true); - - aPropertyHandler.put("options_farben_hintergrund_downloadFertig", -13382656); - aPropertyHandler.put("options_farben_hintergrund_quelle", -205); - - initLookAndFeels(aPropertyHandler); - - aPropertyHandler.put("options_lookandfeels_default_name", "JGoodies Plastic"); - aPropertyHandler.put("options_location_height", ""); - aPropertyHandler.put("options_location_width", ""); - aPropertyHandler.put("options_location_x", ""); - aPropertyHandler.put("options_location_y", ""); - aPropertyHandler.put("options_columns_download_column0_width", DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_download_column0_index", 0); - for(int i = 1; i < DownloadsTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_download_column" + i + "_width", DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_download_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_download_column" + i + "_index", i); - } - - aPropertyHandler.put("options_download_sort_column", "0"); - aPropertyHandler.put("options_download_sort_order", "1"); - - aPropertyHandler.put("options_download_sources_sort_column", "0"); - aPropertyHandler.put("options_download_sources_sort_order", "1"); - - aPropertyHandler.put("options_upload_sort_column", "0"); - aPropertyHandler.put("options_upload_sort_order", "1"); - - aPropertyHandler.put("options_search_sort_column", "0"); - aPropertyHandler.put("options_search_sort_order", "1"); - - aPropertyHandler.put("options_upload_waiting_sort_column", "0"); - aPropertyHandler.put("options_upload_waiting_sort_order", "1"); - - aPropertyHandler.put("options_server_sort_column", "0"); - aPropertyHandler.put("options_server_sort_order", "1"); - - aPropertyHandler.put("options_columns_downloadsources_column0_width", DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_downloadsources_column0_index", 0); - for(int i = 1; i < DownloadSourcesTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_downloadsources_column" + i + "_width", DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_downloadsources_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_downloadsources_column" + i + "_index", i); - } - - aPropertyHandler.put("options_columns_upload_column0_width", DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_upload_column0_index", 0); - for(int i = 1; i < UploadActiveTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_upload_column" + i + "_width", DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_upload_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_upload_column" + i + "_index", i); - } - - aPropertyHandler.put("options_columns_uploadwaiting_column0_width", DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_uploadwaiting_column0_index", 0); - for(int i = 1; i < UploadWaitingTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_width", DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_index", i); - } - - aPropertyHandler.put("options_columns_server_column0_width", DEFAULT_SERVER_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_server_column0_index", 0); - for(int i = 1; i < ServerTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_server_column" + i + "_width", DEFAULT_SERVER_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_server_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_server_column" + i + "_index", i); - } - - aPropertyHandler.put("options_columns_search_column0_width", DEFAULT_SEARCH_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_search_column0_index", 0); - for(int i = 1; i < SearchTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_search_column" + i + "_width", DEFAULT_SEARCH_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_search_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_search_column" + i + "_index", i); - } - - aPropertyHandler.put("options_columns_share_column0_width", DEFAULT_SHARE_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_share_column0_index", 0); - for(int i = 1; i < ShareTableModel.CLASS_TYPES.length; i++) - { - aPropertyHandler.put("options_columns_share_column" + i + "_width", DEFAULT_SHARE_TABLE_COLUMN_WIDTH); - aPropertyHandler.put("options_columns_share_column" + i + "_visibility", true); - aPropertyHandler.put("options_columns_share_column" + i + "_index", i); - } - - aPropertyHandler.put("options_browser_file", ""); - aPropertyHandler.put("options_program_file", -1); - aPropertyHandler.put("options_proxy_host", ""); - aPropertyHandler.put("options_proxy_port", ""); - aPropertyHandler.put("options_proxy_use", false); - aPropertyHandler.put("options_proxy_userpass", ""); - aPropertyHandler.save(); - } - catch(IllegalArgumentException e1) - { - // sollte eigentlich nie passieren - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e1); - } - } - - protected void init() - { - try - { - propertyHandler = new PropertyHandler(path, "appleJuice-Java-GUI Propertyfile", true); - if(isVeraltet()) - { - throw new Exception("ajgui.properties hat altes Format. Wird neu erstellt."); - } - - String temp = propertyHandler.get("options_location_x", ""); - - if(temp.length() != 0) - { - legal = true; - - int mainX = propertyHandler.getAsInt("options_location_x", 1); - int mainY = propertyHandler.getAsInt("options_location_y", 1); - - mainXY = new Point(mainX, mainY); - int mainWidth = propertyHandler.getAsInt("options_location_width", 400); - int mainHeight = propertyHandler.getAsInt("options_location_height", 400); - - mainDimension = new Dimension(mainWidth, mainHeight); - } - - downloadWidths = new int[DownloadsTableModel.CLASS_TYPES.length]; - for(int i = 0; i < downloadWidths.length; i++) - { - downloadWidths[i] = propertyHandler.getAsInt("options_columns_download_column" + i + "_width", - DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); - } - - downloadSort = new int[2]; - downloadSort[0] = propertyHandler.getAsInt("options_download_sort_column", 0); - downloadSort[1] = propertyHandler.getAsInt("options_download_sort_order", 1); - - downloadSourcesSort = new int[2]; - downloadSourcesSort[0] = propertyHandler.getAsInt("options_download_sources_sort_column", 0); - downloadSourcesSort[1] = propertyHandler.getAsInt("options_download_sources_sort_order", 1); - - uploadSort = new int[2]; - uploadSort[0] = propertyHandler.getAsInt("options_upload_sort_column", 0); - uploadSort[1] = propertyHandler.getAsInt("options_upload_sort_order", 1); - - searchSort = new int[2]; - searchSort[0] = propertyHandler.getAsInt("options_search_sort_column", 0); - searchSort[1] = propertyHandler.getAsInt("options_search_sort_order", 1); - - uploadWaitingSort = new int[2]; - uploadWaitingSort[0] = propertyHandler.getAsInt("options_upload_waiting_sort_column", 0); - uploadWaitingSort[1] = propertyHandler.getAsInt("options_upload_waiting_sort_order", 1); - - serverSort = new int[2]; - serverSort[0] = propertyHandler.getAsInt("options_server_sort_column", 0); - serverSort[1] = propertyHandler.getAsInt("options_server_sort_order", 1); - - downloadSourcesWidths = new int[DownloadSourcesTableModel.CLASS_TYPES.length]; - for(int i = 0; i < downloadSourcesWidths.length; i++) - { - downloadSourcesWidths[i] = propertyHandler.getAsInt("options_columns_downloadsources_column" + i + "_width", - DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); - } - - uploadWidths = new int[UploadActiveTableModel.CLASS_TYPES.length]; - for(int i = 0; i < uploadWidths.length; i++) - { - uploadWidths[i] = propertyHandler.getAsInt("options_columns_upload_column" + i + "_width", - DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); - } - - uploadWaitingWidths = new int[UploadWaitingTableModel.CLASS_TYPES.length]; - for(int i = 0; i < uploadWaitingWidths.length; i++) - { - uploadWaitingWidths[i] = propertyHandler.getAsInt("options_columns_uploadwaiting_column" + i + "_width", - DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); - } - - uploadWaitingVisibilities = new boolean[UploadWaitingTableModel.CLASS_TYPES.length]; - uploadWaitingVisibilities[0] = true; - for(int i = 1; i < uploadWaitingVisibilities.length; i++) - { - uploadWaitingVisibilities[i] = propertyHandler.getAsBoolean("options_columns_uploadwaiting_column" + i + "_visibility", - true); - } - - serverWidths = new int[ServerTableModel.CLASS_TYPES.length]; - for(int i = 0; i < serverWidths.length; i++) - { - serverWidths[i] = propertyHandler.getAsInt("options_columns_server_column" + i + "_width", - DEFAULT_SERVER_TABLE_COLUMN_WIDTH); - } - - shareWidths = new int[ShareTableModel.CLASS_TYPES.length]; - for(int i = 0; i < shareWidths.length; i++) - { - shareWidths[i] = propertyHandler.getAsInt("options_columns_share_column" + i + "_width", - DEFAULT_SHARE_TABLE_COLUMN_WIDTH); - } - - downloadVisibilities = new boolean[DownloadsTableModel.CLASS_TYPES.length]; - downloadVisibilities[0] = true; - for(int i = 1; i < downloadVisibilities.length; i++) - { - downloadVisibilities[i] = propertyHandler.getAsBoolean("options_columns_download_column" + i + "_visibility", true); - } - - downloadSourcesVisibilities = new boolean[DownloadSourcesTableModel.CLASS_TYPES.length]; - downloadSourcesVisibilities[0] = true; - for(int i = 1; i < downloadSourcesVisibilities.length; i++) - { - downloadSourcesVisibilities[i] = propertyHandler.getAsBoolean("options_columns_downloadsources_column" + i + - "_visibility", true); - } - - uploadVisibilities = new boolean[UploadActiveTableModel.CLASS_TYPES.length]; - uploadVisibilities[0] = true; - for(int i = 1; i < uploadVisibilities.length; i++) - { - uploadVisibilities[i] = propertyHandler.getAsBoolean("options_columns_upload_column" + i + "_visibility", true); - } - - downloadIndex = new int[DownloadsTableModel.CLASS_TYPES.length]; - for(int i = 0; i < downloadIndex.length; i++) - { - downloadIndex[i] = propertyHandler.getAsInt("options_columns_download_column" + i + "_index", i); - } - - downloadSourcesIndex = new int[DownloadSourcesTableModel.CLASS_TYPES.length]; - for(int i = 0; i < downloadSourcesIndex.length; i++) - { - downloadSourcesIndex[i] = propertyHandler.getAsInt("options_columns_downloadsources_column" + i + "_index", i); - } - - uploadIndex = new int[UploadActiveTableModel.CLASS_TYPES.length]; - for(int i = 1; i < uploadIndex.length; i++) - { - uploadIndex[i] = propertyHandler.getAsInt("options_columns_upload_column" + i + "_index", i); - } - - uploadWaitingIndex = new int[UploadWaitingTableModel.CLASS_TYPES.length]; - for(int i = 1; i < uploadWaitingIndex.length; i++) - { - uploadWaitingIndex[i] = propertyHandler.getAsInt("options_columns_uploadwaiting_column" + i + "_index", i); - } - - boolean use = propertyHandler.getAsBoolean("options_proxy_use", false); - int port = propertyHandler.getAsInt("options_proxy_port", -1); - - String userpass = propertyHandler.get("options_proxy_userpass", ""); - String host = propertyHandler.get("options_proxy_host", ""); - - proxySettings = new ProxySettings(use, host, port, userpass); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(PROPERTIES_ERROR_MESSAGE, e); - } - - if(firstReadError == true) - { - PropertiesManager.restoreProperties(); - AppleJuiceDialog.showInformation(PROPERTIES_ERROR); - firstReadError = false; - init(); - } - else - { - AppleJuiceDialog.rewriteProperties = true; - AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); - } - } - } - - public void save() - { - try - { - propertyHandler.put("options_location_x", mainXY.x); - propertyHandler.put("options_location_y", mainXY.y); - propertyHandler.put("options_location_width", mainDimension.width); - propertyHandler.put("options_location_height", mainDimension.height); - - propertyHandler.put("options_download_sort_column", downloadSort[0]); - propertyHandler.put("options_download_sort_order", downloadSort[1]); - - propertyHandler.put("options_download_sources_sort_column", downloadSourcesSort[0]); - propertyHandler.put("options_download_sources_sort_order", downloadSourcesSort[1]); - - propertyHandler.put("options_upload_sort_column", uploadSort[0]); - propertyHandler.put("options_upload_sort_order", uploadSort[1]); - - propertyHandler.put("options_search_sort_column", searchSort[0]); - propertyHandler.put("options_search_sort_order", searchSort[1]); - - propertyHandler.put("options_upload_waiting_sort_column", uploadWaitingSort[0]); - propertyHandler.put("options_upload_waiting_sort_order", uploadWaitingSort[1]); - - propertyHandler.put("options_server_sort_column", serverSort[0]); - propertyHandler.put("options_server_sort_order", serverSort[1]); - - for(int i = 0; i < downloadWidths.length; i++) - { - propertyHandler.put("options_columns_download_column" + i + "_width", downloadWidths[i]); - } - - for(int i = 0; i < downloadSourcesWidths.length; i++) - { - propertyHandler.put("options_columns_downloadsources_column" + i + "_width", downloadSourcesWidths[i]); - } - - for(int i = 0; i < uploadWidths.length; i++) - { - propertyHandler.put("options_columns_upload_column" + i + "_width", uploadWidths[i]); - } - - for(int i = 0; i < uploadWaitingWidths.length; i++) - { - propertyHandler.put("options_columns_uploadwaiting_column" + i + "_width", uploadWaitingWidths[i]); - } - - for(int i = 0; i < serverWidths.length; i++) - { - propertyHandler.put("options_columns_server_column" + i + "_width", serverWidths[i]); - } - - for(int i = 0; i < shareWidths.length; i++) - { - propertyHandler.put("options_columns_share_column" + i + "_width", shareWidths[i]); - } - - for(int i = 0; i < downloadVisibilities.length; i++) - { - propertyHandler.put("options_columns_download_column" + i + "_visibility", downloadVisibilities[i]); - } - - for(int i = 0; i < downloadSourcesVisibilities.length; i++) - { - propertyHandler.put("options_columns_downloadsources_column" + i + "_visibility", downloadSourcesVisibilities[i]); - } - - for(int i = 0; i < uploadVisibilities.length; i++) - { - propertyHandler.put("options_columns_upload_column" + i + "_visibility", uploadVisibilities[i]); - } - - for(int i = 0; i < uploadWaitingVisibilities.length; i++) - { - propertyHandler.put("options_columns_uploadwaiting_column" + i + "_visibility", uploadWaitingVisibilities[i]); - } - - for(int i = 0; i < downloadIndex.length; i++) - { - propertyHandler.put("options_columns_download_column" + i + "_index", downloadIndex[i]); - } - - for(int i = 0; i < downloadSourcesIndex.length; i++) - { - propertyHandler.put("options_columns_downloadsources_column" + i + "_index", downloadSourcesIndex[i]); - } - - for(int i = 0; i < uploadWaitingIndex.length; i++) - { - propertyHandler.put("options_columns_uploadwaiting_column" + i + "_index", uploadWaitingIndex[i]); - } - - saveFile(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public void setMainXY(Point p) - { - mainXY = p; - } - - public Point getMainXY() - { - return mainXY; - } - - public void setMainDimension(Dimension dimension) - { - mainDimension = dimension; - } - - public Dimension getMainDimension() - { - return mainDimension; - } - - public void setDownloadWidths(int[] widths) - { - downloadWidths = widths; - } - - public boolean isLegal() - { - return legal; - } - - public int[] getDownloadWidths() - { - return downloadWidths; - } - - public int[] getUploadWidths() - { - return uploadWidths; - } - - public void setUploadWidths(int[] uploadWidths) - { - this.uploadWidths = uploadWidths; - } - - public int[] getUploadWaitingWidths() - { - return uploadWaitingWidths; - } - - public void setUploadWaitingWidths(int[] uploadWaitingWidths) - { - this.uploadWaitingWidths = uploadWaitingWidths; - } - - public int[] getServerWidths() - { - return serverWidths; - } - - public void setServerWidths(int[] serverWidths) - { - this.serverWidths = serverWidths; - } - - public int[] getShareWidths() - { - return shareWidths; - } - - public void setShareWidths(int[] shareWidths) - { - this.shareWidths = shareWidths; - } - - public void setDownloadColumnVisible(int column, boolean visible) - { - if(column != 0) - { - downloadVisibilities[column] = visible; - } - } - - public boolean[] getDownloadColumnVisibilities() - { - return downloadVisibilities; - } - - public void setDownloadColumnIndex(int column, int index) - { - downloadIndex[column] = index; - } - - public int[] getDownloadSort() - { - return downloadSort; - } - - public void setDownloadSort(int column, boolean ascent) - { - downloadSort = new int[] {column, ascent ? 1 : 0}; - - } - - public int[] getDownloadSourcesSort() - { - return downloadSourcesSort; - } - - public int[] getSearchSort() - { - return searchSort; - } - - public int[] getUploadSort() - { - return uploadSort; - } - - public void setDownlodSourcesSort(int column, boolean ascent) - { - downloadSourcesSort = new int[] {column, ascent ? 1 : 0}; - - } - - public void setSearchSort(int column, boolean ascent) - { - searchSort = new int[] {column, ascent ? 1 : 0}; - - } - - public void setUploadSort(int column, boolean ascent) - { - uploadSort = new int[] {column, ascent ? 1 : 0}; - - } - - public int[] getServerSort() - { - return serverSort; - } - - public int[] getUploadWaitingSort() - { - return uploadWaitingSort; - } - - public void setServerSort(int column, boolean ascent) - { - serverSort = new int[] {column, ascent ? 1 : 0}; - - } - - public void setUploadWaitingSort(int column, boolean ascent) - { - uploadWaitingSort = new int[] {column, ascent ? 1 : 0}; - - } - - public int[] getDownloadColumnIndizes() - { - return downloadIndex; - } - - public void setUploadColumnIndex(int column, int index) - { - uploadIndex[column] = index; - } - - public int[] getUploadColumnIndizes() - { - return uploadIndex; - } - - public void setUploadColumnVisible(int column, boolean visible) - { - if(column != 0) - { - uploadVisibilities[column] = visible; - } - } - - public boolean[] getUploadColumnVisibilities() - { - return uploadVisibilities; - } - - public ConnectionSettings[] getConnectionsSet() - { - ArrayList<ConnectionSettings> connectionSet = new ArrayList<ConnectionSettings>(); - - for(int i = 0;; i++) - { - ConnectionSettings temp = new ConnectionSettings(); - - temp.setHost(propertyHandler.get("options_remote" + i + "_host", "")); - if(temp.getHost().length() == 0) - { - break; - } - - int port = propertyHandler.getAsInt("options_remote" + i + "_port", -1); - - temp.setXmlPort(port); - connectionSet.add(temp); - } - - return (ConnectionSettings[]) connectionSet.toArray(new ConnectionSettings[] {}); - } - - public void setConnectionsSet(ConnectionSettings[] set) - { - for(int i = 0; i < set.length; i++) - { - if((set.length - 1 < i) || ("".equals(set[i].getHost()))) - { - propertyHandler.put("options_remote" + i + "_host", ""); - propertyHandler.put("options_remote" + i + "_port", 0); - } - else - { - propertyHandler.put("options_remote" + i + "_host", set[i].getHost()); - propertyHandler.put("options_remote" + i + "_port", set[i].getXmlPort()); - } - } - } - - public int[] getUploadWaitingColumnIndizes() - { - return uploadWaitingIndex; - } - - public boolean[] getUploadWaitingColumnVisibilities() - { - return uploadWaitingVisibilities; - } - - public void setUploadWaitingColumnIndex(int column, int index) - { - uploadWaitingIndex[column] = index; - } - - public void setUploadWaitingColumnVisible(int column, boolean visible) - { - if(column != 0) - { - uploadWaitingVisibilities[column] = visible; - } - } - - public int[] getDownloadSourcesColumnIndizes() - { - return downloadSourcesIndex; - } - - public boolean[] getDownloadSourcesColumnVisibilities() - { - return downloadSourcesVisibilities; - } - - public int[] getDownloadSourcesWidths() - { - return downloadSourcesWidths; - } - - public void setDownloadSourcesColumnIndex(int column, int index) - { - downloadSourcesIndex[column] = index; - - } - - public void setDownloadSourcesColumnVisible(int column, boolean visible) - { - if(column != 0) - { - downloadSourcesVisibilities[column] = visible; - } - } - - public void setDownloadSourcesWidths(int[] widths) - { - downloadSourcesWidths = widths; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertyHandler.java b/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertyHandler.java deleted file mode 100644 index bcca582f..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertyHandler.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.controller; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import java.util.HashSet; -import java.util.Properties; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; - -public class PropertyHandler -{ - private Logger logger; - private HashSet<PropertyChangeListener> listeners = null; - private String path; - private Properties props; - private String beschreibung; - private boolean inform = true; - - public PropertyHandler(String propertiesLocation, String beschreibung, boolean load) - throws IllegalArgumentException - { - logger = Logger.getLogger(getClass()); - try - { - path = propertiesLocation; - if(beschreibung == null) - { - this.beschreibung = ""; - } - else - { - this.beschreibung = beschreibung; - } - - if(load) - { - reload(); - } - else - { - props = new Properties(); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void informListener(String identifier, String oldValue, String newValue) - { - if(listeners != null && inform) - { - PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, identifier, oldValue, newValue); - - for(PropertyChangeListener curListener : listeners) - { - curListener.propertyChange(propertyChangeEvent); - } - } - } - - public void allowInform(boolean shouldInform) - { - inform = shouldInform; - } - - public void put(String identifier, String value) - { - try - { - String oldValue = get(identifier, null); - - props.put(identifier, value); - informListener(identifier, oldValue, value); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public void put(String identifier, int value) - { - put(identifier, Integer.toString(value)); - } - - public void put(String identifier, boolean value) - { - put(identifier, Boolean.toString(value)); - } - - public String get(String identifier, String defaultValue) - { - Object obj = props.get(identifier); - - if(obj == null) - { - return defaultValue; - } - else - { - return obj.toString(); - } - } - - public Boolean getAsBoolean(String identifier, Boolean defaultValue) - { - String obj = (String) props.get(identifier); - - if(null == obj) - { - return defaultValue; - } - - if("true".equalsIgnoreCase(obj) || "false".equalsIgnoreCase(obj)) - { - return Boolean.valueOf(obj); - } - else - { - return defaultValue; - } - } - - public Integer getAsInt(String identifier, int defaultValue) - { - String obj = (String) props.get(identifier); - - try - { - return new Integer(Integer.parseInt(obj)); - } - catch(NumberFormatException nfE) - { - return defaultValue; - } - } - - public void reload() throws IllegalArgumentException - { - try - { - props = new Properties(); - FileInputStream inputStream = null; - - try - { - inputStream = new FileInputStream(path); - } - catch(FileNotFoundException e) - { - throw new IllegalArgumentException("PropertyDatei konnte nicht gefunden werden."); - - } - - props = new Properties(); - try - { - props.load(inputStream); - inputStream.close(); - } - catch(IOException e2) - { - throw new IllegalArgumentException("Ungueltige PropertyDatei."); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public void save() throws IllegalArgumentException - { - try - { - File aFile = new File(path); - - try - { - aFile.createNewFile(); - FileOutputStream outputStream = new FileOutputStream(aFile); - - props.store(outputStream, beschreibung); - outputStream.close(); - } - catch(IOException e) - { - throw new IllegalArgumentException("PropertyDatei konnte nicht gespeichert werden."); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public boolean addPropertyChangeListener(PropertyChangeListener propertyChangeListener) - { - if(listeners == null) - { - listeners = new HashSet<PropertyChangeListener>(); - } - - return listeners.add(propertyChangeListener); - } - - public boolean removePropertyChangeListener(PropertyChangeListener propertyChangeListener) - { - if(listeners == null) - { - return false; - } - - return listeners.remove(propertyChangeListener); - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugController.java b/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugController.java deleted file mode 100644 index 5c03443b..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugController.java +++ /dev/null @@ -1,77 +0,0 @@ -package de.applejuicenet.client.gui.debug; - -import javax.swing.JComponent; - -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.util.Value; - - -public class DebugController extends GuiController { - - private static DebugController instance = null; - - public static final int UPDATE_LOGGER = 1; - - private DebugPanel debugPanel; - - private DebugController() { - super(); - debugPanel = new DebugPanel(this); - Logger.getRootLogger().addAppender(new LiveAppender(this)); - try{ - init(); - } catch (Exception e) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public static synchronized DebugController getInstance() { - if (null == instance) { - instance = new DebugController(); - } - return instance; - } - - private void init() { - } - - public Value[] getCustomizedValues(){ - return new Value[0]; - } - - public void fireAction(int actionId, Object source) { - switch (actionId){ - case UPDATE_LOGGER:{ - updateLogger((LoggingEvent)source); - break; - } - default:{ - return; - } - } - } - - private void updateLogger(LoggingEvent event) { - debugPanel.addMessage(event.getRenderedMessage()); - } - - public JComponent getComponent() { - return debugPanel; - } - - public void componentSelected() { - } - - public void componentLostSelection() { - } - - protected void languageChanged() { - } - - protected void contentChanged(DATALISTENER_TYPE type, Object content) { - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugPanel.java deleted file mode 100644 index c3bb03a8..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/debug/DebugPanel.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.applejuicenet.client.gui.debug; - -import java.awt.BorderLayout; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.JScrollPane; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.TklPanel; -import de.tklsoft.gui.controls.TKLTextArea; - - -public class DebugPanel extends TklPanel { - - private TKLTextArea debugArea = new TKLTextArea(); - private JScrollPane sp = new JScrollPane(debugArea); - private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS"); - - public DebugPanel(GuiController guiController) { - super(guiController); - try { - init(); - } catch (Exception e) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - private void init() { - debugArea.setEditable(false); - setLayout(new BorderLayout()); - add(sp, BorderLayout.CENTER); - } - - public void addMessage(String message){ - Date now = new Date(System.currentTimeMillis()); - debugArea.append(dateFormatter.format(now) + "\t - " + message + "\r\n"); - debugArea.setCaretPosition(debugArea.getDocument().getLength()); - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/debug/LiveAppender.java b/AJClientGUI/src/de/applejuicenet/client/gui/debug/LiveAppender.java deleted file mode 100644 index 408abc6a..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/debug/LiveAppender.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.applejuicenet.client.gui.debug; - -import java.io.StringWriter; - -import org.apache.log4j.SimpleLayout; -import org.apache.log4j.WriterAppender; -import org.apache.log4j.spi.LoggingEvent; - -public class LiveAppender extends WriterAppender{ - - private final DebugController debugController; - - public LiveAppender(DebugController debugController){ - this.debugController = debugController; - setWriter(new StringWriter()); - setLayout(new SimpleLayout()); - } - - protected void subAppend(LoggingEvent lE) { - super.subAppend(lE); - debugController.fireAction(DebugController.UPDATE_LOGGER, lE); - } -} \ No newline at end of file diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadController.java b/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadController.java deleted file mode 100644 index 99cae83b..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadController.java +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.download; - -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import java.io.File; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.fassade.event.DownloadDataPropertyChangeEvent; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.GuiControllerActionListener; -import de.applejuicenet.client.gui.components.table.HeaderListener; -import de.applejuicenet.client.gui.components.util.Value; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.download.table.DownloadSourcesTableModel; -import de.applejuicenet.client.gui.download.table.DownloadsTableModel; -import de.applejuicenet.client.gui.options.IncomingDirSelectionDialog; -import de.applejuicenet.client.gui.upload.HeaderPopupListener; -import de.applejuicenet.client.gui.upload.UploadMouseMotionListener; -import de.applejuicenet.client.shared.DesktopTools; -import de.applejuicenet.client.shared.ReleaseInfoDialog; -import de.applejuicenet.client.shared.SoundPlayer; - -public class DownloadController extends GuiController -{ - private static DownloadController instance = null; - private static final int ABBRECHEN = 0; - private static final int COPY_TO_CLIPBOARD = 1; - private static final int COPY_TO_CLIPBOARD_WITH_SOURCES = 2; - private static final int OPEN_WITH_PROGRAM = 3; - private static final int OPEN_WITH_DEFAULT_PROGRAM = 16; - private static final int PAUSE = 4; - private static final int FORTSETZEN = 5; - private static final int UMBENENNEN = 6; - private static final int ZIELORDNER_AENDERN = 7; - private static final int FERTIGE_ENTFERNEN = 8; - private static final int PARTLISTE_ANZEIGEN = 9; - private static final int START_DOWNLOAD = 10; - private static final int PARTLISTE_ANZEIGEN_PER_BUTTON = 11; - private static final int START_POWERDOWNLOAD = 12; - private static final int HEADER_DOWNLOAD_POPUP = 13; - private static final int HEADER_DOWNLOAD_SOURCES_POPUP = 14; - private static final int HEADER_DOWNLOAD_DRAGGED = 15; - private static final int HEADER_DOWNLOAD_SOURCES_DRAGGED = 17; - private static final int RELEASE_INFO = 18; - private DownloadPanel downloadPanel; - private boolean initialized = false; - private String dialogTitel; - private String downloadAbbrechen; - private DownloadPartListWatcher downloadPartListWatcher; - private boolean firstUpdate = true; - private boolean isFirstDownloadPropertyChanged = true; - private boolean selected = false; - private String alreadyLoaded; - private String invalidLink; - private String linkFailure; - - private DownloadController() - { - super(); - downloadPanel = new DownloadPanel(this); - try - { - init(); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); - - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public static synchronized DownloadController getInstance() - { - if(null == instance) - { - instance = new DownloadController(); - } - - return instance; - } - - private void init() - { - downloadPanel.getMnuAbbrechen().addActionListener(new GuiControllerActionListener(this, ABBRECHEN)); - downloadPanel.getMnuCopyToClipboard().addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD)); - downloadPanel.getMnuCopyToClipboardWithSources() - .addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD_WITH_SOURCES)); - downloadPanel.getMnuPause().addActionListener(new GuiControllerActionListener(this, PAUSE)); - downloadPanel.getMnuFortsetzen().addActionListener(new GuiControllerActionListener(this, FORTSETZEN)); - downloadPanel.getMnuUmbenennen().addActionListener(new GuiControllerActionListener(this, UMBENENNEN)); - downloadPanel.getMnuZielordner().addActionListener(new GuiControllerActionListener(this, ZIELORDNER_AENDERN)); - downloadPanel.getMnuFertigeEntfernen().addActionListener(new GuiControllerActionListener(this, FERTIGE_ENTFERNEN)); - downloadPanel.getMnuReleaseInfo().addActionListener(new GuiControllerActionListener(this, RELEASE_INFO)); - downloadPanel.getBtnPowerDownload().addActionListener(new GuiControllerActionListener(this, START_POWERDOWNLOAD)); - if(AppleJuiceClient.getAjFassade().isLocalhost()) - { - downloadPanel.getMnuOpenWithProgram().addActionListener(new GuiControllerActionListener(this, OPEN_WITH_PROGRAM)); - downloadPanel.getMnuOpenWithProgram().setVisible(true); - if(DesktopTools.isAdvancedSupported()) - { - downloadPanel.getMnuOpenWithDefaultProgram() - .addActionListener(new GuiControllerActionListener(this, OPEN_WITH_DEFAULT_PROGRAM)); - } - else - { - downloadPanel.getMnuOpenWithDefaultProgram().setVisible(false); - } - } - else - { - downloadPanel.getMnuOpenWithProgram().setEnabled(false); - downloadPanel.getMnuOpenWithDefaultProgram().setVisible(false); - } - - downloadPanel.getDownloadTable().addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - if(SwingUtilities.isLeftMouseButton(e)) - { - int selected = downloadPanel.getDownloadTable().getSelectedRow(); - - if(selected == -1) - { - return; - } - - Download download = downloadPanel.getDownloadTableModel().getRow(selected); - - downloadClicked(download); - if(downloadPanel.getDownloadSourcesTableModel().setDownload(download)) - { - downloadPanel.getDownloadSourcesTableModel().fireTableDataChanged(); - } - } - else if(SwingUtilities.isRightMouseButton(e)) - { - int row = downloadPanel.getDownloadTable().rowAtPoint(e.getPoint()); - - if(!downloadPanel.getDownloadTable().getSelectionModel().isSelectedIndex(row)) - { - downloadPanel.getDownloadTable().getSelectionModel().setSelectionInterval(row, row); - } - - maybeShowDownloadPopup(e); - } - } - }); - downloadPanel.getDownloadTable().addKeyListener(new KeyAdapter() - { - public void keyPressed(KeyEvent ke) - { - switch(ke.getKeyCode()) - { - - case KeyEvent.VK_F2: - { - renameDownload(); - break; - } - - case KeyEvent.VK_F3: - { - changeTargetDir(); - break; - } - - case KeyEvent.VK_F5: - { - pausieren(); - break; - } - - case KeyEvent.VK_F6: - { - fortsetzen(); - break; - } - - default: - break; - } - } - }); - downloadPanel.getDownloadSourceTable().addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - if(SwingUtilities.isLeftMouseButton(e)) - { - int selected = downloadPanel.getDownloadSourceTable().getSelectedRow(); - - if(selected == -1) - { - return; - } - - DownloadSource downloadSource = downloadPanel.getDownloadSourcesTableModel().getRow(selected); - - downloadSourceClicked(downloadSource); - } - } - }); - downloadPartListWatcher = new DownloadPartListWatcher(this); - - JTableHeader header = downloadPanel.getDownloadTable().getTableHeader(); - - header.addMouseListener(new HeaderPopupListener(this, HEADER_DOWNLOAD_POPUP)); - header.addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DOWNLOAD_DRAGGED)); - - header = downloadPanel.getDownloadSourceTable().getTableHeader(); - - header.addMouseListener(new HeaderPopupListener(this, HEADER_DOWNLOAD_SOURCES_POPUP)); - header.addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DOWNLOAD_SOURCES_DRAGGED)); - - LanguageSelector.getInstance().addLanguageListener(this); - } - - public Value[] getCustomizedValues() - { - return new Value[0]; - } - - public void fireAction(int actionId, Object source) - { - switch(actionId) - { - - case HEADER_DOWNLOAD_DRAGGED: - { - headerDownloadsDragged(); - break; - } - - case HEADER_DOWNLOAD_SOURCES_DRAGGED: - { - headerDownloadSourcesDragged(); - break; - } - - case HEADER_DOWNLOAD_POPUP: - { - headerDownloadsPopup((MouseEvent) source); - break; - } - - case HEADER_DOWNLOAD_SOURCES_POPUP: - { - headerDownloadSourcesPopup((MouseEvent) source); - break; - } - - case ABBRECHEN: - { - downloadAbbrechen(); - break; - } - - case COPY_TO_CLIPBOARD: - { - copyDownloadLinkToClipboard(); - break; - } - - case COPY_TO_CLIPBOARD_WITH_SOURCES: - { - copyDownloadLinkToClipboardWithSources(); - break; - } - - case OPEN_WITH_PROGRAM: - { - openWithProgram(); - break; - } - - case OPEN_WITH_DEFAULT_PROGRAM: - { - openWithDefaultProgram(); - break; - } - - case PAUSE: - { - pausieren(); - break; - } - - case FORTSETZEN: - { - fortsetzen(); - break; - } - - case UMBENENNEN: - { - renameDownload(); - break; - } - - case ZIELORDNER_AENDERN: - { - changeTargetDir(); - break; - } - - case FERTIGE_ENTFERNEN: - { - clearReadyDownloads(); - break; - } - - case START_POWERDOWNLOAD: - { - startPowerDownload(); - break; - } - - case RELEASE_INFO: - { - showReleaseInfo(); - break; - } - - default: - logger.error("Unregistrierte EventId " + actionId); - } - } - - private void showReleaseInfo() - { - Download[] selectedItems = getSelectedDownloads(); - - if(selectedItems == null || selectedItems.length < 1) - { - return; - } - - Download curDownload = selectedItems[0]; - - ReleaseInfoDialog.showReleaseInfo(curDownload.getHash()); - } - - private void headerDownloadsDragged() - { - PositionManager pm = PositionManagerImpl.getInstance(); - TableColumnModel columnModel = downloadPanel.getDownloadTable().getColumnModel(); - TableColumn[] columns = downloadPanel.getDownloadTableColumns(); - - for(int i = 0; i < columns.length; i++) - { - pm.setDownloadColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); - } - } - - private void headerDownloadSourcesDragged() - { - PositionManager pm = PositionManagerImpl.getInstance(); - TableColumnModel columnModel = downloadPanel.getDownloadSourceTable().getColumnModel(); - TableColumn[] columns = downloadPanel.getDownloadSourcesTableColumns(); - - for(int i = 0; i < columns.length; i++) - { - pm.setDownloadSourcesColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); - } - } - - private void headerDownloadsPopup(MouseEvent e) - { - TableColumn[] columns = downloadPanel.getDownloadTableColumns(); - JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadPopupItems(); - TableColumnModel tableColumnModel = downloadPanel.getDownloadTable().getColumnModel(); - - for(int i = 1; i < columns.length; i++) - { - try - { - tableColumnModel.getColumnIndex(columns[i].getIdentifier()); - columnPopupItems[i].setSelected(true); - } - catch(java.lang.IllegalArgumentException iaE) - { - columnPopupItems[i].setSelected(false); - } - } - - downloadPanel.getColumnDownloadPopup().show(downloadPanel.getDownloadTable().getTableHeader(), e.getX(), e.getY()); - } - - private void headerDownloadSourcesPopup(MouseEvent e) - { - TableColumn[] columns = downloadPanel.getDownloadSourcesTableColumns(); - JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadSourcesPopupItems(); - TableColumnModel tableColumnModel = downloadPanel.getDownloadSourceTable().getColumnModel(); - - for(int i = 1; i < columns.length; i++) - { - try - { - tableColumnModel.getColumnIndex(columns[i].getIdentifier()); - columnPopupItems[i].setSelected(true); - } - catch(java.lang.IllegalArgumentException iaE) - { - columnPopupItems[i].setSelected(false); - } - } - - downloadPanel.getColumnDownloadSourcesPopup().show(downloadPanel.getDownloadSourceTable().getTableHeader(), e.getX(), e.getY()); - } - - public JComponent getComponent() - { - return downloadPanel; - } - - private boolean handleDownloadDataPropertyChangeEvent(DownloadDataPropertyChangeEvent event) - { - return false; - } - - private void clearReadyDownloads() - { - new Thread() - { - @Override - public void run() - { - AppleJuiceClient.getAjFassade().cleanDownloadList(); - } - }.start(); - downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(false); - downloadPanel.getPowerDownloadPanel().setPwdlValue(0); - downloadPanel.getDownloadTable().getSelectionModel().clearSelection(); - } - - private void downloadSourceClicked(DownloadSource downloadSource) - { - tryGetPartList(downloadSource); - } - - private void downloadClicked(Download download) - { - tryGetPartList(download); - - if(!downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) - { - downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(true); - if(download.getStatus() == Download.SUCHEN_LADEN || download.getStatus() == Download.PAUSIERT) - { - downloadPanel.getPowerDownloadPanel().setPwdlValue(download.getPowerDownload()); - } - else - { - downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(false); - downloadPanel.getPowerDownloadPanel().setPwdlValue(0); - } - } - } - - private void startPowerDownload() - { - try - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length != 0) - { - int powerDownload = 0; - - if(!downloadPanel.getBtnPowerDownloadInaktiv().isSelected()) - { - String temp = downloadPanel.getRatioField().getText(); - double power = 2.2; - - try - { - power = Double.parseDouble(temp); - } - catch(NumberFormatException nfE) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, nfE); - } - - downloadPanel.getRatioField().setText("2.2"); - } - - powerDownload = (int) (power * 10 - 10); - } - - List<Download> temp = new ArrayList<Download>(); - - for(Download curDownload : selectedDownloads) - { - if(curDownload.getStatus() == Download.PAUSIERT || curDownload.getStatus() == Download.SUCHEN_LADEN) - { - temp.add(curDownload); - } - } - - AppleJuiceClient.getAjFassade().setPowerDownload(temp, new Integer(powerDownload)); - if(downloadPanel.getBtnPowerDownloadAktiv().isSelected()) - { - SoundPlayer.getInstance().playSound(SoundPlayer.POWER); - } - } - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - private void maybeShowDownloadPopup(MouseEvent e) - { - int[] selected = downloadPanel.getDownloadTable().getSelectedRows(); - - if(null == selected || selected.length == 0) - { - return; - } - - Download[] selectedDownloads = new Download[selected.length]; - - for(int i = 0; i < selected.length; i++) - { - selectedDownloads[i] = downloadPanel.getDownloadTableModel().getRow(selected[i]); - } - - boolean pausiert = false; - boolean laufend = false; - - downloadPanel.getMnuZielordner().setEnabled(true); - for(Download curDownload : selectedDownloads) - { - if(curDownload.getStatus() == Download.SUCHEN_LADEN) - { - laufend = true; - } - else if(curDownload.getStatus() == Download.PAUSIERT) - { - pausiert = true; - } - } - - downloadPanel.getMnuUmbenennen().setEnabled(selected.length == 1); - downloadPanel.getMnuCopyToClipboard().setEnabled(selected.length == 1); - downloadPanel.getMnuCopyToClipboardWithSources().setEnabled(selected.length == 1); - downloadPanel.getMnuPause().setEnabled(laufend); - downloadPanel.getMnuFortsetzen().setEnabled(pausiert); - downloadPanel.getPopup().show(downloadPanel.getDownloadTable(), e.getX(), e.getY()); - } - - private void tryGetPartList(DownloadSource downloadSource) - { - downloadPartListWatcher.setDownloadNode(downloadSource); - } - - private void tryGetPartList(Download download) - { - downloadPartListWatcher.setDownloadNode(download); - } - - private Download[] getSelectedDownloads() - { - try - { - int[] selected = downloadPanel.getDownloadTable().getSelectedRows(); - - if(null == selected || selected.length == 0) - { - return new Download[0]; - } - - Download[] selectedDownloads = new Download[selected.length]; - - for(int i = 0; i < selected.length; i++) - { - selectedDownloads[i] = downloadPanel.getDownloadTableModel().getRow(selected[i]); - } - - return selectedDownloads; - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - return new Download[0]; - } - } - - private void renameDownload() - { - Download[] selectedItems = getSelectedDownloads(); - - if(selectedItems != null && selectedItems.length == 1) - { - Download curDownload = selectedItems[0]; - RenameDownloadDialog renameDownloadDialog = new RenameDownloadDialog(AppleJuiceDialog.getApp(), curDownload); - - renameDownloadDialog.setVisible(true); - String neuerName = renameDownloadDialog.getNewName(); - - if(neuerName == null) - { - return; - } - else - { - if(curDownload.getFilename().compareTo(neuerName) != 0) - { - try - { - AppleJuiceClient.getAjFassade().renameDownload(curDownload, neuerName); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - } - } - - private void pausieren() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length != 0 && - !downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) - { - final List<Download> pausieren = new ArrayList<Download>(); - - for(Download curDownload : selectedDownloads) - { - if(curDownload.getStatus() == Download.SUCHEN_LADEN) - { - pausieren.add(curDownload); - } - } - - if(pausieren.size() > 0) - { - new Thread() - { - public void run() - { - try - { - AppleJuiceClient.getAjFassade().pauseDownload(pausieren); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }.start(); - } - } - } - - private void fortsetzen() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length != 0 && - !downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) - { - final List<Download> fortsetzen = new ArrayList<Download>(); - - for(Download curDownload : selectedDownloads) - { - if(curDownload.getStatus() == Download.PAUSIERT) - { - fortsetzen.add(curDownload); - } - } - - if(fortsetzen.size() > 0) - { - new Thread() - { - public void run() - { - try - { - AppleJuiceClient.getAjFassade().resumeDownload(fortsetzen); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }.start(); - } - } - } - - private void changeTargetDir() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads == null || selectedDownloads.length == 0) - { - return; - } - - String selectedDir = null; - - for(Download curDownload : selectedDownloads) - { - selectedDir = curDownload.getTargetDirectory(); - if(null != selectedDir && selectedDir.trim().length() > 0) - { - break; - } - } - - String[] dirs = AppleJuiceClient.getAjFassade().getCurrentIncomingDirs(); - IncomingDirSelectionDialog incomingDirSelectionDialog = new IncomingDirSelectionDialog(AppleJuiceDialog.getApp(), dirs, - selectedDir); - - incomingDirSelectionDialog.setVisible(true); - String neuerName = incomingDirSelectionDialog.getSelectedIncomingDir(); - - if(neuerName == null) - { - return; - } - else - { - neuerName = neuerName.trim(); - if(neuerName.indexOf(File.separator) == 0 || neuerName.indexOf(ApplejuiceFassade.separator) == 0) - { - neuerName = neuerName.substring(1); - } - } - - List<Download> toChange = new ArrayList<Download>(); - - for(Download curDownload : selectedDownloads) - { - if(!neuerName.equals(curDownload.getTargetDirectory())) - { - toChange.add(curDownload); - } - } - - if(toChange.size() > 0) - { - try - { - AppleJuiceClient.getAjFassade().setTargetDir(toChange, neuerName); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - - private void openWithProgram() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length == 1) - { - String programToExecute = OptionsManagerImpl.getInstance().getOpenProgram(); - - if(programToExecute.length() != 0) - { - for(Download curDownload : selectedDownloads) - { - Integer shareId = new Integer(curDownload.getShareId()); - - try - { - Share share = (Share) AppleJuiceClient.getAjFassade().getObjectById(shareId); - - if(share != null) - { - String filename = share.getFilename(); - - try - { - Runtime.getRuntime().exec(new String[] {programToExecute, filename}); - } - catch(Exception ex) - { - - //nix zu tun - } - } - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - } - } - - private void openWithDefaultProgram() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length == 1) - { - for(Download curDownload : selectedDownloads) - { - Integer shareId = new Integer(curDownload.getShareId()); - - try - { - Share share = (Share) AppleJuiceClient.getAjFassade().getObjectById(shareId); - - if(share != null) - { - String filename = share.getFilename(); - - DesktopTools.open(new File(filename)); - } - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - } - - private void copyDownloadLinkToClipboardWithSources() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length == 1) - { - Download curDownload = selectedDownloads[0]; - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer toCopy = new StringBuffer(); - - toCopy.append("ajfsp://file|"); - boolean copyToClipboard = false; - - toCopy.append(curDownload.getFilename() + "|" + curDownload.getHash() + "|" + curDownload.getGroesse()); - copyToClipboard = true; - - if(copyToClipboard) - { - long port = AppleJuiceClient.getAjFassade().getAJSettings().getPort(); - Information information = AppleJuiceClient.getAjFassade().getInformation(); - - toCopy.append("|"); - toCopy.append(information.getExterneIP()); - toCopy.append(":"); - toCopy.append(port); - if(information.getVerbindungsStatus() == Information.VERBUNDEN) - { - Server server = information.getServer(); - - if(server != null) - { - toCopy.append(":"); - toCopy.append(server.getHost()); - toCopy.append(":"); - toCopy.append(server.getPort()); - } - } - - toCopy.append("/"); - StringSelection contents = new StringSelection(toCopy.toString()); - - cb.setContents(contents, null); - } - } - } - - private void copyDownloadLinkToClipboard() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length == 1) - { - Download curDownload = selectedDownloads[0]; - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer toCopy = new StringBuffer(); - - toCopy.append("ajfsp://file|"); - toCopy.append(curDownload.getFilename() + "|" + curDownload.getHash() + "|" + curDownload.getGroesse() + "/"); - StringSelection contents = new StringSelection(toCopy.toString()); - - cb.setContents(contents, null); - } - } - - private void downloadAbbrechen() - { - Download[] selectedDownloads = getSelectedDownloads(); - - if(selectedDownloads != null && selectedDownloads.length != 0) - { - int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), downloadAbbrechen, dialogTitel, - JOptionPane.YES_NO_OPTION); - - if(result == JOptionPane.YES_OPTION) - { - final List<Download> abbrechen = new ArrayList<Download>(); - - for(Download curDownload : selectedDownloads) - { - abbrechen.add(curDownload); - } - - if(abbrechen.size() > 0) - { - new Thread() - { - public void run() - { - try - { - AppleJuiceClient.getAjFassade().cancelDownload(abbrechen); - SoundPlayer.getInstance().playSound(SoundPlayer.ABGEBROCHEN); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }.start(); - } - } - } - } - - public void componentSelected() - { - try - { - selected = true; - if(!initialized) - { - initialized = true; - firstUpdate = false; - int width = downloadPanel.getScrollPane().getWidth() - 18; - PositionManager pm = PositionManagerImpl.getInstance(); - - TableColumn[] columnsDownload = downloadPanel.getDownloadTableColumns(); - TableColumn[] columnsDownloadSources = downloadPanel.getDownloadSourcesTableColumns(); - int[] sortDownloads = null; - int[] sortDownloadSources = null; - - if(pm.isLegal()) - { - int[] widths = pm.getDownloadWidths(); - boolean[] visibilies = pm.getDownloadColumnVisibilities(); - int[] indizes = pm.getDownloadColumnIndizes(); - ArrayList<TableColumn> visibleColumns = new ArrayList<TableColumn>(); - - for(int i = 0; i < columnsDownload.length; i++) - { - columnsDownload[i].setPreferredWidth(widths[i]); - downloadPanel.getDownloadTable().removeColumn(columnsDownload[i]); - if(visibilies[i]) - { - visibleColumns.add(columnsDownload[i]); - } - } - - int pos = -1; - - for(int i = 0; i < visibleColumns.size(); i++) - { - for(int x = 0; x < columnsDownload.length; x++) - { - if(visibleColumns.contains(columnsDownload[x]) && indizes[x] == pos + 1) - { - downloadPanel.getDownloadTable().addColumn(columnsDownload[x]); - pos++; - break; - } - } - } - - widths = pm.getDownloadSourcesWidths(); - visibilies = pm.getDownloadSourcesColumnVisibilities(); - indizes = pm.getDownloadSourcesColumnIndizes(); - sortDownloads = pm.getDownloadSort(); - - visibleColumns = new ArrayList<TableColumn>(); - - for(int i = 0; i < columnsDownloadSources.length; i++) - { - columnsDownloadSources[i].setPreferredWidth(widths[i]); - downloadPanel.getDownloadSourceTable().removeColumn(columnsDownloadSources[i]); - if(visibilies[i]) - { - visibleColumns.add(columnsDownloadSources[i]); - } - } - - pos = -1; - - sortDownloadSources = pm.getDownloadSourcesSort(); - for(int i = 0; i < visibleColumns.size(); i++) - { - for(int x = 0; x < columnsDownloadSources.length; x++) - { - if(visibleColumns.contains(columnsDownloadSources[x]) && indizes[x] == pos + 1) - { - downloadPanel.getDownloadSourceTable().addColumn(columnsDownloadSources[x]); - pos++; - break; - } - } - } - } - else - { - for(int i = 0; i < columnsDownload.length; i++) - { - columnsDownload[i].setPreferredWidth(width / columnsDownload.length); - } - - for(int i = 0; i < columnsDownloadSources.length; i++) - { - columnsDownloadSources[i].setPreferredWidth(width / columnsDownloadSources.length); - } - } - - downloadPanel.getDownloadTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - downloadPanel.getDownloadSourceTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - int loc = (int) ((downloadPanel.getSplitPane().getHeight() - downloadPanel.getSplitPane().getDividerSize() - - downloadPanel.getPowerDownloadPanel().getPreferredSize().height)); - - downloadPanel.getSplitPane().setDividerLocation(loc); - if(null != sortDownloads) - { - for(MouseListener curMl : downloadPanel.getDownloadTable().getTableHeader().getMouseListeners()) - { - if(curMl instanceof HeaderListener) - { - ((HeaderListener) curMl).sort(sortDownloads[0], sortDownloads[1] == 1); - } - } - } - - if(null != sortDownloadSources) - { - for(MouseListener curMl : downloadPanel.getDownloadSourceTable().getTableHeader().getMouseListeners()) - { - if(curMl instanceof HeaderListener) - { - ((HeaderListener) curMl).sort(sortDownloadSources[0], sortDownloadSources[1] == 1); - } - } - } - } - - downloadPanel.getDownloadTable().updateUI(); - if(downloadPanel.getDownloadSourcesScrollPane().isVisible()) - { - downloadPanel.getDownloadSourceTable().updateUI(); - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void componentLostSelection() - { - selected = false; - downloadPartListWatcher.setDownloadNode((Download) null); - } - - protected void languageChanged() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String text = languageSelector.getFirstAttrbuteByTagName("mainform.Label14.caption"); - - dialogTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - downloadAbbrechen = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext5"); - String[] tableColumns = new String[DownloadsTableModel.CLASS_TYPES.length]; - - tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col0caption"); - tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col1caption"); - tableColumns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col2caption"); - tableColumns[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col3caption"); - tableColumns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col4caption"); - tableColumns[5] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col5caption"); - tableColumns[6] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); - tableColumns[7] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col7caption"); - tableColumns[8] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col8caption"); - tableColumns[9] = "Zielverzeichnis"; - TableColumn[] columns = downloadPanel.getDownloadTableColumns(); - JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadPopupItems(); - - for(int i = 0; i < columns.length; i++) - { - columns[i].setHeaderValue(tableColumns[i]); - columnPopupItems[i].setText(tableColumns[i]); - } - - tableColumns = new String[DownloadSourcesTableModel.CLASS_TYPES.length]; - - tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col0caption"); - tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col1caption"); - tableColumns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); - tableColumns[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col2caption"); - tableColumns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col3caption"); - tableColumns[5] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col4caption"); - tableColumns[6] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col5caption"); - tableColumns[7] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); - tableColumns[8] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col7caption"); - tableColumns[9] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col8caption"); - tableColumns[10] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col9caption"); - - columns = downloadPanel.getDownloadSourcesTableColumns(); - columnPopupItems = downloadPanel.getColumnDownloadSourcesPopupItems(); - for(int i = 0; i < columns.length; i++) - { - columns[i].setHeaderValue(tableColumns[i]); - columnPopupItems[i].setText(tableColumns[i]); - } - - downloadPanel.getMnuReleaseInfo().setText(languageSelector.getFirstAttrbuteByTagName("releaseinfo.menu")); - downloadPanel.getMnuAbbrechen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.canceldown.caption")); - downloadPanel.getMnuPause().setText(languageSelector.getFirstAttrbuteByTagName("mainform.pausedown.caption") + " [F5]"); - downloadPanel.getMnuFortsetzen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.resumedown.caption") + " [F6]"); - downloadPanel.getMnuUmbenennen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.renamefile.caption") + " [F2]"); - downloadPanel.getMnuZielordner().setText(languageSelector.getFirstAttrbuteByTagName("mainform.changetarget.caption") + - " [F3]"); - downloadPanel.getMnuFertigeEntfernen() - .setText(languageSelector.getFirstAttrbuteByTagName("mainform.Clearfinishedentries1.caption")); - downloadPanel.getMnuCopyToClipboard().setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); - downloadPanel.getMnuCopyToClipboardWithSources() - .setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.getlinkwithsources")); - downloadPanel.getMnuOpenWithProgram().setText("VLC"); - downloadPanel.getMnuOpenWithDefaultProgram() - .setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.startemitstandard")); - alreadyLoaded = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.bereitsgeladen"); - invalidLink = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.falscherlink"); - linkFailure = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.sonstigerlinkfehlerlang"); - } - - @SuppressWarnings("unchecked") - protected void contentChanged(DATALISTENER_TYPE type, final Object content) - { - Map<Integer, Download> downloads = (Map<Integer, Download>) content; - - final boolean downloadChanged = downloadPanel.getDownloadTableModel().setDownloads(downloads); - Download curDownload = downloadPanel.getDownloadSourcesTableModel().getDownload(); - - boolean sourcesChangedTmp = false; - - if(null != curDownload) - { - Download freshDownload = downloads.get(curDownload.getId()); - - sourcesChangedTmp = downloadPanel.getDownloadSourcesTableModel().setDownload(freshDownload); - } - - final boolean sourcesChanged = sourcesChangedTmp; - - if(selected && (downloadChanged || sourcesChanged)) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - if(downloadChanged) - { - downloadPanel.getDownloadTableModel().forceResort(); - downloadPanel.getDownloadTable().updateUI(); - } - - if(sourcesChanged) - { - downloadPanel.getDownloadSourcesTableModel().forceResort(); - downloadPanel.getDownloadSourceTable().updateUI(); - } - } - }); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java deleted file mode 100644 index 4afd53d5..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ -package de.applejuicenet.client.gui.download; - - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java,v 1.8 2009/02/01 14:49:17 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import java.text.DecimalFormat; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.PartList; -import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.shared.Settings; - -public class DownloadOverviewPanel extends JPanel implements LanguageListener -{ - private DownloadPartListPanel actualDlOverviewTable; - private JLabel actualDLDateiName = new JLabel(); - private JLabel label5 = new JLabel(); - private JLabel label4 = new JLabel(); - private JLabel label3 = new JLabel(); - private JLabel label2 = new JLabel(); - private JLabel label1 = new JLabel(); - private Logger logger; - private JCheckBox holeListe = new JCheckBox(); - private PartListWorkerThread partListWorkerThread = null; - private DownloadPanel downloadPanel; - private String verfuegbar; - private DecimalFormat decimalFormat = new DecimalFormat("#.##"); - private Object lastPartlistObject = null; - - public DownloadOverviewPanel(DownloadPanel parent) - { - logger = Logger.getLogger(getClass()); - try - { - downloadPanel = parent; - actualDlOverviewTable = DownloadPartListPanel.getInstance(); - init(); - LanguageSelector.getInstance().addLanguageListener(this); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - holeListe.setSelected(Settings.getSettings().isDownloadUebersicht()); - holeListe.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if(!holeListe.isSelected() && null != partListWorkerThread) - { - partListWorkerThread.interrupt(); - partListWorkerThread = null; - actualDLDateiName.setText(null); - actualDlOverviewTable.setPartList(null, null); - } - else if(holeListe.isSelected() && null != lastPartlistObject) - { - if(lastPartlistObject instanceof Download) - { - setDownload((Download) lastPartlistObject); - } - else - { - setDownloadSource((DownloadSource) lastPartlistObject); - } - } - - Settings settings = Settings.getSettings(); - - settings.setDownloadUebersicht(holeListe.isSelected()); - settings.save(); - } - }); - setLayout(new BorderLayout()); - JPanel tempPanel1 = new JPanel(); - - tempPanel1.setLayout(new FlowLayout()); - - JLabel gelb = new JLabel(" "); - - gelb.setOpaque(true); - gelb.setBackground(Color.YELLOW); - tempPanel1.add(gelb); - tempPanel1.add(label5); - - JLabel blau = new JLabel(" "); - - blau.setOpaque(true); - blau.setBackground(Color.BLUE); - tempPanel1.add(blau); - tempPanel1.add(label4); - - JLabel red = new JLabel(" "); - - red.setOpaque(true); - red.setBackground(Color.RED); - tempPanel1.add(red); - tempPanel1.add(label3); - - JLabel black = new JLabel(" "); - - black.setOpaque(true); - black.setBackground(Color.BLACK); - tempPanel1.add(black); - tempPanel1.add(label2); - - JLabel green = new JLabel(" "); - - green.setOpaque(true); - green.setBackground(Color.GREEN); - tempPanel1.add(green); - tempPanel1.add(label1); - - JPanel panel3 = new JPanel(new BorderLayout()); - - panel3.add(holeListe, BorderLayout.WEST); - panel3.add(tempPanel1, BorderLayout.CENTER); - - add(panel3, BorderLayout.NORTH); - actualDLDateiName.setPreferredSize(new Dimension(actualDLDateiName.getPreferredSize().width, 17)); - JPanel panel1 = new JPanel(new BorderLayout()); - - panel1.add(actualDLDateiName, BorderLayout.NORTH); - panel1.add(actualDlOverviewTable, BorderLayout.CENTER); - add(panel1, BorderLayout.CENTER); - } - - public void setDownload(Download download) - { - lastPartlistObject = download; - if(!holeListe.isSelected()) - { - return; - } - - try - { - if(partListWorkerThread != null) - { - if(partListWorkerThread.isInterrupted()) - { - partListWorkerThread = null; - } - else - { - if(partListWorkerThread.getObjectDO() == download) - { - return; - } - else - { - partListWorkerThread.cancel(); - partListWorkerThread = null; - } - } - } - - partListWorkerThread = new PartListWorkerThread(); - partListWorkerThread.setDownload(download); - partListWorkerThread.start(); - } - catch(Exception e) - { - if(partListWorkerThread != null) - { - partListWorkerThread.cancel(); - partListWorkerThread = null; - } - - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public void setDownloadSource(DownloadSource downloadSource) - { - lastPartlistObject = downloadSource; - if(!holeListe.isSelected()) - { - return; - } - - try - { - if(partListWorkerThread != null) - { - if(partListWorkerThread.isInterrupted()) - { - partListWorkerThread = null; - } - else - { - partListWorkerThread.cancel(); - partListWorkerThread = null; - } - } - - partListWorkerThread = new PartListWorkerThread(); - partListWorkerThread.setDownloadSourceDO(downloadSource); - partListWorkerThread.start(); - } - catch(Exception e) - { - if(partListWorkerThread != null) - { - partListWorkerThread.cancel(); - partListWorkerThread = null; - } - - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public void fireLanguageChanged() - { - try - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - label5.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.aktiveuebertragung")); - label4.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label4.caption")); - label3.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label3.caption")); - label2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label2.caption")); - label1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label1.caption")); - holeListe.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.partlisteanzeigen")); - verfuegbar = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.verfuegbar"); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private class PartListWorkerThread extends Thread - { - private Object objectDO = null; - private boolean firstRun = true; - - public void run() - { - while(!interrupted()) - { - if(objectDO == null) - { - break; - } - - boolean shortPause = false; - - if(objectDO instanceof Download) - { - if(((Download) objectDO).getStatus() == Download.PAUSIERT || - ((Download) objectDO).getStatus() == Download.SUCHEN_LADEN) - { - shortPause = workDownloadDO((Download) objectDO); - } - else - { - objectDO = null; - break; - } - } - else - { - shortPause = workDownloadSourceDO((DownloadSource) objectDO); - } - - if(shortPause) - { - try - { - sleep(5000); - firstRun = false; - continue; - } - catch(InterruptedException iE) - { - interrupt(); - } - } - else - { - break; - } - } - } - - public Object getObjectDO() - { - return objectDO; - } - - private boolean workDownloadDO(Download download) - { - if(download.getStatus() != Download.FERTIGSTELLEN && download.getStatus() != Download.FERTIG) - { - String dateiNameText = " " + download.getFilename() + " (" + download.getTemporaryFileNumber() + ".data) "; - - if(firstRun) - { - actualDLDateiName.setText(dateiNameText); - } - - PartList partList = null; - - try - { - partList = AppleJuiceClient.getAjFassade().getPartList(download); - } - catch(WebSiteNotFoundException wsnfE) - { - // Core ist wahrscheinlich zurzeit ueberlastet - partList = null; - } - - if(partList != null && !isInterrupted()) - { - String tmp = verfuegbar.replaceFirst("%s", decimalFormat.format(partList.getProzentVerfuegbar())); - - actualDLDateiName.setText(dateiNameText + " - " + tmp); - actualDlOverviewTable.setPartList(partList, new Integer(download.getId())); - } - - return true; - } - else - { - return false; - } - } - - private boolean workDownloadSourceDO(DownloadSource downloadSoure) - { - PartList partList; - String tmp = downloadSoure.getFilename() + " (" + downloadSoure.getNickname() + ")"; - - actualDLDateiName.setText(tmp); - try - { - partList = AppleJuiceClient.getAjFassade().getPartList(downloadSoure); - } - catch(WebSiteNotFoundException ex) - { - // Core ist wahrscheinlich zurzeit ueberlastet - partList = null; - } - - if(partList != null && !isInterrupted()) - { - actualDLDateiName.setText(tmp + " - " + - verfuegbar.replaceFirst("%s", decimalFormat.format(partList.getProzentVerfuegbar()))); - actualDlOverviewTable.setPartList(partList, new Integer(downloadSoure.getId())); - } - - return false; - } - - public void setDownload(Download download) - { - if(download == null) - { - objectDO = null; - clear(); - } - else if(objectDO != download) - { - objectDO = download; - clear(); - } - } - - public void setDownloadSourceDO(DownloadSource downloadSoure) - { - if(downloadSoure == null) - { - objectDO = null; - clear(); - } - else if(objectDO != downloadSoure) - { - objectDO = downloadSoure; - clear(); - } - } - - private void clear() - { - actualDLDateiName.setText(""); - actualDlOverviewTable.setPartList(null, null); - } - - public void cancel() - { - interrupt(); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPanel.java deleted file mode 100644 index 138e2925..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPanel.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.download; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.JSplitPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.TklPanel; -import de.applejuicenet.client.gui.components.table.HeaderListener; -import de.applejuicenet.client.gui.components.table.SortButtonRenderer; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.download.table.DownloadSourcesTableModel; -import de.applejuicenet.client.gui.download.table.DownloadTableDownloadFilenameCellRenderer; -import de.applejuicenet.client.gui.download.table.DownloadTableFilenameCellRenderer; -import de.applejuicenet.client.gui.download.table.DownloadTablePowerdownloadCellRenderer; -import de.applejuicenet.client.gui.download.table.DownloadsTableModel; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.tablecellrenderer.ProgressTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.SizeTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.SpeedTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.StringTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.VersionTableCellRenderer; -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/DownloadPanel.java,v - * 1.109 2004/06/23 12:39:15 maj0r Exp $ - * - * <p> - * Titel: AppleJuice Client-GUI - * </p> - * <p> - * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - * </p> - * <p> - * Copyright: General Public License - * </p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class DownloadPanel extends TklPanel -{ - private DownloadOverviewPanel downloadOverviewPanel; - private PowerDownloadPanel powerDownloadPanel; - private DownloadsTableModel downloadActiveTableModel; - private JTable downloadActiveTable; - private DownloadSourcesTableModel downloadSourceTableModel; - private JTable downloadSourceTable; - private JPopupMenu popup = new JPopupMenu(); - private JScrollPane aScrollPane; - private JMenuItem abbrechen; - private JMenuItem pause; - private JMenuItem fortsetzen; - private JMenuItem umbenennen; - private JMenuItem zielordner; - private JMenuItem fertigEntfernen; - private JMenuItem itemReleaseInfo = new JMenuItem(); - private JMenuItem itemCopyToClipboard = new JMenuItem(); - private JMenuItem itemCopyToClipboardWithSources = new JMenuItem(); - private JMenuItem itemOpenWithProgram = new JMenuItem(); - private JMenuItem itemOpenWithDefaultProgram = new JMenuItem(); - private JSplitPane splitPane; - private Logger logger; - private TableColumn[] downloadColumns = new TableColumn[DownloadsTableModel.CLASS_TYPES.length]; - private TableColumn[] downloadSourceColumns = new TableColumn[DownloadSourcesTableModel.CLASS_TYPES.length]; - private JPopupMenu columnDownloadPopup = new JPopupMenu(); - private JCheckBoxMenuItem[] columnDownloadPopupItems = new JCheckBoxMenuItem[downloadColumns.length]; - private JPopupMenu columnDownloadSourcesPopup = new JPopupMenu(); - private JCheckBoxMenuItem[] columnDownloadSourcesPopupItems = new JCheckBoxMenuItem[downloadSourceColumns.length]; - private JPopupMenu menu; - private JScrollPane downloadSourcesScrollPane; - - public DownloadPanel(GuiController guiController) - { - super(guiController); - try - { - downloadOverviewPanel = new DownloadOverviewPanel(this); - powerDownloadPanel = new PowerDownloadPanel((DownloadController) guiController); - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public JTable getDownloadTable() - { - return downloadActiveTable; - } - - public JTable getDownloadSourceTable() - { - return downloadSourceTable; - } - - public TableColumn[] getDownloadTableColumns() - { - return downloadColumns; - } - - public TableColumn[] getDownloadSourcesTableColumns() - { - return downloadSourceColumns; - } - - public DownloadOverviewPanel getDownloadOverviewPanel() - { - return downloadOverviewPanel; - } - - public JScrollPane getScrollPane() - { - return aScrollPane; - } - - public JSplitPane getSplitPane() - { - return splitPane; - } - - public PowerDownloadPanel getPowerDownloadPanel() - { - return powerDownloadPanel; - } - - public DownloadsTableModel getDownloadTableModel() - { - return downloadActiveTableModel; - } - - public DownloadSourcesTableModel getDownloadSourcesTableModel() - { - return downloadSourceTableModel; - } - - public JButton getBtnPowerDownload() - { - return powerDownloadPanel.getBtnPdl(); - } - - public JRadioButton getBtnPowerDownloadInaktiv() - { - return powerDownloadPanel.btnInaktiv; - } - - public JRadioButton getBtnPowerDownloadAktiv() - { - return powerDownloadPanel.btnAktiv; - } - - public TKLTextField getRatioField() - { - return powerDownloadPanel.ratio; - } - - public JMenuItem getMnuAbbrechen() - { - return abbrechen; - } - - public JMenuItem getMnuPause() - { - return pause; - } - - public JMenuItem getMnuFortsetzen() - { - return fortsetzen; - } - - public JMenuItem getMnuUmbenennen() - { - return umbenennen; - } - - public JMenuItem getMnuZielordner() - { - return zielordner; - } - - public JMenuItem getMnuFertigeEntfernen() - { - return fertigEntfernen; - } - - public JMenuItem getMnuReleaseInfo() - { - return itemReleaseInfo; - } - - public JMenuItem getMnuOpenWithProgram() - { - return itemOpenWithProgram; - } - - public JMenuItem getMnuOpenWithDefaultProgram() - { - return itemOpenWithDefaultProgram; - } - - public JMenuItem getMnuCopyToClipboard() - { - return itemCopyToClipboard; - } - - public JMenuItem getMnuCopyToClipboardWithSources() - { - return itemCopyToClipboardWithSources; - } - - public JPopupMenu getPopup() - { - return popup; - } - - private void init() throws Exception - { - setLayout(new BorderLayout()); - JPanel topPanel = new JPanel(); - - topPanel.setLayout(new GridBagLayout()); - JPanel bottomPanel = new JPanel(); - - bottomPanel.setLayout(new BorderLayout()); - - abbrechen = new JMenuItem(); - pause = new JMenuItem(); - fortsetzen = new JMenuItem(); - umbenennen = new JMenuItem(); - zielordner = new JMenuItem(); - fertigEntfernen = new JMenuItem(); - - menu = new JPopupMenu(); - - IconManager im = IconManager.getInstance(); - - abbrechen.setIcon(im.getIcon("abbrechen")); - pause.setIcon(im.getIcon("pause")); - umbenennen.setIcon(im.getIcon("umbenennen")); - zielordner.setIcon(im.getIcon("zielordner")); - fertigEntfernen.setIcon(im.getIcon("bereinigen")); - fortsetzen.setIcon(im.getIcon("pause")); - itemReleaseInfo.setIcon(im.getIcon("hint")); - itemCopyToClipboard.setIcon(im.getIcon("clipboard")); - itemCopyToClipboardWithSources.setIcon(im.getIcon("clipboard")); - - popup.add(fortsetzen); - popup.add(pause); - popup.add(abbrechen); - popup.add(new JSeparator()); - popup.add(umbenennen); - popup.add(zielordner); - popup.add(new JSeparator()); - popup.add(fertigEntfernen); - popup.add(new JSeparator()); - popup.add(itemCopyToClipboard); - popup.add(itemCopyToClipboardWithSources); - popup.add(new JSeparator()); - popup.add(itemReleaseInfo); - popup.add(itemOpenWithProgram); - itemOpenWithProgram.setIcon(im.getIcon("vlc")); - popup.add(itemOpenWithDefaultProgram); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.gridwidth = 3; - constraints.gridheight = 1; - - GridBagConstraints constraints2 = new GridBagConstraints(); - - constraints2.anchor = GridBagConstraints.NORTH; - constraints2.fill = GridBagConstraints.BOTH; - constraints2.gridx = 0; - constraints2.gridy = 0; - - constraints.gridwidth = 3; - constraints.gridx = 0; - constraints.gridy = 1; - constraints.weighty = 0.4; - constraints.weightx = 1; - - downloadActiveTableModel = new DownloadsTableModel(); - downloadActiveTable = new JTable(downloadActiveTableModel); - downloadActiveTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(0).setCellRenderer(new DownloadTableDownloadFilenameCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(2).setCellRenderer(new SizeTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(3).setCellRenderer(new SizeTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(4).setCellRenderer(new SpeedTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(6).setCellRenderer(new ProgressTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(7).setCellRenderer(new SizeTableCellRenderer()); - downloadActiveTable.getColumnModel().getColumn(8).setCellRenderer(new DownloadTablePowerdownloadCellRenderer()); - - TableColumnModel model = downloadActiveTable.getColumnModel(); - SortButtonRenderer renderer = new SortButtonRenderer(); - - JTableHeader header = downloadActiveTable.getTableHeader(); - - header.setDefaultRenderer(renderer); - header.addMouseListener(new HeaderListener(header, renderer) - { - private PositionManager pm = PositionManagerImpl.getInstance(); - - @Override - public void internalSort(int column, boolean ascent) - { - pm.setDownloadSort(column, ascent); - - super.internalSort(column, ascent); - } - }); - for(int i = 0; i < model.getColumnCount(); i++) - { - downloadColumns[i] = model.getColumn(i); - columnDownloadPopupItems[i] = new JCheckBoxMenuItem((String) downloadColumns[i].getHeaderValue()); - final int x = i; - - columnDownloadPopupItems[i].addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(columnDownloadPopupItems[x].isSelected()) - { - downloadActiveTable.getColumnModel().addColumn(downloadColumns[x]); - PositionManagerImpl.getInstance().setDownloadColumnVisible(x, true); - PositionManagerImpl.getInstance() - .setDownloadColumnIndex(x, - downloadActiveTable.getColumnModel().getColumnIndex(downloadColumns[x].getIdentifier())); - } - else - { - downloadActiveTable.getColumnModel().removeColumn(downloadColumns[x]); - PositionManagerImpl.getInstance().setDownloadColumnVisible(x, false); - for(int y = 0; y < downloadColumns.length; y++) - { - try - { - PositionManagerImpl.getInstance() - .setDownloadColumnIndex(y, - downloadActiveTable.getColumnModel() - .getColumnIndex(downloadColumns[y].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - } - }); - columnDownloadPopup.add(columnDownloadPopupItems[i]); - } - - columnDownloadPopupItems[0].setEnabled(false); - - aScrollPane = new JScrollPane(downloadActiveTable); - aScrollPane.setBackground(downloadActiveTable.getBackground()); - downloadActiveTable.getTableHeader().setBackground(downloadActiveTable.getBackground()); - aScrollPane.getViewport().setOpaque(false); - topPanel.add(aScrollPane, constraints); - - downloadSourceTableModel = new DownloadSourcesTableModel(); - downloadSourceTable = new JTable(downloadSourceTableModel); - downloadSourceTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(0).setCellRenderer(new DownloadTableFilenameCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(3).setCellRenderer(new SizeTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(4).setCellRenderer(new SizeTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(5).setCellRenderer(new SpeedTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(7).setCellRenderer(new ProgressTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(8).setCellRenderer(new SizeTableCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(9).setCellRenderer(new DownloadTablePowerdownloadCellRenderer()); - downloadSourceTable.getColumnModel().getColumn(10).setCellRenderer(new VersionTableCellRenderer()); - - renderer = new SortButtonRenderer(); - - header = downloadSourceTable.getTableHeader(); - - header.setDefaultRenderer(renderer); - header.addMouseListener(new HeaderListener(header, renderer) - { - private PositionManager pm = PositionManagerImpl.getInstance(); - - @Override - public void internalSort(int column, boolean ascent) - { - pm.setDownlodSourcesSort(column, ascent); - - super.internalSort(column, ascent); - } - }); - model = downloadSourceTable.getColumnModel(); - for(int i = 0; i < model.getColumnCount(); i++) - { - downloadSourceColumns[i] = model.getColumn(i); - columnDownloadSourcesPopupItems[i] = new JCheckBoxMenuItem((String) downloadSourceColumns[i].getHeaderValue()); - final int x = i; - - columnDownloadSourcesPopupItems[i].addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(columnDownloadSourcesPopupItems[x].isSelected()) - { - downloadSourceTable.getColumnModel().addColumn(downloadSourceColumns[x]); - PositionManagerImpl.getInstance().setDownloadSourcesColumnVisible(x, true); - PositionManagerImpl.getInstance() - .setDownloadSourcesColumnIndex(x, - downloadSourceTable.getColumnModel() - .getColumnIndex(downloadSourceColumns[x].getIdentifier())); - } - else - { - downloadSourceTable.getColumnModel().removeColumn(downloadSourceColumns[x]); - PositionManagerImpl.getInstance().setDownloadSourcesColumnVisible(x, false); - for(int y = 0; y < downloadSourceColumns.length; y++) - { - try - { - PositionManagerImpl.getInstance() - .setDownloadSourcesColumnIndex(y, - downloadSourceTable.getColumnModel() - .getColumnIndex(downloadSourceColumns[y].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - } - }); - columnDownloadSourcesPopup.add(columnDownloadSourcesPopupItems[i]); - } - - downloadSourcesScrollPane = new JScrollPane(downloadSourceTable); - - downloadSourcesScrollPane.setBackground(downloadSourceTable.getBackground()); - downloadSourceTable.getTableHeader().setBackground(downloadSourceTable.getBackground()); - downloadSourcesScrollPane.getViewport().setOpaque(false); - - constraints.gridwidth = 3; - constraints.gridx = 0; - constraints.gridy = 2; - constraints.weighty = 0.6; - constraints.weightx = 1; - - topPanel.add(downloadSourcesScrollPane, constraints); - - constraints.gridx = 0; - constraints.gridy = 0; - constraints.weighty = 1; - - bottomPanel.add(powerDownloadPanel, BorderLayout.WEST); - bottomPanel.add(downloadOverviewPanel, BorderLayout.CENTER); - - splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); - splitPane.setBorder(null); - add(splitPane, BorderLayout.CENTER); - - downloadActiveTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - } - - public JScrollPane getDownloadSourcesScrollPane() - { - return downloadSourcesScrollPane; - } - - public int[] getDownloadColumnWidths() - { - int[] widths = new int[downloadColumns.length]; - - for(int i = 0; i < downloadColumns.length; i++) - { - widths[i] = downloadColumns[i].getWidth(); - } - - return widths; - } - - public int[] getDownloadSourcesColumnWidths() - { - int[] widths = new int[downloadSourceColumns.length]; - - for(int i = 0; i < downloadSourceColumns.length; i++) - { - widths[i] = downloadSourceColumns[i].getWidth(); - } - - return widths; - } - - public JCheckBoxMenuItem[] getColumnDownloadPopupItems() - { - return columnDownloadPopupItems; - } - - public JPopupMenu getColumnDownloadPopup() - { - return columnDownloadPopup; - } - - public JPopupMenu getColumnDownloadSourcesPopup() - { - return columnDownloadSourcesPopup; - } - - public JCheckBoxMenuItem[] getColumnDownloadSourcesPopupItems() - { - return columnDownloadSourcesPopupItems; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPartListPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPartListPanel.java deleted file mode 100644 index 52bc8013..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPartListPanel.java +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.download; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; -import java.awt.image.BufferedImage; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Part; -import de.applejuicenet.client.fassade.entity.PartList; -import de.applejuicenet.client.fassade.shared.ZeichenErsetzer; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.listener.LanguageListener; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/DownloadPartListPanel.java,v - * 1.33 2004/07/09 12:42:01 loevenwong Exp $ - * - * <p> - * Titel: AppleJuice Client-GUI - * </p> - * <p> - * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - * </p> - * <p> - * Copyright: General Public License - * </p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class DownloadPartListPanel extends JPanel implements MouseMotionListener, LanguageListener -{ - private static DownloadPartListPanel instance = null; - private PartList partList; - private Logger logger; - private BufferedImage image = null; - private int width; - private int height; - private long fertigSeit = -1; - private boolean miniFile = false; - private String ueberprueft; - private String nichtVorhanden; - private String vorhanden; - private String quellen; - private String uebertragen; - private MouseEvent savedMouseEvent = null; - private Integer id = null; - private int zeilenHoehe; - private int pixelSize; - private BufferedImage lineImage; - - private DownloadPartListPanel() - { - super(new BorderLayout()); - logger = Logger.getLogger(getClass()); - addMouseMotionListener(this); - LanguageSelector.getInstance().addLanguageListener(this); - } - - public static synchronized DownloadPartListPanel getInstance() - { - if(instance == null) - { - instance = new DownloadPartListPanel(); - } - - return instance; - } - - public void paintComponent(Graphics g) - { - if(partList != null && image != null) - { - if(height != (int) getSize().height || width != (int) getSize().width) - { - setPartList(partList, id); - } - - g.setColor(getBackground()); - g.fillRect(0, 0, width, height); - if(image != null) - { - g.drawImage(image, 0, 0, null); - } - } - else - { - super.paintComponent(g); - } - } - - private void updatePanel() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - updateUI(); - } - }); - } - - public synchronized void setPartList(PartList newPartList, Integer newId) - { - try - { - if(newPartList == null || newId == null) - { - partList = null; - lineImage = null; - image = null; - savedMouseEvent = null; - updatePanel(); - return; - } - - boolean idChanged = false; - - if(id == null) - { - idChanged = true; - id = newId; - } - - if(id.longValue() != newId.longValue()) - { - idChanged = true; - } - - boolean redraw = false; - - if(idChanged) - { - id = newId; - partList = null; - } - else if(partList != null && newPartList != null) - { - if(height != getSize().height || width != getSize().width) - { - redraw = true; - } - - if(!redraw) - { - Part[] parts = partList.getParts(); - Part[] newParts = newPartList.getParts(); - - if(parts.length == newParts.length) - { - boolean sameParts = true; - - for(int i = 0; i < parts.length; i++) - { - if(!parts[i].equals(newParts[i])) - { - sameParts = false; - break; - } - } - - if(sameParts) - { - insertSources(partList, lineImage); - updatePanel(); - return; - } - } - } - } - - partList = newPartList; - height = getSize().height; - width = getSize().width; - if(partList != null && partList.getGroesse() > 0 && partList.getParts().length > 0) - { - Part[] parts = partList.getParts(); - - zeilenHoehe = 15; - int zeilen = height / zeilenHoehe; - - miniFile = false; - pixelSize = (int) (partList.getGroesse() / (zeilen * width)); - if(pixelSize == 0) - { - pixelSize = (int) ((zeilen * width) / partList.getGroesse()); - miniFile = true; - } - - lineImage = new BufferedImage(width * zeilen, 15, BufferedImage.TYPE_INT_ARGB); - Graphics graphics = lineImage.getGraphics(); - int obenLinks = 0; - int breite = 0; - - fertigSeit = -1; - for(int i = 0; i < parts.length - 1; i++) - { - drawPart(false, (partList.getPartListType() == PartList.MAIN_PARTLIST), graphics, pixelSize, parts[i].getType(), - zeilenHoehe, parts[i].getFromPosition(), parts[i + 1].getFromPosition()); - } - - drawPart(true, (partList.getPartListType() == PartList.MAIN_PARTLIST), graphics, pixelSize, - parts[parts.length - 1].getType(), zeilenHoehe, parts[parts.length - 1].getFromPosition(), - partList.getGroesse()); - BufferedImage imgWithSources = insertSources(partList, lineImage); - - if(savedMouseEvent != null) - { - processMouseMotionEvent(savedMouseEvent); - } - } - else - { - image = null; - savedMouseEvent = null; - } - } - catch(Exception e) - { - logger.debug(ApplejuiceFassade.ERROR_MESSAGE, e); - partList = null; - lineImage = null; - image = null; - savedMouseEvent = null; - } - - updatePanel(); - } - - private BufferedImage insertSources(PartList partList, BufferedImage sourceImage) - { - BufferedImage imageWithSources = new BufferedImage(sourceImage.getWidth(), 15, BufferedImage.TYPE_INT_ARGB); - Graphics graphics = imageWithSources.getGraphics(); - - graphics.drawImage(sourceImage.getSubimage(0, 0, sourceImage.getWidth(), zeilenHoehe), 0, 0, null); - int obenLinks; - int breite; - - if(partList.getPartListType() == PartList.MAIN_PARTLIST) - { - Download download = (Download) partList.getValueObject(); - - if(download.getStatus() == Download.SUCHEN_LADEN) - { - for(DownloadSource curSource : download.getSources()) - { - if(curSource.getStatus() == DownloadSource.UEBERTRAGUNG) - { - if(!miniFile) - { - obenLinks = curSource.getDownloadFrom() / pixelSize; - breite = (curSource.getDownloadTo() / pixelSize) - obenLinks; - } - else - { - obenLinks = curSource.getDownloadFrom() * pixelSize; - breite = (curSource.getDownloadTo() * pixelSize) - obenLinks; - } - - graphics.setColor(getColorByPercent(curSource.getReadyPercent())); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - } - } - } - } - else - { - DownloadSource downloadSource = (DownloadSource) partList.getValueObject(); - - if(downloadSource.getStatus() == DownloadSource.UEBERTRAGUNG) - { - if(!miniFile) - { - obenLinks = downloadSource.getDownloadFrom() / pixelSize; - breite = (downloadSource.getDownloadTo() / pixelSize) - obenLinks; - } - else - { - obenLinks = downloadSource.getDownloadFrom() * pixelSize; - breite = (downloadSource.getDownloadTo() * pixelSize) - obenLinks; - } - - graphics.setColor(getColorByPercent(downloadSource.getReadyPercent())); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - } - } - - image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); - Graphics g = image.getGraphics(); - int x = 0; - int zeilen = height / zeilenHoehe; - - for(int i = 0; i < zeilen; i++) - { - g.drawImage(imageWithSources.getSubimage(x, 0, width, zeilenHoehe), 0, i * zeilenHoehe, null); - x += width; - } - - return imageWithSources; - } - - private void drawPart(boolean forceDraw, boolean isMainList, Graphics graphics, int pixelSize, int partType, int zeilenHoehe, - long currentFrom, long nextFrom) - { - int obenLinks = 0; - int breite = 0; - - if(isMainList) - { - if(partType == -1 && !forceDraw) - { - if(fertigSeit != -1) - { - return; - } - else - { - fertigSeit = currentFrom; - } - } - else - { - if(fertigSeit != -1) - { - obenLinks = (int) (fertigSeit / pixelSize); - int mbCount = (int) (currentFrom - fertigSeit) / 1048576; - - breite = mbCount * 1048576 / pixelSize; - graphics.setColor(PartList.COLOR_TYPE_UEBERPRUEFT); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - obenLinks += breite; - breite = (int) (currentFrom / pixelSize) - obenLinks; - if(partType == -1 || forceDraw) - { - graphics.setColor(PartList.COLOR_TYPE_UEBERPRUEFT); - } - else - { - graphics.setColor(PartList.COLOR_TYPE_OK); - } - - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - obenLinks = (int) currentFrom / pixelSize; - breite = (int) (nextFrom / pixelSize) - obenLinks; - graphics.setColor(getColorByType(partType)); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - fertigSeit = -1; - } - else - { - if(!miniFile) - { - obenLinks = (int) (currentFrom / pixelSize); - breite = (int) (nextFrom / pixelSize) - obenLinks; - } - else - { - obenLinks = (int) (currentFrom * pixelSize); - breite = (int) (nextFrom * pixelSize) - obenLinks; - } - - graphics.setColor(getColorByType(partType)); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - } - } - } - else - { - if(!miniFile) - { - obenLinks = (int) (currentFrom / pixelSize); - breite = (int) (nextFrom / pixelSize) - obenLinks; - } - else - { - obenLinks = (int) (currentFrom * pixelSize); - breite = (int) (nextFrom * pixelSize) - obenLinks; - } - - graphics.setColor(getColorByType(partType)); - graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); - } - } - - private Color getColorByType(int type) - { - switch(type) - { - - case -1: - return PartList.COLOR_TYPE_OK; - - case 0: - return PartList.COLOR_TYPE_0; - - case 1: - return PartList.COLOR_TYPE_1; - - case 2: - return PartList.COLOR_TYPE_2; - - case 3: - return PartList.COLOR_TYPE_3; - - case 4: - return PartList.COLOR_TYPE_4; - - case 5: - return PartList.COLOR_TYPE_5; - - case 6: - return PartList.COLOR_TYPE_6; - - case 7: - return PartList.COLOR_TYPE_7; - - case 8: - return PartList.COLOR_TYPE_8; - - case 9: - return PartList.COLOR_TYPE_9; - - case 10: - return PartList.COLOR_TYPE_10; - - default: - return PartList.COLOR_TYPE_10; - } - } - - private Color getColorByPercent(double percent) - { - if(percent < 10) - { - return PartList.COLOR_READY_10; - } - else if(percent < 30) - { - return PartList.COLOR_READY_30; - } - else if(percent < 50) - { - return PartList.COLOR_READY_50; - } - else if(percent < 70) - { - return PartList.COLOR_READY_70; - } - else if(percent < 90) - { - return PartList.COLOR_READY_90; - } - else - { - return PartList.COLOR_READY_100; - } - } - - public void mouseDragged(MouseEvent mouseEvent) - { - } - - public void mouseMoved(MouseEvent mouseEvent) - { - if(image != null) - { - savedMouseEvent = mouseEvent; - Point p = mouseEvent.getPoint(); - - try - { - int rgb = image.getRGB((int) p.getX(), (int) p.getY()); - - if(rgb == PartList.COLOR_TYPE_UEBERPRUEFT.getRGB()) - { - setToolTipText(ueberprueft); - } - else if(rgb == PartList.COLOR_TYPE_0.getRGB()) - { - setToolTipText(nichtVorhanden); - } - else if(rgb == PartList.COLOR_TYPE_OK.getRGB()) - { - setToolTipText(vorhanden); - } - else if(rgb == PartList.COLOR_TYPE_1.getRGB()) - { - setToolTipText("1" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_2.getRGB()) - { - setToolTipText("2" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_3.getRGB()) - { - setToolTipText("3" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_4.getRGB()) - { - setToolTipText("4" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_5.getRGB()) - { - setToolTipText("5" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_6.getRGB()) - { - setToolTipText("6" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_7.getRGB()) - { - setToolTipText("7" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_8.getRGB()) - { - setToolTipText("8" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_9.getRGB()) - { - setToolTipText("9" + quellen); - } - else if(rgb == PartList.COLOR_TYPE_10.getRGB()) - { - setToolTipText("10+" + quellen); - } - else if(rgb == PartList.COLOR_READY_10.getRGB()) - { - setToolTipText("0-10" + uebertragen); - } - else if(rgb == PartList.COLOR_READY_30.getRGB()) - { - setToolTipText("10-30" + uebertragen); - } - else if(rgb == PartList.COLOR_READY_50.getRGB()) - { - setToolTipText("30-50" + uebertragen); - } - else if(rgb == PartList.COLOR_READY_70.getRGB()) - { - setToolTipText("50-70" + uebertragen); - } - else if(rgb == PartList.COLOR_READY_90.getRGB()) - { - setToolTipText("70-90" + uebertragen); - } - else if(rgb == PartList.COLOR_READY_100.getRGB()) - { - setToolTipText("90-100" + uebertragen); - } - else - { - setToolTipText(null); - } - } - catch(ArrayIndexOutOfBoundsException aoobE) - { - setToolTipText(null); - } - } - else - { - setToolTipText(null); - } - } - - public void fireLanguageChanged() - { - try - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - vorhanden = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label4.caption")); - nichtVorhanden = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label3.caption")); - ueberprueft = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label1.caption")); - quellen = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.quellen")); - uebertragen = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.uebertragen")); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/PowerDownloadPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/download/PowerDownloadPanel.java deleted file mode 100644 index d990010e..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/PowerDownloadPanel.java +++ /dev/null @@ -1,829 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.download; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import java.io.File; - -import java.lang.reflect.Constructor; - -import java.net.URL; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JToolTip; -import javax.swing.SwingConstants; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.gui.powerdownload.AutomaticPowerdownloadPolicy; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.MultiLineToolTip; -import de.applejuicenet.client.shared.NumberInputVerifier; -import de.applejuicenet.client.shared.PolicyJarClassLoader; - -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/download/PowerDownloadPanel.java,v 1.20 2009/01/26 13:31:36 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class PowerDownloadPanel extends JPanel implements LanguageListener, DataUpdateListener -{ - private final Color BLUE_BACKGROUND = new Color(118, 112, 148); - public JRadioButton btnInaktiv = new JRadioButton(); - public JRadioButton btnAktiv = new JRadioButton(); - private JRadioButton btnAutoInaktiv = new JRadioButton(); - private JRadioButton btnAutoAktiv = new JRadioButton(); - private JLabel btnHint; - private JLabel btnHint2; - private JLabel btnHint3; - private JLabel btnPdlUp; - private JLabel btnPdlDown; - private float ratioWert = 2.2f; - public TKLTextField ratio = new TKLTextField("2.2"); - private TKLTextField autoAb = new TKLTextField(); - private TKLTextField autoBis = new TKLTextField(); - private JButton btnPdl = new JButton(); - private JButton btnAutoPdl = new JButton(); - private JLabel powerdownload = new JLabel(); - private JLabel label6 = new JLabel(); - private JLabel label7 = new JLabel(); - private JLabel label8 = new JLabel(); - private JLabel label9 = new JLabel(); - private JLabel label10 = new JLabel(); - private JLabel label11 = new JLabel(); - private Logger logger; - private RatioFocusAdapter ratioFocusAdapter; - private JComboBox pwdlPolicies = new JComboBox(); - private JButton autoPwdlEinstellungen = new JButton(); - private int standardAutomaticPwdlAb = 200; - private int standardAutomaticPwdlBis = 30; - private DownloadController downloadController; - private AutomaticPowerdownloadPolicy autoPwdlThread; - private Information lastInformation; - private JPanel backPanel = new JPanel(); - - public PowerDownloadPanel(DownloadController downloadController) - { - logger = Logger.getLogger(getClass()); - try - { - this.downloadController = downloadController; - btnPdl.setEnabled(false); - init(); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - - private void init() throws Exception - { - ratio.disableDirtyComponent(true); - autoAb.disableDirtyComponent(true); - autoBis.disableDirtyComponent(true); - setLayout(new BorderLayout()); - LanguageSelector.getInstance().addLanguageListener(this); - backPanel.setLayout(new GridBagLayout()); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.gridheight = 1; - constraints.gridwidth = 3; - JPanel tempPanel = new JPanel(); - - tempPanel.setLayout(new BorderLayout()); - powerdownload.setForeground(Color.white); - powerdownload.setOpaque(true); - powerdownload.setBackground(BLUE_BACKGROUND); - ratioFocusAdapter = new RatioFocusAdapter(); - ratio.addFocusListener(ratioFocusAdapter); - ratio.setBackground(Color.white); - ratio.setMinimumSize(new Dimension(50, 21)); - ratio.setPreferredSize(new Dimension(50, 21)); - ratio.setHorizontalAlignment(SwingConstants.RIGHT); - KeyAdapter ratioKlicker = new KeyAdapter() - { - public void keyPressed(KeyEvent ke) - { - switch(ke.getKeyCode()) - { - - case KeyEvent.VK_ENTER: - { - ratioFocusAdapter.focusLost(null); - btnPdl.doClick(); - break; - } - - case KeyEvent.VK_UP: - { - btnAktiv.setSelected(true); - alterRatio(true); - break; - } - - case KeyEvent.VK_DOWN: - { - btnAktiv.setSelected(true); - alterRatio(false); - break; - } - - default: - break; - } - } - }; - - btnInaktiv.addKeyListener(ratioKlicker); - btnAktiv.addKeyListener(ratioKlicker); - ratio.addKeyListener(ratioKlicker); - - tempPanel.add(powerdownload, BorderLayout.CENTER); - - IconManager im = IconManager.getInstance(); - ImageIcon icon = im.getIcon("hint"); - - btnHint = new JLabel(icon) - { - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - }; - btnHint.setOpaque(true); - btnHint.setBackground(BLUE_BACKGROUND); - tempPanel.add(btnHint, BorderLayout.EAST); - backPanel.add(tempPanel, constraints); - constraints.insets.left = 5; - constraints.insets.right = 5; - constraints.gridy = 1; - backPanel.add(label6, constraints); - constraints.gridwidth = 1; - constraints.gridy = 2; - ButtonGroup buttonGroup = new ButtonGroup(); - - buttonGroup.add(btnInaktiv); - buttonGroup.add(btnAktiv); - btnInaktiv.setSelected(true); - backPanel.add(btnInaktiv, constraints); - constraints.gridy = 3; - backPanel.add(btnAktiv, constraints); - - JPanel tempPanel3 = new JPanel(new GridBagLayout()); - GridBagConstraints constraints2 = new GridBagConstraints(); - - constraints2.anchor = GridBagConstraints.NORTH; - constraints2.fill = GridBagConstraints.BOTH; - constraints2.gridx = 0; - constraints2.gridy = 0; - - tempPanel3.add(label7, constraints2); - ImageIcon icon2 = im.getIcon("increase"); - - btnPdlUp = new JLabel(icon2); - ImageIcon icon3 = im.getIcon("decrease"); - - btnPdlDown = new JLabel(icon3); - - btnPdlUp.addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent e) - { - btnAktiv.setSelected(true); - alterRatio(true); - } - }); - btnPdlDown.addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent e) - { - btnAktiv.setSelected(true); - alterRatio(false); - } - }); - constraints2.gridx = 1; - tempPanel3.add(btnPdlDown, constraints2); - constraints2.gridx = 2; - tempPanel3.add(ratio, constraints2); - constraints2.gridx = 3; - tempPanel3.add(btnPdlUp, constraints2); - constraints2.gridx = 4; - constraints2.insets.left = 5; - tempPanel3.add(label8, constraints2); - - constraints.gridy = 4; - backPanel.add(tempPanel3, constraints); - constraints.gridy = 5; - constraints.gridwidth = 3; - backPanel.add(btnPdl, constraints); - - constraints.gridy = 6; - backPanel.add(new JLabel(" "), constraints); - constraints.gridx = 0; - constraints.gridy = 7; - constraints.gridheight = 1; - constraints.gridwidth = 3; - JPanel tempPanel2 = new JPanel(); - - tempPanel2.setLayout(new BorderLayout()); - label9.setForeground(Color.white); - label9.setOpaque(true); - label9.setBackground(BLUE_BACKGROUND); - tempPanel2.add(label9, BorderLayout.CENTER); - btnHint2 = new JLabel(icon) - { - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - }; - btnHint2.setOpaque(true); - btnHint2.setBackground(BLUE_BACKGROUND); - btnHint3 = new JLabel(icon) - { - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - }; - tempPanel2.add(btnHint2, BorderLayout.EAST); - constraints.insets.left = 0; - constraints.insets.right = 0; - backPanel.add(tempPanel2, constraints); - constraints.insets.left = 5; - constraints.insets.right = 5; - - constraints.gridwidth = 1; - constraints.gridy = 8; - ButtonGroup buttonGroup2 = new ButtonGroup(); - - buttonGroup2.add(btnAutoInaktiv); - buttonGroup2.add(btnAutoAktiv); - btnAutoInaktiv.setSelected(true); - pwdlPolicies.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - AutomaticPowerdownloadPolicy policy = (AutomaticPowerdownloadPolicy) pwdlPolicies.getSelectedItem(); - StringBuffer text = new StringBuffer(policy.getDescription()); - int i = 0; - - while(i < text.length()) - { - if(text.charAt(i) == '.') - { - text.insert(i + 1, '|'); - i++; - } - - i++; - } - - text.insert(0, policy.toString() + "|" + "Autor: " + policy.getAuthor() + "|" + "Beschreibung:|"); - btnHint3.setToolTipText(text.toString()); - } - }); - fillPwdlPolicies(); - JPanel panel1 = new JPanel(new FlowLayout()); - - panel1.add(pwdlPolicies); - panel1.add(btnHint3); - backPanel.add(panel1, constraints); - constraints.insets.left = 0; - constraints.insets.right = 0; - JPanel panel2 = new JPanel(new GridBagLayout()); - - constraints.gridy = 0; - panel2.add(btnAutoInaktiv, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel2.add(new JLabel(), constraints); - constraints.weightx = 0; - constraints.gridx = 2; - panel2.add(autoPwdlEinstellungen, constraints); - constraints.gridx = 0; - constraints.gridy = 9; - constraints.insets.left = 5; - constraints.insets.right = 5; - backPanel.add(panel2, constraints); - constraints.gridy = 10; - backPanel.add(btnAutoAktiv, constraints); - constraints.gridy = 11; - JPanel panel = new JPanel(new FlowLayout()); - - panel.add(label10); - autoAb.setDocument(new NumberInputVerifier()); - autoAb.setPreferredSize(new Dimension(40, 21)); - autoAb.setText(Integer.toString(standardAutomaticPwdlAb)); - autoBis.setDocument(new NumberInputVerifier()); - autoBis.setPreferredSize(new Dimension(40, 21)); - autoBis.setText(Integer.toString(standardAutomaticPwdlBis)); - autoAb.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - int eingegeben = Integer.parseInt(autoAb.getText()); - - if(eingegeben < Integer.parseInt(autoBis.getText())) - { - autoAb.setText(Integer.toString(standardAutomaticPwdlAb)); - } - } - }); - autoBis.addFocusListener(new FocusAdapter() - { - public void focusLost(FocusEvent fe) - { - int eingegeben = Integer.parseInt(autoBis.getText()); - - if(eingegeben < standardAutomaticPwdlBis || eingegeben > Integer.parseInt(autoAb.getText())) - { - autoBis.setText(Integer.toString(standardAutomaticPwdlBis)); - } - } - }); - panel.add(autoAb); - panel.add(new JLabel("MB ")); - panel.add(label11); - panel.add(autoBis); - panel.add(new JLabel("MB ")); - backPanel.add(panel, constraints); - constraints.gridy = 12; - constraints.gridwidth = 3; - constraints.insets.bottom = 5; - backPanel.add(btnAutoPdl, constraints); - btnAutoPdl.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - alterAutoPwdl(); - } - }); - - JScrollPane sp = new JScrollPane(backPanel); - - sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - add(sp, BorderLayout.NORTH); - autoPwdlEinstellungen.setVisible(false); - autoPwdlEinstellungen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - oeffneAutomPwdlEinstellungen(); - } - }); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); - } - - public void setPwdlValue(int pwdlValue) - { - if(pwdlValue < 12) - { - ratio.setText("2.2"); - ratioWert = 2.2f; - btnInaktiv.setSelected(true); - } - else - { - float wert = (float) ((float) (pwdlValue + 10) / 10); - - ratio.setText(Float.toString(wert)); - ratioWert = wert; - btnAktiv.setSelected(true); - } - } - - private void alterAutoPwdl() - { - if(btnAutoAktiv.isSelected()) - { - if(pwdlPolicies.isEnabled()) - { - pwdlPolicies.setEnabled(false); - autoAb.setEnabled(false); - autoBis.setEnabled(false); - btnPdl.setEnabled(false); - AutomaticPowerdownloadPolicy selectedPolicy = (AutomaticPowerdownloadPolicy) pwdlPolicies.getSelectedItem(); - - manageAutoPwdl(selectedPolicy); - AppleJuiceDialog.getApp().informAutomaticPwdlEnabled(true); - } - } - else - { - if(!pwdlPolicies.isEnabled()) - { - pwdlPolicies.setEnabled(true); - autoAb.setEnabled(true); - autoBis.setEnabled(true); - if(autoPwdlThread != null) - { - autoPwdlThread.interrupt(); - autoPwdlThread = null; - } - } - } - } - - public boolean isAutomaticPwdlActive() - { - return (!pwdlPolicies.isEnabled() && autoPwdlThread != null); - } - - @SuppressWarnings("unchecked") - private void manageAutoPwdl(final AutomaticPowerdownloadPolicy selectedPolicy) - { - if(autoPwdlThread != null) - { - autoPwdlThread.interrupt(); - autoPwdlThread = null; - } - - AutomaticPowerdownloadPolicy policy = null; - - try - { - Constructor con = selectedPolicy.getClass().getConstructor(new Class[] {ApplejuiceFassade.class}); - - policy = (AutomaticPowerdownloadPolicy) con.newInstance(new Object[] {AppleJuiceClient.getAjFassade()}); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - autoPwdlThread = policy; - autoPwdlThread.setParentToInform(this); - checkForPause(autoPwdlThread); - autoPwdlThread.start(); - autoPwdlEinstellungen.setVisible(autoPwdlThread.hasPropertiesDialog()); - } - - private void checkForPause(AutomaticPowerdownloadPolicy pwdlThread) - { - long eingegebenBis = Integer.parseInt(autoBis.getText()) * 1048576L; - long eingegebenAb = Integer.parseInt(autoAb.getText()) * 1048576L; - - if(lastInformation == null) - { - lastInformation = AppleJuiceClient.getAjFassade().getInformation(); - } - - if(lastInformation.getCredits() < eingegebenBis) - { - pwdlThread.setPaused(true); - } - } - - private void oeffneAutomPwdlEinstellungen() - { - if(autoPwdlThread != null && autoPwdlThread.hasPropertiesDialog()) - { - try - { - autoPwdlThread.showPropertiesDialog(AppleJuiceDialog.getApp()); - } - catch(Exception ex) - { - logger.error(ex.getMessage(), ex); - } - } - } - - public void autoPwdlFinished() - { - autoPwdlEinstellungen.setVisible(false); - autoPwdlThread = null; - btnAutoInaktiv.setSelected(true); - btnAutoPdl.doClick(); - AppleJuiceDialog.getApp().informAutomaticPwdlEnabled(false); - } - - public Dimension getPreferredSize() - { - return backPanel.getPreferredSize(); - } - - private void fillPwdlPolicies() - { - AutomaticPowerdownloadPolicy[] policies = loadPolicies(); - - for(int i = 0; i < policies.length; i++) - { - pwdlPolicies.addItem(policies[i]); - } - - if(pwdlPolicies.getItemCount() > 0) - { - pwdlPolicies.setSelectedIndex(0); - } - } - - private AutomaticPowerdownloadPolicy[] loadPolicies() - { - try - { - String path = System.getProperty("user.dir") + File.separator + "pwdlpolicies" + File.separator; - File policyPath = new File(path); - - if(!policyPath.isDirectory()) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Warnung: Kein Verzeichnis 'pwdlpolicies' vorhanden!"); - } - - return new AutomaticPowerdownloadPolicy[0]; - } - - String[] tempListe = policyPath.list(); - PolicyJarClassLoader jarLoader = null; - ArrayList<AutomaticPowerdownloadPolicy> policies = new ArrayList<AutomaticPowerdownloadPolicy>(); - - for(int i = 0; i < tempListe.length; i++) - { - if(tempListe[i].toLowerCase().endsWith(".jar")) - { - URL url = null; - - try - { - url = new URL("file://" + path + tempListe[i]); - jarLoader = new PolicyJarClassLoader(url); - AutomaticPowerdownloadPolicy aPolicy = jarLoader.getPolicy(path + tempListe[i]); - - if(aPolicy != null) - { - policies.add(aPolicy); - } - } - catch(Exception e) - { - //Von einer Policy lassen wir uns nicht beirren! ;-) - logger.error("Eine PowerdownloadPolicy konnte nicht instanziert werden", e); - continue; - } - } - } - - return (AutomaticPowerdownloadPolicy[]) policies.toArray(new AutomaticPowerdownloadPolicy[policies.size()]); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - return new AutomaticPowerdownloadPolicy[0]; - } - } - - private void alterRatio(boolean increase) - { - try - { - String temp = ratio.getText(); - int pos = temp.indexOf('.'); - int ganzZahl; - int nachKomma; - - if(pos == -1) - { - ganzZahl = Integer.parseInt(temp); - nachKomma = 0; - } - else - { - ganzZahl = Integer.parseInt(temp.substring(0, pos)); - nachKomma = Integer.parseInt(temp.substring(pos + 1)); - } - - if(increase) - { - if(ratioWert < 50f) - { - if(nachKomma == 9) - { - nachKomma = 0; - ganzZahl += 1; - } - else - { - nachKomma += 1; - } - } - else - { - return; - } - } - else - { - if(ratioWert > 2.2f) - { - if(nachKomma == 0) - { - nachKomma = 9; - ganzZahl -= 1; - } - else - { - nachKomma -= 1; - } - } - else - { - return; - } - } - - ratio.setText(ganzZahl + "." + nachKomma); - ratioWert = Float.parseFloat(ratio.getText()); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - - public void fireLanguageChanged() - { - try - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - powerdownload.setText(" " + languageSelector.getFirstAttrbuteByTagName("mainform.powerdownload.caption")); - label6.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label6.caption")); - btnInaktiv.setText(languageSelector.getFirstAttrbuteByTagName("mainform.powerinactive.caption")); - btnAktiv.setText(languageSelector.getFirstAttrbuteByTagName("mainform.poweractive.caption")); - label7.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label7.caption")); - label8.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label8.caption")); - label9.setText(" " + languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.label1")); - btnAutoInaktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.rbInaktiv")); - btnAutoAktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.rbAktiv")); - label10.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.pdlAb")); - label11.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.pdlBis")); - String ok = languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.btnOK"); - - btnAutoPdl.setText(ok); - btnPdl.setText(ok); - btnHint.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.tooltipps.powerdownload")); - btnHint2.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.tooltipps.autopowerdownload")); - autoPwdlEinstellungen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.einstellungen")); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - - @SuppressWarnings("unchecked") - public void fireContentChanged(DATALISTENER_TYPE type, Object content) - { - try - { - if(type == DATALISTENER_TYPE.INFORMATION_CHANGED) - { - lastInformation = (Information) content; - if(autoPwdlThread != null && lastInformation != null) - { - long eingegebenBis = Long.parseLong(autoBis.getText()) * 1048576L; - long eingegebenAb = Long.parseLong(autoAb.getText()) * 1048576L; - - if(lastInformation.getCredits() > eingegebenAb) - { - autoPwdlThread.setPaused(false); - } - else if(lastInformation.getCredits() < eingegebenBis) - { - autoPwdlThread.setPaused(true); - } - } - } - else if(type == DATALISTENER_TYPE.DOWNLOAD_CHANGED && autoPwdlThread != null && autoPwdlThread.isPaused()) - { - HashMap<String, Download> downloads = (HashMap<String, Download>) content; - - synchronized(downloads) - { - List<Download> toPause = new Vector<Download>(); - - for(Download curDownload : downloads.values()) - { - if(curDownload.getStatus() == Download.SUCHEN_LADEN) - { - toPause.add(curDownload); - } - } - - AppleJuiceClient.getAjFassade().pauseDownload(toPause); - } - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public JButton getBtnPdl() - { - return btnPdl; - } - - private class RatioFocusAdapter extends FocusAdapter - { - public void focusLost(FocusEvent fe) - { - try - { - String temp = ratio.getText(); - - temp = temp.replaceAll(",", "."); - int pos = temp.lastIndexOf('.'); - - if(pos != -1) - { - temp = temp.substring(0, pos + 2); - } - - double pwdl = new Double(temp).doubleValue(); - - if(pwdl < 2.2 || pwdl > 50) - { - ratio.setText("2.2"); - } - else - { - ratio.setText(temp); - } - - btnAktiv.setSelected(true); - } - catch(Exception ex) - { - ratio.setText("2.2"); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODAnsichtPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODAnsichtPanel.java deleted file mode 100644 index 182ee57f..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODAnsichtPanel.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import java.io.File; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JColorChooser; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JToolTip; -import javax.swing.border.Border; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManager; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.MultiLineToolTip; -import de.applejuicenet.client.shared.Settings; - -import de.tklsoft.gui.controls.TKLCheckBox; -import de.tklsoft.gui.controls.TKLLabel; -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODAnsichtPanel.java,v 1.12 2009/01/26 13:31:36 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODAnsichtPanel extends JPanel implements OptionsRegister -{ - private TKLLabel farbeFertigerDownload = new TKLLabel(" "); - private TKLLabel farbeQuelle = new TKLLabel(" "); - private Settings settings; - private TKLCheckBox cmbAktiv = new TKLCheckBox(); - private TKLCheckBox enableToolTip = new TKLCheckBox(); - private TKLCheckBox cmbStartscreenZeigen = new TKLCheckBox(); - private Logger logger; - private Icon menuIcon; - private String menuText; - private boolean dirty = false; - private TKLTextField openProgram = new TKLTextField(); - private TKLLabel program = new TKLLabel("VLC "); - private Border emptyBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1); - - public ODAnsichtPanel() - { - logger = Logger.getLogger(getClass()); - try - { - settings = Settings.getSettings(); - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - IconManager im = IconManager.getInstance(); - - menuIcon = im.getIcon("opt_ansicht"); - cmbAktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.aktiv")); - cmbStartscreenZeigen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.zeigestartscreen")); - enableToolTip.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.zeigetooltipps")); - - setLayout(new BorderLayout()); - farbeFertigerDownload.setOpaque(true); - farbeFertigerDownload.setBorder(emptyBorder); - farbeFertigerDownload.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - farbeFertigerDownload.addMouseListener(new ColorChooserMouseAdapter()); - farbeQuelle.setOpaque(true); - farbeQuelle.setBorder(emptyBorder); - farbeQuelle.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - farbeQuelle.addMouseListener(new ColorChooserMouseAdapter()); - OptionsManager om = OptionsManagerImpl.getInstance(); - - cmbStartscreenZeigen.setSelected(om.shouldShowConnectionDialogOnStartup()); - cmbStartscreenZeigen.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent ce) - { - dirty = true; - } - }); - cmbAktiv.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent ce) - { - dirty = true; - settings.setFarbenAktiv(cmbAktiv.isSelected()); - } - }); - enableToolTip.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - dirty = true; - settings.enableToolTipEnabled(enableToolTip.isSelected()); - } - }); - - ImageIcon icon = im.getIcon("hint"); - TKLLabel hint1 = new TKLLabel(icon) - { - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - }; - - TKLLabel hint2 = new TKLLabel(icon) - { - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - }; - - String tooltipp = languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.ttipp_farbewaehlen"); - - hint1.setToolTipText(tooltipp); - hint2.setToolTipText(tooltipp); - - openProgram.setEditable(false); - openProgram.setBackground(Color.WHITE); - openProgram.setText(om.getOpenProgram()); - openProgram.ignoreInvalidRules(false); - Icon icon2 = im.getIcon("folderopen"); - Icon icon3 = im.getIcon("vlc"); - - program.setIcon(icon3); - TKLLabel selectProgram = new TKLLabel(icon2); - - selectProgram.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - selectProgram.addMouseListener(new MouseAdapter() - { - public void mouseEntered(MouseEvent e) - { - TKLLabel source = (TKLLabel) e.getSource(); - - source.setBorder(BorderFactory.createLineBorder(Color.black)); - } - - public void mouseClicked(MouseEvent e) - { - TKLLabel source = (TKLLabel) e.getSource(); - JFileChooser fileChooser = new JFileChooser(); - - fileChooser.setDialogType(JFileChooser.FILES_ONLY); - fileChooser.setDialogTitle(program.getText()); - if(openProgram.getText().length() != 0) - { - File tmpFile = new File(openProgram.getText()); - - if(tmpFile.isFile()) - { - fileChooser.setCurrentDirectory(tmpFile); - } - } - - int returnVal = fileChooser.showOpenDialog(source); - - if(returnVal == JFileChooser.APPROVE_OPTION) - { - File browserFile = fileChooser.getSelectedFile(); - - if(browserFile.isFile()) - { - openProgram.setText(browserFile.getPath()); - dirty = true; - openProgram.fireCheckRules(); - } - } - } - - public void mouseExited(MouseEvent e) - { - TKLLabel source = (TKLLabel) e.getSource(); - - source.setBorder(null); - } - }); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.WEST; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.bottom = 5; - - JPanel panel4 = new JPanel(new GridBagLayout()); - - panel4.add(program, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel4.add(openProgram, constraints); - constraints.weightx = 0; - constraints.gridx = 2; - panel4.add(selectProgram, constraints); - - JPanel panel1 = new JPanel(); - - constraints.gridx = 0; - constraints.gridy = 0; - panel1.setLayout(new GridBagLayout()); - panel1.setBorder(BorderFactory.createTitledBorder(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.hintergrundfarben"))); - panel1.add(cmbAktiv, constraints); - constraints.gridy = 1; - constraints.insets.left = 5; - constraints.insets.right = 5; - panel1.add(new TKLLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.fertigerdownload")), constraints); - constraints.gridy = 2; - panel1.add(new TKLLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.quelle")), constraints); - menuText = languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.caption"); - constraints.gridx = 1; - constraints.gridy = 1; - panel1.add(farbeFertigerDownload, constraints); - constraints.gridy = 2; - panel1.add(farbeQuelle, constraints); - constraints.gridx = 2; - constraints.gridy = 1; - panel1.add(hint1, constraints); - constraints.gridy = 2; - panel1.add(hint2, constraints); - JPanel panel2 = new JPanel(new BorderLayout()); - - panel2.add(panel1, BorderLayout.NORTH); - JPanel panel3 = new JPanel(new GridBagLayout()); - - constraints.insets.bottom = 0; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.weightx = 1; - constraints.weighty = 0; - panel3.add(panel4, constraints); - constraints.gridy = 1; - panel3.add(cmbStartscreenZeigen, constraints); - constraints.gridy = 2; - panel3.add(enableToolTip, constraints); - panel2.add(panel3, BorderLayout.SOUTH); - - add(panel2, BorderLayout.WEST); - - reloadSettings(); - - cmbAktiv.confirmNewValue(); - enableToolTip.confirmNewValue(); - cmbStartscreenZeigen.confirmNewValue(); - } - - public boolean save() - { - try - { - boolean bRet = false; - OptionsManager om = OptionsManagerImpl.getInstance(); - - if(om.shouldShowConnectionDialogOnStartup() != shouldShowStartcreen()) - { - om.showConnectionDialogOnStartup(shouldShowStartcreen()); - bRet = true; - } - - if(!om.getOpenProgram().equals(getProgramPfad())) - { - om.setOpenProgram(getProgramPfad()); - bRet = true; - } - - if(settings.save()) - { - bRet = true; - } - - return bRet; - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - return false; - } - } - - public boolean isDirty() - { - return dirty; - } - - public boolean shouldShowStartcreen() - { - return cmbStartscreenZeigen.isSelected(); - } - - public Icon getIcon() - { - return menuIcon; - } - - public String getMenuText() - { - return menuText; - } - - public String getProgramPfad() - { - return openProgram.getText(); - } - - public void reloadSettings() - { - settings = Settings.getSettings(); - farbeQuelle.setBackground(settings.getQuelleHintergrundColor()); - farbeFertigerDownload.setBackground(settings.getDownloadFertigHintergrundColor()); - cmbAktiv.setSelected(settings.isFarbenAktiv()); - enableToolTip.setSelected(settings.isToolTipEnabled()); - } - - class ColorChooserMouseAdapter extends MouseAdapter - { - public void mouseEntered(MouseEvent e) - { - TKLLabel source = (TKLLabel) e.getSource(); - - source.setBorder(BorderFactory.createLineBorder(Color.black)); - } - - public void mouseClicked(MouseEvent e) - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - TKLLabel source = (TKLLabel) e.getSource(); - Color newColor = JColorChooser.showDialog(null, - languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.hintergrundfarbewaehlen"), - source.getBackground()); - - if(newColor != null && newColor.getRGB() != source.getBackground().getRGB()) - { - source.setBackground(newColor); - if(source == farbeQuelle) - { - settings.setQuelleHintergrundColor(newColor); - } - else - { - settings.setDownloadFertigHintergrundColor(newColor); - } - } - } - - public void mouseExited(MouseEvent e) - { - TKLLabel source = (TKLLabel) e.getSource(); - - source.setBorder(emptyBorder); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODDirectoryChooser.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODDirectoryChooser.java deleted file mode 100644 index 38d2fa4e..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODDirectoryChooser.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeModel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.components.tree.WaitNode; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserNode; -import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserTreeCellRenderer; -import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserTreeModel; -import de.applejuicenet.client.shared.SwingWorker; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODDirectoryChooser.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODDirectoryChooser extends JDialog -{ - private JTree folderTree = new JTree(); - private JButton uebernehmen = new JButton(); - private JButton abbrechen = new JButton(); - private boolean change = false; - private String path; - private Logger logger; - - public ODDirectoryChooser(JDialog parent, String title) - { - super(parent, true); - logger = Logger.getLogger(getClass()); - try - { - setTitle(title); - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(new JScrollPane(folderTree), BorderLayout.CENTER); - folderTree.setModel(new DefaultTreeModel(new WaitNode())); - folderTree.setCellRenderer(new DirectoryChooserTreeCellRenderer()); - uebernehmen.setEnabled(false); - final SwingWorker worker = new SwingWorker() - { - public Object construct() - { - DirectoryChooserTreeModel treeModel = new DirectoryChooserTreeModel(); - - folderTree.setModel(treeModel); - folderTree.setRootVisible(false); - uebernehmen.setEnabled(true); - return null; - } - }; - - worker.start(); - JPanel aPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - aPanel.add(uebernehmen); - aPanel.add(abbrechen); - uebernehmen.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Button1.caption")); - uebernehmen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - uebernehmen(); - } - }); - abbrechen.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Button2.caption")); - abbrechen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - getContentPane().add(aPanel, BorderLayout.SOUTH); - pack(); - setSize(getWidth() * 2, getHeight()); - } - - public boolean isNewPathSelected() - { - return change; - } - - public String getSelectedPath() - { - return path; - } - - private void uebernehmen() - { - try - { - if(folderTree.getSelectionCount() != 0) - { - change = true; - DirectoryChooserNode node = (DirectoryChooserNode) folderTree.getLastSelectedPathComponent(); - - path = node.getDirectory().getPath(); - } - - dispose(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java deleted file mode 100644 index 03e8dfde..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPanel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java,v 1.6 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODPluginOptionsDialog extends JDialog -{ - private PluginConnector pluginConnector; - private JButton schliessen = new JButton(); - private Logger logger; - - public ODPluginOptionsDialog(JDialog parent, PluginConnector pluginConnector) - { - super(parent, true); - try - { - this.pluginConnector = pluginConnector; - logger = Logger.getLogger(getClass()); - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - schliessen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - ODPluginOptionsDialog.this.dispose(); - } - }); - - String title = pluginConnector.getTitle() + " - "; - - title += languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.einstellungen"); - schliessen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.schliessen")); - setTitle(title); - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(pluginConnector.getOptionPanel(), BorderLayout.CENTER); - JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - southPanel.add(schliessen); - getContentPane().add(southPanel, BorderLayout.SOUTH); - pack(); - Dimension appDimension = getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODProxyPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODProxyPanel.java deleted file mode 100644 index ef530356..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODProxyPanel.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.NumberInputVerifier; -import de.tklsoft.gui.controls.TKLCheckBox; -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODProxyPanel.java,v 1.7 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODProxyPanel extends JPanel implements OptionsRegister -{ - private boolean dirty = false; - private JLabel label1; - private JLabel label2; - private JLabel label3; - private JLabel label4; - private TKLTextField host = new TKLTextField(); - private TKLTextField port = new TKLTextField(); - private TKLTextField user = new TKLTextField(); - private JPasswordField passwort = new JPasswordField(); - private TKLCheckBox use = new TKLCheckBox(); - private ProxySettings proxySettings; - private Logger logger; - private Icon menuIcon; - private String menuText; - - public ODProxyPanel() - { - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - private void init() throws Exception - { - IconManager im = IconManager.getInstance(); - - menuIcon = im.getIcon("opt_proxy"); - setLayout(new BorderLayout()); - JPanel panel1 = new JPanel(new GridBagLayout()); - FlowLayout flowL = new FlowLayout(); - - flowL.setAlignment(FlowLayout.RIGHT); - JPanel panel2 = new JPanel(flowL); - - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - proxySettings = ProxyManagerImpl.getInstance().getProxySettings(); - - label1 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.host")); - label2 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.port")); - label3 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.benutzername")); - label4 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.passwort")); - use.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.verwenden")); - menuText = languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.caption"); - host.setText(proxySettings.getHost()); - host.addFocusListener(new HostFocusListener()); - port.setDocument(new NumberInputVerifier()); - if(proxySettings.getPort() != -1) - { - port.setText(Integer.toString(proxySettings.getPort())); - } - - port.addFocusListener(new PortFocusListener()); - user.addFocusListener(new UserFocusListener()); - passwort.addFocusListener(new PasswortFocusListener()); - use.setSelected(proxySettings.isUse()); - use.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - dirty = true; - } - }); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.top = 5; - constraints.insets.left = 5; - - panel1.add(label1, constraints); - - constraints.gridy = 1; - panel1.add(label2, constraints); - - constraints.gridy = 2; - panel1.add(label3, constraints); - - constraints.gridy = 3; - panel1.add(label4, constraints); - - constraints.insets.right = 5; - constraints.gridy = 0; - constraints.gridx = 1; - constraints.weightx = 1; - panel1.add(host, constraints); - - constraints.gridy = 1; - panel1.add(port, constraints); - - constraints.gridy = 2; - panel1.add(user, constraints); - - constraints.gridy = 3; - panel1.add(passwort, constraints); - - constraints.gridy = 4; - constraints.gridx = 0; - constraints.gridwidth = 2; - panel2.add(use); - panel1.add(panel2, constraints); - - add(panel1, BorderLayout.NORTH); - - host.confirmNewValue(); - port.confirmNewValue(); - user.confirmNewValue(); - use.confirmNewValue(); - } - - public ProxySettings getProxySettings() - { - if(dirty) - { - proxySettings.setUse(use.isSelected()); - proxySettings.setHost(host.getText()); - String tmpPort = port.getText(); - - if(tmpPort.length() == 0) - { - proxySettings.setPort(-1); - } - else - { - proxySettings.setPort(Integer.parseInt(tmpPort)); - } - - proxySettings.setUserpass(user.getText(), new String(passwort.getPassword())); - } - - return proxySettings; - } - - public boolean isDirty() - { - return dirty; - } - - public Icon getIcon() - { - return menuIcon; - } - - public String getMenuText() - { - return menuText; - } - - public void reloadSettings() - { - - // nothing to do... - } - - class PasswortFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - dirty = true; - } - } - - - class UserFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - dirty = true; - } - } - - - class PortFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - if(Integer.toString(proxySettings.getPort()).compareTo(host.getText()) != 0) - { - dirty = true; - } - } - } - - - class HostFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - if(proxySettings.getHost().compareTo(host.getText()) != 0) - { - dirty = true; - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODStandardPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODStandardPanel.java deleted file mode 100644 index 0728b373..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODStandardPanel.java +++ /dev/null @@ -1,669 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import java.io.File; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JToolTip; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManager; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.shared.ConnectionSettings; -import de.applejuicenet.client.shared.DesktopTools; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.MultiLineToolTip; -import de.applejuicenet.client.shared.NumberInputVerifier; - -import de.tklsoft.gui.controls.TKLCheckBox; -import de.tklsoft.gui.controls.TKLComboBox; -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODStandardPanel.java,v 1.10 2009/01/14 15:54:31 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODStandardPanel extends JPanel implements OptionsRegister -{ - private boolean dirty = false; - private boolean xmlPortDirty = false; - private JLabel label1 = new JLabel(); - private JLabel label2 = new JLabel(); - private JLabel label3 = new JLabel(); - private JLabel label4 = new JLabel(); - private JLabel label6 = new JLabel(); - private JLabel label7 = new JLabel(); - private JLabel selectStandardBrowser; - private JLabel openTemp; - private JLabel openIncoming; - private TKLTextField temp = new TKLTextField(); - private TKLTextField incoming = new TKLTextField(); - private TKLTextField port = new TKLTextField(); - private TKLTextField xmlPort = new TKLTextField(); - private TKLTextField nick = new TKLTextField(); - private TKLTextField browser = new TKLTextField(); - private JLabel hint1; - private JLabel hint2; - private JLabel hint3; - private JLabel hint4; - private JLabel hint5; - private JLabel hint6; - private JDialog parent; - private AJSettings ajSettings; - private TKLComboBox cmbLog; - private TKLComboBox updateInfoModus; - private TKLCheckBox loadPlugins = new TKLCheckBox(); - private Logger logger; - private ConnectionSettings remote; - private Icon menuIcon; - private String menuText; - - public ODStandardPanel(JDialog parent, AJSettings ajSettings, ConnectionSettings remote) - { - logger = Logger.getLogger(getClass()); - try - { - this.remote = remote; - this.parent = parent; - this.ajSettings = ajSettings; - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public boolean isDirty() - { - return dirty; - } - - public Level getLogLevel() - { - return ((LevelItem) cmbLog.getSelectedItem()).getLevel(); - } - - public int getVersionsinfoModus() - { - if(updateInfoModus.getSelectedIndex() == -1) - { - return 1; - } - else - { - UpdateInfoItem selectedItem = (UpdateInfoItem) updateInfoModus.getSelectedItem(); - - return selectedItem.getModus(); - } - } - - public String getBrowserPfad() - { - return browser.getText(); - } - - public boolean shouldLoadPluginsOnStartup() - { - return loadPlugins.isSelected(); - } - - private void init() throws Exception - { - OptionsManager optionsManager = OptionsManagerImpl.getInstance(); - IconManager im = IconManager.getInstance(); - - menuIcon = im.getIcon("opt_standard"); - port.setDocument(new NumberInputVerifier()); - xmlPort.setDocument(new NumberInputVerifier()); - temp.setEditable(false); - temp.setBackground(Color.WHITE); - incoming.setEditable(false); - incoming.setBackground(Color.WHITE); - browser.setEditable(false); - browser.setBackground(Color.WHITE); - browser.setText(optionsManager.getStandardBrowser()); - port.addFocusListener(new PortFocusListener()); - xmlPort.addFocusListener(new XmlPortFocusListener()); - nick.addFocusListener(new NickFocusListener()); - - JPanel panel8 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - panel8.add(new JLabel("Logging: ")); - LanguageSelector languageSelector = LanguageSelector.getInstance(); - Level logLevel = optionsManager.getLogLevel(); - - LevelItem[] levelItems = new LevelItem[3]; //{ "Info", "Debug", "keins"}; - - levelItems[0] = new LevelItem(Level.INFO, languageSelector.getFirstAttrbuteByTagName("javagui.options.logging.info")); - levelItems[1] = new LevelItem(Level.DEBUG, languageSelector.getFirstAttrbuteByTagName("javagui.options.logging.debug")); - levelItems[2] = new LevelItem(Level.OFF, languageSelector.getFirstAttrbuteByTagName("javagui.options.logging.off")); - menuText = languageSelector.getFirstAttrbuteByTagName("einstform.standardsheet.caption"); - cmbLog = new TKLComboBox(levelItems); - cmbLog.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - dirty = true; - } - }); - - int index = 0; - - if(logLevel == Level.INFO) - { - index = 0; - } - else if(logLevel == Level.DEBUG) - { - index = 1; - } - else if(logLevel == Level.OFF) - { - index = 2; - } - - cmbLog.setSelectedIndex(index); - - panel8.add(cmbLog); - - updateInfoModus = new TKLComboBox(); - UpdateInfoItem item0 = new UpdateInfoItem(0, - languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.updateinfo0")); - UpdateInfoItem item1 = new UpdateInfoItem(1, - languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.updateinfo1")); - UpdateInfoItem item2 = new UpdateInfoItem(2, - languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.updateinfo2")); - - updateInfoModus.addItem(item0); - updateInfoModus.addItem(item1); - updateInfoModus.addItem(item2); - int infoModus = optionsManager.getVersionsinfoModus(); - - switch(infoModus) - { - - case 0: - { - updateInfoModus.setSelectedItem(item0); - break; - } - - case 1: - { - updateInfoModus.setSelectedItem(item1); - break; - } - - case 2: - { - updateInfoModus.setSelectedItem(item2); - break; - } - - default: - updateInfoModus.setSelectedIndex(-1); - } - - updateInfoModus.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - dirty = true; - } - }); - - JPanel panel9 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JLabel label10 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.updateinfotext")); - - panel9.add(label10); - panel9.add(updateInfoModus); - - setLayout(new BorderLayout()); - port.setHorizontalAlignment(JLabel.RIGHT); - xmlPort.setHorizontalAlignment(JLabel.RIGHT); - reloadSettings(); - JPanel panel6 = new JPanel(new GridBagLayout()); - - label1.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label2.caption")); - label2.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label7.caption")); - label3.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label3.caption")); - label4.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label8.caption")); - label6.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.xmlport")); - label7.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.standardbrowser")); - loadPlugins.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ladeplugins")); - - loadPlugins.setSelected(optionsManager.shouldLoadPluginsOnStartup()); - - ImageIcon icon = im.getIcon("hint"); - - hint1 = new HintLabel(icon); - hint2 = new HintLabel(icon); - hint3 = new HintLabel(icon); - hint4 = new HintLabel(icon); - hint5 = new HintLabel(icon); - hint6 = new HintLabel(icon); - hint1.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_temp")); - hint2.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_port")); - hint3.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_nick")); - hint4.setToolTipText(languageSelector.getFirstAttrbuteByTagName("einstform.Label1.caption")); - hint5.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.logging.ttip")); - hint6.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_xmlport")); - - Icon icon2 = im.getIcon("folderopen"); - DirectoryChooserMouseAdapter dcMouseAdapter = new DirectoryChooserMouseAdapter(); - - openTemp = new JLabel(icon2); - openTemp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - openTemp.addMouseListener(dcMouseAdapter); - openIncoming = new JLabel(icon2); - openIncoming.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - openIncoming.addMouseListener(dcMouseAdapter); - selectStandardBrowser = new JLabel(icon2); - selectStandardBrowser.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - - selectStandardBrowser.addMouseListener(new SelectBrowserMouseListener()); - - loadPlugins.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - dirty = true; - } - }); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.top = 5; - - JPanel panel1 = new JPanel(new GridBagLayout()); - JPanel panel2 = new JPanel(new GridBagLayout()); - JPanel panel3 = new JPanel(new GridBagLayout()); - JPanel panel4 = new JPanel(new GridBagLayout()); - JPanel panel7 = new JPanel(new GridBagLayout()); - JPanel panel10 = new JPanel(new GridBagLayout()); - JPanel panel11 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - panel11.add(loadPlugins); - - constraints.insets.right = 5; - constraints.insets.left = 4; - panel1.add(label1, constraints); - panel2.add(label2, constraints); - panel3.add(label3, constraints); - panel4.add(label4, constraints); - panel7.add(label6, constraints); - panel10.add(label7, constraints); - - constraints.insets.left = 0; - constraints.insets.right = 2; - constraints.gridx = 1; - constraints.weightx = 1; - panel1.add(temp, constraints); - panel2.add(incoming, constraints); - panel3.add(port, constraints); - panel7.add(xmlPort, constraints); - panel4.add(nick, constraints); - panel10.add(browser, constraints); - constraints.gridx = 2; - constraints.weightx = 0; - panel1.add(openTemp, constraints); - panel2.add(openIncoming, constraints); - panel10.add(selectStandardBrowser, constraints); - - constraints.gridx = 0; - constraints.gridy = 0; - constraints.weightx = 1; - panel6.add(panel1, constraints); - constraints.gridy = 1; - panel6.add(panel2, constraints); - constraints.gridy = 2; - panel6.add(panel3, constraints); - constraints.gridy = 3; - panel6.add(panel7, constraints); - constraints.gridy = 4; - panel6.add(panel4, constraints); - constraints.gridy = 5; - panel6.add(panel10, constraints); - - constraints.insets.top = 10; - constraints.gridx = 1; - constraints.gridy = 0; - constraints.weightx = 0; - panel6.add(hint1, constraints); - constraints.gridy = 2; - panel6.add(hint2, constraints); - constraints.gridy = 3; - panel6.add(hint6, constraints); - constraints.gridy = 4; - panel6.add(hint3, constraints); - - constraints.gridy = 6; - constraints.gridx = 0; - constraints.gridwidth = 1; - panel6.add(panel8, constraints); - constraints.gridx = 1; - panel6.add(hint5, constraints); - constraints.gridy = 7; - constraints.gridx = 0; - panel6.add(panel9, constraints); - constraints.gridy = 8; - constraints.gridx = 0; - panel6.add(panel11, constraints); - - add(panel6, BorderLayout.NORTH); - - temp.confirmNewValue(); - incoming.confirmNewValue(); - port.confirmNewValue(); - xmlPort.confirmNewValue(); - nick.confirmNewValue(); - browser.confirmNewValue(); - cmbLog.confirmNewValue(); - updateInfoModus.confirmNewValue(); - loadPlugins.confirmNewValue(); - - if(DesktopTools.isAdvancedSupported() && System.getProperty("os.name").toLowerCase().indexOf("linux") == -1) - { - selectStandardBrowser.setVisible(false); - browser.setVisible(false); - label7.setVisible(false); - } - } - - public boolean isXmlPortDirty() - { - return xmlPortDirty; - } - - public Icon getIcon() - { - return menuIcon; - } - - public String getMenuText() - { - return menuText; - } - - public void reloadSettings() - { - AJSettings ajSettings2 = AppleJuiceClient.getAjFassade().getAJSettings(); - - temp.setText(ajSettings2.getTempDir()); - incoming.setText(ajSettings2.getIncomingDir()); - port.setText(Long.toString(ajSettings2.getPort())); - xmlPort.setText(Long.toString(ajSettings2.getXMLPort())); - nick.setText(ajSettings2.getNick()); - } - - class PortFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - int portNr = Integer.parseInt(port.getText()); - - if(ajSettings.getPort() != portNr) - { - if(portNr > 1024 && portNr <= 32000) - { - dirty = true; - ajSettings.setPort(Integer.parseInt(port.getText())); - } - else - { - port.setText(Long.toString(ajSettings.getPort())); - } - } - } - } - - - class NickFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - if(ajSettings.getNick().compareTo(nick.getText()) != 0) - { - dirty = true; - ajSettings.setNick(nick.getText()); - } - } - } - - - class XmlPortFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - int xmlPortNr = Integer.parseInt(xmlPort.getText()); - - if(ajSettings.getXMLPort() != Long.parseLong(xmlPort.getText())) - { - if(xmlPortNr > 1024 && xmlPortNr <= 32000) - { - dirty = true; - xmlPortDirty = true; - remote.setXmlPort(Integer.parseInt(xmlPort.getText())); - ajSettings.setXMLPort(Long.parseLong(xmlPort.getText())); - } - else - { - xmlPort.setText(Long.toString(ajSettings.getXMLPort())); - } - } - } - } - - - class HintLabel extends JLabel - { - HintLabel(Icon image) - { - super(image); - } - - public JToolTip createToolTip() - { - MultiLineToolTip tip = new MultiLineToolTip(); - - tip.setComponent(this); - return tip; - } - } - - - class SelectBrowserMouseListener extends MouseAdapter - { - public void mouseEntered(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(BorderFactory.createLineBorder(Color.black)); - } - - public void mouseClicked(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - JFileChooser fileChooser = new JFileChooser(); - - fileChooser.setDialogType(JFileChooser.FILES_ONLY); - fileChooser.setDialogTitle(label7.getText()); - if(browser.getText().length() != 0) - { - File tmpFile = new File(browser.getText()); - - if(tmpFile.isFile()) - { - fileChooser.setCurrentDirectory(tmpFile); - } - } - - int returnVal = fileChooser.showOpenDialog(source); - - if(returnVal == JFileChooser.APPROVE_OPTION) - { - File browserFile = fileChooser.getSelectedFile(); - - if(browserFile.isFile()) - { - browser.setText(browserFile.getPath()); - dirty = true; - browser.fireCheckRules(); - } - } - } - - public void mouseExited(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(null); - } - } - - - class DirectoryChooserMouseAdapter extends MouseAdapter - { - public void mouseEntered(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(BorderFactory.createLineBorder(Color.black)); - } - - public void mouseClicked(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - String title = ""; - - if(source == openTemp) - { - title = label1.getText(); - } - else - { - title = label2.getText(); - } - - ODDirectoryChooser chooser = new ODDirectoryChooser(parent, title); - - chooser.setLocation(parent.getLocation()); - chooser.setVisible(true); - if(chooser.isNewPathSelected()) - { - dirty = true; - String path = chooser.getSelectedPath(); - - if(source == openTemp) - { - temp.setText(path); - temp.fireCheckRules(); - ajSettings.setTempDir(path); - } - else - { - incoming.setText(path); - incoming.fireCheckRules(); - ajSettings.setIncomingDir(path); - } - } - } - - public void mouseExited(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(null); - } - } - - - class LevelItem - { - private Level level; - private String bezeichnung; - - public LevelItem(Level level, String bezeichnung) - { - this.level = level; - this.bezeichnung = bezeichnung; - } - - public Level getLevel() - { - return level; - } - - public String toString() - { - return bezeichnung; - } - } - - - class UpdateInfoItem - { - private int modus; - private String bezeichnung; - - public UpdateInfoItem(int modus, String bezeichnung) - { - this.modus = modus; - this.bezeichnung = bezeichnung; - } - - public int getModus() - { - return modus; - } - - public String toString() - { - return bezeichnung; - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODVerbindungPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/options/ODVerbindungPanel.java deleted file mode 100644 index 9a9e5edf..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODVerbindungPanel.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.options; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSlider; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.NumberInputVerifier; -import de.tklsoft.gui.controls.TKLButton; -import de.tklsoft.gui.controls.TKLCheckBox; -import de.tklsoft.gui.controls.TKLTextField; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODVerbindungPanel.java,v 1.7 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class ODVerbindungPanel extends JPanel implements OptionsRegister -{ - private boolean dirty = false; - private JLabel label1; - private JLabel label2; - private JLabel label3; - private JLabel label4; - private JLabel label5; - private JLabel label6; - private JLabel kbSlot; - private TKLCheckBox automaticConnect; - private TKLTextField maxSourcesPerFile = new TKLTextField(); - private TKLTextField maxVerbindungen = new TKLTextField(); - private TKLTextField maxUpload = new TKLTextField(); - private TKLTextField maxDownload = new TKLTextField(); - private JSlider kbSlider; - private TKLTextField maxVerbindungenProTurn = new TKLTextField(); - private AJSettings ajSettings; - private Logger logger; - private Icon menuIcon; - private String menuText; - private TKLButton wizzard = new TKLButton(); - private OptionsDialog parent; - - public ODVerbindungPanel(OptionsDialog parent, AJSettings ajSettings) - { - logger = Logger.getLogger(getClass()); - this.parent = parent; - this.ajSettings = ajSettings; - try - { - init(); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - public boolean isDirty() - { - return dirty; - } - - private void init() throws Exception - { - IconManager im = IconManager.getInstance(); - - menuIcon = im.getIcon("opt_verbindung"); - setLayout(new BorderLayout()); - JPanel panel1 = new JPanel(new GridBagLayout()); - - JPanel panel2 = new JPanel(new GridBagLayout()); - JPanel panel3 = new JPanel(new GridBagLayout()); - JPanel panel4 = new JPanel(new GridBagLayout()); - JPanel panel5 = new JPanel(new GridBagLayout()); - JPanel panel6 = new JPanel(new GridBagLayout()); - JPanel panel7 = new JPanel(new GridBagLayout()); - JPanel panel8 = new JPanel(new GridBagLayout()); - JPanel panel10 = new JPanel(new GridBagLayout()); - JPanel panel12 = new JPanel(new GridBagLayout()); - FlowLayout flowL = new FlowLayout(); - - flowL.setAlignment(FlowLayout.RIGHT); - JPanel panel9 = new JPanel(flowL); - - maxVerbindungen.setDocument(new NumberInputVerifier()); - maxVerbindungen.setHorizontalAlignment(JLabel.RIGHT); - maxVerbindungen.addFocusListener(new MaxVerbindungenFocusListener()); - maxUpload.setDocument(new NumberInputVerifier()); - maxUpload.setHorizontalAlignment(JLabel.RIGHT); - maxUpload.addFocusListener(new MaxUploadFocusListener()); - maxDownload.setDocument(new NumberInputVerifier()); - maxDownload.setHorizontalAlignment(JLabel.RIGHT); - maxDownload.addFocusListener(new MaxDownloadFocusListener()); - maxSourcesPerFile.setDocument(new NumberInputVerifier()); - maxSourcesPerFile.setHorizontalAlignment(JLabel.RIGHT); - maxSourcesPerFile.addFocusListener(new MaxSourcesPerFileFocusListener()); - maxVerbindungenProTurn.setDocument(new NumberInputVerifier()); - maxVerbindungenProTurn.setHorizontalAlignment(JLabel.RIGHT); - maxVerbindungenProTurn.addFocusListener(new MaxVerbindungenProTurnFocusListener()); - - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - label1 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label4.caption")); - label2 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label5.caption")); - label3 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label3")); - label4 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label13.caption")); - label5 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label5")); - label6 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label6")); - menuText = languageSelector.getFirstAttrbuteByTagName("einstform.connectionsheet.caption"); - wizzard.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.labelwizard")); - kbSlot = new JLabel(); - - int untereGrenze = (int) Math.pow((double) ajSettings.getMaxUploadInKB(), 0.2); - int obereGrenze = (int) Math.pow((double) ajSettings.getMaxUploadInKB(), 0.6); - - kbSlider = new JSlider(untereGrenze, obereGrenze); - kbSlider.setMajorTickSpacing(1); - kbSlider.setMinorTickSpacing(1); - kbSlider.setSnapToTicks(true); - kbSlider.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - JSlider slider = (JSlider) e.getSource(); - - kbSlot.setText(Integer.toString(slider.getValue()) + " kb/s"); - dirty = true; - ajSettings.setSpeedPerSlot(slider.getValue()); - } - }); - automaticConnect = new TKLCheckBox(languageSelector.getFirstAttrbuteByTagName("einstform.autoconn.caption")); - automaticConnect.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - dirty = true; - ajSettings.setAutoConnect(automaticConnect.isSelected()); - } - }); - wizzard.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - displayConnectionWizard(); - } - }); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.top = 5; - - constraints.insets.left = 5; - panel2.add(label1, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel2.add(maxVerbindungen, constraints); - constraints.weightx = 0; - - constraints.gridx = 0; - panel3.add(label2, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel3.add(maxUpload, constraints); - constraints.weightx = 0; - - constraints.gridx = 0; - panel4.add(label3, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel4.add(kbSlider, constraints); - constraints.gridx = 2; - constraints.weightx = 0; - panel4.add(kbSlot, constraints); - - constraints.gridx = 0; - panel5.add(label4, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel5.add(maxDownload, constraints); - constraints.weightx = 0; - - constraints.gridx = 0; - panel10.add(label5, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel10.add(maxVerbindungenProTurn, constraints); - constraints.weightx = 0; - - constraints.gridx = 0; - panel12.add(label6, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel12.add(maxSourcesPerFile, constraints); - constraints.weightx = 0; - - panel9.add(automaticConnect); - - constraints.gridx = 0; - constraints.weightx = 1; - constraints.gridy = 0; - constraints.insets.right = 5; - panel1.add(panel2, constraints); - constraints.gridy = 1; - panel1.add(panel3, constraints); - constraints.gridy = 2; - panel1.add(panel4, constraints); - constraints.gridy = 3; - panel1.add(panel5, constraints); - constraints.gridy = 4; - panel1.add(panel6, constraints); - constraints.gridy = 5; - panel1.add(panel7, constraints); - constraints.gridy = 6; - panel1.add(panel8, constraints); - constraints.gridy = 7; - panel1.add(panel10, constraints); - constraints.gridy = 8; - panel1.add(panel12, constraints); - constraints.gridy = 9; - panel1.add(panel9, constraints); - - constraints.gridy = 10; - JPanel panel11 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - panel11.add(wizzard); - panel1.add(panel11, constraints); - - add(panel1, BorderLayout.NORTH); - - reloadSettings(); - - maxSourcesPerFile.confirmNewValue(); - maxVerbindungen.confirmNewValue(); - maxUpload.confirmNewValue(); - maxDownload.confirmNewValue(); - maxVerbindungenProTurn.confirmNewValue(); - automaticConnect.confirmNewValue(); - } - - public Icon getIcon() - { - return menuIcon; - } - - public String getMenuText() - { - return menuText; - } - - public void displayConnectionWizard() - { - boolean regularClosed = AppleJuiceClient.showConnectionWizard(parent, ajSettings); - - if(regularClosed) - { - parent.reloadSettings(); - } - } - - public void reloadSettings() - { - AJSettings ajSettings2 = AppleJuiceClient.getAjFassade().getAJSettings(); - - /* - ajSettings.setAutoConnect(ajSettings2.isAutoConnect()); - ajSettings.setIncomingDir(ajSettings2.getIncomingDir()); - ajSettings.setMaxConnections(ajSettings2.getMaxConnections()); - ajSettings.setMaxDownload(ajSettings2.getMaxDownload()); - ajSettings.setMaxNewConnectionsPerTurn(ajSettings2.getMaxNewConnectionsPerTurn()); - ajSettings.setMaxSourcesPerFile(ajSettings2.getMaxSourcesPerFile()); - ajSettings.setMaxUpload(ajSettings2.getMaxUpload()); - ajSettings.setNick(ajSettings2.getNick()); - ajSettings.setPort(ajSettings2.getPort()); - ajSettings.setShareDirs(ajSettings2.getShareDirs()); - ajSettings.setSpeedPerSlot(ajSettings2.getSpeedPerSlot()); - ajSettings.setTempDir(ajSettings2.getTempDir()); - ajSettings.setXMLPort(ajSettings2.getXMLPort()); - */ - maxUpload.setText(Long.toString(ajSettings2.getMaxUploadInKB())); - maxDownload.setText(Long.toString(ajSettings2.getMaxDownloadInKB())); - maxVerbindungen.setText(Long.toString(ajSettings2.getMaxConnections())); - kbSlider.setValue(ajSettings2.getSpeedPerSlot()); - kbSlot.setText(Integer.toString(kbSlider.getValue()) + " kb/s"); - automaticConnect.setSelected(ajSettings2.isAutoConnect()); - maxVerbindungenProTurn.setText(Long.toString(ajSettings2.getMaxNewConnectionsPerTurn())); - maxSourcesPerFile.setText(Long.toString(ajSettings2.getMaxSourcesPerFile())); - } - - class MaxVerbindungenProTurnFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - long wert = Long.parseLong(maxVerbindungenProTurn.getText()); - - if(wert != ajSettings.getMaxNewConnectionsPerTurn()) - { - if(wert < 1 || wert > 200) - { - maxVerbindungenProTurn.setText(Long.toString(ajSettings.getMaxNewConnectionsPerTurn())); - } - else - { - dirty = true; - ajSettings.setMaxNewConnectionsPerTurn(Long.parseLong(maxVerbindungenProTurn.getText())); - } - } - } - } - - - class MaxSourcesPerFileFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - long wert = Long.parseLong(maxSourcesPerFile.getText()); - - if(wert != ajSettings.getMaxSourcesPerFile()) - { - if(wert < 1) - { - maxSourcesPerFile.setText(Long.toString(ajSettings.getMaxSourcesPerFile())); - } - else - { - dirty = true; - ajSettings.setMaxSourcesPerFile(Long.parseLong(maxSourcesPerFile.getText())); - } - } - } - } - - - class MaxDownloadFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - if(Long.parseLong(maxDownload.getText()) != ajSettings.getMaxDownloadInKB()) - { - dirty = true; - ajSettings.setMaxDownload(Long.parseLong(maxDownload.getText()) * 1024); - } - } - } - - - class MaxUploadFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - int untereGrenze = (int) Math.pow(Double.parseDouble(maxUpload.getText()), 0.2); - int obereGrenze = (int) Math.pow(Double.parseDouble(maxUpload.getText()), 0.6); - - kbSlider.setMinimum(untereGrenze); - kbSlider.setMaximum(obereGrenze); - if(Long.parseLong(maxUpload.getText()) != ajSettings.getMaxUploadInKB()) - { - dirty = true; - ajSettings.setMaxUpload(Long.parseLong(maxUpload.getText()) * 1024); - } - } - } - - - class MaxVerbindungenFocusListener extends FocusAdapter - { - public void focusLost(FocusEvent e) - { - if(Long.parseLong(maxVerbindungen.getText()) != ajSettings.getMaxConnections()) - { - dirty = true; - ajSettings.setMaxConnections(Long.parseLong(maxVerbindungen.getText())); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java b/AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java deleted file mode 100644 index 28414186..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.plugincontrol; - -import java.io.File; - -import java.util.HashSet; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.plugins.PluginConnector; -import de.applejuicenet.client.shared.PluginJarClassLoader; - -public abstract class PluginFactory -{ - private static Set<PluginConnector> plugins = null; - private static Logger logger = Logger.getLogger(PluginFactory.class); - - public static Set<PluginConnector> getPlugins() - { - if(null == plugins) - { - boolean isDebugPlugins = System.getProperty("Plugins") != null; - - if(isDebugPlugins) - { - plugins = loadPluginsFromClasspath(); - return plugins; - } - - plugins = new HashSet<PluginConnector>(); - - String path; - - if(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) - { - path = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui" + File.separator + - "plugins" + File.separator; - } - else - { - path = System.getProperty("user.dir") + File.separator + "plugins" + File.separator; - } - - File delFile = new File(path + "ajIrcPlugin_1_3.jar"); - - if(delFile.isFile()) - { - delFile.delete(); - } - - delFile = new File(path + "ajIrcPlugin_1_31.jar"); - if(delFile.isFile()) - { - delFile.delete(); - } - - delFile = new File(path + "IrcPlugin_1_31.jar"); - if(delFile.isFile()) - { - delFile.delete(); - } - - File pluginPath = new File(path); - - if(!pluginPath.isDirectory()) - { - pluginPath.mkdir(); - return plugins; - } - - String[] tempListe = pluginPath.list(); - PluginJarClassLoader jarLoader = null; - - for(int i = 0; i < tempListe.length; i++) - { - if(tempListe[i].toLowerCase().endsWith(".jar")) - { - try - { - File pluginFile = new File(path + tempListe[i]); - - if(pluginFile.isFile()) - { - ZipFile jf = new ZipFile(pluginFile); - ZipEntry entry = jf.getEntry("plugin.properties"); - - if(entry == null) - { - continue; - } - } - else - { - continue; - } - - jarLoader = new PluginJarClassLoader(); - PluginConnector aPlugin = jarLoader.getPlugin(new File(path + tempListe[i])); - - if(aPlugin != null) - { - plugins.add(aPlugin); - String nachricht = "Plugin " + aPlugin.getTitle() + " geladen..."; - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - } - } - catch(Exception e) - { - //Von einem Plugin lassen wir uns nicht beirren! ;-) - logger.error("Ein Plugin konnte nicht instanziert werden", e); - continue; - } - } - } - } - - return plugins; - } - - private static Set<PluginConnector> loadPluginsFromClasspath() - { - Set<PluginConnector> thePlugins = new HashSet<PluginConnector>(); - String[] which = new String[] { //"de.applejuicenet.client.gui.plugins.jabber.JabberTestLoader",// -// "de.applejuicenet.client.gui.plugins.versionchecker.VersioncheckerTestLoader" -// "de.applejuicenet.client.gui.plugins.serverwatcher.ServerWatcherTestLoader" -// "de.applejuicenet.client.gui.plugins.logviewer.LogViewerTestLoader" - "de.applejuicenet.client.gui.plugins.speedgraph.SpeedGraphPluginTestLoader" -// "de.applejuicenet.client.gui.plugins.ircplugin.IrcPluginTestLoader" - }; - - for(String curWhich : which) - { - PluginConnector plugin = loadPlugin(curWhich); - - if(null != plugin) - { - thePlugins.add(plugin); - String nachricht = "Plugin " + plugin.getTitle() + " geladen..."; - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - } - } - - return thePlugins; - } - - @SuppressWarnings("unchecked") - private static PluginConnector loadPlugin(String which) - { - try - { - Class pluginClass = Class.forName(which); - TestLoader testLoader = (TestLoader) pluginClass.newInstance(); - PluginConnector pluginConnector = testLoader.getPlugin(); - - return pluginConnector; - } - catch(Throwable e) - { - //Von einem Plugin lassen wir uns nicht beirren! ;-) - logger.error("Ein Plugin konnte nicht instanziert werden", e); - } - - return null; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java b/AJClientGUI/src/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java deleted file mode 100644 index 7d82e80f..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.powerdownload; - -import java.awt.Frame; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.gui.download.PowerDownloadPanel; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java,v 1.23 2009/01/28 09:44:09 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public abstract class AutomaticPowerdownloadPolicy extends Thread -{ - private Set<Thread> threads = new HashSet<Thread>(); - private Logger logger = Logger.getLogger(getClass()); - private PowerDownloadPanel parentToInformEnde = null; - private boolean paused = false; - - //diese Variable auf false setzen, um das automatische Pausieren von Dateien zu verhindern - protected boolean shouldPause = true; - protected final ApplejuiceFassade applejuiceFassade; - - public AutomaticPowerdownloadPolicy(ApplejuiceFassade applejuiceFassade) - { - this.applejuiceFassade = applejuiceFassade; - } - - public final void run() - { - try - { - if(initAction()) - { - while(!isInterrupted()) - { - if(!paused) - { - doAction(); - sleep(getSleeptime()); - } - - sleep(1000); - } - } - } - catch(InterruptedException iE) - { - if(shouldPause) - { - pauseAllDownloads(); - } - - interrupt(); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - - if(parentToInformEnde != null) - { - parentToInformEnde.autoPwdlFinished(); - parentToInformEnde = null; - } - - if(threads != null) - { - threads.clear(); - } - - logger = null; - } - - protected int getSleeptime() - { - return 30000; - } - - public final void setParentToInform(PowerDownloadPanel parentToInformEnde) - { - this.parentToInformEnde = parentToInformEnde; - } - - public final boolean shouldPause() - { - return shouldPause; - } - - public final void interrupt() - { - try - { - for(Thread curThread : threads) - { - try - { - curThread.interrupt(); - } - catch(Exception ex) - { - logger.error("Fehler beim Beenden eines Threads in " + toString(), ex); - } - } - - super.interrupt(); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - - public final synchronized void setPaused(boolean pause) - { - if(pause == paused) - { - return; - } - - paused = !paused; - if(paused) - { - pauseAllDownloads(); - try - { - informPaused(); - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - private final void pauseAllDownloads() - { - try - { - Map<Integer, Download> downloads = applejuiceFassade.getDownloadsSnapshot(); - - synchronized(downloads) - { - List<Download> dos = new ArrayList<Download>(); - - for(Download curDownload : downloads.values()) - { - dos.add(curDownload); - } - - applejuiceFassade.pauseDownload(dos); - applejuiceFassade.setPowerDownload(dos, new Integer(0)); - } - } - catch(Exception ex) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - - public final boolean isPaused() - { - return paused; - } - - /** - * Zur Instanzierung muss der Standardkonstruktor vorhanden sein!!!!! - * Ansonsten funktioniert der ganze Krams nicht!!!!! - * Laesst sich natuerlich nicht in einer abstrakten Klasse vorbauen, folglich - * muss der Entwickler dran denken!!!!! - **/ - - // public AutomaticPowerdownloadPolicy(); - - /** - * Initialisierung - * Hier koennen Initialisierungen fuer die doAction()-Methode vorgenommen werden, - * sie gehoeren nicht in den Konstruktor. - * - **/ - public abstract boolean initAction() throws Exception; - - /** - * Umsetzung der Powerdownloadverarbeitung - * Es wird nur EIN Durchlauf mit abschlieszender sleep(ms)-Anweisung(!!!) implementiert. - * Die Schleife ergibt sich durch die run()-Methode des Threads. - **/ - public abstract void doAction() throws Exception; - - /** - * Alle eigenen verwendeten Threads sollten mittels dieser Methode registriert werden. - * So ist sichergestellt, dass diese beim Beenden des Autom. Pwdl beendet werden. - **/ - protected final void addThreadToWatch(Thread aThread) - { - if(aThread != null) - { - threads.add(aThread); - } - } - - /** - * - * Wird aufgerufen um zu informieren, dass aktuell nicht mehr genug Credits - * vorhanden sind. - * So kann falls noetig darauf reagiert werden. - * - **/ - public abstract void informPaused() throws Exception; - - /** - * Versions-String - */ - public abstract String getVersion(); - - /** - * kurze Beschreibung der PowerdownloadPolicy - */ - public abstract String getDescription(); - - /** - * Name des Autors - */ - public abstract String getAuthor(); - - /** - * toString wird fuer die Ausgabe in der Combobox verwendet - */ - public abstract String toString(); - - /** - * Diese Methode ueberschreiben, wenn bei aktivierten Autom. Pwdl ein Button - * fuer Einstellungen eingeblendet werden soll - */ - public boolean hasPropertiesDialog() - { - return false; - } - - /** - * Diese Methode mit dem Öffnen und Auswerten des Einstellungendialogs ueberschreiben. - */ - public void showPropertiesDialog(Frame parent) - { - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultPanel.java deleted file mode 100644 index 2cc1ede8..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultPanel.java +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.search; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JToggleButton; -import javax.swing.SwingUtilities; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Search; -import de.applejuicenet.client.fassade.entity.SearchEntry; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.shared.FileType; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.components.table.SortButtonRenderer; -import de.applejuicenet.client.gui.components.table.SortableTableModel; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.search.table.SearchEntryIconRenderer; -import de.applejuicenet.client.gui.search.table.SearchEntrySizeRenderer; -import de.applejuicenet.client.gui.search.table.SearchTableModel; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.ReleaseInfoDialog; -import de.applejuicenet.client.shared.SoundPlayer; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultPanel.java,v 1.19 2009/02/12 13:03:34 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class SearchResultPanel extends JPanel -{ - private static String offeneSuchen = "%i offene Suchen"; - private static String gefundeneDateien = "%i gefundene Dateien"; - private static String durchsuchteClients = "%i durchsuchte Clients"; - private static String linkLaden = "Link"; - private static String sucheStoppen = "Suche stoppen"; - private static String alreadyLoaded; - private static String invalidLink; - private static String linkFailure; - private static String dialogTitel; - private static String releaseInfo; - private static String[] columns; - private Logger logger; - private JTable searchResultTable; - private SearchTableModel searchResultTableModel; - private Search search; - private JButton sucheAbbrechen = new JButton(); - private JLabel label1 = new JLabel(); - private JLabel label2 = new JLabel(); - private JLabel label3 = new JLabel(); - private JPopupMenu popup = new JPopupMenu(); - private JMenuItem item1 = new JMenuItem(); - private JMenuItem mnuReleaseInfo = new JMenuItem(); - private JToggleButton[] filterButtons; - private TableColumn[] tableColumns = new TableColumn[3]; - - public SearchResultPanel(Search aSearch) - { - search = aSearch; - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public Search getSearch() - { - return search; - } - - private void init() throws Exception - { - IconManager im = IconManager.getInstance(); - - item1.setText(linkLaden); - item1.setIcon(im.getIcon("download")); - sucheAbbrechen.setText(sucheStoppen); - sucheAbbrechen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - sucheAbbrechen.setEnabled(false); - try - { - AppleJuiceClient.getAjFassade().cancelSearch(search); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }); - popup.add(item1); - - mnuReleaseInfo.setIcon(im.getIcon("hint")); - mnuReleaseInfo.setText(releaseInfo); - mnuReleaseInfo.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - int[] sel = searchResultTable.getSelectedRows(); - - if(null == sel || sel.length < 1) - { - return; - } - - SearchEntry curSearchEntry = searchResultTableModel.getRow(sel[0]); - - ReleaseInfoDialog.showReleaseInfo(curSearchEntry.getChecksumme(), true, - curSearchEntry.getFileNames()[0].getDateiName(), curSearchEntry.getGroesse()); - } - }); - popup.add(mnuReleaseInfo); - setLayout(new BorderLayout()); - updateZahlen(); - JPanel buttonPanel = new JPanel(new FlowLayout()); - JButton all = new JButton(IconManager.getInstance().getIcon("abbrechen")); - - buttonPanel.add(all); - - FileType[] allTypes = FileType.values(); - - filterButtons = new JToggleButton[allTypes.length]; - for(int i = 0; i < allTypes.length; i++) - { - filterButtons[i] = new JToggleButton(IconManager.getInstance().getIcon(allTypes[i].toString())); - filterButtons[i].addActionListener(new FilterAdapter(allTypes[i])); - buttonPanel.add(filterButtons[i]); - } - - all.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - for(int i = 0; i < filterButtons.length; i++) - { - filterButtons[i].setSelected(false); - } - - search.clearFilter(); - searchResultTableModel.fireTableDataChanged(); - } - }); - - add(buttonPanel, BorderLayout.NORTH); - searchResultTableModel = new SearchTableModel(search); - searchResultTable = new JTable(searchResultTableModel); - - searchResultTable.setDefaultRenderer(SearchEntry.class, new SearchEntryIconRenderer()); - searchResultTable.setDefaultRenderer(Long.class, new SearchEntrySizeRenderer()); - - add(new JScrollPane(searchResultTable), BorderLayout.CENTER); - JPanel southPanel = new JPanel(new BorderLayout()); - JPanel textPanel = new JPanel(new FlowLayout()); - - textPanel.add(label1); - textPanel.add(label2); - textPanel.add(label3); - - JPanel panel1 = new JPanel(new FlowLayout()); - - panel1.add(sucheAbbrechen); - southPanel.add(panel1, BorderLayout.WEST); - southPanel.add(textPanel, BorderLayout.CENTER); - add(southPanel, BorderLayout.SOUTH); - MouseAdapter popupMouseAdapter = new MouseAdapter() - { - public void mousePressed(MouseEvent me) - { - if(SwingUtilities.isRightMouseButton(me)) - { - Point p = me.getPoint(); - int row = searchResultTable.rowAtPoint(p); - - if(row != -1 && !searchResultTable.getSelectionModel().isSelectedIndex(row)) - { - searchResultTable.getSelectionModel().setSelectionInterval(row, row); - } - } - - maybeShowPopup(me); - } - - public void mouseReleased(MouseEvent e) - { - super.mouseReleased(e); - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { - if(e.isPopupTrigger()) - { - int[] sel = searchResultTable.getSelectedRows(); - - if(null != sel && sel.length > 0) - { - popup.show(searchResultTable, e.getX(), e.getY()); - } - } - } - }; - - searchResultTable.addMouseListener(popupMouseAdapter); - item1.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - int[] sel = searchResultTable.getSelectedRows(); - - if(null != sel && sel.length > 0) - { - SearchEntry curSearchEntry; - - for(int curRow : sel) - { - curSearchEntry = searchResultTableModel.getRow(curRow); - StringBuilder toCopy = new StringBuilder(); - - toCopy.append("ajfsp://file|"); - toCopy.append(curSearchEntry.getFileNames()[0].getDateiName() + "|" + curSearchEntry.getChecksumme() + "|" + - curSearchEntry.getGroesse() + "/"); - String link = toCopy.toString(); - - processLink(link); - } - } - } - }); - - TableColumnModel model = searchResultTable.getColumnModel(); - SortButtonRenderer renderer = new SortButtonRenderer(); - - for(int i = 0; i < tableColumns.length; i++) - { - tableColumns[i] = model.getColumn(i); - tableColumns[i].setHeaderRenderer(renderer); - } - - JTableHeader header = searchResultTable.getTableHeader(); - - SortMouseAdapter sortMouseAdapter = new SortMouseAdapter(header, renderer); - - header.addMouseListener(sortMouseAdapter); - - PositionManager pm = PositionManagerImpl.getInstance(); - int[] sort = pm.getSearchSort(); - - sortMouseAdapter.sort(sort[0], sort[1] == 1); - if(!search.isRunning()) - { - sucheAbbrechen.setEnabled(false); - } - } - - private void processLink(final String link) - { - new Thread() - { - public void run() - { - try - { - final String result = AppleJuiceClient.getAjFassade().processLink(link, ""); - - SoundPlayer.getInstance().playSound(SoundPlayer.LADEN); - if(result.indexOf("ok") != 0) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - String message = null; - - if(result.indexOf("already downloaded") != -1) - { - message = alreadyLoaded.replaceAll("%s", link); - } - else if(result.indexOf("incorrect link") != -1) - { - message = invalidLink.replaceAll("%s", link); - } - else if(result.indexOf("failure") != -1) - { - message = linkFailure; - } - - if(message != null) - { - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message, dialogTitel, - JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); - } - } - }); - } - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }.start(); - } - - public static void setTexte(String[] texte, String[] tableColumns) - { - offeneSuchen = texte[0]; - gefundeneDateien = texte[1]; - durchsuchteClients = texte[2]; - linkLaden = texte[3]; - sucheStoppen = texte[4]; - alreadyLoaded = texte[5]; - invalidLink = texte[6]; - linkFailure = texte[7]; - dialogTitel = texte[8]; - releaseInfo = texte[9]; - columns = tableColumns; - } - - public void updateSearchContent() - { - if(!SwingUtilities.isEventDispatchThread()) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - updateSearchContent(); - - } - }); - return; - } - - try - { - searchResultTableModel.forceResort(); - searchResultTable.updateUI(); - updateZahlen(); - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - public void updateZahlen() - { - if(!SwingUtilities.isEventDispatchThread()) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - updateZahlen(); - - } - }); - return; - } - - List<SearchEntry> searchEntries = search.getAllSearchEntries(); - - label1.setText(offeneSuchen.replaceFirst("%i", Integer.toString(search.getOffeneSuchen()))); - label2.setText(gefundeneDateien.replaceFirst("%i", Integer.toString(searchEntries.size()))); - label3.setText(durchsuchteClients.replaceFirst("%i", Integer.toString(search.getDurchsuchteClients()))); - } - - public void aendereSprache() - { - try - { - item1.setText(linkLaden); - mnuReleaseInfo.setText(releaseInfo); - sucheAbbrechen.setText(sucheStoppen); - label1.setText(offeneSuchen.replaceFirst("%i", Integer.toString(search.getOffeneSuchen()))); - label2.setText(gefundeneDateien.replaceFirst("%i", Long.toString(search.getEntryCount()))); - label3.setText(durchsuchteClients.replaceFirst("%i", Integer.toString(search.getDurchsuchteClients()))); - TableColumnModel tcm = searchResultTable.getColumnModel(); - - for(int i = 0; i < tcm.getColumnCount(); i++) - { - tcm.getColumn(i).setHeaderValue(columns[i]); - } - } - catch(Exception e) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - - class SortMouseAdapter extends MouseAdapter - { - private JTableHeader header; - private SortButtonRenderer renderer; - private PositionManager pm = PositionManagerImpl.getInstance(); - - public SortMouseAdapter(JTableHeader header, SortButtonRenderer renderer) - { - this.header = header; - this.renderer = renderer; - header.repaint(); - } - - public void mouseClicked(MouseEvent e) - { - if(e.getButton() != MouseEvent.BUTTON1) - { - return; - } - - int col = header.columnAtPoint(e.getPoint()); - int curSelectedColumn = renderer.getSelectedColumn(); - boolean ascent; - - if(col == curSelectedColumn) - { - ascent = !renderer.getState(); - } - else - { - ascent = true; - } - - pm.setSearchSort(col, ascent); - sort(col, ascent); - } - - @SuppressWarnings("unchecked") - public void sort(int column, boolean ascent) - { - renderer.setSelectedColumn(column, ascent); - header.repaint(); - - if(header.getTable().isEditing()) - { - header.getTable().getCellEditor().stopCellEditing(); - } - - int sortCol = header.getTable().convertColumnIndexToModel(column); - - ((SortableTableModel) header.getTable().getModel()).sortByColumn(sortCol, ascent); - header.repaint(); - } - } - - - private class FilterAdapter implements ActionListener - { - private FileType filter; - - public FilterAdapter(FileType newFilter) - { - filter = newFilter; - } - - public void actionPerformed(ActionEvent ae) - { - JToggleButton source = (JToggleButton) ae.getSource(); - - if(source.isSelected()) - { - search.removeFilter(filter); - } - else - { - search.addFilter(filter); - } - - searchResultTableModel.fireTableDataChanged(); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/server/NewServerDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/server/NewServerDialog.java deleted file mode 100644 index c3addacf..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/server/NewServerDialog.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.server; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.shared.NumberInputVerifier; -import de.applejuicenet.client.shared.SoundPlayer; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/server/NewServerDialog.java,v 1.5 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r <aj@tkl-soft.de> - * - */ -public class NewServerDialog extends JDialog -{ - private JButton ok = new JButton(); - private JTextField dyn = new JTextField(); - private JTextField port = new JTextField(); - private boolean legal = false; - private String link = ""; - private Logger logger; - - public NewServerDialog(Frame parent, boolean modal) - { - super(parent, modal); - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - close(); - } - }); - - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - setTitle(languageSelector.getFirstAttrbuteByTagName("addserverform.caption")); - ok.setText(languageSelector.getFirstAttrbuteByTagName("addserverform.okbtn.caption")); - dyn.setColumns(15); - port.setColumns(5); - port.setDocument(new NumberInputVerifier()); - getContentPane().setLayout(new BorderLayout()); - JPanel panel2 = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 5; - panel2.add(new JLabel(languageSelector.getFirstAttrbuteByTagName("addserverform.serverlbl.caption") + ": "), constraints); - constraints.gridy = 1; - panel2.add(new JLabel(languageSelector.getFirstAttrbuteByTagName("addserverform.portlbl.caption") + ": "), constraints); - constraints.insets.left = 0; - constraints.gridx = 1; - constraints.gridy = 0; - panel2.add(dyn, constraints); - constraints.gridy = 1; - panel2.add(port, constraints); - getContentPane().add(panel2, BorderLayout.CENTER); - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - panel1.add(ok); - getContentPane().add(panel1, BorderLayout.SOUTH); - pack(); - port.addKeyListener(new KeyAdapter() - { - public void keyPressed(KeyEvent ke) - { - if(ke.getKeyCode() == KeyEvent.VK_ENTER) - { - ok.doClick(); - } - } - }); - ok.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(dyn.getText().length() > 0 && port.getText().length() > 0) - { - legal = true; - link = "ajfsp://server|" + dyn.getText() + "|" + port.getText(); - close(); - } - } - }); - SoundPlayer.getInstance().playSound(SoundPlayer.KONKRETISIEREN); - } - - private void close() - { - dispose(); - } - - public String getLink() - { - return link; - } - - public boolean isLegal() - { - return legal; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/server/ServerPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/server/ServerPanel.java deleted file mode 100644 index 87b5a2a2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/server/ServerPanel.java +++ /dev/null @@ -1,625 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.server; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.fassade.shared.NetworkInfo; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.RegisterI; -import de.applejuicenet.client.gui.components.table.HeaderListener; -import de.applejuicenet.client.gui.components.table.SortButtonRenderer; -import de.applejuicenet.client.gui.components.table.SortableTableModel; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.gui.server.table.ServerTableCellRenderer; -import de.applejuicenet.client.gui.server.table.ServerTableDateCellRenderer; -import de.applejuicenet.client.gui.server.table.ServerTableModel; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.SoundPlayer; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/ServerPanel.java,v - * 1.57 2004/06/11 09:24:30 maj0r Exp $ - * - * <p> - * Titel: AppleJuice Client-GUI - * </p> - * <p> - * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - * </p> - * <p> - * Copyright: General Public License - * </p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class ServerPanel extends JPanel implements LanguageListener, DataUpdateListener, RegisterI -{ - private static ServerPanel instance; - private JTable serverTable; - private JButton sucheServer = new JButton(); - private JPopupMenu popup = new JPopupMenu(); - private JPopupMenu popup2 = new JPopupMenu(); - private JPopupMenu popup3 = new JPopupMenu(); - private JMenuItem verbinden; - private JMenuItem loeschen1; - private JMenuItem hinzufuegen2; - private JMenuItem hinzufuegen3; - private JMenuItem hinzufuegen1; - private JMenuItem loeschen2; - private JMenuItem itemCopyToClipboard; - private JLabel verbunden = new JLabel(); - private JLabel versucheZuVerbinden = new JLabel(); - private JLabel aelter24h = new JLabel(); - private JLabel juenger24h = new JLabel(); - private Logger logger; - private boolean initialized = false; - private String warnungTitel; - private String warnungNachricht; - private boolean tabSelected; - - private ServerPanel() - { - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public static synchronized ServerPanel getInstance() - { - if(instance == null) - { - instance = new ServerPanel(); - } - - return instance; - } - - private void init() throws Exception - { - setLayout(new BorderLayout()); - LanguageSelector.getInstance().addLanguageListener(this); - - sucheServer.setForeground(Color.BLUE); - IconManager im = IconManager.getInstance(); - - verbinden = new JMenuItem(); - verbinden.setIcon(im.getIcon("serververbinden")); - hinzufuegen1 = new JMenuItem(); - hinzufuegen1.setIcon(im.getIcon("serverneu")); - loeschen1 = new JMenuItem(); - loeschen1.setIcon(im.getIcon("serverloeschen")); - hinzufuegen2 = new JMenuItem(); - hinzufuegen2.setIcon(im.getIcon("serverneu")); - hinzufuegen3 = new JMenuItem(); - hinzufuegen3.setIcon(im.getIcon("serverneu")); - loeschen2 = new JMenuItem(); - loeschen2.setIcon(im.getIcon("serverloeschen")); - itemCopyToClipboard = new JMenuItem(); - itemCopyToClipboard.setIcon(im.getIcon("clipboard")); - - popup.add(verbinden); - popup.add(hinzufuegen3); - popup.add(itemCopyToClipboard); - popup.add(loeschen1); - popup2.add(hinzufuegen2); - popup3.add(hinzufuegen1); - popup3.add(loeschen2); - verbinden.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - int selected = serverTable.getSelectedRow(); - Server server = (Server) ((ServerTableModel) serverTable.getModel()).getRow(selected); - ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); - - if(af.getInformation().getVerbindungsStatus() == Information.VERBUNDEN) - { - NetworkInfo netInfo = af.getNetworkInfo(); - long timestamp = af.getLastCoreTimestamp().longValue(); - - if(timestamp == 0) - { - /* - * Es wurden noch keine Referenzdaten geholt. Wir nehmen - * die eigene Zeit, in der Hoffnung, dass die - * uebereinstimmen. - */ - timestamp = System.currentTimeMillis(); - } - - long timeDiff = timestamp - netInfo.getConnectionTime(); - int minuten = (int) (timeDiff / 60000); - - if(minuten < 0) - { - minuten = 0; - } - - if(minuten <= 30) - { - String tmp = warnungNachricht.replaceAll("%s", Integer.toString(minuten)); - int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), tmp, warnungTitel, - JOptionPane.YES_NO_OPTION); - - if(result != JOptionPane.YES_OPTION) - { - return; - } - } - } - - try - { - AppleJuiceClient.getAjFassade().connectToServer(server); - SoundPlayer.getInstance().playSound(SoundPlayer.VERBINDEN); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }); - - ActionListener loescheServerListener = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - int[] selected = serverTable.getSelectedRows(); - - if(selected.length > 0) - { - Server server = null; - List<Server> toRemove = new Vector<Server>(); - - for(int i = 0; i < selected.length; i++) - { - server = (Server) ((ServerTableModel) serverTable.getModel()).getRow(selected[i]); - if(server != null) - { - toRemove.add(server); - } - } - - try - { - AppleJuiceClient.getAjFassade().entferneServer(toRemove); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - }; - - ActionListener clipboardListener = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - int[] selectedItems = serverTable.getSelectedRows(); - - if(selectedItems.length == 1) - { - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer toCopy = new StringBuffer(); - - toCopy.append("ajfsp://server|"); - Server server = (Server) ((ServerTableModel) serverTable.getModel()).getRow(selectedItems[0]); - - toCopy.append(server.getHost()); - toCopy.append("|"); - toCopy.append(server.getPort()); - toCopy.append("/"); - StringSelection contents = new StringSelection(toCopy.toString()); - - cb.setContents(contents, null); - } - } - }; - - itemCopyToClipboard.addActionListener(clipboardListener); - loeschen1.addActionListener(loescheServerListener); - loeschen2.addActionListener(loescheServerListener); - ActionListener newServerListener = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - NewServerDialog newServerDialog = new NewServerDialog(AppleJuiceDialog.getApp(), true); - Dimension appDimension = newServerDialog.getSize(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - newServerDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); - newServerDialog.setVisible(true); - if(newServerDialog.isLegal()) - { - final String link = newServerDialog.getLink(); - - new Thread() - { - public void run() - { - try - { - AppleJuiceClient.getAjFassade().processLink(link, ""); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - }.start(); - } - } - }; - - hinzufuegen2.addActionListener(newServerListener); - hinzufuegen3.addActionListener(newServerListener); - hinzufuegen1.addActionListener(newServerListener); - - JPanel panel1 = new JPanel(); - - panel1.setLayout(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - - sucheServer.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - Thread worker = new Thread() - { - public void run() - { - ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); - String[] server = af.getNetworkKnownServers(); - - if(server == null || server.length == 0) - { - return; - } - - for(int i = 0; i < server.length; i++) - { - try - { - af.processLink(server[i], ""); - } - catch(IllegalArgumentException e) - { - logger.error(e); - } - } - } - }; - - worker.start(); - } - }); - panel1.add(sucheServer, constraints); - constraints.gridx = 1; - constraints.weightx = 1; - panel1.add(new JLabel(), constraints); - add(panel1, BorderLayout.NORTH); - serverTable = new JTable(); - serverTable.setModel(new ServerTableModel()); - serverTable.setShowGrid(false); - serverTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - SortButtonRenderer renderer = new SortButtonRenderer(); - TableColumnModel model = serverTable.getColumnModel(); - int n = model.getColumnCount(); - - for(int i = 0; i < n; i++) - { - model.getColumn(i).setHeaderRenderer(renderer); - model.getColumn(i).setPreferredWidth(model.getColumn(i).getWidth()); - } - - JTableHeader header = serverTable.getTableHeader(); - - header.addMouseListener(new HeaderListener(header, renderer) - { - private PositionManager pm = PositionManagerImpl.getInstance(); - - @Override - public void internalSort(int column, boolean ascent) - { - pm.setServerSort(column, ascent); - - super.internalSort(column, ascent); - } - }); - - serverTable.setDefaultRenderer(Server.class, new ServerTableCellRenderer()); - serverTable.setDefaultRenderer(Date.class, new ServerTableDateCellRenderer()); - final JScrollPane aScrollPane = new JScrollPane(serverTable); - - aScrollPane.setBackground(serverTable.getBackground()); - serverTable.getTableHeader().setBackground(serverTable.getBackground()); - aScrollPane.getViewport().setOpaque(false); - MouseAdapter popupMouseAdapter = new MouseAdapter() - { - public void mousePressed(MouseEvent me) - { - super.mouseReleased(me); - maybeShowPopup(me); - } - - public void mouseReleased(MouseEvent e) - { - super.mouseReleased(e); - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { - if(e.isPopupTrigger()) - { - int selectedRow = serverTable.rowAtPoint(e.getPoint()); - - if(selectedRow != -1) - { - if(serverTable.getSelectedRowCount() == 0) - { - serverTable.setRowSelectionInterval(selectedRow, selectedRow); - } - else - { - int[] currentSelectedRows = serverTable.getSelectedRows(); - - for(int i = 0; i < currentSelectedRows.length; i++) - { - if(currentSelectedRows[i] == selectedRow) - { - selectedRow = -1; - break; - } - } - - if(selectedRow != -1) - { - serverTable.setRowSelectionInterval(selectedRow, selectedRow); - } - } - } - - if(serverTable.getSelectedRowCount() == 1) - { - popup.show(serverTable, e.getX(), e.getY()); - } - else if(serverTable.getSelectedRowCount() > 1) - { - popup3.show(serverTable, e.getX(), e.getY()); - } - else - { - popup2.show(serverTable, e.getX(), e.getY()); - } - } - } - }; - - aScrollPane.addMouseListener(popupMouseAdapter); - serverTable.addMouseListener(popupMouseAdapter); - add(aScrollPane, BorderLayout.CENTER); - JPanel legende = new JPanel(new FlowLayout()); - ImageIcon icon1 = im.getIcon("serververbunden"); - ImageIcon icon2 = im.getIcon("serverversuche"); - ImageIcon icon3 = im.getIcon("aelter24h"); - ImageIcon icon4 = im.getIcon("juenger24h"); - JLabel label1 = new JLabel(icon1); - JLabel label2 = new JLabel(icon2); - JLabel label3 = new JLabel(icon3); - JLabel label4 = new JLabel(icon4); - - legende.add(label1); - legende.add(verbunden); - legende.add(label2); - legende.add(versucheZuVerbinden); - legende.add(label3); - legende.add(aelter24h); - legende.add(label4); - legende.add(juenger24h); - add(legende, BorderLayout.SOUTH); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.SERVER_CHANGED); - } - - public void registerSelected() - { - tabSelected = true; - try - { - if(!initialized) - { - initialized = true; - TableColumnModel headerModel = serverTable.getTableHeader().getColumnModel(); - int columnCount = headerModel.getColumnCount(); - PositionManager pm = PositionManagerImpl.getInstance(); - int[] sort = pm.getServerSort(); - - if(pm.isLegal()) - { - int[] widths = pm.getServerWidths(); - - for(int i = 0; i < columnCount; i++) - { - headerModel.getColumn(i).setPreferredWidth(widths[i]); - } - } - else - { - for(int i = 0; i < columnCount; i++) - { - headerModel.getColumn(i).setPreferredWidth(serverTable.getWidth() / columnCount); - } - } - - if(null != sort) - { - for(MouseListener curMl : serverTable.getTableHeader().getMouseListeners()) - { - if(curMl instanceof HeaderListener) - { - ((HeaderListener) curMl).sort(sort[0], sort[1] == 1); - } - } - } - - serverTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - @SuppressWarnings("unchecked") - public void fireContentChanged(DATALISTENER_TYPE type, final Object content) - { - if(type == DATALISTENER_TYPE.SERVER_CHANGED) - { - boolean changed = ((ServerTableModel) serverTable.getModel()).setTable((HashMap<String, Server>) content); - - if(changed && tabSelected) - { - ((SortableTableModel) serverTable.getModel()).forceResort(); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - serverTable.updateUI(); - - } - }); - } - } - } - - public void fireLanguageChanged() - { - try - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - sucheServer.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label11.caption")); - String[] columns = new String[5]; - - columns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col0caption"); - columns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col1caption"); - columns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col3caption"); - columns[3] = languageSelector.getFirstAttrbuteByTagName("javagui.serverform.col4caption"); - columns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col5caption"); - verbinden.setText(languageSelector.getFirstAttrbuteByTagName("mainform.connserv.caption")); - loeschen1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.delserv.caption")); - hinzufuegen2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); - hinzufuegen3.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); - hinzufuegen1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); - loeschen2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.delserv.caption")); - verbunden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.verbunden")); - versucheZuVerbinden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.verbinden")); - aelter24h.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.aelter24h")); - juenger24h.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.juenger24h")); - warnungTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); - warnungNachricht = languageSelector.getFirstAttrbuteByTagName("javagui.serverform.warnungnachricht"); - itemCopyToClipboard.setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); - - TableColumnModel tcm = serverTable.getColumnModel(); - - for(int i = 0; i < tcm.getColumnCount(); i++) - { - tcm.getColumn(i).setHeaderValue(columns[i]); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public int[] getColumnWidths() - { - TableColumnModel tcm = serverTable.getColumnModel(); - int[] widths = new int[tcm.getColumnCount()]; - - for(int i = 0; i < tcm.getColumnCount(); i++) - { - widths[i] = tcm.getColumn(i).getWidth(); - } - - return widths; - } - - public void lostSelection() - { - tabSelected = false; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/DateiListeDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/share/DateiListeDialog.java deleted file mode 100644 index 4a65301e..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/DateiListeDialog.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.share; - -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Point; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.FileWriter; - -import javax.swing.BorderFactory; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.gui.components.dragndrop.DndTargetAdapter; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.share.table.DateiListeTableModel; -import de.applejuicenet.client.gui.share.table.ShareNode; -import de.applejuicenet.client.shared.IconManager; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/DateiListeDialog.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ - * - * <p>Titel: AppleJuice Client-GUI</p> - * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> - * <p>Copyright: General Public License</p> - * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class DateiListeDialog extends JDialog -{ - private JLabel speicherTxt = new JLabel(); - private JLabel speicherHtml = new JLabel(); - private JTable table = new JTable(); - private JLabel text = new JLabel(); - private JPopupMenu popup = new JPopupMenu(); - private Logger logger; - - public DateiListeDialog(Frame parent, boolean modal) - { - super(parent, modal); - logger = Logger.getLogger(getClass()); - init(); - } - - private void removeSelectedColumn() - { - int[] selected = table.getSelectedRows(); - - if(selected.length > 0) - { - DateiListeTableModel model = (DateiListeTableModel) table.getModel(); - - for(int i = selected.length - 1; i >= 0; i--) - { - model.removeRow(selected[i]); - } - } - } - - private void init() - { - try - { - JMenuItem entfernen = new JMenuItem(); - - entfernen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - removeSelectedColumn(); - } - }); - popup.add(entfernen); - table.setModel(new DateiListeTableModel()); - table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - getContentPane().setLayout(new GridBagLayout()); - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - IconManager im = IconManager.getInstance(); - - speicherTxt.setIcon(im.getIcon("speichern")); - speicherTxt.addMouseListener(new SpeichernMouseAdapter()); - speicherHtml.setIcon(im.getIcon("web")); - speicherHtml.addMouseListener(new SpeichernMouseAdapter()); - panel1.add(speicherTxt); - panel1.add(speicherHtml); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.weightx = 1; - getContentPane().add(panel1, constraints); - constraints.weightx = 0; - constraints.gridy = 1; - getContentPane().add(text, constraints); - constraints.gridy = 2; - constraints.weighty = 1; - JScrollPane scroll = new JScrollPane(table); - - scroll.setDropTarget(new DropTarget(scroll, new ListeDndTargetAdapter())); - table.setDropTarget(new DropTarget(table, new ListeDndTargetAdapter())); - table.addKeyListener(new KeyAdapter() - { - public void keyPressed(KeyEvent ke) - { - if(ke.getKeyCode() == KeyEvent.VK_DELETE) - { - removeSelectedColumn(); - } - else - { - super.keyPressed(ke); - } - } - }); - table.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent me) - { - if(SwingUtilities.isRightMouseButton(me)) - { - Point p = me.getPoint(); - int iRow = table.rowAtPoint(p); - int iCol = table.columnAtPoint(p); - - table.setRowSelectionInterval(iRow, iRow); - table.setColumnSelectionInterval(iCol, iCol); - } - - maybeShowPopup(me); - } - - public void mouseReleased(MouseEvent e) - { - super.mouseReleased(e); - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { - if(e.isPopupTrigger() && table.getSelectedRowCount() > 0) - { - popup.show(table, e.getX(), e.getY()); - } - } - }); - getContentPane().add(scroll, constraints); - constraints.weighty = 0; - initLanguage(); - pack(); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - public void initLanguage() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - setTitle(languageSelector.getFirstAttrbuteByTagName("linklist.caption")); - text.setText(languageSelector.getFirstAttrbuteByTagName("linklist.Label1.caption")); - String[] tableColumns = new String[2]; - - tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("linklist.files.col0caption"); - tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("linklist.files.col1caption"); - TableColumnModel tcm = table.getColumnModel(); - - for(int i = 0; i < tableColumns.length; i++) - { - tcm.getColumn(i).setHeaderValue(tableColumns[i]); - } - } - - class SpeichernMouseAdapter extends MouseAdapter - { - public void mouseEntered(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(BorderFactory.createLineBorder(Color.black)); - } - - public void mouseClicked(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - JFileChooser fileChooser = new JFileChooser(); - - fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); - if(source == speicherTxt) - { - fileChooser.setFileFilter(new TxtFileFilter()); - } - else - { - fileChooser.setFileFilter(new HtmlFileFilter()); - } - - int i = fileChooser.showSaveDialog(DateiListeDialog.this); - - if(i == JFileChooser.APPROVE_OPTION) - { - File file = fileChooser.getSelectedFile(); - StringBuffer text = new StringBuffer(); - Share[] share = ((DateiListeTableModel) table.getModel()).getShares(); - - if(source != speicherTxt) - { - if(!file.getPath().toLowerCase().endsWith(".htm") && !file.getPath().toLowerCase().endsWith(".html")) - { - file = new File(file.getPath() + ".html"); - } - - text.append("<html><head><title>appleJuice Linklist
" + - "\r\n"); - Share[] sortedShareDOs = sortShares(share); - - for(int x = 0; x < share.length; x++) - { - text.append("" + "\r\n"); - } - - text.append("
appleJuice Dateien
"); - text.append(sortedShareDOs[x].getShortfilename()); - text.append("
"); - } - else - { - if(!file.getPath().toLowerCase().endsWith(".ajl")) - { - file = new File(file.getPath() + ".ajl"); - } - - text.append("\r\n" + "Du benoetigst ein appleJuice-GUI, um diese Datei zu oeffnen. Das gibts z.B. hier " + - "http://developer.berlios.de/projects/applejuicejava/" + "\r\n\r\n"); - text.append("Diese Datei darf nicht modifiziert werden!" + "\r\n" + "-----\r\n100\r\n"); - Share[] sortedShares = sortShares(share); - - for(int x = 0; x < sortedShares.length; x++) - { - text.append(sortedShares[x].getShortfilename() + "\r\n"); - text.append(sortedShares[x].getCheckSum() + "\r\n"); - text.append(sortedShares[x].getSize() + "\r\n"); - } - } - - try - { - FileWriter fileWriter = new FileWriter(file); - - fileWriter.write(text.toString()); - fileWriter.close(); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - } - - private Share[] sortShares(Share[] share) - { - Share[] sortedDOs = share; - int n = sortedDOs.length; - Share tmp; - - for(int i = 0; i < n - 1; i++) - { - int k = i; - - for(int j = i + 1; j < n; j++) - { - if(sortedDOs[j].getShortfilename().compareToIgnoreCase(sortedDOs[k].getShortfilename()) < 0) - { - k = j; - } - } - - tmp = sortedDOs[i]; - sortedDOs[i] = sortedDOs[k]; - sortedDOs[k] = tmp; - } - - return sortedDOs; - } - - public void mouseExited(MouseEvent e) - { - JLabel source = (JLabel) e.getSource(); - - source.setBorder(null); - } - } - - - class TxtFileFilter extends FileFilter - { - public boolean accept(File file) - { - if(!file.isFile()) - { - return true; - } - else - { - String name = file.getName(); - - return (name.toLowerCase().endsWith(".ajl")); - } - } - - public String getDescription() - { - return "AJL-Dateien"; - } - } - - - class HtmlFileFilter extends FileFilter - { - public boolean accept(File file) - { - if(!file.isFile()) - { - return true; - } - else - { - String name = file.getName(); - - return (name.toLowerCase().endsWith(".htm") || name.toLowerCase().endsWith(".html")); - } - } - - public String getDescription() - { - return "HTML-Dateien"; - } - } - - - private class ListeDndTargetAdapter extends DndTargetAdapter - { - protected Object getTarget(Point point) - { - return this; - } - - public void drop(DropTargetDropEvent event) - { - Transferable tr = event.getTransferable(); - - if(tr.isDataFlavorSupported(new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, "ShareNodesTransferer"))) - { - try - { - event.acceptDrop(DnDConstants.ACTION_COPY); - Object[] transfer = (Object[]) tr.getTransferData(new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, - "ShareNodesTransferer")); - - if(transfer != null && transfer.length != 0) - { - DateiListeTableModel model = (DateiListeTableModel) table.getModel(); - - for(int i = 0; i < transfer.length; i++) - { - model.addNodes((ShareNode) transfer[i]); - } - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - - event.getDropTargetContext().dropComplete(false); - } - } - - event.getDropTargetContext().dropComplete(true); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/SharePanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/share/SharePanel.java deleted file mode 100644 index 49b12455..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/SharePanel.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.share; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; - -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.JSplitPane; -import javax.swing.ListSelectionModel; -import javax.swing.border.TitledBorder; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumnModel; -import javax.swing.tree.DefaultTreeModel; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.TklPanel; -import de.applejuicenet.client.gui.components.table.NormalHeaderRenderer; -import de.applejuicenet.client.gui.components.tree.WaitNode; -import de.applejuicenet.client.gui.share.table.ShareNode; -import de.applejuicenet.client.gui.share.table.ShareTable; -import de.applejuicenet.client.gui.share.table.ShareTableModel; -import de.applejuicenet.client.gui.share.tree.DirectoryTree; -import de.applejuicenet.client.gui.share.tree.ShareSelectionTreeCellRenderer; -import de.applejuicenet.client.shared.IconManager; - -import de.tklsoft.gui.controls.TKLButton; -import de.tklsoft.gui.controls.TKLComboBox; -import de.tklsoft.gui.layout.Synchronizer; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/SharePanel.java,v 1.13 2009/02/12 09:11:24 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class SharePanel extends TklPanel -{ - private JPanel panelCenter; - private DirectoryTree folderTree = new DirectoryTree(); - private TitledBorder folderTreeBolder; - private TitledBorder mailPanelBolder; - private JLabel dateien = new JLabel(); - private TKLButton neueListe = new TKLButton(); - private TKLButton neuLaden = new TKLButton(); - private TKLButton refresh = new TKLButton(); - private TKLButton prioritaetSetzen = new TKLButton(); - private TKLButton prioritaetAufheben = new TKLButton(); - private TKLComboBox cmbPrio = new TKLComboBox(); - private AJSettings ajSettings; - private ShareTable shareTable; - private ShareTableModel shareModel; - private JPopupMenu popup = new JPopupMenu(); - private JMenuItem sharedwsub; - private JMenuItem sharedwosub; - private JMenuItem notshared; - private JPopupMenu popup2 = new JPopupMenu(); - private JMenuItem itemReleaseInfo = new JMenuItem(); - private JMenuItem itemCopyToClipboard = new JMenuItem(); - private JMenuItem itemCopyToClipboardWithSources = new JMenuItem(); - private JMenuItem itemCopyToClipboardAsUBBCode = new JMenuItem(); - private JMenuItem itemOpenWithProgram = new JMenuItem(); - private JMenuItem itemOpenWithStandardProgramm = new JMenuItem(); - private Logger logger; - - public SharePanel(GuiController guiController) - { - super(guiController); - logger = Logger.getLogger(getClass()); - try - { - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public JMenuItem getMnuOpenWithStandardProgram() - { - return itemOpenWithStandardProgramm; - } - - public TKLButton getBtnPrioritaetAufheben() - { - return prioritaetAufheben; - } - - public TKLButton getBtnPrioritaetSetzen() - { - return prioritaetSetzen; - } - - public TKLButton getBtnNeuLaden() - { - return neuLaden; - } - - public TKLButton getBtnRefresh() - { - return refresh; - } - - public TKLButton getBtnNeueListe() - { - return neueListe; - } - - public JMenuItem getMnuNotShared() - { - return notshared; - } - - public JMenuItem getMnuSharedWithoutSub() - { - return sharedwosub; - } - - public JMenuItem getMnuSharedWithSub() - { - return sharedwsub; - } - - public JMenuItem getMnuCopyToClipboard() - { - return itemCopyToClipboard; - } - - public JMenuItem getMnuReleaseInfo() - { - return itemReleaseInfo; - } - - public JMenuItem getMnuCopyToClipboardWithSources() - { - return itemCopyToClipboardWithSources; - } - - public JMenuItem getMnuCopyToClipboardAsUBBCode() - { - return itemCopyToClipboardAsUBBCode; - } - - public JMenuItem getMnuOpenWithProgram() - { - return itemOpenWithProgram; - } - - public ShareTable getShareTable() - { - return shareTable; - } - - public ShareTableModel getShareModel() - { - return shareModel; - } - - public JLabel getLblDateien() - { - return dateien; - } - - public TKLComboBox getCmbPrioritaet() - { - return cmbPrio; - } - - public DirectoryTree getDirectoryTree() - { - return folderTree; - } - - public JPopupMenu getPopupMenu() - { - return popup; - } - - public JPopupMenu getPopupMenu2() - { - return popup2; - } - - public TitledBorder getFolderTreeBolder() - { - return folderTreeBolder; - } - - public TitledBorder getMainPanelBolder() - { - return mailPanelBolder; - } - - private void init() throws Exception - { - IconManager im = IconManager.getInstance(); - - itemReleaseInfo.setIcon(im.getIcon("hint")); - itemCopyToClipboard.setIcon(im.getIcon("clipboard")); - itemCopyToClipboardAsUBBCode.setIcon(im.getIcon("clipboard")); - itemCopyToClipboardWithSources.setIcon(im.getIcon("clipboard")); - prioritaetAufheben.setEnabled(false); - prioritaetSetzen.setEnabled(false); - neuLaden.setEnabled(false); - refresh.setEnabled(false); - - popup2.add(itemCopyToClipboard); - popup2.add(itemCopyToClipboardWithSources); - popup2.add(itemCopyToClipboardAsUBBCode); - popup2.add(new JSeparator()); - popup2.add(itemReleaseInfo); - popup2.add(itemOpenWithProgram); - popup2.add(itemOpenWithStandardProgramm); - itemOpenWithProgram.setIcon(im.getIcon("vlc")); - folderTree.setModel(new DefaultTreeModel(new WaitNode())); - folderTree.setCellRenderer(new ShareSelectionTreeCellRenderer()); - - cmbPrio.setEditable(false); - for(int i = 1; i < 251; i++) - { - cmbPrio.addItem(new Integer(i)); - } - - sharedwsub = new JMenuItem(); - sharedwsub.setIcon(im.getIcon("sharedwsub")); - sharedwosub = new JMenuItem(); - sharedwosub.setIcon(im.getIcon("sharedwosub")); - notshared = new JMenuItem(); - notshared.setIcon(im.getIcon("notshared")); - popup.add(sharedwsub); - popup.add(sharedwosub); - popup.add(notshared); - - shareModel = new ShareTableModel(new ShareNode(null, null)); - shareTable = new ShareTable(shareModel); - shareTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - TableColumnModel model = shareTable.getColumnModel(); - int n = model.getColumnCount(); - TableCellRenderer renderer = new NormalHeaderRenderer(); - - for(int i = 0; i < n; i++) - { - model.getColumn(i).setHeaderRenderer(renderer); - } - - folderTreeBolder = new TitledBorder("Test"); - mailPanelBolder = new TitledBorder("Tester"); - setLayout(new BorderLayout()); - panelCenter = new JPanel(new BorderLayout()); - panelCenter.setBorder(mailPanelBolder); - - neueListe.setIcon(IconManager.getInstance().getIcon("treeRoot")); - neuLaden.setIcon(IconManager.getInstance().getIcon("erneuern")); - - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - Synchronizer synchronizer = new Synchronizer(Synchronizer.METHOD.HEIGHT); - - synchronizer.add(neuLaden); - synchronizer.add(neueListe); - synchronizer.add(cmbPrio); - synchronizer.add(prioritaetSetzen); - synchronizer.add(prioritaetAufheben); - panel1.add(neuLaden); - panel1.add(neueListe); - panel1.add(cmbPrio); - panel1.add(prioritaetSetzen); - panel1.add(prioritaetAufheben); - - panelCenter.add(panel1, BorderLayout.NORTH); - JScrollPane scrollPane = new JScrollPane(shareTable); - - scrollPane.setBackground(shareTable.getBackground()); - scrollPane.getViewport().setOpaque(false); - - panelCenter.add(scrollPane, BorderLayout.CENTER); - panelCenter.add(dateien, BorderLayout.SOUTH); - - JScrollPane aScrollPane = new JScrollPane(folderTree); - - aScrollPane.setBorder(folderTreeBolder); - JPanel panelWest = new JPanel(new BorderLayout()); - - panelWest.add(aScrollPane, BorderLayout.CENTER); - panelWest.add(refresh, BorderLayout.SOUTH); - JSplitPane splitPane = new JSplitPane(); - - splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); - splitPane.setLeftComponent(panelWest); - splitPane.setRightComponent(panelCenter); - splitPane.setBorder(null); - add(splitPane, BorderLayout.CENTER); - - cmbPrio.disableDirtyComponent(true); - } - - public int[] getColumnWidths() - { - TableColumnModel tcm = shareTable.getColumnModel(); - int[] widths = new int[tcm.getColumnCount()]; - - for(int i = 0; i < tcm.getColumnCount(); i++) - { - widths[i] = tcm.getColumn(i).getWidth(); - } - - return widths; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/start/HyperlinkAdapter.java b/AJClientGUI/src/de/applejuicenet/client/gui/start/HyperlinkAdapter.java deleted file mode 100644 index a752def3..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/start/HyperlinkAdapter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.start; - -import java.awt.Component; -import java.awt.Cursor; -import java.net.URI; - -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.shared.DesktopTools; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/HyperlinkAdapter.java,v 1.9 2009/02/12 10:27:34 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class HyperlinkAdapter implements HyperlinkListener -{ - private Logger logger; - private Component parent; - - public HyperlinkAdapter(Component parent) - { - logger = Logger.getLogger(getClass()); - this.parent = parent; - } - - public void hyperlinkUpdate(HyperlinkEvent e) - { - HyperlinkEvent.EventType type = e.getEventType(); - - if(type == HyperlinkEvent.EventType.ENTERED) - { - parent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - - } - else if(type == HyperlinkEvent.EventType.EXITED) - { - parent.setCursor(Cursor.getDefaultCursor()); - } - else if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) - { - if(e.getURL() != null) - { - String url = e.getURL().toString(); - - if(url.length() != 0) - { - executeLink(url); - } - } - } - } - - private void executeLink(String link) - { - try - { - DesktopTools.browse(new URI(link)); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/start/NachrichtenWorker.java b/AJClientGUI/src/de/applejuicenet/client/gui/start/NachrichtenWorker.java deleted file mode 100644 index f93f9834..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/start/NachrichtenWorker.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.start; - -import javax.swing.JLabel; -import javax.swing.JTextPane; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/NachrichtenWorker.java,v 1.5 2009/02/12 13:11:40 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class NachrichtenWorker extends Thread -{ - private final Logger logger; - private StartController startController; - private JLabel version; - private JTextPane nachrichten; - - public NachrichtenWorker(StartController startController, JLabel version, JTextPane nachrichten) - { - logger = Logger.getLogger(getClass()); - this.startController = startController; - this.version = version; - this.nachrichten = nachrichten; - } - - public void run() - { - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("NachrichtenWorkerThread gestartet. " + this); - } - - try - { - final String coreVersion = AppleJuiceClient.getAjFassade().getCoreVersion().getVersion(); - String nachricht = "verwendeter Core: " + coreVersion; - - if(logger.isEnabledFor(Level.INFO)) - { - logger.info(nachricht); - } - - ProxySettings proxy = ProxyManagerImpl.getInstance().getProxySettings(); - String htmlText = WebsiteContentLoader.getWebsiteContent(proxy, "http://www.applejuicenet.org", 80, - "/inprog/news.php?version=" + - AppleJuiceClient.getAjFassade().getCoreVersion() - .getVersion()); - - int pos = htmlText.toLowerCase().indexOf(""); - - StringBuilder buffer = new StringBuilder(); - - if(pos != -1) - { - buffer.append(htmlText.substring(pos)); - } - else - { - buffer.append(""); - buffer.append(htmlText); - buffer.append(""); - } - - int index; - - while((index = buffer.indexOf(". ")) != -1) - { - buffer.replace(index, index + 1, ".
"); - } - - htmlText = buffer.toString(); - final String htmlContent = htmlText; - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - version.setText("GUI: " + AppleJuiceDialog.GUI_VERSION + "/" + ApplejuiceFassade.FASSADE_VERSION + - "
Core: " + coreVersion + ""); - nachrichten.setContentType("text/html"); - nachrichten.setText(htmlContent); - nachrichten.setFont(version.getFont()); - } - }); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Versionsabhaengige Nachrichten konnten nicht geladen werden. Server down?"); - } - } - - if(logger.isEnabledFor(Level.DEBUG)) - { - logger.debug("NachrichtenWorkerThread beendet. " + this); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/start/StartController.java b/AJClientGUI/src/de/applejuicenet/client/gui/start/StartController.java deleted file mode 100644 index 678d8d39..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/start/StartController.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.start; - -import java.util.Map; - -import javax.swing.JComponent; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Level; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.shared.NetworkInfo; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.util.Value; -import de.applejuicenet.client.gui.controller.LanguageSelector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/StartController.java,v 1.13 2009/01/28 09:44:09 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class StartController extends GuiController -{ - private static StartController instance = null; - private final StartPanel startPanel; - private boolean firstChange = true; - private boolean firewalled = false; - private String status2Text; - private String verbindungNachrichtText; - private NetworkInfo netInfo = null; - private Information information = null; - private String firewallWarningText; - private String keinServer = ""; - private String verbindungenText; - - private StartController() - { - super(); - startPanel = new StartPanel(this); - try - { - init(); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public static synchronized StartController getInstance() - { - if(null == instance) - { - instance = new StartController(); - } - - return instance; - } - - private void init() - { - HyperlinkAdapter hyperlinkAdapter = new HyperlinkAdapter(startPanel.getServerMessagePane()); - - startPanel.getServerMessagePane().addHyperlinkListener(hyperlinkAdapter); - startPanel.getNachrichtenPane().addHyperlinkListener(hyperlinkAdapter); - startPanel.getFaqPane().addHyperlinkListener(hyperlinkAdapter); - - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.NETINFO_CHANGED); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); - LanguageSelector.getInstance().addLanguageListener(this); - } - - public Value[] getCustomizedValues() - { - return null; - } - - public void fireAction(int actionId, Object source) - { - - // nix - } - - public JComponent getComponent() - { - return startPanel; - } - - public void componentSelected() - { - - // nix zu tun - } - - public void componentLostSelection() - { - - // nix zu tun - } - - protected void languageChanged() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - keinServer = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.keinserver"); - status2Text = languageSelector.getFirstAttrbuteByTagName("mainform.status.status2"); - StringBuffer temp = new StringBuffer(status2Text); - int pos; - - if(netInfo != null) - { - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJUserGesamtAsStringWithPoints()); - } - - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJAnzahlDateienAsStringWithPoints()); - } - - pos = temp.indexOf("%s"); - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJGesamtShareWithPoints(0)); - } - } - else - { - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, "0"); - } - - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, "0"); - } - - pos = temp.indexOf("%s"); - if(pos != -1) - { - temp.replace(pos, pos + 2, "0 MB"); - } - } - - startPanel.getLblStatus().setText(temp.toString()); - firewallWarningText = languageSelector.getFirstAttrbuteByTagName("mainform.firewallwarning.caption"); - if(firewalled) - { - startPanel.getLblWarnung().setVisible(true); - startPanel.getLblWarnungIcon().setVisible(true); - startPanel.getLblFirewallWarning().setText(firewallWarningText); - } - else - { - startPanel.getLblWarnung().setVisible(false); - startPanel.getLblWarnungIcon().setVisible(false); - startPanel.getLblFirewallWarning().setText(""); - } - - verbindungNachrichtText = languageSelector.getFirstAttrbuteByTagName("mainform.html10"); - temp = new StringBuffer(verbindungNachrichtText); - pos = temp.indexOf("%s"); - if(pos != -1) - { - temp.replace(pos, pos + 2, keinServer); - } - - pos = temp.indexOf("%d"); - if(pos != -1) - { - Map servers = AppleJuiceClient.getAjFassade().getAllServer(); - int count; - - if(servers != null) - { - count = servers.size(); - } - else - { - count = 0; - } - - temp.replace(pos, pos + 2, Integer.toString(count)); - } - - startPanel.getLblVerbindungsnachricht().setText(temp.toString()); - verbindungenText = languageSelector.getFirstAttrbuteByTagName("mainform.status.status0"); - temp = new StringBuffer(verbindungenText); - pos = temp.indexOf("%d"); - if(pos != -1) - { - if(information != null) - { - temp.replace(pos, pos + 2, Long.toString(information.getOpenConnections())); - } - else - { - temp.replace(pos, pos + 2, "0"); - } - } - - startPanel.getLblVerbindungen().setText(temp.toString()); - startPanel.getLblNetzwerk() - .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html7") + "

"); - startPanel.getLblNeuigkeiten() - .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html13") + "

"); - startPanel.getLblDeinClient() - .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html1") + "

"); - startPanel.getLblWarnung() - .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html15") + "

"); - } - - protected void contentChanged(DATALISTENER_TYPE type, final Object content) - { - if(type == DATALISTENER_TYPE.NETINFO_CHANGED) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - try - { - if(firstChange) - { - firstChange = false; - new NachrichtenWorker(StartController.this, startPanel.getLblVersion(), startPanel.getNachrichtenPane()).start(); - } - - netInfo = (NetworkInfo) content; - StringBuffer temp = new StringBuffer(status2Text); - int pos = temp.indexOf("%d"); - - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJUserGesamtAsStringWithPoints()); - } - - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJAnzahlDateienAsStringWithPoints()); - } - - pos = temp.indexOf("%s"); - if(pos != -1) - { - temp.replace(pos, pos + 2, netInfo.getAJGesamtShareWithPoints(0)); - } - - startPanel.getLblStatus().setText(temp.toString()); - if(netInfo.isFirewalled() != firewalled) - { - firewalled = !firewalled; - startPanel.getLblWarnung().setVisible(firewalled); - startPanel.getLblWarnungIcon().setVisible(firewalled); - if(firewalled) - { - startPanel.getLblFirewallWarning().setText(firewallWarningText); - } - else - { - startPanel.getLblFirewallWarning().setText(""); - } - - startPanel.repaint(); - } - - String tmp = netInfo.getWelcomeMessage(); - - if(tmp.compareTo(startPanel.getServerMessagePane().getText()) != 0) - { - startPanel.getServerMessagePane().setText(tmp); - startPanel.getServerMessagePane().setCaretPosition(0); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - }); - } - else if(type == DATALISTENER_TYPE.INFORMATION_CHANGED) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - try - { - information = (Information) content; - StringBuffer temp = new StringBuffer(verbindungNachrichtText); - int pos = temp.indexOf("%s"); - - if(pos != -1) - { - if(information.getVerbindungsStatus() == Information.VERBUNDEN) - { - if(information.getServerName() == null || information.getServerName().length() == 0) - { - Server server = information.getServer(); - - if(server != null) - { - String tmp = server.getHost() + ":" + server.getPort(); - - temp.replace(pos, pos + 2, tmp); - } - else - { - temp.replace(pos, pos + 2, "?"); - } - } - else - { - temp.replace(pos, pos + 2, information.getServerName()); - } - } - else - { - temp.replace(pos, pos + 2, keinServer); - } - - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, Integer.toString(AppleJuiceClient.getAjFassade().getAllServer().size())); - } - } - - startPanel.getLblVerbindungsnachricht().setText(temp.toString()); - temp = new StringBuffer(verbindungenText); - pos = temp.indexOf("%d"); - if(pos != -1) - { - temp.replace(pos, pos + 2, Long.toString(information.getOpenConnections())); - } - - startPanel.getLblVerbindungen().setText(temp.toString()); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - }); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/start/StartPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/start/StartPanel.java deleted file mode 100644 index bf84055e..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/start/StartPanel.java +++ /dev/null @@ -1,244 +0,0 @@ -package de.applejuicenet.client.gui.start; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; - -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; - -import org.apache.log4j.Level; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.shared.NetworkInfo; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.TklPanel; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.shared.IconManager; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/StartPanel.java,v - * 1.57 2004/06/15 16:19:19 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ - -public class StartPanel extends TklPanel { - - private static final Color APFEL_ROT = new Color(146, 36, 60); - - private JLabel warnungen; - private JLabel deinClient; - private JLabel firewallWarning; - private JTextPane nachrichten; - private JLabel neuigkeiten; - private JLabel netzwerk; - private JLabel status; - private JLabel verbindungsNachricht; - private JLabel verbindungen; - private JLabel version; - private JTextPane faq; - private JLabel warnungIcon; - private JTextPane serverMessage; - private NetworkInfo netInfo; - private Information information; - private LanguageSelector languageSelector; - - public StartPanel(GuiController guiController) { - super(guiController); - try { - init(); - } catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public JTextPane getNachrichtenPane(){ - return nachrichten; - } - - public JTextPane getServerMessagePane(){ - return serverMessage; - } - - public JTextPane getFaqPane(){ - return faq; - } - - public JLabel getLblVersion(){ - return version; - } - - public JLabel getLblWarnung(){ - return warnungen; - } - - public JLabel getLblWarnungIcon(){ - return warnungIcon; - } - - public JLabel getLblStatus(){ - return status; - } - - public JLabel getLblFirewallWarning(){ - return firewallWarning; - } - - public JLabel getLblVerbindungsnachricht(){ - return verbindungsNachricht; - } - - public JLabel getLblVerbindungen(){ - return verbindungen; - } - - public JLabel getLblNetzwerk(){ - return netzwerk; - } - - public JLabel getLblDeinClient(){ - return deinClient; - } - - public JLabel getLblNeuigkeiten(){ - return neuigkeiten; - } - - private void init() throws Exception { - setLayout(new BorderLayout()); - serverMessage = new JTextPane(); - serverMessage.setContentType("text/html"); - serverMessage.setEditable(false); - - JPanel panel3 = new JPanel(new GridBagLayout()); - panel3.setBackground(Color.WHITE); - JPanel panel4 = new JPanel(new BorderLayout()); - panel4.setBackground(Color.WHITE); - - IconManager im = IconManager.getInstance(); - JPanel panel1 = new NorthPanel(serverMessage); - panel1.setBackground(Color.WHITE); - - GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.NORTH; - constraints.fill = GridBagConstraints.BOTH; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 5; - - ImageIcon icon2 = im.getIcon("start"); - JLabel label2 = new JLabel(icon2); - panel3.add(label2, constraints); - - constraints.gridx = 1; - constraints.weightx = 1; - deinClient = new JLabel(); - deinClient.setForeground(APFEL_ROT); - panel3.add(deinClient, constraints); - constraints.weightx = 0; - - constraints.gridy++; - constraints.insets.left = 15; - version = new JLabel(); - panel3.add(version, constraints); - constraints.gridy++; - constraints.insets.left = 15; - faq = new JTextPane(); - faq.setContentType("text/html"); - faq.setEditable(false); - faq.setText("FAQ"); - panel3.add(faq, constraints); - - constraints.gridy++; - constraints.insets.left = 5; - constraints.gridx = 0; - ImageIcon icon3 = im.getIcon("warnung"); - warnungIcon = new JLabel(icon3); - panel3.add(warnungIcon, constraints); - - constraints.gridx = 1; - warnungen = new JLabel(); - warnungen.setForeground(APFEL_ROT); - panel3.add(warnungen, constraints); - - constraints.gridy++; - constraints.insets.left = 15; - firewallWarning = new JLabel(); - firewallWarning.setForeground(Color.RED); - - panel3.add(firewallWarning, constraints); - - constraints.gridy++; - constraints.insets.left = 5; - constraints.gridx = 0; - ImageIcon icon4 = im.getIcon("netzwerk"); - JLabel label4 = new JLabel(icon4); - panel3.add(label4, constraints); - - constraints.gridx = 1; - neuigkeiten = new JLabel(); - neuigkeiten.setForeground(APFEL_ROT); - panel3.add(neuigkeiten, constraints); - - constraints.gridy++; - constraints.insets.left = 15; - nachrichten = new JTextPane(); - panel3.add(nachrichten, constraints); - nachrichten.setEditable(false); - - constraints.gridy++; - constraints.insets.left = 5; - constraints.gridx = 0; - ImageIcon icon5 = im.getIcon("server"); - JLabel label5 = new JLabel(icon5); - panel3.add(label5, constraints); - - constraints.gridx = 1; - netzwerk = new JLabel(); - netzwerk.setForeground(APFEL_ROT); - panel3.add(netzwerk, constraints); - - constraints.gridy++; - constraints.insets.left = 15; - verbindungsNachricht = new JLabel(); - panel3.add(verbindungsNachricht, constraints); - - verbindungen = new JLabel(); - constraints.gridy++; - constraints.insets.top = 5; - panel3.add(verbindungen, constraints); - - constraints.gridy++; - status = new JLabel(); - panel3.add(status, constraints); - - constraints.insets.top = 0; - - add(panel1, BorderLayout.NORTH); - panel4.add(panel3, BorderLayout.NORTH); - JScrollPane scrollPane = new JScrollPane(panel4); - scrollPane.setBorder(null); - add(scrollPane, BorderLayout.CENTER); - } -} \ No newline at end of file diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/tray/TrayIF.java b/AJClientGUI/src/de/applejuicenet/client/gui/tray/TrayIF.java deleted file mode 100644 index 82ed5ee2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/tray/TrayIF.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.tray; - -import java.awt.Image; - -import javax.swing.Icon; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - -import de.applejuicenet.client.gui.AppleJuiceDialog; - -public interface TrayIF -{ - boolean makeTray(Image image, String title, final AppleJuiceDialog dialog, final JMenuItem popupShowHideMenuItem, - final Icon zeigenIcon, final Icon versteckenIcon, final JPopupMenu popup); - - void setTextVerstecken(String verstecken); - - void setTextZeigen(String zeigen); - - void showBallon(String caption, String message); -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadController.java b/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadController.java deleted file mode 100644 index aa6a2f60..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadController.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.upload; - -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import java.util.ArrayList; -import java.util.Map; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.fassade.entity.Upload; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.GuiControllerActionListener; -import de.applejuicenet.client.gui.components.table.HeaderListener; -import de.applejuicenet.client.gui.components.util.Value; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; - -public class UploadController extends GuiController -{ - private static UploadController instance = null; - private static final int HEADER_DRAGGED = 0; - private static final int HEADER_POPUP = 1; - private static final int TABLE_MOUSE_CLICKED = 2; - private static final int TABLE_POPUP = 3; - private static final int COPY_TO_CLIPBOARD = 4; - private static final int HEADER_WAITING_DRAGGED = 8; - private static final int HEADER_WAITING_POPUP = 9; - private final UploadPanel uploadPanel; - private boolean componentSelected = false; - private boolean initialized = false; - private int anzahlClients = 0; - private String clientText; - private String warteschlangeVoll = ""; - - private UploadController() - { - super(); - uploadPanel = new UploadPanel(this); - try - { - init(); - LanguageSelector.getInstance().addLanguageListener(this); - AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.UPLOAD_CHANGED); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public static synchronized UploadController getInstance() - { - if(null == instance) - { - instance = new UploadController(); - } - - return instance; - } - - public Value[] getCustomizedValues() - { - return null; - } - - private void init() - { - uploadPanel.getUploadActiveTable().getTableHeader().addMouseListener(new HeaderPopupListener(this, HEADER_POPUP)); - uploadPanel.getUploadActiveTable().getTableHeader().addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DRAGGED)); - uploadPanel.getUploadActiveTable().addMouseListener(new UploadTableMouseListener(this, TABLE_MOUSE_CLICKED)); - uploadPanel.getUploadActiveTable().addMouseListener(new UploadTablePopupListener(this, TABLE_POPUP)); - uploadPanel.getMnuCopyToClipboard().addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD)); - - uploadPanel.getUploadWaitingTable().getTableHeader().addMouseListener(new HeaderPopupListener(this, HEADER_WAITING_POPUP)); - uploadPanel.getUploadWaitingTable().getTableHeader() - .addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_WAITING_DRAGGED)); - } - - public void fireAction(int actionId, Object obj) - { - switch(actionId) - { - - case HEADER_DRAGGED: - { - headerDragged(); - break; - } - - case HEADER_POPUP: - { - headerPopup((MouseEvent) obj); - break; - } - - case HEADER_WAITING_DRAGGED: - { - headerWaitingDragged(); - break; - } - - case HEADER_WAITING_POPUP: - { - headerWaitingPopup((MouseEvent) obj); - break; - } - - case TABLE_MOUSE_CLICKED: - { - tableMouseClicked((MouseEvent) obj); - break; - } - - case TABLE_POPUP: - { - tablePopup((MouseEvent) obj); - break; - } - - case COPY_TO_CLIPBOARD: - { - copyLinkToClipboard(); - break; - } - - default: - logger.error("Unregistrierte EventId " + actionId); - } - } - - private void headerDragged() - { - PositionManager pm = PositionManagerImpl.getInstance(); - TableColumnModel columnModel = uploadPanel.getUploadActiveTable().getColumnModel(); - TableColumn[] columns = uploadPanel.getTableActiveColumns(); - - for(int i = 0; i < columns.length; i++) - { - try - { - pm.setUploadColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - - private void headerWaitingDragged() - { - PositionManager pm = PositionManagerImpl.getInstance(); - TableColumnModel columnModel = uploadPanel.getUploadWaitingTable().getColumnModel(); - TableColumn[] columns = uploadPanel.getTableWaitingColumns(); - - for(int i = 0; i < columns.length; i++) - { - try - { - pm.setUploadWaitingColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - - private void tablePopup(MouseEvent e) - { - Point p = e.getPoint(); - int selectedRow = uploadPanel.getUploadActiveTable().rowAtPoint(p); - - if(selectedRow != -1) - { - uploadPanel.getUploadActiveTable().setRowSelectionInterval(selectedRow, selectedRow); - - // Object selectedItem = ((TreeTableModelAdapter) uploadPanel.getTable().getModel()).nodeForRow(selectedRow); - // - // if(selectedItem instanceof Upload) - // { - // uploadPanel.getPopup().show(uploadPanel.getTable(), e.getX(), e.getY()); - // } - } - } - - private void tableMouseClicked(MouseEvent e) - { - Point p = e.getPoint(); - - // if(uploadPanel.getTable().columnAtPoint(p) != 0) - // { - // int selectedRow = uploadPanel.getTable().rowAtPoint(p); - // - // if(e.getClickCount() == 2) - // { - // ((TreeTableModelAdapter) uploadPanel.getTable().getModel()).expandOrCollapseRow(selectedRow); - // } - // } - } - - private void copyLinkToClipboard() - { - int selected = uploadPanel.getUploadActiveTable().getSelectedRow(); - - if(selected == -1) - { - return; - } - - Upload upload = uploadPanel.getUploadActiveTableModel().getRow(selected); - - Integer shareFileId = upload.getShareFileID(); - Map share = AppleJuiceClient.getAjFassade().getShare(false); - - if(share.containsKey(shareFileId)) - { - Share shareObj = share.get(shareFileId); - - if(share != null) - { - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer toCopy = new StringBuffer(); - - toCopy.append("ajfsp://file|"); - toCopy.append(shareObj.getShortfilename() + "|" + shareObj.getCheckSum() + "|" + shareObj.getSize() + "/"); - StringSelection contents = new StringSelection(toCopy.toString()); - - cb.setContents(contents, null); - } - } - } - - private void headerPopup(MouseEvent e) - { - TableColumn[] columns = uploadPanel.getTableActiveColumns(); - JCheckBoxMenuItem[] columnPopupItems = uploadPanel.getColumnActivePopupItems(); - TableColumnModel tableColumnModel = uploadPanel.getUploadActiveTable().getColumnModel(); - - for(int i = 1; i < columns.length; i++) - { - try - { - tableColumnModel.getColumnIndex(columns[i].getIdentifier()); - columnPopupItems[i].setSelected(true); - } - catch(IllegalArgumentException niaE) - { - columnPopupItems[i].setSelected(false); - } - } - - uploadPanel.getColumnActivePopup().show(uploadPanel.getUploadActiveTable().getTableHeader(), e.getX(), e.getY()); - } - - private void headerWaitingPopup(MouseEvent e) - { - TableColumn[] columns = uploadPanel.getTableWaitingColumns(); - JCheckBoxMenuItem[] columnPopupItems = uploadPanel.getColumnWaitingPopupItems(); - TableColumnModel tableColumnModel = uploadPanel.getUploadWaitingTable().getColumnModel(); - - for(int i = 1; i < columns.length; i++) - { - try - { - tableColumnModel.getColumnIndex(columns[i].getIdentifier()); - columnPopupItems[i].setSelected(true); - } - catch(IllegalArgumentException niaE) - { - columnPopupItems[i].setSelected(false); - } - } - - uploadPanel.getColumnWaitingPopup().show(uploadPanel.getUploadWaitingTable().getTableHeader(), e.getX(), e.getY()); - } - - public JComponent getComponent() - { - return uploadPanel; - } - - public void componentSelected() - { - try - { - componentSelected = true; - if(!initialized) - { - initialized = true; - TableColumnModel headerModelActive = uploadPanel.getUploadActiveTable().getTableHeader().getColumnModel(); - TableColumnModel headerModelWaiting = uploadPanel.getUploadWaitingTable().getTableHeader().getColumnModel(); - - TableColumn[] columnsActive = uploadPanel.getTableActiveColumns(); - int columnCountActive = headerModelActive.getColumnCount(); - int[] uploadActiveSort = null; - TableColumn[] columnsWaiting = uploadPanel.getTableWaitingColumns(); - int columnCountWaiting = headerModelWaiting.getColumnCount(); - PositionManager pm = PositionManagerImpl.getInstance(); - int[] uploadWaitingSort = null; - - if(pm.isLegal()) - { - int[] uploadActiveWidths = pm.getUploadWidths(); - boolean[] uploadActiveVisibilies = pm.getUploadColumnVisibilities(); - int[] indizesActive = pm.getUploadColumnIndizes(); - - uploadActiveSort = pm.getUploadSort(); - ArrayList visibleColumnsActive = new ArrayList(); - - for(int i = 0; i < columnsActive.length; i++) - { - columnsActive[i].setPreferredWidth(uploadActiveWidths[i]); - uploadPanel.getUploadActiveTable().removeColumn(columnsActive[i]); - if(uploadActiveVisibilies[i]) - { - visibleColumnsActive.add(columnsActive[i]); - } - } - - int pos = -1; - - for(int i = 0; i < visibleColumnsActive.size(); i++) - { - for(int x = 0; x < columnsActive.length; x++) - { - if(visibleColumnsActive.contains(columnsActive[x]) && indizesActive[x] == pos + 1) - { - uploadPanel.getUploadActiveTable().addColumn(columnsActive[x]); - pos++; - break; - } - } - } - - int[] uploadWaitingWidths = pm.getUploadWaitingWidths(); - boolean[] uploadWaitingVisibilies = pm.getUploadWaitingColumnVisibilities(); - int[] indizesWaiting = pm.getUploadWaitingColumnIndizes(); - - uploadWaitingSort = pm.getUploadWaitingSort(); - ArrayList visibleColumnsWaiting = new ArrayList(); - - for(int i = 0; i < columnsWaiting.length; i++) - { - columnsWaiting[i].setPreferredWidth(uploadWaitingWidths[i]); - uploadPanel.getUploadWaitingTable().removeColumn(columnsWaiting[i]); - if(uploadWaitingVisibilies[i]) - { - visibleColumnsWaiting.add(columnsWaiting[i]); - } - } - - pos = -1; - - for(int i = 0; i < visibleColumnsWaiting.size(); i++) - { - for(int x = 0; x < columnsWaiting.length; x++) - { - if(visibleColumnsWaiting.contains(columnsWaiting[x]) && indizesWaiting[x] == pos + 1) - { - uploadPanel.getUploadWaitingTable().addColumn(columnsWaiting[x]); - pos++; - break; - } - } - } - } - else - { - for(int i = 0; i < columnCountActive; i++) - { - headerModelActive.getColumn(i).setPreferredWidth(uploadPanel.getUploadActiveTable().getWidth() / columnCountActive); - } - - for(int i = 0; i < columnCountWaiting; i++) - { - headerModelWaiting.getColumn(i) - .setPreferredWidth(uploadPanel.getUploadWaitingTable().getWidth() / columnCountWaiting); - } - } - - uploadPanel.getUploadActiveTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - uploadPanel.getUploadWaitingTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - if(null != uploadActiveSort) - { - for(MouseListener curMl : uploadPanel.getUploadActiveTable().getTableHeader().getMouseListeners()) - { - if(curMl instanceof HeaderListener) - { - ((HeaderListener) curMl).sort(uploadActiveSort[0], uploadActiveSort[1] == 1); - } - } - } - - if(null != uploadWaitingSort) - { - for(MouseListener curMl : uploadPanel.getUploadWaitingTable().getTableHeader().getMouseListeners()) - { - if(curMl instanceof HeaderListener) - { - ((HeaderListener) curMl).sort(uploadWaitingSort[0], uploadWaitingSort[1] == 1); - } - } - } - } - - uploadPanel.getUploadActiveTable().updateUI(); - uploadPanel.getUploadWaitingTable().updateUI(); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - public void componentLostSelection() - { - componentSelected = false; - } - - protected void languageChanged() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - clientText = languageSelector.getFirstAttrbuteByTagName("mainform.uplcounttext"); - uploadPanel.getUploadListeLabel().setText(clientText.replaceAll("%d", Integer.toString(anzahlClients))); - String[] columnsText = new String[7]; - - columnsText[0] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col0caption"); - columnsText[1] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); - columnsText[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col2caption"); - columnsText[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); - columnsText[4] = languageSelector.getFirstAttrbuteByTagName("javagui.uploadform.columnwasserstand"); - columnsText[5] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col4caption"); - columnsText[6] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col5caption"); - TableColumn[] columns = uploadPanel.getTableActiveColumns(); - - for(int i = 0; i < columns.length; i++) - { - columns[i].setHeaderValue(columnsText[i]); - } - - columns[0].setPreferredWidth(100); - - columnsText = new String[7]; - - columnsText[0] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col0caption"); - columnsText[1] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col3caption"); - columnsText[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); - columnsText[3] = languageSelector.getFirstAttrbuteByTagName("javagui.uploadform.columnwasserstand"); - columnsText[4] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col4caption"); - columnsText[5] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.colletzteverbindung"); - columnsText[6] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col5caption"); - columns = uploadPanel.getTableWaitingColumns(); - - for(int i = 0; i < columns.length; i++) - { - columns[i].setHeaderValue(columnsText[i]); - } - - columns[0].setPreferredWidth(100); - - warteschlangeVoll = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.warteschlangevoll"); - uploadPanel.getMnuCopyToClipboard().setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); - } - - protected void contentChanged(DATALISTENER_TYPE type, final Object content) - { - if(type == DATALISTENER_TYPE.UPLOAD_CHANGED) - { - SwingUtilities.invokeLater(new Runnable() - { - @SuppressWarnings("unchecked") - public void run() - { - try - { - boolean change = uploadPanel.getUploadActiveTableModel().setUploads((Map) content); - - if(uploadPanel.getUploadWaitingTableModel().setUploads((Map) content)) - { - change = true; - } - - anzahlClients = uploadPanel.getUploadActiveTableModel().getRowCount() + - uploadPanel.getUploadWaitingTableModel().getRowCount(); - String tmp = clientText.replaceAll("%d", Integer.toString(anzahlClients)); - long maxUploadPos = AppleJuiceClient.getAjFassade().getInformation().getMaxUploadPositions(); - - if(anzahlClients >= maxUploadPos) - { - tmp += " (" + warteschlangeVoll + ")"; - } - - uploadPanel.getUploadListeLabel().setText(tmp); - if(componentSelected && change) - { - uploadPanel.getUploadActiveTableModel().forceResort(); - uploadPanel.getUploadActiveTable().updateUI(); - uploadPanel.getUploadWaitingTableModel().forceResort(); - uploadPanel.getUploadWaitingTable().updateUI(); - } - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - }); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadPanel.java b/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadPanel.java deleted file mode 100644 index a06a6c51..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadPanel.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.upload; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import java.util.Date; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.apache.log4j.Level; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.entity.Version; -import de.applejuicenet.client.gui.RegisterI; -import de.applejuicenet.client.gui.components.GuiController; -import de.applejuicenet.client.gui.components.TklPanel; -import de.applejuicenet.client.gui.components.table.HeaderListener; -import de.applejuicenet.client.gui.components.table.SortButtonRenderer; -import de.applejuicenet.client.gui.controller.PositionManager; -import de.applejuicenet.client.gui.controller.PositionManagerImpl; -import de.applejuicenet.client.gui.upload.table.UploadActiveTableModel; -import de.applejuicenet.client.gui.upload.table.UploadTableDateCellRenderer; -import de.applejuicenet.client.gui.upload.table.UploadTableFilenameCellRenderer; -import de.applejuicenet.client.gui.upload.table.UploadTablePrioCellRenderer; -import de.applejuicenet.client.gui.upload.table.UploadTableWaitingStatusCellRenderer; -import de.applejuicenet.client.gui.upload.table.UploadWaitingTableModel; -import de.applejuicenet.client.shared.IconManager; -import de.applejuicenet.client.shared.tablecellrenderer.ProgressTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.SpeedTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.StringTableCellRenderer; -import de.applejuicenet.client.shared.tablecellrenderer.VersionTableCellRenderer; - -import info.clearthought.layout.TableLayout; - -/** - * $Header: - * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/UploadPanel.java,v - * 1.48 2004/06/23 13:31:24 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class UploadPanel extends TklPanel implements RegisterI -{ - private JLabel uploadListeLabel = new JLabel("0 Clients in Deiner Uploadliste"); - private JPopupMenu popupMenu = new JPopupMenu(); - private JMenuItem itemCopyToClipboard; - private JPopupMenu columnActivePopup = new JPopupMenu(); - private TableColumn[] columnsActiveUploads = new TableColumn[7]; - private JCheckBoxMenuItem[] columnPopupItemsActiveUploads = new JCheckBoxMenuItem[columnsActiveUploads.length]; - private JPopupMenu columnWaitingPopup = new JPopupMenu(); - private TableColumn[] columnsWaitingUploads = new TableColumn[7]; - private JCheckBoxMenuItem[] columnPopupItemsWaitingUploads = new JCheckBoxMenuItem[columnsActiveUploads.length]; - private JTable uploadActiveTable; - private UploadActiveTableModel uploadActiveTableModel; - private JTable uploadWaitingTable; - private UploadWaitingTableModel uploadWaitingTableModel; - - public UploadPanel(GuiController guiController) - { - super(guiController); - try - { - init(); - } - catch(Exception ex) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } - } - } - - private void init() throws Exception - { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[][] sizes = - { - {5, f, 5}, - {5, f, f, p} - }; - - TableLayout tableLayout = new TableLayout(sizes); - - setLayout(tableLayout); - uploadActiveTableModel = new UploadActiveTableModel(); - uploadActiveTable = new JTable(uploadActiveTableModel); - - uploadActiveTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(0).setCellRenderer(new UploadTableFilenameCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(2).setCellRenderer(new SpeedTableCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(3).setCellRenderer(new ProgressTableCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(4).setCellRenderer(new ProgressTableCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(5).setCellRenderer(new UploadTablePrioCellRenderer()); - uploadActiveTable.getColumnModel().getColumn(6).setCellRenderer(new VersionTableCellRenderer()); - - TableColumnModel modelActive = uploadActiveTable.getColumnModel(); - - for(int i = 0; i < columnsActiveUploads.length; i++) - { - columnsActiveUploads[i] = modelActive.getColumn(i); - columnPopupItemsActiveUploads[i] = new JCheckBoxMenuItem((String) columnsActiveUploads[i].getHeaderValue()); - final int x = i; - - columnPopupItemsActiveUploads[i].addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(columnPopupItemsActiveUploads[x].isSelected()) - { - uploadActiveTable.getColumnModel().addColumn(columnsActiveUploads[x]); - PositionManagerImpl.getInstance().setUploadColumnVisible(x, true); - PositionManagerImpl.getInstance() - .setUploadColumnIndex(x, - uploadActiveTable.getColumnModel().getColumnIndex(columnsActiveUploads[x].getIdentifier())); - } - else - { - uploadActiveTable.getColumnModel().removeColumn(columnsActiveUploads[x]); - PositionManagerImpl.getInstance().setUploadColumnVisible(x, false); - for(int y = 0; y < columnsActiveUploads.length; y++) - { - try - { - PositionManagerImpl.getInstance() - .setUploadColumnIndex(y, - uploadActiveTable.getColumnModel() - .getColumnIndex(columnsActiveUploads[y].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - } - }); - columnActivePopup.add(columnPopupItemsActiveUploads[i]); - } - - columnPopupItemsActiveUploads[0].setEnabled(false); - columnPopupItemsActiveUploads[0].setSelected(true); - - SortButtonRenderer renderer = new SortButtonRenderer(); - JTableHeader header = uploadActiveTable.getTableHeader(); - - header.setDefaultRenderer(renderer); - header.addMouseListener(new HeaderListener(header, renderer) - { - private PositionManager pm = PositionManagerImpl.getInstance(); - - @Override - public void internalSort(int column, boolean ascent) - { - pm.setUploadSort(column, ascent); - - super.internalSort(column, ascent); - } - }); - - uploadWaitingTableModel = new UploadWaitingTableModel(); - uploadWaitingTable = new JTable(uploadWaitingTableModel); - - uploadWaitingTable.getColumnModel().getColumn(1).setCellRenderer(new UploadTableWaitingStatusCellRenderer()); - uploadWaitingTable.getColumnModel().getColumn(3).setCellRenderer(new ProgressTableCellRenderer()); - uploadWaitingTable.getColumnModel().getColumn(4).setCellRenderer(new UploadTablePrioCellRenderer()); - - uploadWaitingTable.setDefaultRenderer(Version.class, new VersionTableCellRenderer()); - uploadWaitingTable.setDefaultRenderer(Date.class, new UploadTableDateCellRenderer()); - - renderer = new SortButtonRenderer(); - - header = uploadWaitingTable.getTableHeader(); - header.setDefaultRenderer(renderer); - header.addMouseListener(new HeaderListener(header, renderer) - { - private PositionManager pm = PositionManagerImpl.getInstance(); - - @Override - public void internalSort(int column, boolean ascent) - { - pm.setUploadWaitingSort(column, ascent); - - super.internalSort(column, ascent); - } - }); - - TableColumnModel modelWaiting = uploadWaitingTable.getColumnModel(); - - for(int i = 0; i < columnsWaitingUploads.length; i++) - { - columnsWaitingUploads[i] = modelWaiting.getColumn(i); - columnPopupItemsWaitingUploads[i] = new JCheckBoxMenuItem((String) columnsWaitingUploads[i].getHeaderValue()); - final int x = i; - - columnPopupItemsWaitingUploads[i].addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(columnPopupItemsWaitingUploads[x].isSelected()) - { - uploadWaitingTable.getColumnModel().addColumn(columnsWaitingUploads[x]); - PositionManagerImpl.getInstance().setUploadWaitingColumnVisible(x, true); - PositionManagerImpl.getInstance() - .setUploadWaitingColumnIndex(x, - uploadWaitingTable.getColumnModel() - .getColumnIndex(columnsWaitingUploads[x].getIdentifier())); - } - else - { - uploadWaitingTable.getColumnModel().removeColumn(columnsWaitingUploads[x]); - PositionManagerImpl.getInstance().setUploadWaitingColumnVisible(x, false); - for(int y = 0; y < columnsWaitingUploads.length; y++) - { - try - { - PositionManagerImpl.getInstance() - .setUploadWaitingColumnIndex(y, - uploadWaitingTable.getColumnModel() - .getColumnIndex(columnsWaitingUploads[y].getIdentifier())); - } - catch(IllegalArgumentException niaE) - { - ; - - //nix zu tun - } - } - } - } - }); - columnWaitingPopup.add(columnPopupItemsWaitingUploads[i]); - } - - columnPopupItemsWaitingUploads[0].setEnabled(false); - columnPopupItemsWaitingUploads[0].setSelected(true); - - JScrollPane aScrollPaneActive = new JScrollPane(uploadActiveTable); - - aScrollPaneActive.setBackground(uploadActiveTable.getBackground()); - aScrollPaneActive.getViewport().setOpaque(false); - add(aScrollPaneActive, "1, 1"); - - JScrollPane aScrollPaneWaiting = new JScrollPane(uploadWaitingTable); - - aScrollPaneWaiting.setBackground(uploadWaitingTable.getBackground()); - aScrollPaneWaiting.getViewport().setOpaque(false); - add(aScrollPaneWaiting, "1, 2"); - - add(uploadListeLabel, "1, 3, L, T"); - itemCopyToClipboard = new JMenuItem(); - itemCopyToClipboard.setIcon(IconManager.getInstance().getIcon("clipboard")); - popupMenu.add(itemCopyToClipboard); - } - - public int[] getColumnActiveWidths() - { - int[] widths = new int[columnsActiveUploads.length]; - - for(int i = 0; i < columnsActiveUploads.length; i++) - { - widths[i] = columnsActiveUploads[i].getWidth(); - } - - return widths; - } - - public int[] getColumnWaitingWidths() - { - int[] widths = new int[columnsWaitingUploads.length]; - - for(int i = 0; i < columnsWaitingUploads.length; i++) - { - widths[i] = columnsWaitingUploads[i].getWidth(); - } - - return widths; - } - - public JTable getUploadWaitingTable() - { - return uploadWaitingTable; - } - - public UploadWaitingTableModel getUploadWaitingTableModel() - { - return uploadWaitingTableModel; - } - - public JTable getUploadActiveTable() - { - return uploadActiveTable; - } - - public UploadActiveTableModel getUploadActiveTableModel() - { - return uploadActiveTableModel; - } - - public TableColumn[] getTableActiveColumns() - { - return columnsActiveUploads; - } - - public TableColumn[] getTableWaitingColumns() - { - return columnsWaitingUploads; - } - - public JCheckBoxMenuItem[] getColumnActivePopupItems() - { - return columnPopupItemsActiveUploads; - } - - public JCheckBoxMenuItem[] getColumnWaitingPopupItems() - { - return columnPopupItemsWaitingUploads; - } - - public JPopupMenu getColumnActivePopup() - { - return columnActivePopup; - } - - public JPopupMenu getColumnWaitingPopup() - { - return columnWaitingPopup; - } - - public JPopupMenu getPopup() - { - return popupMenu; - } - - public JLabel getUploadListeLabel() - { - return uploadListeLabel; - } - - public JMenuItem getMnuCopyToClipboard() - { - return itemCopyToClipboard; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardDialog.java b/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardDialog.java deleted file mode 100644 index 2005308b..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardDialog.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.gui.wizard; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; -import de.applejuicenet.client.gui.listener.LanguageListener; -import de.applejuicenet.client.shared.IconManager; -import de.tklsoft.gui.controls.TKLButton; -import de.tklsoft.gui.controls.TKLPanel; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardDialog.java,v 1.10 2009/01/12 09:19:20 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class WizardDialog extends JDialog implements LanguageListener -{ - private Logger logger; - private WizardPanel aktuellesPanel; - private WizardPanel schritt1 = new Schritt1Panel(); - private WizardPanel schritt2 = new Schritt2Panel(); - private WizardPanel schritt3; - private WizardPanel schritt4 = new Schritt4Panel(); - private WizardPanel schritt5 = new Schritt5Panel(); - private TKLPanel buttons = new TKLPanel(new FlowLayout(FlowLayout.RIGHT)); - private TKLButton zurueck = new TKLButton(); - private TKLButton weiter = new TKLButton(); - private TKLButton ende = new TKLButton(); - private AJSettings ajSettings; - private boolean regularClosed = false; - - public WizardDialog(Frame parent, boolean modal) - { - super(parent, modal); - logger = Logger.getLogger(getClass()); - try - { - init(); - LanguageSelector ls = LanguageSelector.getInstance(); - - ls.addLanguageListener(this); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - public WizardDialog(JDialog parent, boolean modal, AJSettings ajSettings) - { - super(parent, modal); - logger = Logger.getLogger(getClass()); - try - { - this.ajSettings = ajSettings; - init(); - LanguageSelector ls = LanguageSelector.getInstance(); - - ls.addLanguageListener(this); - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.ERROR)) - { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } - } - } - - private void init() - { - if(ajSettings == null) - { - ajSettings = AppleJuiceClient.getAjFassade().getAJSettings(); - } - - schritt3 = new Schritt3Panel(this, ajSettings); - getContentPane().setLayout(new BorderLayout()); - ImageIcon icon1 = IconManager.getInstance().getIcon("wizardbanner"); - JLabel label1 = new JLabel(icon1); - - schritt1.setVorherigesPanel(null); - schritt1.setNaechstesPanel(schritt2); - schritt2.setVorherigesPanel(schritt1); - schritt2.setNaechstesPanel(schritt3); - schritt3.setVorherigesPanel(schritt2); - schritt3.setNaechstesPanel(schritt4); - schritt4.setVorherigesPanel(schritt3); - schritt4.setNaechstesPanel(schritt5); - schritt5.setVorherigesPanel(schritt4); - schritt5.setNaechstesPanel(null); - - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - LanguageSelector.getInstance().removeLanguageListener(WizardDialog.this); - OptionsManagerImpl.getInstance().setErsterStart(false); - dispose(); - } - }); - zurueck.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(aktuellesPanel.getVorherigesPanel() != null) - { - getContentPane().remove(aktuellesPanel); - aktuellesPanel = aktuellesPanel.getVorherigesPanel(); - getContentPane().add(aktuellesPanel, BorderLayout.CENTER); - weiter.setEnabled(true); - if(aktuellesPanel.getVorherigesPanel() == null) - { - zurueck.setEnabled(false); - } - else - { - zurueck.setEnabled(true); - } - - if(aktuellesPanel == schritt3) - { - if(((Schritt3Panel) schritt3).isValidNickname()) - { - setWeiterEnabled(true); - } - else - { - setWeiterEnabled(false); - } - } - else - { - setWeiterEnabled(true); - } - - WizardDialog.this.validate(); - WizardDialog.this.repaint(); - } - } - }); - weiter.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - if(aktuellesPanel.getNaechstesPanel() != null) - { - getContentPane().remove(aktuellesPanel); - aktuellesPanel = aktuellesPanel.getNaechstesPanel(); - getContentPane().add(aktuellesPanel, BorderLayout.CENTER); - zurueck.setEnabled(true); - if(aktuellesPanel.getNaechstesPanel() == null) - { - weiter.setEnabled(false); - } - else - { - if(aktuellesPanel == schritt3) - { - if(((Schritt3Panel) schritt3).isValidNickname()) - { - setWeiterEnabled(true); - } - else - { - setWeiterEnabled(false); - } - } - else - { - setWeiterEnabled(true); - } - } - - WizardDialog.this.validate(); - WizardDialog.this.repaint(); - } - } - }); - ende.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - regularClosed = true; - close(); - } - }); - buttons.add(zurueck); - buttons.add(weiter); - buttons.add(ende); - buttons.setBackground(Color.WHITE); - zurueck.setEnabled(false); - - getContentPane().add(label1, BorderLayout.NORTH); - getContentPane().add(schritt1, BorderLayout.CENTER); - aktuellesPanel = schritt1; - getContentPane().add(buttons, BorderLayout.SOUTH); - setSize(icon1.getIconWidth(), icon1.getIconHeight() + 180 + buttons.getPreferredSize().height); - setResizable(false); - fireLanguageChanged(); - } - - public boolean isRegularClosed() - { - return regularClosed; - } - - private void close() - { - LanguageSelector.getInstance().removeLanguageListener(this); - int result = JOptionPane.showConfirmDialog(this, - LanguageSelector.getInstance().getFirstAttrbuteByTagName("connect.remember.caption") + - " ?", "appleJuice Client", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - - if(result == JOptionPane.YES_OPTION) - { - if(((Schritt3Panel) schritt3).isValidNickname()) - { - ConnectionKind connection = ((Schritt4Panel) schritt4).getVerbindungsart(); - - ajSettings.setNick(((Schritt3Panel) schritt3).getNickname()); - ajSettings.setMaxUpload(connection.getMaxUpload() * 1024); - ajSettings.setMaxDownload(connection.getMaxDownload() * 1024); - ajSettings.setMaxNewConnectionsPerTurn(connection.getMaxNewConnectionsPro10Sek()); - AppleJuiceClient.getAjFassade().saveAJSettings(ajSettings); - } - } - else - { - regularClosed = false; - } - - OptionsManagerImpl.getInstance().setErsterStart(false); - dispose(); - } - - public void setWeiterEnabled(boolean enabled) - { - weiter.setEnabled(enabled); - } - - public void fireLanguageChanged() - { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - - setTitle(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.titel")); - zurueck.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.zurueck")); - weiter.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.weiter")); - ende.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.ende")); - schritt1.fireLanguageChanged(); - schritt2.fireLanguageChanged(); - schritt3.fireLanguageChanged(); - schritt4.fireLanguageChanged(); - schritt5.fireLanguageChanged(); - repaint(); - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/DesktopToolIF.java b/AJClientGUI/src/de/applejuicenet/client/shared/DesktopToolIF.java deleted file mode 100644 index 12fde1ce..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/DesktopToolIF.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ -package de.applejuicenet.client.shared; - -import java.io.File; - -import java.net.URI; - -public interface DesktopToolIF -{ - void browse(URI uri); - - void open(File toOpen); -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/DesktopTools.java b/AJClientGUI/src/de/applejuicenet/client/shared/DesktopTools.java deleted file mode 100644 index bfa6b08f..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/DesktopTools.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.io.File; - -import java.net.URI; - -import javax.swing.JOptionPane; - -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; - -@SuppressWarnings("unchecked") -public class DesktopTools -{ - private static DesktopToolIF desktopToolIF; - - static - { - try - { - Class aClass = Class.forName("de.applejuicenet.client.gui.tray.DesktopToolJava6"); - - desktopToolIF = (DesktopToolIF) aClass.newInstance(); - } - catch(Throwable e) - { - desktopToolIF = null; - } - } - - public static boolean isAdvancedSupported() - { - return null != desktopToolIF; - } - - public static void browse(URI uri) - { - if(null != desktopToolIF && System.getProperty("os.name").toLowerCase().indexOf("linux") == -1) - { - /** - * unter Linux ist #browse() teilweise nicht funktionstuechtig... - */ - desktopToolIF.browse(uri); - } - else - { - String browser = OptionsManagerImpl.getInstance().getStandardBrowser(); - - try - { - Runtime.getRuntime().exec(new String[] {browser, uri.toURL().toString()}); - } - catch(Exception ex) - { - LanguageSelector ls = LanguageSelector.getInstance(); - String nachricht = ls.getFirstAttrbuteByTagName("javagui.startup.updatefehlernachricht"); - String titel = ls.getFirstAttrbuteByTagName("mainform.caption"); - - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), nachricht, titel, JOptionPane.INFORMATION_MESSAGE); - } - } - } - - public static void open(File toOpen) - { - if(null != desktopToolIF) - { - desktopToolIF.open(toOpen); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/DownloadDO.java b/AJClientGUI/src/de/applejuicenet/client/shared/DownloadDO.java deleted file mode 100644 index 725f0f89..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/DownloadDO.java +++ /dev/null @@ -1,149 +0,0 @@ -package de.applejuicenet.client.shared; - -import java.util.*; - -/** - *

Title: AppleJuice Client-GUI

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @author Maj0r - * @version 1.0 - */ - -public class DownloadDO { - public static final int WARTESCHLANGE = 0; - public static final int UEBERTRAGE = 1; - public static final int VERSUCHEINDIREKT = 2; - public static final int ROOT = 3; - - boolean root; - private String dateiname; - private int status; - private String groesse; - private String bereitsGeladen; - private String prozentGeladen; - private String nochZuLaden; - private String geschwindigkeit; - private String restlicheZeit; - private String powerdownload; - private Version version; - private String nick; - private HashSet sources = new HashSet(); //contains DownloadDO leafs - - public DownloadDO(boolean isRoot, String dateiname, int status, - String groesse, - String bereitsGeladen, String prozentGeladen, - String nochZuLaden, String geschwindigkeit, - String restlicheZeit, String powerdownload, - Version version, String nick, HashSet sources) { - root = isRoot; - this.dateiname = dateiname; - this.status = status; - this.groesse = groesse; - this.bereitsGeladen = bereitsGeladen; - this.prozentGeladen = prozentGeladen; - this.nochZuLaden = nochZuLaden; - this.geschwindigkeit = geschwindigkeit; - this.restlicheZeit = restlicheZeit; - this.powerdownload = powerdownload; - this.version = version; - this.nick = nick; - this.sources = sources; - } - - public DownloadDO(){ } - - public void setGroesse(String groesse){ - this.groesse=groesse; - } - - public String getDateiname() { - if (root) { - return dateiname; - } - else { - return dateiname + " (" + getNick() + ")"; - } - } - - public String getNick() { - if (root) { - return ""; - } - else { - return nick; - } - } - - public int getIntStatus() { - return status; - } - - public String getStatus() { - if (status==0) - return "Warteschlange"; - else if (status==1) - return "Übertrage"; - else if (status==2) - return "Versuche indirekt zu verbinden"; - else if (status==3) - return ""; - //to do - return ""; - } - - public String getGroesse() { - return groesse; - } - - public String getBereitsGeladen() { - return bereitsGeladen; - } - - public String getProzentGeladen() { - //to do - return prozentGeladen; - } - - public String getNochZuLaden() { - //to do - return nochZuLaden; - } - - public String getGeschwindigkeit() { - //to do - return geschwindigkeit; - } - - public String getRestlicheZeit() { - //to do - return restlicheZeit; - } - - public String getPowerdownload() { - return powerdownload; - } - - public Version getVersion() { - //to do - return version; - } - - public void addDownloadSource(DownloadDO source) { - if (! (sources.contains(source))) { - sources.add(source); - } - } - - public DownloadDO[] getSources() { - if (sources==null) - return null; - return (DownloadDO[]) sources.toArray(new DownloadDO[sources. - size()]); - } - - public String toString() { - return getDateiname(); - } -} \ No newline at end of file diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/IconManager.java b/AJClientGUI/src/de/applejuicenet/client/shared/IconManager.java deleted file mode 100644 index 5f6e41d0..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/IconManager.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.awt.Image; -import java.awt.Toolkit; - -import java.io.File; -import java.io.FileInputStream; - -import java.net.URL; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javax.swing.ImageIcon; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/IconManager.java,v 1.17 2009/01/07 15:21:33 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class IconManager -{ - private static IconManager instance = null; - private final Logger logger; - private Map icons; - private String pluginPath; - - private IconManager() - { - logger = Logger.getLogger(getClass()); - icons = new HashMap(); - if(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) - { - pluginPath = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui" + File.separator + - "plugins" + File.separator; - } - else - { - pluginPath = System.getProperty("user.dir") + File.separator + "plugins" + File.separator; - } - } - - public static IconManager getInstance() - { - if(instance == null) - { - instance = new IconManager(); - } - - return instance; - } - - public ImageIcon getIcon(String key) - { - ImageIcon result = null; - - try - { - String hashtableKey = key; - - if(icons.containsKey(hashtableKey)) - { - result = icons.get(hashtableKey); - } - else - { - String path = System.getProperty("user.dir") + File.separator + "icons" + File.separator + key + ".gif"; - Image img = Toolkit.getDefaultToolkit().getImage(path); - - result = new ImageIcon(img); - icons.put(hashtableKey, result); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Icon " + key + ".gif nicht gefunden", e); - } - } - - return result; - } - - @SuppressWarnings("unchecked") - public ImageIcon getIcon(String key, boolean isPlugin, Class referenceClass) - { - if(!isPlugin) - { - return getIcon(key); - } - - ImageIcon result = null; - - try - { - result = icons.get(key); - if(null == result) - { - URL url = referenceClass.getClassLoader().getResource(key + ".gif"); - - Image img = Toolkit.getDefaultToolkit().getImage(url); - - result = new ImageIcon(img); - icons.put(key, result); - } - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Plugin-Icon " + key + ".gif nicht gefunden", e); - } - } - - return result; - } - - public Properties getIconProperties(String identifier) - { - String path = System.getProperty("user.dir") + File.separator + "icons" + File.separator + identifier + ".properties"; - File aFile = new File(path); - - if(aFile.isFile()) - { - Properties props = new Properties(); - - try - { - props.load(new FileInputStream(aFile)); - } - catch(Exception e) - { - return null; - } - - return props; - } - else - { - return null; - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/PluginJarClassLoader.java b/AJClientGUI/src/de/applejuicenet/client/shared/PluginJarClassLoader.java deleted file mode 100644 index 313e51b3..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/PluginJarClassLoader.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import java.lang.reflect.Constructor; - -import java.net.MalformedURLException; -import java.net.URL; - -import java.security.SecureClassLoader; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - -import javax.swing.ImageIcon; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.plugins.PluginConnector; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/PluginJarClassLoader.java,v 1.31 2009/01/12 10:33:12 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r aj@tkl-soft.de> - * - */ -public class PluginJarClassLoader extends SecureClassLoader -{ - private static Logger logger = Logger.getLogger(PluginJarClassLoader.class); - private Properties pluginProperties = null; - private ImageIcon pluginIcon = null; - private Map languageFiles = new HashMap(); - private Map availableIcons = new HashMap(); - private Map availableIcons2File = new HashMap(); - - public PluginJarClassLoader() - { - super(); - } - - @SuppressWarnings("unchecked") - public PluginConnector getPlugin(File pluginJar) throws Exception - { - pluginProperties = null; - pluginIcon = null; - languageFiles.clear(); - - try - { - loadClassBytesFromJar(pluginJar); - String theClassName = pluginProperties.getProperty("general.classname"); - Class cl = loadClass(theClassName); - Class[] constructorHelper = {Properties.class, Map.class, ImageIcon.class, Map.class}; - Constructor con = cl.getConstructor(constructorHelper); - PluginConnector aPlugin = (PluginConnector) con.newInstance(new Object[] - { - pluginProperties, languageFiles, pluginIcon, - availableIcons - }); - - return (PluginConnector) aPlugin; - } - catch(Throwable e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Plugin " + pluginJar.getName() + " entspricht nicht dem Standard und wurde nicht geladen.", e); - } - - return null; - } - } - - @SuppressWarnings("unchecked") - private void loadClassBytesFromJar(File jar) throws Exception - { - if(!jar.isFile()) - { - return; - } - - JarFile jf = new JarFile(jar); - String entryName; - HashMap lazyLoad = new HashMap(); - - for(Enumeration e = jf.entries(); e.hasMoreElements();) - { - ZipEntry entry = (ZipEntry) e.nextElement(); - - entryName = entry.getName(); - if(entryName.indexOf("$") == -1) - { - continue; - } - - String name = entryName.replace('/', '.'); - - name = name.replaceAll(".class", ""); - byte[] buf = readEntry(jf, entry); - - lazyLoad.put(name, buf); - } - - for(Enumeration e = jf.entries(); e.hasMoreElements();) - { - ZipEntry entry = (ZipEntry) e.nextElement(); - - entryName = entry.getName(); - if(entryName.indexOf(".class") == -1 && !entryName.equals("plugin.properties") && !entryName.endsWith(".gif") && - !entryName.endsWith(".png") && !entryName.startsWith("language_") && !entryName.endsWith(".jar") && - entryName.indexOf("$") == -1) - { - continue; - } - - byte[] buf = readEntry(jf, entry); - - if(entryName.equals("plugin.properties")) - { - InputStream iS = jf.getInputStream(entry); - - pluginProperties = new Properties(); - pluginProperties.load(iS); - } - else if(entryName.indexOf("icon.gif") != -1) - { - pluginIcon = new ImageIcon(buf); - availableIcons.put(entryName.substring(0, entryName.length() - 4), pluginIcon); - availableIcons2File.put(entryName, jar); - } - else if(entryName.endsWith(".gif") || entryName.endsWith(".png")) - { - ImageIcon icon = new ImageIcon(buf); - - availableIcons.put(entryName.substring(0, entryName.length() - 4), icon); - availableIcons2File.put(entryName, jar); - } - else if(entryName.startsWith("language_") && entryName.endsWith(".properties")) - { - InputStream iS = jf.getInputStream(entry); - - Properties curLanguageProperties = new Properties(); - - curLanguageProperties.load(iS); - - String sprache = curLanguageProperties.getProperty("language"); - - languageFiles.put(sprache, curLanguageProperties); - } - else if(entryName.endsWith(".jar")) - { - File aFile = File.createTempFile("ajg", null); - FileOutputStream os = new FileOutputStream(aFile); - - os.write(buf); - os.close(); - loadClassBytesFromJar(aFile); - aFile.delete(); - } - else - { - String name = entryName.replace('/', '.'); - - name = name.replaceAll(".class", ""); - defineMyClass(buf, name, jf); - String key = name + "$"; - - if(lazyLoad.containsKey(key + "1")) - { - int i = 1; - - while(true) - { - byte[] tmp = lazyLoad.get(key + i); - - if(null == tmp) - { - break; - } - - defineMyClass(tmp, key + i, jf); - i++; - } - } - } - } - - lazyLoad.clear(); - } - - private byte[] readEntry(JarFile jf, ZipEntry entry) - throws IOException - { - InputStream is = jf.getInputStream(entry); - int l = (int) entry.getSize(); - byte[] buf = new byte[l]; - int read = 0; - - while(read < l) - { - int incr = is.read(buf, read, l - read); - - read += incr; - } - - return buf; - } - - @SuppressWarnings("unchecked") - private void defineMyClass(byte[] buf, String name, JarFile jarFile) - throws IOException - { - try - { - Class clazz = findLoadedClass(name); - - if(null != clazz) - { - return; - } - - while(true) - { - try - { - clazz = defineClass(name, buf, 0, buf.length); - break; - } - catch(NoClassDefFoundError clfE) - { - - // rekursiv probieren - String className = clfE.getMessage(); - ZipEntry entry = jarFile.getEntry(className + ".class"); - byte[] innerBuf = readEntry(jarFile, entry); - - className = className.replace('/', '.'); - defineMyClass(innerBuf, className, jarFile); - } - } - - resolveClass(clazz); - } - catch(LinkageError lE) - { - logger.debug("Mist im Plugin", lE); - - //Klasse wurde aus irgendeinem Grund bereits geladen - } - } - - @Override - public URL getResource(String name) - { - File entry = availableIcons2File.get(name); - - if(null == entry) - { - return null; - } - - URL url = null; - - try - { - url = new URL("jar:file:" + entry.getAbsolutePath() + "!/" + name); - } - catch(MalformedURLException e) - { - - // bloed, aber nicht soooo schlimm - ; - } - - return url; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/PolicyJarClassLoader.java b/AJClientGUI/src/de/applejuicenet/client/shared/PolicyJarClassLoader.java deleted file mode 100644 index 748f3a9a..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/PolicyJarClassLoader.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.io.File; -import java.io.InputStream; - -import java.lang.reflect.Constructor; - -import java.net.URL; -import java.net.URLClassLoader; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.gui.powerdownload.AutomaticPowerdownloadPolicy; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/PolicyJarClassLoader.java,v 1.7 2009/01/12 09:02:56 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class PolicyJarClassLoader extends URLClassLoader -{ - private Logger logger; - - public PolicyJarClassLoader(URL url) - { - super(new URL[] {url}); - logger = Logger.getLogger(getClass()); - } - - @SuppressWarnings("unchecked") - public AutomaticPowerdownloadPolicy getPolicy(String jar) - throws Exception - { - try - { - File aJar = new File(jar); - List classes = loadClassBytesFromJar(aJar); - - if(classes == null) - { - return null; - } - - String className; - Class cl; - Constructor con; - AutomaticPowerdownloadPolicy policy; - - for(String curClassName : classes) - { - cl = loadClass(curClassName); - if(AutomaticPowerdownloadPolicy.class.isAssignableFrom(cl)) - { - con = cl.getConstructor(new Class[] {ApplejuiceFassade.class}); - policy = (AutomaticPowerdownloadPolicy) con.newInstance(new Object[] {AppleJuiceClient.getAjFassade()}); - - return policy; - } - } - - return null; - } - catch(Exception e) - { - if(logger.isEnabledFor(Level.INFO)) - { - logger.info("Plugin " + jar + " entspricht nicht dem Standard und wurde nicht geladen.", e); - } - - return null; - } - } - - @SuppressWarnings("unchecked") - private List loadClassBytesFromJar(File jar) - throws Exception - { - if(!jar.isFile()) - { - return null; - } - - JarFile jf = new JarFile(jar); - String entryName; - List classes = new ArrayList(); - ZipEntry entry; - InputStream is; - int l; - byte[] buf; - int read; - int incr; - String name; - - for(Enumeration e = jf.entries(); e.hasMoreElements();) - { - entry = (ZipEntry) e.nextElement(); - - entryName = entry.getName(); - if(entryName.indexOf(".class") == -1) - { - continue; - } - - is = jf.getInputStream(entry); - l = (int) entry.getSize(); - buf = new byte[l]; - read = 0; - - while(read < l) - { - incr = is.read(buf, read, l - read); - - read += incr; - } - - name = entryName.replace('/', '.'); - - name = name.replaceAll(".class", ""); - defineClass(name, buf, 0, buf.length); - classes.add(name); - } - - return classes; - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/ReleaseInfoDialog.java b/AJClientGUI/src/de/applejuicenet/client/shared/ReleaseInfoDialog.java deleted file mode 100644 index 8ce5cfa2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/ReleaseInfoDialog.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URLConnection; -import java.text.SimpleDateFormat; -import java.util.Calendar; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.AppleJuiceClient; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.ReleaseInfo; -import de.applejuicenet.client.gui.AppleJuiceDialog; -import de.applejuicenet.client.gui.controller.LanguageSelector; -import de.applejuicenet.client.gui.controller.ProxyManagerImpl; -import de.applejuicenet.client.gui.start.HyperlinkAdapter; - -public class ReleaseInfoDialog extends JDialog { - - private static Logger logger = Logger.getLogger(ReleaseInfoDialog.class); - private JTextPane txtContent; - private final ReleaseInfo releaseInfo; - private final boolean downloadOption; - private final String filename; - private final Long size; - - private ReleaseInfoDialog(ReleaseInfo releaseInfo, boolean downloadOption, - String filename, Long size) { - super(AppleJuiceDialog.getApp(), releaseInfo.getTitle(), true); - this.releaseInfo = releaseInfo; - this.downloadOption = downloadOption; - this.filename = filename; - this.size = size; - init(); - pack(); - setSize(700, 600); - setLocationRelativeTo(AppleJuiceDialog.getApp()); - setVisible(true); - } - - private void init() { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String txtCategories = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.categories"); - String txtFormat = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.format"); - String txtViewed = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.viewed"); - String txtCount = - languageSelector.getFirstAttrbuteByTagName("releaseinfo.count"); - String txtClicks = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.clicks"); - String txtPublished = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.published"); - String txtToday = - languageSelector.getFirstAttrbuteByTagName("releaseinfo.today"); - String txtYesterday = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.yesterday"); - String txtLanguages = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.languages"); - String txtGenres = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.genres"); - String txtRatingVideo = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.rating.video"); - String txtRatingAudio = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.rating.audio"); - String txtFsk18 = - languageSelector.getFirstAttrbuteByTagName("releaseinfo.fsk18"); - String txtJa = - languageSelector.getFirstAttrbuteByTagName("releaseinfo.yes"); - String txtNein = - languageSelector.getFirstAttrbuteByTagName("releaseinfo.no"); - - HyperlinkAdapter hyperlinkAdapter = - new HyperlinkAdapter(getTxtContent()); - - getTxtContent().addHyperlinkListener(hyperlinkAdapter); - - getContentPane().setLayout(new BorderLayout()); - - StringBuilder theContent = new StringBuilder(); - - theContent.append(""); - theContent.append("
"); - if (null != releaseInfo.getDescriptionURL()) { - theContent.append(" " - + releaseInfo.getTitle() + ""); - } else { - theContent.append(releaseInfo.getTitle()); - } - - theContent.append("
"); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - String tmp = txtCount; - - if (null != releaseInfo.getViewsTotal()) { - tmp = tmp.replaceAll("%all", "" + releaseInfo.getViewsTotal()); - } else { - tmp = tmp.replaceAll("%all", "-"); - } - - if (null != releaseInfo.getViewsCurrentMonth()) { - tmp = - tmp.replaceAll("%month", - "" + releaseInfo.getViewsCurrentMonth()); - } else { - tmp = tmp.replaceAll("%month", "-"); - } - - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - File imageFileGood = - new File(System.getProperty("user.dir") + File.separator - + "icons" + File.separator + "led_green.gif"); - File imageFileBad = - new File(System.getProperty("user.dir") + File.separator - + "icons" + File.separator + "led_gray.gif"); - - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - theContent.append(" "); - - theContent.append("
" + txtCategories + ""); - if (null != releaseInfo.getCategory()) { - theContent.append(releaseInfo.getCategory()); - } - - theContent.append(" "); - if (null != releaseInfo.getImageURL()) { - String link = releaseInfo.getImageURL().toString(); - - theContent.append(""); - } - - theContent.append("
" + txtFormat + ""); - if (null != releaseInfo.getFormat()) { - theContent.append(releaseInfo.getFormat()); - } - - theContent.append("
" + txtViewed + "" + tmp); - theContent.append("
" + txtPublished + ""); - if (null != releaseInfo.getReleaseDate()) { - Calendar calHeute = Calendar.getInstance(); - Calendar calRelease = Calendar.getInstance(); - - calRelease.setTime(releaseInfo.getReleaseDate()); - if (calHeute.get(Calendar.YEAR) == calRelease.get(Calendar.YEAR) - && calHeute.get(Calendar.DAY_OF_YEAR) == calRelease - .get(Calendar.DAY_OF_YEAR)) { - theContent.append("" + txtToday + " - "); - } else { - calHeute.add(Calendar.DATE, -1); - if (calHeute.get(Calendar.YEAR) == calRelease - .get(Calendar.YEAR) - && calHeute.get(Calendar.DAY_OF_YEAR) == calRelease - .get(Calendar.DAY_OF_YEAR)) { - theContent.append("" + txtYesterday + " - "); - } - } - - SimpleDateFormat formater = - new SimpleDateFormat("dd.MM.yyyy HH:mm"); - - theContent.append(formater.format(releaseInfo.getReleaseDate())); - } - - theContent.append("
" + txtLanguages + ""); - if (null != releaseInfo.getLanguageImage()) { - String link = releaseInfo.getLanguageImage().toString(); - - theContent.append(""); - } - - if (null != releaseInfo.getLanguage()) { - theContent.append(releaseInfo.getLanguage()); - } - - theContent.append("
" + txtGenres + ""); - if (null != releaseInfo.getGenres()) { - int x = 0; - - for (String curGenre : releaseInfo.getGenres()) { - if (x > 0) { - theContent.append(", "); - } - - theContent.append(curGenre); - x++; - } - } - - theContent.append("
" + txtFsk18 + ""); - theContent.append(releaseInfo.isFsk18() ? txtJa : txtNein); - theContent.append("
"); - theContent.append("Qualit\u00e4t:"); - theContent.append(" "); - theContent.append(releaseInfo.getQuality()); - theContent.append("
"); - theContent.append(""); - ProxySettings proxySettings = - ProxyManagerImpl.getInstance().getProxySettings(); - if (proxySettings != null) { - System.getProperties().put("proxyHost", proxySettings.getHost()); - System.getProperties().put("proxyPort", - Integer.toString(proxySettings.getPort())); - } - - getTxtContent().setContentType("text/html"); - getTxtContent().setText(theContent.toString()); - getTxtContent().setEditable(false); - getTxtContent().setBackground(getBackground()); - getContentPane().add(getTxtContent(), BorderLayout.CENTER); - - JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - IconManager im = IconManager.getInstance(); - - JButton btnClose = new JButton(); - - btnClose.setIcon(im.getIcon("abbrechen")); - btnClose.setText(languageSelector - .getFirstAttrbuteByTagName("assistant.closebutton.caption")); - btnClose.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - setVisible(false); - } - }); - southPanel.add(btnClose); - - JButton btnDownloadImage = new JButton(); - - btnDownloadImage.setIcon(im.getIcon("download")); - btnDownloadImage.setText(languageSelector - .getFirstAttrbuteByTagName("releaseinfo.downloadimage")); - btnDownloadImage.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - downloadImage(); - } - }); - southPanel.add(btnDownloadImage); - - JButton btnBrowseRelease = new JButton(); - - btnBrowseRelease.setIcon(im.getIcon("browsen")); - btnBrowseRelease.setText(languageSelector - .getFirstAttrbuteByTagName("releaseinfo.browse")); - btnBrowseRelease.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - try { - DesktopTools - .browse(releaseInfo.getDescriptionURL().toURI()); - } catch (URISyntaxException e1) { - logger.error(e1.getMessage(), e1); - } - } - }); - southPanel.add(btnBrowseRelease); - - if (downloadOption) { - JButton btnDownload = new JButton(); - - btnDownload.setIcon(im.getIcon("download")); - btnDownload.setText(languageSelector - .getFirstAttrbuteByTagName("mainform.Getlink3.caption")); - btnDownload.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent ae) { - download(); - } - }); - southPanel.add(btnDownload); - } - - getTxtContent().doLayout(); - - getContentPane().add(southPanel, BorderLayout.SOUTH); - // pack(); - } - - protected void download() { - StringBuilder toCopy = new StringBuilder(); - - toCopy.append("ajfsp://file|"); - toCopy.append(filename + "|" + releaseInfo.getMd5() + "|" + size + "/"); - final String link = toCopy.toString(); - - new Thread() { - - public void run() { - try { - final String result = - AppleJuiceClient.getAjFassade().processLink(link, - ""); - - SoundPlayer.getInstance().playSound(SoundPlayer.LADEN); - if (result.indexOf("ok") != 0) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - String message = null; - LanguageSelector languageSelector = - LanguageSelector.getInstance(); - - if (result.indexOf("already downloaded") != -1) { - message = - languageSelector - .getFirstAttrbuteByTagName("javagui.downloadform.bereitsgeladen"); - message = message.replaceAll("%s", link); - } else if (result.indexOf("incorrect link") != -1) { - message = - languageSelector - .getFirstAttrbuteByTagName("javagui.downloadform.falscherlink"); - message = message.replaceAll("%s", link); - } else if (result.indexOf("failure") != -1) { - message = - languageSelector - .getFirstAttrbuteByTagName("javagui.downloadform.sonstigerlinkfehlerlang"); - } - - if (message != null) { - JOptionPane.showMessageDialog( - AppleJuiceDialog.getApp(), - message, - languageSelector - .getFirstAttrbuteByTagName("mainform.caption"), - JOptionPane.OK_OPTION - | JOptionPane.INFORMATION_MESSAGE); - } - } - }); - } - } catch (IllegalArgumentException e) { - logger.error(e); - } - } - }.start(); - setVisible(false); - } - - private JTextPane getTxtContent() { - if (null == txtContent) { - txtContent = new JTextPane(); - } - - return txtContent; - } - - public void downloadImage() { - if (null == releaseInfo.getImageURL()) { - return; - } - - try { - final JFileChooser fileChooser = new JFileChooser(); - - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - String defaultFileName = releaseInfo.getImageURL().getFile(); - int index = defaultFileName.lastIndexOf("/"); - - if (index != -1) { - defaultFileName = defaultFileName.substring(index + 1); - } - index = defaultFileName.lastIndexOf("?"); - if (index != -1) { - defaultFileName = defaultFileName.substring(0, index); - } - - fileChooser.setSelectedFile(new File(fileChooser - .getCurrentDirectory().getAbsolutePath() - + File.separator - + defaultFileName)); - - int result = fileChooser.showSaveDialog(this); - - if (result != JFileChooser.APPROVE_OPTION) { - return; - } - - File destFile = fileChooser.getSelectedFile(); - - ProxySettings proxySettings = - ProxyManagerImpl.getInstance().getProxySettings(); - if (proxySettings != null) { - System.getProperties() - .put("proxyHost", proxySettings.getHost()); - System.getProperties().put("proxyPort", - Integer.toString(proxySettings.getPort())); - } - URLConnection urlconnection = - releaseInfo.getImageURL().openConnection(); - if (proxySettings != null) { - urlconnection.setRequestProperty("Proxy-Authorization", - "Basic " + proxySettings.getUserpass()); - } - - urlconnection.setUseCaches(true); - - InputStream urlStream = urlconnection.getInputStream(); - - FileOutputStream fos = new FileOutputStream(destFile); - - int bytesread = 0; - - byte[] buf = new byte[1024]; - while ((bytesread = urlStream.read(buf)) > 0) { - fos.write(buf, 0, bytesread); - } - - fos.close(); - urlStream.close(); - - if (proxySettings != null) { - System.getProperties().remove("proxyHost"); - System.getProperties().remove("proxyPort"); - } - - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String message = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.downloadimage.ok"); - - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message); - } catch (IOException ioe) { - logger.info(ioe.getMessage(), ioe); - } - } - - public static void showReleaseInfo(String hash) { - showReleaseInfo(hash, false, null, null); - } - - public static void showReleaseInfo(String hash, boolean downloadOption, - String filename, Long size) { - ReleaseInfo releaseInfo = null; - - try { - releaseInfo = - AppleJuiceClient.getAjFassade().getReleaseInfo(hash, - ProxyManagerImpl.getInstance().getProxySettings()); - } catch (Exception e) { - logger.info(e.getMessage(), e); - } - - if (null == releaseInfo) { - LanguageSelector languageSelector = LanguageSelector.getInstance(); - String message = - languageSelector - .getFirstAttrbuteByTagName("releaseinfo.na"); - - JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message); - } else { - new ReleaseInfoDialog(releaseInfo, downloadOption, filename, size); - } - } -} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/SoundPlayer.java b/AJClientGUI/src/de/applejuicenet/client/shared/SoundPlayer.java deleted file mode 100644 index 605b0df2..00000000 --- a/AJClientGUI/src/de/applejuicenet/client/shared/SoundPlayer.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.shared; - -import java.io.File; -import java.io.IOException; - -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.UnsupportedAudioFileException; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.gui.controller.OptionsManagerImpl; - -/** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/SoundPlayer.java,v 1.10 2009/01/05 12:07:30 maj0r Exp $ - * - *

Titel: AppleJuice Client-GUI

- *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

- *

Copyright: General Public License

- * - * @author: Maj0r - * - */ -public class SoundPlayer -{ - public static final int ABGEBROCHEN = 0; - public static final int SUCHEN = 1; - public static final int VERBINDEN = 2; - public static final int GESPEICHERT = 3; - public static final int KOMPLETT = 4; - public static final int LADEN = 5; - public static final int POWER = 6; - public static final int VERWEIGERT = 7; - public static final int KONKRETISIEREN = 8; - public static final int ZUGANG_GEWAEHRT = 9; - public static final int GESTARTET = 10; - private static SoundPlayer instance = null; - private static Logger logger; - private String soundPath; - - private SoundPlayer() - { - soundPath = System.getProperty("user.dir") + File.separator + "sounds" + File.separator; - } - - public static SoundPlayer getInstance() - { - if(instance == null) - { - instance = new SoundPlayer(); - logger = Logger.getLogger(instance.getClass()); - } - - return instance; - } - - public void playSound(int sound) - { - try - { - if(!OptionsManagerImpl.getInstance().isSoundEnabled()) - { - return; - } - - File soundFile = null; - - switch(sound) - { - - case ABGEBROCHEN: - { - soundFile = new File(soundPath + "abgebrochen.wav"); - break; - } - - case SUCHEN: - { - soundFile = new File(soundPath + "suchen.wav"); - break; - } - - case VERBINDEN: - { - soundFile = new File(soundPath + "verbinden.wav"); - break; - } - - case GESPEICHERT: - { - soundFile = new File(soundPath + "gespeichert.wav"); - break; - } - - case KOMPLETT: - { - soundFile = new File(soundPath + "komplett.wav"); - break; - } - - case LADEN: - { - soundFile = new File(soundPath + "laden.wav"); - break; - } - - case POWER: - { - soundFile = new File(soundPath + "pwdl.wav"); - break; - } - - case VERWEIGERT: - { - soundFile = new File(soundPath + "verweigert.wav"); - break; - } - - case KONKRETISIEREN: - { - soundFile = new File(soundPath + "konkretisieren.wav"); - break; - } - - case ZUGANG_GEWAEHRT: - { - soundFile = new File(soundPath + "zuganggestattet.wav"); - break; - } - - case GESTARTET: - { - soundFile = new File(soundPath + "gestartet.wav"); - break; - } - - default: - logger.error("SoundPlayer::playSound() ungueltiger Parameter: " + sound); - } - - final Clip soundToPlay = loadSound(soundFile); - - if(null != soundToPlay) - { - new Thread("SoundPlayer") - { - public void run() - { - soundToPlay.start(); - while(soundToPlay.isRunning()) - { - try - { - sleep(50); - } - catch(InterruptedException ex) - { - soundToPlay.stop(); - interrupt(); - } - } - - soundToPlay.stop(); - } - }.start(); - } - } - catch(Exception e) - { - logger.error(e); - } - } - - private Clip loadSound(File file) - { - Clip clip = null; - - try - { - AudioInputStream sound = null; - - sound = AudioSystem.getAudioInputStream(file); - AudioFormat format = sound.getFormat(); - - if((format.getEncoding() == AudioFormat.Encoding.ULAW) || (format.getEncoding() == AudioFormat.Encoding.ALAW)) - { - AudioFormat tmp = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), - format.getSampleSizeInBits() * 2, format.getChannels(), format.getFrameSize() * 2, - format.getFrameRate(), true); - - sound = AudioSystem.getAudioInputStream(tmp, sound); - format = tmp; - } - - DataLine.Info info = new DataLine.Info(Clip.class, sound.getFormat(), - ((int) sound.getFrameLength() * format.getFrameSize())); - - clip = (Clip) AudioSystem.getLine(info); - clip.open(sound); - } - catch(LineUnavailableException luE) - { - logger.info("Kein Audioausgabegeraet gefunden. Bitte Soundausgabe deaktivieren.", luE); - } - catch(IOException ioE) - { - logger.error("Die Datei " + file.getAbsolutePath() + " konnte nicht gefunden werden."); - } - catch(UnsupportedAudioFileException uafE) - { - logger.error("Die Datei " + file.getAbsolutePath() + " hat ein ungueltiges Format und kann nicht ausgegeben werden."); - } - catch(Exception e) - { - logger.error(e); - } - - return clip; - } -} diff --git a/AJClientGUI/starterexe/AJCoreGUI.dpr b/AJClientGUI/starterexe/AJCoreGUI.dpr deleted file mode 100644 index 97c7b216..00000000 --- a/AJClientGUI/starterexe/AJCoreGUI.dpr +++ /dev/null @@ -1,19 +0,0 @@ -program AJCoreGUI; -uses ShellAPI, SysUtils; - -var verzeichnis, argumente, arg: string; - i: integer; -begin -verzeichnis:=ExtractFilePath(ParamStr(0)); -if fileexists(verzeichnis+'\AJCoreGUI.jar')=true then begin - argumente:='-jar AJCoreGUI.jar'; - i:=1; - while ParamStr(i)<>'' do begin - arg:=ParamStr(i); - if copy(arg,0,8)='ajfsp://' then arg:='-link='+arg; - argumente:=argumente+' "'+arg+'"'; - i:=i+1; - end; - ShellExecute(0, 'open' ,PChar('javaw.exe'), PChar(argumente), PChar(verzeichnis), 1); - end; -end. diff --git a/AJClientGUI/themes/readme.first b/AJClientGUI/themes/readme.first deleted file mode 100644 index b6f798c7..00000000 --- a/AJClientGUI/themes/readme.first +++ /dev/null @@ -1,2 +0,0 @@ -Weitere Themes gibt’s auf http://javootoo.l2fprod.com/plaf/skinlf/index.php . -Es werden nur zip-Formate unterstützt! \ No newline at end of file diff --git a/AJClientGUI/tools/apfel.ico b/AJClientGUI/tools/apfel.ico deleted file mode 100644 index c2d4329d..00000000 Binary files a/AJClientGUI/tools/apfel.ico and /dev/null differ diff --git a/AJClientGUI/tools/pack.jar b/AJClientGUI/tools/pack.jar deleted file mode 100644 index ca3f1a69..00000000 Binary files a/AJClientGUI/tools/pack.jar and /dev/null differ diff --git a/AJClientGUI/wizard.xml b/AJClientGUI/wizard.xml deleted file mode 100644 index 2d2b9a82..00000000 --- a/AJClientGUI/wizard.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000..e85235ff --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,5 @@ +# Primary Authors + +- Maj0r +- loevenwong +- red171 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..eab76cbe --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,677 @@ +# Changelog + +**0.85.3** +- [red171] Zeige Core Version auch an, wenn die News einen 404 liefern (z.B. wenn die News URL nicht erreichbar ist) + +**0.85.2** +- [red171] erzeuge den `Splashscreen` direkt transparent ohne ScreenCapture (erzeugt keine ScreenShare Abfrage mehr) + +**0.85.1** +- [red171] erlaube `%7C` (`|`) in Links auch im "link hinzufügen" Feld +- [red171] in der `wizard.xml` den `maxdownloads` Wert per default auf `0` gestellt + +**0.85.0** +- [meins57] iconpack `modern` zusammengestellt +- [meins57] neue JavaGUI logos für `modern` erstellt +- [red171] iconpack `modern` als standard hinzugefügt +- [red171] `speedgraph` plugin wiederhergestellt +- [red171] logger `log4j` gegen `logback` ausgetauscht +- [red171] `ajcorefassade` lib als eigenständiges modul +- [red171] `tklcontrols` lib als eigenständiges modul + +**0.84.2** +- [red171] `iconpack` Support (siehe [icons](./resources/icons/) Ordner) +- [red171] `soundpack` Support (siehe [sounds](./resources/sounds/) Ordner) +- [red171] unter macOS funktioniert nun CMD+V / CMD+C usw. + +**0.84.1** +- [red171] Darkmode via `Darcula` Java `Look and Feel` Theme integriert +- [red171] die alternativen Skins funktionieren wieder +- [red171] alle alternativen Skins werden mit installiert +- [red171] Sounds funktionieren wieder! + +**0.84.0** +- [red171] Code Basis auf Java 11 angehoben +- [red171] `ajfsp` URL Handler funktioniert nun unter macOS und Linux +- [red171] `.ajl` Dateien können direkt mit dem GUI geöffnet/verknüpft werden +- [red171] das `serverwatcher` plugin wurde entfernt +- [red171] standard plugins werden jetzt auf allen Plattformen geladen +- [red171] für macOS wird jetzt ein `.dmg` File erstellt (vereinfacht Installation) + +**0.83.4** +- [red171] die URL für die GUI NEWS ist nun manuell in der `ajgui.properties` konfigurierbar (`options_news_url`) +- [red171] die URL für die Serverliste ist nun manuell in der `ajgui.properties` konfigurierbar (`options_server_list_url`) +- [red171] die URL für den Update-Server Feed ist nun manuell in der `ajgui.properties` konfigurierbar (`options_update_server_url`) +- [red171] den Browser Bug bei der Update-Benachrichtigung final behoben ;) +- [red171] der FAQ link aus dem "Dein Client" Bereich wurde entfernt + +**0.83.3** + +- [red171] import der dekompilierten `tklcontrols` +- [red171] alte `AjCoreGUI.exe` wiederhergestellt (mehrfach Linkübernahme funktioniert nun wieder!) + +**0.83.1** + +- [red171] neues, zeitgemäßes Icon der ausführbaren Dateien und Trayicon +- [red171] Linkübernahme in Browsern auf Basis von Chromium behoben, auch wenn die GUI bereits geöffnet ist +- [red171] der Release Info Button öffnet nun eine konfigurierte URL mit `ajfsp` Link angehängt +- [red171] die Konfiguration der Release-Info wird nun ebenfalls im `user.home` gespeichert, außerdem ist der API Pfad konfigurierbar +- [red171] Im Upload Tab ist jetzt auch Kontext Menü +- [red171] das IRC Plugin wurde entfernt +- [red171] für die Update-Überprüfung gibt es nur noch einen an/aus Schalter +- [red171] der "neue Version verfügbar" Dialog hat nur noch eine URL und zeigt auf das Github Release +- [red171] Gui und Plugins werden mit Maven kompiliert, Pakete (leider) noch via `ant` komprimiert +- [red171] alle GUI Plugins mit Java8 und UTF-8 Encoding neu kompiliert, Sprachdateien mit UTF-8 neu kodiert + +**0.82.1** + +- [red171] benutze unter Linux [xdg-open](https://wiki.ubuntuusers.de/xdg-utils/#xdg-open) als Standard Browser für URLs + +**0.82.0** + +- [red171] [wizard.xml](./AJClientGUI/wizard.xml) an die aktuellen Gegebenheiten angepasst +- [red171] jegliche Konfigurationsdateien werden jetzt im `user.home` gesichert +- [red171] unter Linux wird jetzt der interne Fenster Titel korrekt gesetzt (für `.desktop` Files wichtig) + +**0.81.1** + +- [red171] Linkübernahme in Browsern auf Basis von Chromium behoben (`%7C` vs `|`) + +**0.80.1** + +- [red171] VCS import +- [red171] JRE Version checker entfernt (so funktioniert das GUI auch mit Java >= 11) +- [red171] Update Checker URL auf github umgestellt +- [red171] ant `build.xml` kompatibilität zu Java 8 hergestellt + +**0.71.1** + +- [Maj0r] Release-Info auf `applefiles.cc` umgestellt + +**0.71.0** + +- [Maj0r] Sortierung der Tabellen wird gespeichert +- [Maj0r] Menüpunkt Release-Info in Share, Suche und Download hinzugefügt +- [Maj0r] Bäume in Suche, Download und Upload durch Tabellen ersetzt + +**0.70.5** + +- [Maj0r] Fehler beim Hinzufügen von Share-Ordnern behoben +- [Maj0r] Priorität der Uploads in der Form 1:2,2 (Priowert) anzeigen +- [Maj0r] Sortierung im Downloadreiter korrigiert + +**0.70.4** + +- [Maj0r] Deadlock beim Start gefixt +- [Maj0r] Anzeige der Downloadgechwindigkeit und des Gesamtdown- und uploads korrigiert +- [Maj0r] PwDl der Uploads in der Form 1:2,2 anzeigen +- [Maj0r] Mit Java6 lassen sich bei lokaler Coreverbindung Sharedateien und laufende Downloads nun mit dem Standardprogramm öffnen +- [Maj0r] Bug #670 Reiter per Tastaturschnelltaste anwaehlbar + +**0.70.2** + +- [Maj0r] Core-Versionsprüfung gefixt + +**0.70.1** + +Java ab 5.0 wird benötigt + +- [Maj0r] TrayIcon von Java6 eingebaut und funktioniert nun unter Windows, Mac und Linux (Gnome-Tray und KDE-Tray) +- [Maj0r] CPU-Last der Suchergebnisdarstellung wesentlich verringert. + Nun sind auch große Treffermengen gut verwendbar (Test mit 1500 bis 2000 Treffern pro Suche bei 3 Suchen). + Lediglich das initiale Laden der Treffer dauert etwas, das Zeug muss halt über die Leitung und einmal geparst werden. +- [Maj0r] Anzahl aller unterschiedlichen gefundenen Dateien einer Suche wird im Suchergebnisreiter angezeigt +- [Maj0r] Ist beim Start Loglevel Debug eingestellt, wird ein weiterer Reiter "Debug" angezeigt, der alle Lognachrichten enthält +- [Maj0r] Featurerequest: Gesamtpunkte der gesetzten Priorität wird im Sharebereich ( x/1000 ) angezeigt. (Danke an `fdh`) +- [Maj0r] TKLControls eingebaut ([www.tkl-soft.de](http://www.tkl-soft.de)) + In den Optionen und im Wizard werden nun Felder mit modifizierten Werten blau umrahmt. Mit `Strg+z` kann der Ursprungswert wieder hergestellt werden. + Ungültige Werte werden rot umrahmt (z.B. im Downloadlinkfeld im Downloadbereich). +- [Maj0r] Bug #527 gefixt: 100%-CPU-Bug behoben. Trat immer auf, wenn man die Größe der Partliste veränderte. (Danke an `fdh`) +- [Maj0r] Featurerequest #476: Suchergebnisse, die bereits im Temp oder im Share vorhanden sind, werden grün markiert. (Danke an `clickweg`) +- [Maj0r] GUI komplett refactored und auf die neue `CoreFassade 1.0` umgebaut +- [loevenwong] Featurerequest #549 Automatischen Powerdownload komplett überarbeitet. (Danke an `xxluckystrikexx`) + +**0.61.2** + +- [Maj0r] Bug #528 gefixt: Deadlock bei der Darstellung der Partliste behoben. (Danke an `akku`) +- [Maj0r] Bug #525 gefixt: Das GUI nutzte bei ungünstiger Datenkonstellation 100% CPU-Zeit (Danke an `akku` und `apokalypse1982`) + +**0.61.1** + +- [Maj0r] Auf vielfachen Wunsch Partlistanzeige wieder auf mehrere Threads aufgeteilt. Braucht wieder etwas mehr Ressourcen, ist aber beim gefühlten Laden schneller. +- [Maj0r] Bug #524 gefixt (Danke an `akku` und `fdh`) +- [Maj0r] Bug gefixt: Nach Benutzung von "Priorität löschen" wurde die View nicht aktualisiert. + +**0.61.0** + +Core ab Version **0.30.146.1202** wird benötigt + +- [Maj0r] Wenn ein Download hinzugefügt wird, gibt es nun, wenn der Core einen Fehler meldet, eine Benachrichtigung. +- [Maj0r] Bug gefixt (Danke an Up) + Coreseitig beendete Suchen werden nun auch im GUI als beendet dargestellt. +- [Maj0r] `skinlf.jar` aktualisiert +- [Maj0r] ajl-Listen können nun direkt mit Angabe eines Zielverzeichnisses importiert werden +- [Maj0r] Downloads können nun direkt mit Angabe eines Zielverzeichnisses gestartet werden +- [Maj0r] Anzeige zusätzlicher Information gesharter Dateien (Datum letzter Anfrage, Anzahl Downloadanfragen, Anzahl Suchanfragen) +- [Maj0r] Bug gefixt + Es konnte mit jedem offenen Port eine Verbindung hergestellt werden, das GUI blieb anschließend leer. + Unterscheidung zwischen ungültiger Coreadresse und falschem Passwort eingebaut. +- [Maj0r] Featurerequest #465 (Danke an clickweg) + Beim ersten Start des GUIs wird versucht, anhand der Standardeinstellungen zu verbinden. +- [Maj0r] Die Datei properties.xml wurde durch die Datei ajgui.properties ersetzt. +- [Maj0r] Einschränkung aufgehoben + Im Verbindungsdialog können nun beliebig viele Cores gespeichert werden. +- [Maj0r] Bug #490 gefixt (Danke an Up) + Umlaute sind nun in Verzeichnis- und Dateinamen in den Optionen möglich. +- [Maj0r] Bug gefixt + Im Verbindungsdialog funktionierte die Datenübernahme nicht, wenn im Host- oder Passwortfeld Return betätigt wurde. +- [Maj0r] Featurerequest #475 (Danke an clickweg) + Anzeige der Verfügbarkeit in Prozent der aktuell gezeigten Partliste. +- [Maj0r] Featurerequest #481 (Danke an johannes8) + Firewall-Warnung wird nun zusätzlich als Symbol und als Tooltipp ganz links in der Statusleiste angezeigt. +- [Maj0r] Bug #494 gefixt (Danke an dsp2004) +- [Maj0r] Bug #505 gefixt (Danke an rexcorda) +- [loevenwong] Focus wird auf das Passwort-Feld gesetzt. + +**0.60.0** + +- [Maj0r] Featurerequest #472 (Danke an clickweg) + Downloads, Shares und Suchergebnisse werden nun mit passenden Icons dargestellt (vgl. Suche). +- [loevenwong] Featurerequest #458; Verbindungswizard kann über Optionen->Verbindungen gestartet werden.- [loevenwong] Featurerequest #414 (Danke an clickweg) + Download-Tooltipps können per Optionen->Ansicht deaktiviert werden. +- [loevenwong] Wenn automatisch Verbinden ausgewählt ist, wird anschliessend noch geprüft, ob die SHIFT-Taste gedrückt wird (nach Erscheinen des Splash-Screens), + falls doch ein anderer Core verwendet werden soll.- [loevenwong] Tastaturereignisse beim Anmeldedialog um ENTER/ESCAPE erweitert.- [Maj0r] Featurerequest + Unter Optionen->Ansicht kann ein Programm ausgewählt werden (z.B. VLC). + Wenn der Core auf dem gleichen Rechner wie das GUI läuft, dann wird in der Downloadtabelle und in der Sharetabelle im Kontextmenü ein neuer Menüpunkt aktiviert. + Mit diesem wird der Shareeintrag an das verknüpfte Programm übergeben. +- [Maj0r] Bug #175 gefixt (Danke an jr17) + TrayIcon gefixt. +- [Maj0r] Bug #413 gefixt (Danke an hirsch.marcel) + Leere Suchen werden nicht mehr ausgeführt. Leerstellen am Anfang und am Ende eines Suchbegriffs werden entfernt. +- [Maj0r] Featurerequest #442 (Danke an clickweg) + Uploads können nun per Kontextmenü als Links in die Zwischenablage kopiert werden. +- [Maj0r] Stats eingebaut. Parameter: -command=getajstats +- [loevenwong] Versionsanzeige eingebaut. Parameter: -command=getajinfo + +**0.59.3** + +- [Maj0r] Bugfix (Danke an muhviehstarr) + Zwei Deadlocks behoben. Einer bewirkte, dass das GUI beim Start beim Splashscreen hängen bleiben konnte. +- [Maj0r] \n in der Servernachricht wird nicht mehr beachtet. Html-Tags verwenden. +- [Maj0r] Featurerequest + Automatischer Powerdownload pausiert nun standardmäßig nicht mehr die Downloads. + Außerdem kann nun ein Einstellungendialog implementiert werden, um Anpassungen während des Betriebs des autom. Pwdls vorzunehmen. +- [Maj0r] Bugfix + Bei sehr hohen Maxupload- und/oder Maxdownloadwerten kam es zu Fehlern im TrayIcon. +- [Maj0r] Bug #421 gefixt (Danke an Up) + Wizard wurde um Standardeinstellungen für DSL 1000, DSL 2000 und DSL 3000 erweitert. +- [Maj0r] Bug #423 gefixt (Danke an hirsch.marcel und Up) + Aktive, indirekte Uploads werden wieder angezeigt. +- [Maj0r] Dreckigen Rest im Uploadbereich entfernt. + +**0.59.2** + +- [Maj0r] Bug #420 gefixt (Danke an Up) + Ganz frischen NullPointer gefixt. + +**0.59.1** + +Core ab Version **0.30.145.610** wird benötigt + +- [Maj0r] Wasserstände der einzelnen Uploader werden angezeigt. +- [Maj0r] Beim Serverwechsel wird nun eine qualifizierte Warnung ausgegeben, wenn die aktuelle Verbindung noch keine 30 Minuten besteht. +- [Maj0r] Bugfix + Beim Neuerzeigen der properties.xml wurden die neuen Coredaten nicht für die aktuelle Sitzung übernommen. + Folge war ein Verbindungsverlust. + +**0.59.0** + +- [Maj0r] Durch Ändern einer Source-Variable in der AutomaticPowerdownloadPolicy.java kann das Pausieren von Dateien verhindert werden. +- [Maj0r] Bug #392 gefixt (Danke an Up und jr17) + Im Zuge der XML-Parser-Umstellung (0.56.1) ist die Firewallwarnung verschütt gegangen. +- [Maj0r] Icons für Uploads in der Warteschlange korrigiert. +- [Maj0r] Downloadadresse für die Updateinfodatei auf Wunsch der berlios-Crew von berlios.de auf tkl-soft.de geändert. +- [Maj0r] Uploads, die zwar in der Warteschlange sind, aber keine aktive Verbindung halten, werden jetzt im dreckigen Rest angezeigt. + +**0.58.0** + +Core ab Version **0.30.144.522** wird benötigt + +- [Maj0r] Bug #360 gefixt (Danke an fapu & panterfrau) + Beim Linkklicken konnte es passieren, dass zwei GUIs gestartet werden. +- [Maj0r] Bug #361 gefixt (Danke an panterfrau) + Logfehlermeldung bei überlastetem Core wird nun nur noch als Debug gelogt. +- [Maj0r] Featurerequest (Danke an Up) + Bei Servern ohne Namen wird nun im Startbereich IP:Port angezeigt. +- [Maj0r] Willkommensnachricht des Servers eingebaut. +- [Maj0r] Anzeige, ob die Warteschlange voll ist, im Uploadbereich eingebaut. +- [maj0r] In der Statusspalte eines nicht aktiven Uploads wird nun die Corezeit der letzen Aktivität angezeigt. + +**0.57.1** + +- [Maj0r] Bugfix (Danke an mich ;) ) + Beim Laden von Plugins konnten Fehler beim Classloading auftreten. Wenn der Statusbalken bei "Lade Plugins..." hängen bleibt, bitte updaten. +- [Maj0r] Change (Danke an hirsch.marcel) + Irc-Server im Infodialog angepasst. +- [Maj0r] Archivdifferenzierung beseitigt (Besonderen Dank an Up für die Windows-Starter-Exe !!) + Es gibt fortan keine separaten Archive mehr für Windows und andere Betriebssysteme. +- [Maj0r] Featurerequest #319 (Danke an tom62) + Sortierung im Dateilistenexport eingebaut. +- [Maj0r] Bugfix (Danke an muhviehstarr) + Sortierung nach Zeit in der Serveranzeige korrigiert. +- [Maj0r] Bug #322 gefixt (Danke an torsten_altreiter) + Der Dateiname wurde per Linkübernahme aus der Suche nicht korrekt übernommen. +- [loevenwong] Updateprüfung auch per Menüeintrag ermöglicht. +- [Maj0r] Standardaussehen auf JGoodies geändert (weniger ressourcenlastig) + Themes können natürlich weiterhin verwendet werden. + +**0.57.0** + +- [Maj0r] Bugfix (Danke an whitewindow) + Die Anzahl der Quellen pro gefundener Datei wurde bei neuen Ergebnissen nicht korrigiert. + Die Anzahl der gefundenen Dateien war korrekt, jedoch die Anzahl der Quellen pro Datei entsprechend niedrig. +- [Maj0r] Bug #306 gefixt (Danke an dsp2004) + Bei Partlistanfragen an einen überlasteten Core kam es zu Fehlern. +- [Maj0r] Fortschrittsbalken in den Splashscreen eingebaut. +- [Maj0r] Tooltipps in der ersten Spalte der Downloadtabelle eingebaut. +- [Maj0r] Info-Dialog geändert + Credits geändert. + Credits lassen sich nun per Mausklick in den Dialog anhalten bzw. fortsetzen. + +**0.56.2** + +- [Maj0r] Bug #293 gefixt (Danke an dsp2004) + Bei Partlistanfragen an einen überlasteten Core kam es zu Fehlern. +- [Maj0r] Bug #260 gefixt (Danke an computer.ist.org) + Buttons im Sharebereich dürfen erst aktiviert werden, wenn die Einstellungen vom Core geholt wurden. +- [Maj0r] Bug #282 gefixt (Danke an tnt23) + NullPointer behoben, der auftrat, wenn man im Sharebereich auf "Prioritaet setzen" geklickt hat, ohne vorher einen Eintrag zu selektieren. +- [Maj0r] Bug #273 gefixt + Es kam zu einem Fehler, wenn die Partliste nicht den gesamten reservierten Bereich bedeckte und dieser Teil von der Maus überwandert wurde. +- [loevenwong] Featurerequest #222: Combobox zur Auswahl der letzten 3 Verbindungen eingebaut. (Danke an `hirsch.marcel`) +- [Maj0r] Featurerequest #222 (Danke an `johannes8`) + Download-Umbennen-Dialog bietet nun eine Auswahl der gefundenen Namen der Sourcen des Downloads an. +- [Maj0r] Kontextmenü im Downloadbereich überarbeitet + F-Tasten eingebaut. + Pausieren und Fortsetzen auf vielfachen Wunsch getrennt. +- [Maj0r] Dialog zur Eingabe eines Datei-Incoming-Verzeichnisses kann jetzt per `RETURN` bestätigt werden. +- [Maj0r] Bug behoben, der sich durch die dynamische Generierung der properties.xml ohne Neustart eingeschlichen hat. +- [loevenwong] Einfügen per Kontextmenü im Download-Textfeld eingebaut. +- [loevenwong] Einstellungen der JGoodies werden jetzt gespeichert. +- [Maj0r] Installierte Look&Feels werden beim Generieren der Standard-XML mit aufgenommen. + +**0.56.1** + +diese Version benötigt den Core ab Version **0.29.135.208** + +- [Maj0r] GUI startet nur noch bei unterstützter Coreversion +- [loevenwong] GUI muss nicht neugestartet werden, wenn noch kein Property-File vorhanden ist (wird weiterhin automatisch erzeugt). +- [Maj0r] Featurerequest #254 gefixt (Danke an te_real_ZeroBANG) + Downloadtabelle wird jetzt beim Start standarmäßig nach Dateiname sortiert. +- [Maj0r] Featurerequest #274 gefixt (Danke an johannes8) + Downloads können per F2 umbenannt werden. +- [Maj0r] Bug #264 gefixt (Danke an muhviestarr) + Verbindungsstatus wird richtig angezeigt. +- [Maj0r] Modifizierbare und potenziell modifizierbare Dateien bei Nicht-Windows-System verschoben + properties.xml nach ~/appleJuice/gui + Plugins nach ~/appleJuice/gui/plugins + Logs nach ~/appleJuice/gui/logs +- [Maj0r] Pluginschnittstelle komplett überarbeitet + Alle vorhandenen Plugins müssen an die neue Schnittstelle angepasst werden. + Gründe für die Überarbeitung: + 1\. einfacher + 2\. Eingrenzung der Plugins und Minimierung der Fehlermöglichkeiten + 3\. Sprachdateien werden unterstützt (zB language_xml_deutsch.xml im Plugin-Jar) +- [Maj0r] Suchergebnisse werden nun, wenn möglich mit einem sprechenden Icon angezeigt. +- [Maj0r] Suche um Filter erweitert + Die Filter in der Suchergebnistabelle wirken sich NICHT auf die Suche aus, lediglich die Treffer werden gefiltert. +- [Maj0r] Status "Warteschlange voll" wird nun auch in "In Warteschlange" angezeigt, da diese zB für Pwdl-Änderungen genauso relevant sind. +- [Maj0r] TableHeader werden in allen Tabellen gleich dargestellt. +- [Maj0r] Unterstützung für fremde Look&Feels eingebaut + Um Look&Feels zu verwenden, müssen die Themes deaktiviert werden. + Ausgeliefert werden nur JGoodies als alternative Look&Feels. + Es können alle konformen Look&Feels verwendet werden. Dazu einfach ein passendes Jar in /lib legen und die Look&Feel-Klasse in der propertes.xml eintragen. +- [Maj0r] Unnützes Passwortfeld unter Optionen->Passwort entfernt. +- [Maj0r] Passwortfeld unter Optionen->Proxy ist nun wirklich ein Passwortfeld und stellt das Passwort nicht mehr im Klartext dar. +- [Maj0r] Standardthemepack auf Toxic geändert. + +**0.56.0** + +meine wahrscheinlich letzte GUI für den Core 0.29.x +**- Soundausgabe bei korrektem Login korrigiert. +- Sound bei fertigem Download eingebaut. +- Unicode-Verwendung im Umgang mit den Sprachdateien korrigiert. +- Kleinere Korrekturen. + +**0.55.10** + +- Bug #246 gefixt: Nun können auch bei "voller" Dateilistetabelle im Sharebereich neue Dateien hinein gezogen werden. (Danke an `mail_tom62`) +- Automatische Sortierung nach Dateiname eingebaut. +- Featurerequest #244 gefixt: Standardmäßig ist nun beim automatischen Powerdownload der Inaktiv-Button selektiert. (Danke an `Homer1Simpson`) +- Bug #243 gefixt: GUI stört sich nicht mehr an Nicht-Themes-Zips im Themes-Verzeichnis. (Danke an `RoadRunner`) +- Bug #241 gefixt: Farbgebung war genau umgekehrt. Nun gilt wirklich: je dunkler, desto mehr Quellen gefunden. (Danke an `computer.ist.org`) +- Partliste zeigt nun per MausOver-Effekt den Tooltipp zum ausgewählten Partstück an. + +**0.55.9** + +- Link zur FAQ im Startbereich hinzugefügt. +- Bug #242 gefixt: Legende für Partliste um "aktive Übertragung" erweitert. (Danke an `Kossi-Jaki`) +- Bug behoben, der im VersionChecker zu einer NoSuchElementException führte. (Danke an `computer.ist.org`) +- Bug #239 gefixt: ArrayIndexOutOfBoundsException behoben. (Danke an `dsp2004`) +- Bug #235 gefixt: Passwortfeld im Logindialog funktioniert wieder ordentlich. (Danke an `Up`) + +**0.55.8** + +- Bug #234 gefixt: Tabellen werden beim Ändern von Spaltengrößen nicht mehr sortiert. (Danke an `hirsch.marcel`) +- Featurerequest #228: Im Pwdl-Eingabefeld funktionieren nun auch die Hoch/Runter-Pfeiltasten. (Danke an `Major-Tom`) +- Links werden nun bei Übernahme in eine verwertbare Schreibweise geparst. +- Bug #226 gefixt (Danke an dsp2004) +- GUI reagiert ordentlich auf eine coreseitige Passwortänderung. +- Server werden nun korrekt angezeigt. +- weitere Speicheroptimierung. + +**0.55.7** + +- Bug #223 und #224 gefixt: Das waren noch Bugs in Verbindung mit der DOM/SAX-Umstellung... (Danke an `dsp2004`, `Up` und `whitewindow`) + +**0.55.6** + +- meisten Teile von DOM auf SAX umgebaut, RAM-Verbrauch sollte dadurch spürbar gesenkt werden. +- Bug #219 gefixt: 100%-CPU bei Eingabe eines falschen Passwortes beim Anmeldedialog gefixt. (Danke an `Up`) +- Bug #220 gefixt: OutOfMemoryError behoben. (Danke an `dsp2004`) + +**0.55.5** + +- alten Timestampfehler beseitigt. Trotz Sessionumsetzung wurde immer noch der Timestamp mitgeschleppt. +- Bug #215 gefixt: Partliste wird nun auch bei kleinen Dateien korrekt gezeichnet. (Danke an `dsp2004`) +- Bug #129 gefixt: WebsiteException durch Überlastung des Cores sollte nun weitgehend unterbunden sein. (Danke an dsp2004) + +**0.55.4** + +- Bug #23 gefixt: Suche abbrechen korrigiert. (Danke an `computer.ist.org`) + +**0.55.3** + +- Mehr Logging für WebSiteNotFoundException eingebaut. +- Partliste bearbeitet: + Hoffentlich den letzten Fehler behoben. + Anzeige der Teile, die zurzeit übertragen werden (hellgelb bis dunkelgelb). + Aktualisierungintervall auf 2 Sekunden geändert. +- Button zum Verwerfen einer abgebrochenen Suche in den Suchreiter verschoben. +- Link mit Quellen kann nun auch im Sharebereich erzeugt werden. +- Bug #195 gefixt: Bug bei Pwdl-Einstellung korrigiert.. (Danke an `supermuhkuh`) +- Bug #167 gefixt: Sortierung nach Anzahl in der Suchtabelle korrigiert. (Danke an `arnoldfake`) +- Bug #198 gefixt: Sortierung nach Downloadstatus korrigiert. (Danke an `froeschle567`) + +**0.55.2** + +Core ab **0.29.135.208** ist zu verwenden. + +- Max. Anzahl von Quellen pro Datei kann nun begrenzt werden +- SplitPane in Sharebereich eingebaut. +- Sortierung des Sharebaums verbessert. +- Sortierung in Incoming- / Tempauswahlbaum eingebaut. +- Partliste überarbeitet. +- Startbereich scrollbar gemacht, wenn die Darstellung zu klein ist. +- Rand der JSplitPane im Downloadbereich entfernt (Danke an `muhviestarr`). +- Icons für Upload-DirectStates eingebaut. +- verwendete Java-Version wird in die Logdatei geschrieben. +- Wizarddialog korrigiert: Nickname wird nun auf Richtigkeit geprüft und gespeichert wird erst nach Durchlaufen des gesamten Wizards. +- Bug #94 gefixt: Zulässige Werte für Core-Port und XML-Port sind 1024 (Danke an muhviestarr). +- Legende für die Servertabelle eingebaut (Danke an muhviestarr). +- Text von Netzwerk, Neuigkeiten und Nachrichten ist nun auch schwarz (Danke an muhviestarr). +- Die Überschrift "Warnungen" auf der Startseite wird nun ausgeblendet, wenn es keine Warnungen gibt (Danke an muhviestarr). +- Gridlines werden nun in der Servertabelle nicht mehr angezeigt (Danke an muhviestarr). +- Splashscreen wird nun früher angezeigt (Danke an muhviestarr). +- Bug in der Partliste behoben. +- Dau-Button zum Anzeigen der Partliste eingebaut. +- Bug der Tableheader der Share- und der Uploadtabelle behoben (Danke an muhviestarr). + +**0.49** + +- Bug bei der Wiedergabe von Sounds korrigiert (Danke an mrbond). + Sounddevice wird nun nach Ausgabe eines Sounds wieder freigegeben. +- Es kann nun der Link einer gesharten Datei über das Popupmenü der Sharetabelle als UBB-Code in die Ablage kopiert werden. +- Entwicklercreditsanzeige im Infodialog korrigiert. +- Bug im Sharebaum behoben. +- Bug beim Sortieren der Sharetabelle behoben. + +**0.48** + +- Initialen Aufruf des Sharetabs durch einen Initialisierungsthread beschleunigt. +- In der Downloadtabelle nun ein Warteicon angezeigt, bis erstmalig Daten geholt wurden. +- Verhalten des Popupmenüs der Servertabelle überarbeitet. +- Partliste wird nun nur noch über das PopupMenü geholt. + Wenn der Downloadtab verlassen wird, wird das Aktualisieren der aktuellen Partliste beendet. + +**0.47** + +- Sharetabelle auf vielfachen Wunsch komplett überarbeitet. +- Partliste wird erst nach 2 Sekunden Wartezeit geholt (Danke an muhviestarr). + Wenn innerhalb dieser Zeit auf einen anderen Download.bzw. eine andere Quelle geklickt wird, wird die Wartezeit neu gestartet. +- Suche kann nun GUI-seitig abgebrochen werden. + Der aktuelle Core (0.29.124.1215) hat an dieser Stelle noch einen Bug, eine Suche wird jedoch nach einiger Zeit automatisch beendet. +- Tabellenspaltenroothandles werden nun in der Downloadtabelle angezeigt (Danke an muhviestarr). + So weiss auch der letzte Benutzer, dass man auf einen Download klicken kann, um die Quellen zu finden. +- Neuen Downloadstatus "Fehler beim Fertigstellen" und neuen Quellenstatus "Eigenes Limit erreicht" eingebaut. +- Rundungsfehler beim automatischen Powerdownload behoben (Danke an garnichda). + +**0.46** + +- Bug beim autom. Pwdl behoben, der auftrat, wenn nur eine Datei im Download war. +- Bug im Menü behoben, Auswahl eines Menüpunktes geht nun gewohnt schnell.. +- Kleinere optische Korrekturen (Danke an DBZfan) + z.B. Hintergrundfarben aller Scrollbereiche an ihre Tabelle angepasst. +- Prozentangabe bei Downloads nun auf zwei Nachkommastellen genau (Danke an muhviestarr) +- Parameterübergabe an das GUI geändert + Mögliche Parameter können per -help angezeigt werden. + Die reg-Datei muss neu angepasst und importiert werden, da diese ebenfalls modifiziert werden musste. +- diverse andere Bugs behoben + +**0.45** + +- Links können nun an das GUI übermittelt werden (für den INet-Explorer muss die entsprechende reg-Datei angepasst und importiert und die Windows-Exe verwendet werden). +- Themes sind nun deaktivierbar + +**0.44** + +- Themes eingebaut (Danke an `LinuxDoc`) + Passende Themes gibt?s auf https://github.com/l2fprod/javootoo.com/tree/master/plaf/skinlf/themepacks. +- Automatischen Powerdownload eingebaut. + Verschiedene Arten des autom. Pwdls können in Zukunft durch selbst implementierte Klassen per Combobox ausgewählt werden (nächste Version). + +**0.43** + +- max.RAM-Anzeige in Memory-Monitor eingebaut (Anzeige oben links nun "reserviert / max allocated"). +- Soundicons optisch korrigiert. +- Fehler bei der Soundausgabe bei fehlerhaften Sounddateien (z.B. falsches Format) oder fehlendem Sounddevice behoben. + +**0.42** + +- Memory-Monitor eingebaut (ja, die Anzeige geht richtig und zeigt den echten RAM-Verbrauch der Anwendung) +- manuellen GarbageCollector bei jeder 30\ +- Aktualisierung eingebaut + +**0.41** + +- Fehler im Pwdl-Textfeld behoben +- Sortieren der Downloadtabelle nach Status eingefügt +- Speicheroptimierungen. + +**0.40** + +- Soundeffekte für diverse Ereignisse eingefügt. + +**0.39** + +- Standarduploadpriorität ist im Core noch nicht implementiert und deshalb erstmal wieder aus dem GUI geflogen (Danke an `xcalibur`) +- Buttons zum Ändern der Pwdl-Werte entsprechend dem Standard vertauscht (Danke an `lova`) +- Baum zur Auswahl des Temp- und Incomingordners korrigiert. Bug hat sich erst mit `v0.38` eingeschlichen (Danke an `lova` und `akku`) diff --git a/CONFIG.md b/CONFIG.md new file mode 100644 index 00000000..4d07380e --- /dev/null +++ b/CONFIG.md @@ -0,0 +1,21 @@ +# versteckte Parameter + +Die nachfolgenden Parameter können nur direkt in den `properties` Dateien geändert werden. + +## ajgui.properties + +- GUI NEWS URL als `options_news_url` +- Serverliste URL als `options_server_list_url` +- Update-Server Feed als `options_update_server_url` + +## rel.properties + +Der `Suche nach mehr Informationen` Button im Kontextmenü öffnet eine URL, mit dem dahinterliegenden `ajfsp` Link als GET Parameter. + +Dafür muss im `~/appleJuice/gui/` Ordner eine `rel.properties` Datei mit folgender Konfiguration vorhanden sein (wird automatisch angelegt): + +```ini +host=https://relinfo.tld/api/ajfsp/?link=%s +``` + +Das letzte `%s` wird mit dem vollständigen `ajfsp` Link ersetzt (urlencoded). diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 00000000..4f85aa52 --- /dev/null +++ b/DEVELOP.md @@ -0,0 +1,26 @@ +# development + +### neues Release in dieser Reihenfolge erstellen + +```bash +mvn versions:set \ + -DgroupId=de.applejuicenet.client.gui \ + -DartifactId=AJCoreGUI \ + -DgenerateBackupPoms=false \ + -DoldVersion="*" \ + -N versions:update-child-modules \ + -DnewVersion=0.85.3 + + mvn versions:set \ + -DgroupId=de.applejuicenet.client \ + -DartifactId=AJClientGUI \ + -DgenerateBackupPoms=false \ + -DoldVersion="*" \ + -N versions:update-child-modules \ + -DnewVersion=0.85.3 +``` + +2. Changelog anpassen +3. Änderungen committen und mit der neuen Version taggen +4. die github action erstellt zum Tag das Release mit passenden Assets + diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..31e1c6df --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + Preamble + +The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains + a notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", below, + refers to any such program or work, and a "work based on the Program" + means either the Program or any derivative work under copyright law: + that is to say, a work containing the Program or a portion of it, + either verbatim or with modifications and/or translated into another + language. (Hereinafter, translation is included without limitation in + the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any warranty; + and give any other recipients of the Program a copy of this License + along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this License. + However, parties who have received copies, or rights, from you under + this License will not have their licenses terminated so long as such + parties remain in full compliance. + +5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties to + this License. + +7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Program at all. For example, if a patent + license would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License + may add an explicit geographical distribution limitation excluding + those countries, so that distribution is permitted only in or among + countries not thus excluded. In such case, this License incorporates + the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions + of the General Public License from time to time. Such new versions will + be similar in spirit to the present version, but may differ in detail to + address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the author + to ask for permission. For software which is copyrighted by the Free + Software Foundation, write to the Free Software Foundation; we sometimes + make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS + TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, + REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, + INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING + OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED + TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program +`Gnomovision' (which makes passes at compilers) written by James Hacker. + +, 1 April 1989 +Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ProcessNoST/.classpath b/ProcessNoST/.classpath deleted file mode 100644 index 39a54068..00000000 --- a/ProcessNoST/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/ProcessNoST/.project b/ProcessNoST/.project deleted file mode 100644 index 02d88992..00000000 --- a/ProcessNoST/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - ProcessNoST - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/ProcessNoST/lib/junit.jar b/ProcessNoST/lib/junit.jar deleted file mode 100644 index 674d71e8..00000000 Binary files a/ProcessNoST/lib/junit.jar and /dev/null differ diff --git a/ProcessNoST/lib/mm.mysql-2.0.14-bin.jar b/ProcessNoST/lib/mm.mysql-2.0.14-bin.jar deleted file mode 100644 index 32f04104..00000000 Binary files a/ProcessNoST/lib/mm.mysql-2.0.14-bin.jar and /dev/null differ diff --git a/ProcessNoST/lib/pride.jar b/ProcessNoST/lib/pride.jar deleted file mode 100644 index 04552c74..00000000 Binary files a/ProcessNoST/lib/pride.jar and /dev/null differ diff --git a/ProcessNoST/lib/pride2.2.0-plugin.zip b/ProcessNoST/lib/pride2.2.0-plugin.zip deleted file mode 100644 index 38afc7b4..00000000 Binary files a/ProcessNoST/lib/pride2.2.0-plugin.zip and /dev/null differ diff --git a/ProcessNoST/src/de/tklsoft/processnost/server/database/DatabaseLocator.java b/ProcessNoST/src/de/tklsoft/processnost/server/database/DatabaseLocator.java deleted file mode 100644 index a9cdf599..00000000 --- a/ProcessNoST/src/de/tklsoft/processnost/server/database/DatabaseLocator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Created on 09.09.2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package de.tklsoft.processnost.server.database; - -import de.mathema.pride.DatabaseFactory; -import de.mathema.pride.ResourceAccessor; -import de.mathema.pride.ResourceAccessorJ2SE; -import de.tklsoft.processnost.shared.ProcessNoSTProperties; - -/** - * @author krallt - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public final class DatabaseLocator { - private static DatabaseLocator instance = null; - - private DatabaseLocator(){ - ProcessNoSTProperties props = ProcessNoSTProperties.getInstance(); - ResourceAccessor accessor = new ResourceAccessorJ2SE(null); - DatabaseFactory.setResourceAccessor(accessor); -// DatabaseFactory.setDatabaseName(props.get.getProperty("pride.db")); - } - - public static synchronized DatabaseLocator getInstance(){ - if (instance == null){ - instance = new DatabaseLocator(); - } - return instance; - } - -} diff --git a/ProcessNoST/src/de/tklsoft/processnost/server/engine/ProcessNoSTEngine.java b/ProcessNoST/src/de/tklsoft/processnost/server/engine/ProcessNoSTEngine.java deleted file mode 100644 index 25414785..00000000 --- a/ProcessNoST/src/de/tklsoft/processnost/server/engine/ProcessNoSTEngine.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Created on 09.09.2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package de.tklsoft.processnost.server.engine; - -/** - * @author krallt - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class ProcessNoSTEngine { - - private ProcessNoSTEngine(){ - // noch eine Menge zu tun... - } - - public static void main(String[] args) { - new ProcessNoSTEngine(); - } -} diff --git a/ProcessNoST/src/de/tklsoft/processnost/shared/ProcessNoSTProperties.java b/ProcessNoST/src/de/tklsoft/processnost/shared/ProcessNoSTProperties.java deleted file mode 100644 index 9100e37f..00000000 --- a/ProcessNoST/src/de/tklsoft/processnost/shared/ProcessNoSTProperties.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Created on 09.09.2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package de.tklsoft.processnost.shared; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; - -/** - * @author krallt - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public final class ProcessNoSTProperties { - - private static ProcessNoSTProperties instance = null; - - private final String propertiesLocation; - private final Properties properties; - - private final String PROPERTY_DRIVER = "db_driver"; - private final String PROPERTY_PORT = "db_port"; - private final String PROPERTY_HOST = "db_host"; - private final String PROPERTY_USER = "db_user"; - private final String PROPERTY_PASSWORD = "db_password"; - - private ProcessNoSTProperties(){ - propertiesLocation = System.getProperty("user.home") + File.separator + "processnost.properties"; - properties = new Properties(); - FileInputStream inputStream = null; - try { - inputStream = new FileInputStream(propertiesLocation); - } catch (FileNotFoundException e) { - // Datei existiert noch nicht. Template wird angelegt - properties.setProperty(PROPERTY_DRIVER, "org.gjt.mm.mysql.Driver"); - properties.setProperty(PROPERTY_PORT, ""); - properties.setProperty(PROPERTY_HOST, ""); - properties.setProperty(PROPERTY_USER, ""); - properties.setProperty(PROPERTY_PASSWORD, ""); - save(); - try { - inputStream = new FileInputStream(propertiesLocation); - } catch (FileNotFoundException e2) { - // Nun kann es nicht mehr passieren. - e2.printStackTrace(); - } - } - try { - properties.load(inputStream); - inputStream.close(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - - public static synchronized ProcessNoSTProperties getInstance(){ - if (instance == null){ - instance = new ProcessNoSTProperties(); - } - return instance; - } - - public String getDbDriver(){ - return properties.getProperty(PROPERTY_DRIVER); - } - - public String getDbHost(){ - return properties.getProperty(PROPERTY_HOST); - } - - public String getDbPort(){ - return properties.getProperty(PROPERTY_PORT); - } - public String getDbUser(){ - return properties.getProperty(PROPERTY_USER); - } - public String getDbPassword(){ - return properties.getProperty(PROPERTY_PASSWORD); - } - - private void save(){ - File aFile = new File(propertiesLocation); - try { - aFile.createNewFile(); - FileOutputStream outputStream = new FileOutputStream(aFile); - properties.store(outputStream, "Property-File for ProcessNoST"); - outputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/README.md b/README.md new file mode 100644 index 00000000..058fc3af --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# appleJuice Client GUI + +![](https://img.shields.io/github/release/applejuicenetz/gui-java.svg) +![](https://img.shields.io/github/downloads/applejuicenetz/gui-java/total) +![](https://img.shields.io/github/license/applejuicenetz/gui-java.svg) + +![](https://github.com/applejuicenetz/gui-java/workflows/release/badge.svg) + +![](https://github.com/applejuicenetz/gui-java/actions/workflows/snapcraft.yml/badge.svg) +![](https://snapcraft.io/applejuice-gui/badge.svg) + +Dieses GUI ist das grafisches Interface (Graphical User Interface) für den appleJuice Core. + +## Installation + +| Platform | Link | +|---------- |-----------------------------------------------------------------------| +| Windows | [setup.exe](https://github.com/applejuicenetz/gui-java/releases) | +| macOS | [AJcoreGUI.dmg](https://github.com/applejuicenetz/gui-java/releases) | +| Linux | [Snap Package](https://snapcraft.io/applejuice-gui) | + +## Changelog + +Ein aktuelles Changelog befindet sich [hier](CHANGELOG.md) diff --git a/ajcorefassade/.classpath b/ajcorefassade/.classpath deleted file mode 100644 index 7a3ef36a..00000000 --- a/ajcorefassade/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/ajcorefassade/.project b/ajcorefassade/.project deleted file mode 100644 index 57cfe3fe..00000000 --- a/ajcorefassade/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - ajcoreFassade - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/ajcorefassade/.settings/org.eclipse.jdt.core.prefs b/ajcorefassade/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 52cbd677..00000000 --- a/ajcorefassade/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,69 +0,0 @@ -#Tue Jan 18 12:26:18 CET 2005 -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -eclipse.preferences.version=1 -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled diff --git a/ajcorefassade/build/build.xml b/ajcorefassade/build/build.xml deleted file mode 100644 index c648766f..00000000 --- a/ajcorefassade/build/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/ApplejuiceFassade.java b/ajcorefassade/src/de/applejuicenet/client/fassade/ApplejuiceFassade.java deleted file mode 100644 index 798d522a..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/ApplejuiceFassade.java +++ /dev/null @@ -1,1190 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.controller.DataPropertyChangeInformer; -import de.applejuicenet.client.fassade.controller.DataUpdateInformer; -import de.applejuicenet.client.fassade.controller.json.ReleaseInfoJsonLoader; -import de.applejuicenet.client.fassade.controller.xml.DirectoryXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.GetObjectXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.InformationXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.ModifiedXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.NetworkServerXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.PartListXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.SettingsXMLHolder; -import de.applejuicenet.client.fassade.controller.xml.ShareXMLHolder; -import de.applejuicenet.client.fassade.entity.Directory; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.PartList; -import de.applejuicenet.client.fassade.entity.Search; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.fassade.entity.ShareEntry; -import de.applejuicenet.client.fassade.entity.Version; -import de.applejuicenet.client.fassade.entity.ShareEntry.SHAREMODE; -import de.applejuicenet.client.fassade.exception.CoreLostException; -import de.applejuicenet.client.fassade.exception.IllegalArgumentException; -import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; -import de.applejuicenet.client.fassade.exception.WrongPasswordException; -import de.applejuicenet.client.fassade.listener.CoreConnectionSettingsListener; -import de.applejuicenet.client.fassade.listener.CoreStatusListener; -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.fassade.listener.CoreStatusListener.STATUS; -import de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE; -import de.applejuicenet.client.fassade.shared.AJSettings; -import de.applejuicenet.client.fassade.shared.HtmlLoader; -import de.applejuicenet.client.fassade.shared.NetworkInfo; -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.ReleaseInfo; -import de.applejuicenet.client.fassade.shared.StringConstants; -import de.applejuicenet.client.fassade.tools.MD5Encoder; - -public class ApplejuiceFassade implements CoreConnectionSettingsListener -{ - public static final String FASSADE_VERSION = "F-1.23"; - public static final String MIN_NEEDED_CORE_VERSION = "0.30.146.1203"; - public static final String ERROR_MESSAGE = "Unbehandelte Exception"; - public static String separator; - private static HashSet coreListener = new HashSet(); - private final CoreConnectionSettingsHolder coreHolder; - private Map informer = new HashMap(); - private ModifiedXMLHolder modifiedXML = null; - private InformationXMLHolder informationXML = null; - private ShareXMLHolder shareXML = null; - private SettingsXMLHolder settingsXML = null; - private DirectoryXMLHolder directoryXML = null; - private Version coreVersion; - private Map share = null; - private PartListXMLHolder partlistXML = null; - private long sleepTime = 2000; - - // Thread - private Thread workerThread; - - public ApplejuiceFassade(CoreConnectionSettingsHolder coreConnectionSettingsHolder) - throws IllegalArgumentException - { - coreHolder = coreConnectionSettingsHolder; - coreHolder.addListener(this); - modifiedXML = new ModifiedXMLHolder(coreHolder, this); - DataUpdateInformer downloadInformer = new DataUpdateInformer(DATALISTENER_TYPE.DOWNLOAD_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getDownloads(); - } - }; - - informer.put(downloadInformer.getDataUpdateListenerType(), downloadInformer); - DataUpdateInformer searchInformer = new DataUpdateInformer(DATALISTENER_TYPE.SEARCH_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getSearchs(); - } - }; - - informer.put(searchInformer.getDataUpdateListenerType(), searchInformer); - DataUpdateInformer serverInformer = new DataUpdateInformer(DATALISTENER_TYPE.SERVER_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getServer(); - } - }; - - informer.put(serverInformer.getDataUpdateListenerType(), serverInformer); - DataUpdateInformer uploadInformer = new DataUpdateInformer(DATALISTENER_TYPE.UPLOAD_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getUploads(); - } - }; - - informer.put(uploadInformer.getDataUpdateListenerType(), uploadInformer); - DataUpdateInformer shareInformer = new DataUpdateInformer(DATALISTENER_TYPE.SHARE_CHANGED) - { - protected Object getContentObject() - { - return shareXML.getShare(); - } - }; - - informer.put(shareInformer.getDataUpdateListenerType(), shareInformer); - DataUpdateInformer networkInformer = new DataUpdateInformer(DATALISTENER_TYPE.NETINFO_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getNetworkInfo(); - } - }; - - informer.put(networkInformer.getDataUpdateListenerType(), networkInformer); - DataUpdateInformer speedInformer = new DataUpdateInformer(DATALISTENER_TYPE.SPEED_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getSpeeds(); - } - }; - - informer.put(speedInformer.getDataUpdateListenerType(), speedInformer); - DataUpdateInformer informationInformer = new DataUpdateInformer(DATALISTENER_TYPE.INFORMATION_CHANGED) - { - protected Object getContentObject() - { - return modifiedXML.getInformation(); - } - }; - - informer.put(informationInformer.getDataUpdateListenerType(), informationInformer); - } - - public DataPropertyChangeInformer getDownloadPropertyChangeInformer() - { - return modifiedXML.getDownloadPropertyChangeInformer(); - } - - public Long getLastCoreTimestamp() - { - if(modifiedXML != null) - { - return new Long(modifiedXML.getTimestamp()); - } - else - { - return null; - } - } - - public void addDataUpdateListener(DataUpdateListener listener, DATALISTENER_TYPE type) - { - if(informer.containsKey(type)) - { - DataUpdateInformer anInformer = informer.get(type); - - anInformer.addDataUpdateListener(listener); - } - } - - public void removeDataUpdateListener(DataUpdateListener listener, DATALISTENER_TYPE type) - { - if(informer.containsKey(type)) - { - DataUpdateInformer anInformer = informer.get(type); - - anInformer.removeDataUpdateListener(listener); - } - } - - public static boolean addCoreStatusListener(CoreStatusListener listener) - { - return coreListener.add(listener); - } - - public static boolean removeCoreStatusListener(CoreStatusListener listener) - { - return coreListener.remove(listener); - } - - private void informCoreStatusListener(STATUS newStatus) - { - for(CoreStatusListener curListener : coreListener) - { - curListener.fireStatusChanged(newStatus); - } - } - - public boolean isLocalhost() - { - return coreHolder.isLocalhost(); - } - - private void checkForValidCoreversion() - { - if(getCoreVersion() == null) - { - return; - } - - if(getCoreVersion().checkForValidCoreVersion() < 0) - { - throw new RuntimeException("invalid coreversion"); - } - } - - private int tryUpdate(int versuch) - { - int anzahl = versuch; - - if(updateModifiedXML()) - { - anzahl = 0; - } - else - { - anzahl++; - if(anzahl == 3) - { - throw new CoreLostException(); - } - } - - return anzahl; - } - - public void startXMLCheck() - { - workerThread = new Thread("ApplejuiceFassadeXMLCheckThread") - { - public void run() - { - setPriority(Thread.NORM_PRIORITY); - int versuch = 0; - - // load XMLs - informationXML = new InformationXMLHolder(coreHolder); - directoryXML = new DirectoryXMLHolder(coreHolder); - shareXML = new ShareXMLHolder(coreHolder); - if(coreVersion == null) - { - coreVersion = informationXML.getCoreVersion(); - checkForValidCoreversion(); - } - - informCoreStatusListener(STATUS.STARTED); - while(!isInterrupted()) - { - try - { - versuch = tryUpdate(versuch); - sleep(sleepTime); - } - catch(InterruptedException e) - { - - // nicht zu tun - ; - } - } - } - }; - workerThread.start(); - } - - public void setUpdateInterval(long millis) - { - if(millis > 0) - { - sleepTime = millis; - } - } - - public void stopXMLCheck() - { - if(workerThread != null) - { - workerThread.interrupt(); - workerThread = null; - informCoreStatusListener(STATUS.CLOSED); - } - } - - public String[] getCurrentIncomingDirs() - { - Map download = getDownloadsSnapshot(); - ArrayList incomingDirs = new ArrayList(); - boolean found; - - synchronized(download) - { - for(Download curDownload : download.values()) - { - if(curDownload.getTargetDirectory().length() == 0) - { - continue; - } - - found = false; - for(int i = 0; i < incomingDirs.size(); i++) - { - if(incomingDirs.get(i).compareToIgnoreCase(curDownload.getTargetDirectory()) == 0) - { - found = true; - break; - } - } - - if(!found) - { - incomingDirs.add(curDownload.getTargetDirectory()); - } - } - } - - incomingDirs.add(""); - return (String[]) incomingDirs.toArray(new String[incomingDirs.size()]); - } - - public Information getInformation() - { - return modifiedXML.getInformation(); - } - - public PartList getPartList(DownloadSource downloadSource) - throws WebSiteNotFoundException - { - if(partlistXML == null) - { - partlistXML = new PartListXMLHolder(coreHolder); - } - - return partlistXML.getPartList(downloadSource); - } - - public PartList getPartList(Download download) throws WebSiteNotFoundException - { - if(partlistXML == null) - { - partlistXML = new PartListXMLHolder(coreHolder); - } - - return partlistXML.getPartList(download); - } - - public String[] getNetworkKnownServers() - { - NetworkServerXMLHolder getServerXMLHolder = NetworkServerXMLHolder.getInstance(); - - return getServerXMLHolder.getNetworkKnownServers(); - } - - public AJSettings getAJSettings() - { - if(settingsXML == null) - { - settingsXML = new SettingsXMLHolder(coreHolder); - } - - return settingsXML.getAJSettings(); - } - - public AJSettings getCurrentAJSettings() - { - if(settingsXML == null) - { - return getAJSettings(); - } - else - { - return settingsXML.getCurrentAJSettings(); - } - } - - public void setMaxUpAndDown(final Long maxUp, final Long maxDown) - throws IllegalArgumentException - { - if(maxUp == null || maxUp.longValue() <= 0) - { - throw new IllegalArgumentException("invalid maxUp"); - } - - if(maxDown == null || maxDown.longValue() <= 0) - { - throw new IllegalArgumentException("invalid maxDown"); - } - - new Thread() - { - public void run() - { - StringBuilder parameters = new StringBuilder("MaxUpload="); - - parameters.append(maxUp.toString()); - parameters.append("&MaxDownload="); - parameters.append(maxDown.toString()); - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + - parameters.toString(), false); - } - }.start(); - } - - public void saveAJSettings(AJSettings ajSettings) - { - StringBuilder parameters = new StringBuilder(); - - try - { - parameters.append("Nickname=" + URLEncoder.encode(ajSettings.getNick(), "UTF-8")); - parameters.append("&XMLPort=" + Long.toString(ajSettings.getXMLPort())); - parameters.append("&Port=" + Long.toString(ajSettings.getPort())); - parameters.append("&MaxUpload=" + Long.toString(ajSettings.getMaxUpload())); - parameters.append("&MaxDownload=" + Long.toString(ajSettings.getMaxDownload())); - parameters.append("&Speedperslot=" + Integer.toString(ajSettings.getSpeedPerSlot())); - parameters.append("&Incomingdirectory=" + URLEncoder.encode(ajSettings.getIncomingDir(), "UTF-8")); - parameters.append("&Temporarydirectory=" + URLEncoder.encode(ajSettings.getTempDir(), "UTF-8")); - parameters.append("&maxconnections=" + URLEncoder.encode(Long.toString(ajSettings.getMaxConnections()), "UTF-8")); - parameters.append("&maxsourcesperfile=" + URLEncoder.encode(Long.toString(ajSettings.getMaxSourcesPerFile()), "UTF-8")); - parameters.append("&autoconnect=" + URLEncoder.encode(Boolean.toString(ajSettings.isAutoConnect()), "UTF-8")); - parameters.append("&maxnewconnectionsperturn=" + - URLEncoder.encode(Long.toString(ajSettings.getMaxNewConnectionsPerTurn()), "UTF-8")); - } - catch(UnsupportedEncodingException ex) - { - throw new RuntimeException(ex); - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + parameters.toString(), - false); - } - - public Map getAllServer() - { - if(modifiedXML != null) - { - return modifiedXML.getServer(); - } - - return null; - } - - public boolean updateModifiedXML() - { - try - { - if(modifiedXML.update()) - { - if(modifiedXML.isServerChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.SERVER_CHANGED); - } - - if(modifiedXML.isDownloadChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.DOWNLOAD_CHANGED); - } - - if(modifiedXML.isUploadChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.UPLOAD_CHANGED); - } - - if(modifiedXML.isNetworkInfoChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.NETINFO_CHANGED); - } - - if(modifiedXML.isSpeedChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.SPEED_CHANGED); - } - - if(modifiedXML.isSearchChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.SEARCH_CHANGED); - } - - if(modifiedXML.isInformationChanged()) - { - informDataUpdateListener(DATALISTENER_TYPE.INFORMATION_CHANGED); - } - } - - return true; - } - catch(WrongPasswordException wpE) - { - stopXMLCheck(); - throw wpE; - } - catch(RuntimeException re) - { - - // connection to core lost, next try - return false; - } - catch(Exception e) - { - return false; - } - } - - public void resumeDownload(List downloads) - throws IllegalArgumentException - { - if(downloads == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - - if(downloads.size() == 0) - { - return; - } - - for(Download curDownload : downloads) - { - if(curDownload == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - } - - StringBuffer parameters = new StringBuffer(); - int index = 0; - - for(Download curDownload : downloads) - { - parameters.append("&id"); - if(index != 0) - { - parameters.append(Integer.toString(index)); - } - - parameters.append("=" + curDownload.getId()); - index++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/resumedownload?password=" + coreHolder.getCorePassword() + parameters, false); - } - - public void startSearch(String searchString) throws IllegalArgumentException - { - if(searchString == null) - { - throw new IllegalArgumentException("invalid search-phrase"); - } - - String toSearch = searchString.trim(); - - if(toSearch.length() == 0) - { - throw new IllegalArgumentException("invalid search-phrase"); - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/search?password=" + coreHolder.getCorePassword() + "&search=" + toSearch, false); - } - - public synchronized void cancelSearch(Search search) - throws IllegalArgumentException - { - if(search == null) - { - throw new IllegalArgumentException("invalid search"); - } - - new CancelThread(search).start(); - } - - public void renameDownload(Download download, String newFilename) - throws IllegalArgumentException - { - if(download == null) - { - throw new IllegalArgumentException("invalid download"); - } - - if(newFilename == null || newFilename.length() == 0 || newFilename.trim().length() == 0) - { - throw new IllegalArgumentException("invalid filename"); - } - - String encodedName = newFilename; - - try - { - StringBuffer tempLink = new StringBuffer(encodedName); - - for(int i = 0; i < tempLink.length(); i++) - { - if(tempLink.charAt(i) == ' ') - { - tempLink.setCharAt(i, '.'); - } - } - - encodedName = URLEncoder.encode(tempLink.toString(), "ISO-8859-1"); - } - catch(UnsupportedEncodingException ex) - { - ; - - // gibbet, also nix zu behandeln... - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/renamedownload?password=" + coreHolder.getCorePassword() + "&id=" + download.getId() + - "&name=" + encodedName, false); - } - - public void setTargetDir(List downloads, String newDirectoryName) - throws IllegalArgumentException - { - if(downloads == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - - if(downloads.size() == 0) - { - return; - } - - newDirectoryName = processSubdir(newDirectoryName); - for(Download curDownload : downloads) - { - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/settargetdir?password=" + coreHolder.getCorePassword() + "&id=" + - curDownload.getId() + "&dir=" + newDirectoryName, false); - } - } - - public void shutdownCore() - { - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/exitcore?password=" + coreHolder.getCorePassword(), false); - } - - public void setPassword(String password, boolean passwordIsPlaintext) - throws IllegalArgumentException - { - if(password == null || (!passwordIsPlaintext && (password.length() == 0 || password.trim().length() == 0))) - { - throw new IllegalArgumentException("invalid password"); - } - - String newPassword = passwordIsPlaintext ? MD5Encoder.getMD5(password) : password; - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/setpassword?password=" + coreHolder.getCorePassword() + "&newpassword=" + - newPassword, false); - coreHolder.setCorePassword(password, false); - } - - public void cancelDownload(List downloads) - throws IllegalArgumentException - { - if(downloads == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - - if(downloads.size() == 0) - { - return; - } - - for(Download curDownload : downloads) - { - if(curDownload == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - } - - StringBuffer parameters = new StringBuffer(); - int index = 0; - - for(Download curDownload : downloads) - { - parameters.append("&id"); - if(index != 0) - { - parameters.append(Integer.toString(index)); - } - - parameters.append("=" + curDownload.getId()); - index++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/canceldownload?password=" + coreHolder.getCorePassword() + parameters, false); - } - - public void cleanDownloadList() - { - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/cleandownloadlist?password=" + coreHolder.getCorePassword(), false); - } - - public void pauseDownload(List downloads) - throws IllegalArgumentException - { - if(downloads == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - - if(downloads.size() == 0) - { - return; - } - - for(Download curDownload : downloads) - { - if(curDownload == null) - { - throw new IllegalArgumentException("invalid download-list"); - } - } - - StringBuffer parameters = new StringBuffer(); - int index = 0; - - for(Download curDownload : downloads) - { - parameters.append("&id"); - if(index != 0) - { - parameters.append(Integer.toString(index)); - } - - parameters.append("=" + curDownload.getId()); - index++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/pausedownload?password=" + coreHolder.getCorePassword() + parameters, false); - } - - public void connectToServer(Server server) throws IllegalArgumentException - { - if(server == null) - { - throw new IllegalArgumentException("invalid server"); - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/serverlogin?password=" + coreHolder.getCorePassword() + "&id=" + server.getId(), false); - } - - public Object getObjectById(Integer id) throws IllegalArgumentException - { - if(id == null) - { - throw new IllegalArgumentException("invalid id"); - } - - GetObjectXMLHolder getObjectXMLHolder = new GetObjectXMLHolder(coreHolder); - - return getObjectXMLHolder.getObjectByID(id.intValue()); - } - - public void entferneServer(List server) throws IllegalArgumentException - { - if(server == null) - { - throw new IllegalArgumentException("invalid server"); - } - - if(server.size() == 0) - { - return; - } - - for(Server curServer : server) - { - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/removeserver?password=" + coreHolder.getCorePassword() + "&id=" + - curServer.getId(), false); - } - } - - public void setPrioritaet(Share share, Integer priority) - throws IllegalArgumentException - { - if(share == null) - { - throw new IllegalArgumentException("invalid share"); - } - - setPrioritaet(share.getId(), priority); - } - - public void setPrioritaet(Download download, Integer priority) - throws IllegalArgumentException - { - if(download == null) - { - throw new IllegalArgumentException("invalid download"); - } - - setPrioritaet(download.getId(), priority); - } - - private void setPrioritaet(int id, Integer priority) - throws IllegalArgumentException - { - if(priority == null) - { - throw new IllegalArgumentException("invalid priority"); - } - - if(priority.intValue() < 1 || priority.intValue() > 250) - { - throw new IllegalArgumentException("invalid priority: has to be 1<= x <=250"); - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/setpriority?password=" + coreHolder.getCorePassword() + "&id=" + id + "&priority=" + - priority.intValue(), false); - } - - private String processSubdir(String subdir) - { - if(subdir == null) - { - subdir = ""; - } - else - { - subdir = subdir.trim(); - if(subdir.indexOf(File.separator) == 0 || subdir.indexOf(ApplejuiceFassade.separator) == 0) - { - subdir = subdir.substring(1); - } - - subdir = subdir.replace(".", "_"); - subdir = subdir.replace(":", "_"); - } - - return subdir; - } - - public synchronized String processLink(final String link, String subdir) - throws IllegalArgumentException - { - if(link == null || link.length() == 0) - { - throw new IllegalArgumentException("invalid link"); - } - - subdir = processSubdir(subdir); - String encodedLink = link; - - try - { - StringBuffer tempLink = new StringBuffer(link); - - for(int i = 0; i < tempLink.length(); i++) - { - if(tempLink.charAt(i) == ' ') - { - tempLink.setCharAt(i, '.'); - } - } - - encodedLink = URLEncoder.encode(tempLink.toString(), "ISO-8859-1"); - } - catch(UnsupportedEncodingException ex) - { - ; - - //gibbet nicht, also nix zu behandeln... - } - - return HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/processlink?password=" + coreHolder.getCorePassword() + "&link=" + - encodedLink + "&subdir=" + subdir, true); - } - - public void setPowerDownload(List downloads, Integer powerDownload) - throws IllegalArgumentException - { - if(downloads == null || downloads.size() == 0) - { - throw new IllegalArgumentException("invalid downloadlist"); - } - - if(downloads.size() == 0) - { - return; - } - - for(Download curDownload : downloads) - { - if(curDownload == null) - { - throw new IllegalArgumentException("invalid download-array"); - } - } - - if(powerDownload.intValue() < 0 || powerDownload.intValue() > 490) - { - throw new IllegalArgumentException("invalid priority: has to be 1<= x <=490"); - } - - StringBuffer parameters = new StringBuffer(StringConstants.AND_PWDL + powerDownload); - int index = 0; - - for(Download curDownload : downloads) - { - parameters.append("&id"); - if(index != 0) - { - parameters.append(Integer.toString(index)); - } - - parameters.append("=" + curDownload.getId()); - index++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - StringConstants.SET_PWDL_URL + coreHolder.getCorePassword() + parameters, false); - } - - /** - * - * 0 = connection 1 = wrong password 2 = no connection - * - */ - public synchronized int isCoreAvailable() - { - try - { - String result = HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - StringConstants.GET_INFORMATION_URL + coreHolder.getCorePassword()); - - if(result.indexOf("") == -1) - { - return 2; - } - } - catch(WebSiteNotFoundException ex) - { - return 2; - } - catch(WrongPasswordException wpE) - { - return 1; - } - - return 0; - } - - public Version getCoreVersion() - { - return coreVersion; - } - - public Map getDownloadsSnapshot() - { - return modifiedXML.getDownloads(); - } - - public void informDataUpdateListener(DATALISTENER_TYPE type) - { - if(informer.containsKey(type)) - { - DataUpdateInformer anInformer = informer.get(type); - - anInformer.informDataUpdateListener(); - } - } - - public Map getShare(boolean reinit) - { - if(share == null || reinit) - { - share = shareXML.getShare(); - } - - return share; - } - - public void addShareEntry(List paths, SHAREMODE shareMode) - { - Set shareDirs = getAJSettings().getShareDirs(); - StringBuilder parameters = new StringBuilder(); - - parameters.append("countshares=" + shareDirs.size() + paths.size()); - int i = 1; - - for(ShareEntry curShareEntry : shareDirs) - { - try - { - parameters.append(StringConstants.AND_SHAREDDIRECTORY); - parameters.append(i); - parameters.append(StringConstants.GLEICH); - parameters.append(URLEncoder.encode(curShareEntry.getDir(), StringConstants.UTF_8)); - } - catch(UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - - parameters.append(StringConstants.AND_SHARESUB); - parameters.append(i); - parameters.append(StringConstants.GLEICH); - parameters.append(curShareEntry.getShareMode() == SHAREMODE.SUBDIRECTORY ? StringConstants.TRUE : StringConstants.FALSE); - i++; - } - - for(String curPath : paths) - { - try - { - parameters.append(StringConstants.AND_SHAREDDIRECTORY); - parameters.append(i); - parameters.append(StringConstants.GLEICH); - parameters.append(URLEncoder.encode(curPath, StringConstants.UTF_8)); - } - catch(UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - - parameters.append(StringConstants.AND_SHARESUB); - parameters.append(i); - parameters.append(StringConstants.GLEICH); - parameters.append(shareMode == SHAREMODE.SUBDIRECTORY ? StringConstants.TRUE : StringConstants.FALSE); - - i++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - StringConstants.SET_SETTINGS_URL + coreHolder.getCorePassword() + StringConstants.AND + - parameters.toString(), false); - } - - public void removeShareEntry(List paths) - { - Set shareDirs = getAJSettings().getShareDirs(); - ArrayList toRemove = new ArrayList(); - - for(String curPath : paths) - { - for(ShareEntry curShareEntry : shareDirs) - { - if(curShareEntry.getDir().compareToIgnoreCase(curPath) == 0) - { - toRemove.add(curShareEntry); - break; - } - } - } - - for(ShareEntry curShareEntry : toRemove) - { - shareDirs.remove(curShareEntry); - } - - setShare(shareDirs); - } - - public void setShare(Set newShare) - { - if(newShare == null) - { - return; - } - - String parameters = "countshares=" + newShare.size(); - int i = 1; - - for(ShareEntry curShareEntry : newShare) - { - try - { - parameters += "&sharedirectory" + i + "=" + URLEncoder.encode(curShareEntry.getDir(), "UTF-8"); - } - catch(UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - - parameters += "&sharesub" + i + "=" + (curShareEntry.getShareMode() == SHAREMODE.SUBDIRECTORY ? "true" : "false"); - i++; - } - - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, - "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + parameters, false); - } - - public List getDirectories(String directory) - throws IllegalArgumentException - { - return directoryXML.getDirectories(directory); - } - - public NetworkInfo getNetworkInfo() - { - return modifiedXML.getNetworkInfo(); - } - - public void fireSettingsChanged(ITEM item, String oldValue, String newValue) - { - } - - public ReleaseInfo getReleaseInfo(String hash, ProxySettings proxy) - throws Exception - { - return new ReleaseInfoJsonLoader(hash, proxy).getReleaseInfo(); - } - - private class CancelThread extends Thread - { - private Search search; - private boolean cancel = false; - private Thread innerThread; - - public CancelThread(Search search) - { - this.search = search; - } - - public void run() - { - try - { - if(search.getCreationTime() > System.currentTimeMillis() - 10000) - { - sleep(10000); - } - while(!cancel) - { - innerThread = new Thread() - { - public void run() - { - HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, - "/function/cancelsearch?password=" + coreHolder.getCorePassword() + "&id=" + - search.getId(), true); - cancel = true; - - } - }; - innerThread.start(); - sleep(4000); - innerThread.interrupt(); - } - } - catch(InterruptedException iE) - { - innerThread.interrupt(); - interrupt(); - } - } - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/DateDeserializer.java b/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/DateDeserializer.java deleted file mode 100644 index 9e959eb4..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/DateDeserializer.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.applejuicenet.client.fassade.controller.json; - -import java.lang.reflect.Type; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; - -public class DateDeserializer implements JsonDeserializer -{ - public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - String dateAsString = json.getAsJsonPrimitive().getAsString(); - dateAsString = dateAsString.substring(0, 19); - SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - try - { - return formater.parse(dateAsString); - } - catch (ParseException e) - { - throw new RuntimeException(e); - } - } -} \ No newline at end of file diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseInfoJsonLoader.java b/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseInfoJsonLoader.java deleted file mode 100644 index 5c1056c1..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseInfoJsonLoader.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade.controller.json; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import de.applejuicenet.client.fassade.shared.ProxySettings; -import de.applejuicenet.client.fassade.shared.ReleaseInfo; -import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; - -public class ReleaseInfoJsonLoader -{ - private static final Map releasesCache = new HashMap(); - private static final long CACHE_TIMEOUT = 300000; - private final ReleaseInfo releaseInfo; - private final ProxySettings proxy; - private final String hash; - private static String releaseInfoHost = null; - private static Integer releaseInfoPort; - - public ReleaseInfoJsonLoader(String hash, ProxySettings proxy) - { - if (null == releaseInfoHost) - { - Properties props = new Properties(); - File aFile = new File(System.getProperty("user.dir") + File.separator + "ajcore.properties"); - if (aFile.exists()) - { - try - { - FileInputStream fiS = new FileInputStream(aFile); - props.load(fiS); - fiS.close(); - releaseInfoHost = props.getProperty("releaseinfo.host"); - String tmp = props.getProperty("releaseinfo.port", "80"); - releaseInfoPort = Integer.parseInt(tmp); - } - catch (Exception e) - { - // nix zu tun - } - } - if (null == releaseInfoHost) - { - releaseInfoHost = "http://applefiles.cc"; - } - if (null == releaseInfoPort) - { - releaseInfoPort = 80; - } - } - this.hash = hash; - releaseInfo = new ReleaseInfo(releaseInfoHost, hash); - this.proxy = proxy; - } - - public ReleaseInfo getReleaseInfo() throws Exception - { - ReleaseCacheObject releaseCacheObject = releasesCache.get(hash); - - if (null != releaseCacheObject) - { - if (releaseCacheObject.getTimestamp() + CACHE_TIMEOUT > System.currentTimeMillis()) - { - return releaseCacheObject.getReleaseInfo(); - } - else - { - releasesCache.remove(hash); - } - } - - String releaseDataTmp = - WebsiteContentLoader.getWebsiteContent(proxy, releaseInfoHost, releaseInfoPort, "/api/get_link_info/?hash=" + hash); - - if ("no result".equals(releaseDataTmp)) - { - releaseCacheObject = new ReleaseCacheObject(System.currentTimeMillis(), null); - releasesCache.put(hash, releaseCacheObject); - return null; - } - - GsonBuilder gsonb = new GsonBuilder(); - gsonb.registerTypeAdapter(Date.class, new DateDeserializer()); - Gson gson = gsonb.create(); - - ReleaseinfoVO data = gson.fromJson(releaseDataTmp, ReleaseinfoVO.class); - - releaseInfo.setTitle(data.getTitle()); - releaseInfo.setCategory(data.getCategory()); - releaseInfo.setViewsCurrentMonth(data.getHitsInMonth()); - releaseInfo.setViewsTotal(data.getHits()); - releaseInfo.setFormat(data.getFormat()); - releaseInfo.setDescription(data.getLink()); - releaseInfo.setFsk18(data.isFsk()); - releaseInfo.setGenres(data.getGenre()); - - releaseInfo.setImage(data.getImg()); - - if (data.getLanguage() != null) - { - releaseInfo.setLanguage(data.getLanguage()); - releaseInfo.setLanguageImage(data.getLanguageImg()); - } - releaseInfo.setQuality(data.getQualiInfo()); - releaseInfo.setReleaseDate(data.getCreated()); - - releaseCacheObject = new ReleaseCacheObject(System.currentTimeMillis(), releaseInfo); - releasesCache.put(hash, releaseCacheObject); - - return releaseInfo; - - } - - private class ReleaseCacheObject - { - private long timestamp; - private ReleaseInfo releaseInfo; - - public ReleaseCacheObject(long timestamp, ReleaseInfo releaseInfo) - { - super(); - this.timestamp = timestamp; - this.releaseInfo = releaseInfo; - } - - public ReleaseInfo getReleaseInfo() - { - return releaseInfo; - } - - public long getTimestamp() - { - return timestamp; - } - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseinfoVO.java b/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseinfoVO.java deleted file mode 100644 index 529f63b1..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/json/ReleaseinfoVO.java +++ /dev/null @@ -1,173 +0,0 @@ -package de.applejuicenet.client.fassade.controller.json; - -import java.util.Date; -import java.util.List; - -public class ReleaseinfoVO -{ - private boolean fsk; - private Date created; - private String qualiInfo; - private long hits; - private String language; - private String link; - private String title; - private Date updated; - private String format; - private String category_link; - private String img; - private String languageImg; - private long hitsInMonth; - private String category; - private List genre; - - public boolean isFsk() - { - return fsk; - } - - public void setFsk(boolean fsk) - { - this.fsk = fsk; - } - - public Date getCreated() - { - return created; - } - - public void setCreated(Date created) - { - this.created = created; - } - - public String getQualiInfo() - { - return qualiInfo; - } - - public void setQualiInfo(String qualiInfo) - { - this.qualiInfo = qualiInfo; - } - - public long getHits() - { - return hits; - } - - public void setHits(long hits) - { - this.hits = hits; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLink() - { - return link; - } - - public void setLink(String link) - { - this.link = link; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Date getUpdated() - { - return updated; - } - - public void setUpdated(Date updated) - { - this.updated = updated; - } - - public String getFormat() - { - return format; - } - - public void setFormat(String format) - { - this.format = format; - } - - public String getCategory_link() - { - return category_link; - } - - public void setCategory_link(String category_link) - { - this.category_link = category_link; - } - - public String getLanguageImg() - { - return languageImg; - } - - public void setLanguageImg(String languageImg) - { - this.languageImg = languageImg; - } - - public long getHitsInMonth() - { - return hitsInMonth; - } - - public void setHitsInMonth(long hitsInMonth) - { - this.hitsInMonth = hitsInMonth; - } - - public String getCategory() - { - return category; - } - - public void setCategory(String category) - { - this.category = category; - } - - public String getImg() - { - return img; - } - - public void setImg(String img) - { - this.img = img; - } - - public List getGenre() - { - return genre; - } - - public void setGenre(List genre) - { - this.genre = genre; - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Version.java b/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Version.java deleted file mode 100644 index 269e5a53..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Version.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade.entity; - -import java.util.StringTokenizer; - -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.StringConstants; - -public abstract class Version -{ - public static final int UNKNOWN = 0; - public static final int WIN32 = 1; - public static final int LINUX = 2; - public static final int MACINTOSH = 3; - public static final int SOLARIS = 4; - public static final int OS2 = 5; - public static final int FREEBSD = 6; - public static final int NETWARE = 7; - - public abstract String getVersion(); - - public abstract int getBetriebsSystem(); - - public final String getBetriebsSystemAsString() - { - String result = ""; - - if(getBetriebsSystem() == LINUX) - { - result = StringConstants.LINUX; - } - else if(getBetriebsSystem() == WIN32) - { - result = StringConstants.WIN32; - } - - return result; - } - - public final static int getOSTypByOSName(String OSName) - { - int result = -1; - - if(OSName.compareToIgnoreCase(StringConstants.WINDOWS_NT) == 0) - { - result = WIN32; - } - else if(OSName.compareToIgnoreCase(StringConstants.LINUX) == 0) - { - result = LINUX; - } - - return result; - } - - public final int compareTo(String versionNr) - { - if(getVersion().compareToIgnoreCase(versionNr) == 0) - { - return 0; - } - - StringTokenizer token1 = new StringTokenizer(getVersion(), StringConstants.POINT); - StringTokenizer token2 = new StringTokenizer(versionNr, StringConstants.POINT); - - if(token1.countTokens() != 4 || token2.countTokens() != 4) - { - - // alles Mist - return 0; - } - - String[] foundCore = new String[4]; - String[] neededCore = new String[4]; - - for(int i = 0; i < 4; i++) - { - foundCore[i] = token1.nextToken(); - neededCore[i] = token2.nextToken(); - } - - boolean coreTooOld = false; - - for(int i = 0; i < 4; i++) - { - if(Integer.parseInt(foundCore[i]) > Integer.parseInt(neededCore[i])) - { - break; - } - else if(Integer.parseInt(foundCore[i]) < Integer.parseInt(neededCore[i])) - { - coreTooOld = true; - return -1; - } - } - - return 1; - } - - @Override - public String toString() - { - return getVersion(); - } - - public final int checkForValidCoreVersion() - { - return compareTo(ApplejuiceFassade.MIN_NEEDED_CORE_VERSION); - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/NetworkInfo.java b/ajcorefassade/src/de/applejuicenet/client/fassade/shared/NetworkInfo.java deleted file mode 100644 index 3ec1ef12..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/NetworkInfo.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade.shared; - - -/** - * $Header: - * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/NetworkInfo.java,v - * 1.1 2004/12/03 07:57:12 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r [aj@tkl-soft.de] - * - */ -public class NetworkInfo -{ - private long ajUserGesamt; - private long ajAnzahlDateien; - private String ajGesamtShare; - private boolean firewalled; - private String externeIP; - private int tryConnectToServer; - private int connectedWithServerId; - private String welcomeMessage; - private long connectionTime; - - public NetworkInfo() - { - } - - public NetworkInfo(long ajUserGesamt, long ajAnzahlDateien, String ajGesamtShare, boolean firewalled, String externeIP, - int tryConnectToServer, int connectedWithServerId, String welcomeMessage, long connectionTime) - { - this.ajUserGesamt = ajUserGesamt; - this.ajAnzahlDateien = ajAnzahlDateien; - this.ajGesamtShare = ajGesamtShare; - this.firewalled = firewalled; - this.externeIP = externeIP; - this.tryConnectToServer = tryConnectToServer; - this.connectedWithServerId = connectedWithServerId; - this.connectionTime = connectionTime; - setWelcomeMessage(welcomeMessage); - } - - public NetworkInfo(String ajUserGesamt, String ajAnzahlDateien, String ajGesamtShare, boolean firewalled, String externeIP, - int tryConnectToServer, int connectedWithServerId) - { - if(ajUserGesamt == null || ajUserGesamt.length() == 0) - { - this.ajUserGesamt = 0; - } - else - { - this.ajUserGesamt = Long.parseLong(ajUserGesamt); - } - - if(ajAnzahlDateien == null || ajAnzahlDateien.length() == 0) - { - this.ajAnzahlDateien = 0; - } - else - { - this.ajAnzahlDateien = Long.parseLong(ajAnzahlDateien); - } - - this.ajGesamtShare = ajGesamtShare; - this.firewalled = firewalled; - this.externeIP = externeIP; - this.tryConnectToServer = tryConnectToServer; - this.connectedWithServerId = connectedWithServerId; - } - - public void setAjUserGesamt(long ajUserGesamt) - { - this.ajUserGesamt = ajUserGesamt; - } - - public void setAjAnzahlDateien(long ajAnzahlDateien) - { - this.ajAnzahlDateien = ajAnzahlDateien; - } - - public void setAjGesamtShare(String ajGesamtShare) - { - this.ajGesamtShare = ajGesamtShare; - } - - public void setFirewalled(boolean firewalled) - { - this.firewalled = firewalled; - } - - public void setExterneIP(String externeIP) - { - this.externeIP = externeIP; - } - - public void setTryConnectToServer(int tryConnectToServer) - { - this.tryConnectToServer = tryConnectToServer; - } - - public void setConnectedWithServerId(int connectedWithServerId) - { - this.connectedWithServerId = connectedWithServerId; - } - - public void setWelcomeMessage(String welcomeMessage) - { - if(welcomeMessage.toLowerCase().indexOf(StringConstants.HTML_START) == -1) - { - welcomeMessage = StringConstants.HTML_START + welcomeMessage + StringConstants.HTML_END; - } - - this.welcomeMessage = welcomeMessage; - } - - public void setConnectionTime(long connectionTime) - { - this.connectionTime = connectionTime; - } - - public String getAJGesamtShare(long faktor) - { - ajGesamtShare = ajGesamtShare.replace(',', '.'); - double share = Double.parseDouble(ajGesamtShare); - - if(share == 0) - { - return StringConstants._0_00_MB; - } - - if(faktor == 0) - { // selbst entscheiden - if(share / 1024 < 1024) - { - faktor = 1024; - } - else if(share / 1048576 < 1024) - { - faktor = 1048576; - } - else - { - faktor = 1; - } - } - - share = share / faktor; - String result = Double.toString(share); - - if(result.indexOf(StringConstants.POINT) + 3 < result.length()) - { - result = result.substring(0, result.indexOf(StringConstants.POINT) + 3); - } - - result = result.replace('.', ','); - if(faktor == 1) - { - result += StringConstants.MB; - } - else if(faktor == 1024) - { - result += StringConstants.GB; - } - else if(faktor == 1048576) - { - result += StringConstants.TB; - } - else - { - result += StringConstants.TWO_QUESTIONMARKS; - } - - return result; - } - - public String getAJGesamtShareWithPoints(long faktor) - { - String result = getAJGesamtShare(faktor); - - return insertPoints(result); - } - - public boolean isFirewalled() - { - return firewalled; - } - - public String getExterneIP() - { - return externeIP; - } - - public long getAJUserGesamt() - { - return ajUserGesamt; - } - - public String getAJUserGesamtAsString() - { - return Long.toString(ajUserGesamt); - } - - public String getAJUserGesamtAsStringWithPoints() - { - String result = getAJUserGesamtAsString(); - - return insertPoints(result); - } - - public long getAJAnzahlDateien() - { - return ajAnzahlDateien; - } - - public String getAJAnzahlDateienAsString() - { - return Long.toString(ajAnzahlDateien); - } - - public String getAJAnzahlDateienAsStringWithPoints() - { - return insertPoints(Long.toString(ajAnzahlDateien)); - } - - private String insertPoints(String tochange) - { - StringBuffer result = new StringBuffer(tochange); - int laenge; - - if(result.indexOf(StringConstants.COMMA) == -1) - { - if(result.indexOf(StringConstants.SPACE) == -1) - { - laenge = result.length(); - } - else - { - laenge = result.indexOf(StringConstants.SPACE); - } - } - else - { - laenge = result.indexOf(StringConstants.COMMA); - } - - int zaehler = 0; - - for(int i = laenge - 1; i > 0; i--) - { - zaehler++; - if(zaehler == 3) - { - zaehler = 0; - result.insert(i, '.'); - } - } - - return result.toString(); - } - - public int getTryConnectToServer() - { - return tryConnectToServer; - } - - public int getConnectedWithServerId() - { - return connectedWithServerId; - } - - public String getWelcomeMessage() - { - if(welcomeMessage == null) - { - return StringConstants.EMPTY; - } - - return welcomeMessage; - } - - public long getConnectionTime() - { - return connectionTime; - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ReleaseInfo.java b/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ReleaseInfo.java deleted file mode 100644 index 5de02e20..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ReleaseInfo.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade.shared; - -import java.net.MalformedURLException; -import java.net.URL; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class ReleaseInfo -{ - private final String host; - private final String md5; - private String title = null; - private Date releaseDate = null; - private String category = null; - private List genres = new ArrayList(); - private String language = null; - private URL languageImage = null; - private String format = null; - private Long viewsTotal = null; - private Long viewsCurrentMonth = null; - private boolean fsk18 = false; - private URL imageURL = null; - private URL descriptionURL = null; - private String quality; - - public ReleaseInfo(String host, String md5) - { - this.host = host; - this.md5 = md5; - } - - public String getMd5() - { - return md5; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Date getReleaseDate() - { - return releaseDate; - } - - public void setReleaseDate(Date releaseDate) - { - this.releaseDate = releaseDate; - } - - public String getCategory() - { - return category; - } - - public void setCategory(String category) - { - this.category = category; - } - - public List getGenres() - { - return genres; - } - - public void setGenres(List genres) - { - this.genres = genres; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public URL getLanguageImage() - { - return languageImage; - } - - public void setLanguageImage(String languageImage) - { - try - { - this.languageImage = new URL(host + languageImage); - } - catch (MalformedURLException e) - { - } - } - - public String getFormat() - { - return format; - } - - public void setFormat(String format) - { - this.format = format; - } - - public Long getViewsTotal() - { - return viewsTotal; - } - - public void setViewsTotal(Long viewsTotal) - { - this.viewsTotal = viewsTotal; - } - - public Long getViewsCurrentMonth() - { - return viewsCurrentMonth; - } - - public void setViewsCurrentMonth(Long viewsCurrentMonth) - { - this.viewsCurrentMonth = viewsCurrentMonth; - } - - public URL getImageURL() - { - return imageURL; - } - - public void setImage(String imageLink) - { - try - { - imageURL = new URL(host + imageLink); - } - catch (MalformedURLException e) - { - } - } - - public URL getDescriptionURL() - { - return descriptionURL; - } - - public void setDescription(String descriptionLink) - { - try - { - descriptionURL = new URL(host + descriptionLink); - } - catch (MalformedURLException e) - { - } - } - - public boolean isFsk18() - { - return fsk18; - } - - public void setFsk18(boolean fsk18) - { - this.fsk18 = fsk18; - } - - public String getQuality() - { - return quality; - } - - public void setQuality(String quality) - { - this.quality = quality; - } - -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java b/ajcorefassade/src/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java deleted file mode 100644 index d2c3d4ab..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2006 TKLSoft.de All rights reserved. - */ - -package de.applejuicenet.client.fassade.shared; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -import java.net.URL; -import java.net.URLConnection; - -import de.applejuicenet.client.fassade.exception.NoAccessException; - -/** - * $Header: - * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java,v - * 1.1 2004/12/03 07:57:12 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r - * - */ -public abstract class WebsiteContentLoader -{ - public static String getWebsiteContent(ProxySettings proxySettings, String website, int port, String pfadAndparameters) - throws NoAccessException - { - StringBuffer htmlContent = new StringBuffer(); - - try - { - String tmpUrl = website + ":" + port + pfadAndparameters; - - if(proxySettings != null) - { - System.getProperties().put("proxyHost", proxySettings.getHost()); - System.getProperties().put("proxyPort", Integer.toString(proxySettings.getPort())); - } - - URL url = new URL(tmpUrl); - URLConnection uc = url.openConnection(); - - if(proxySettings != null) - { - uc.setRequestProperty("Proxy-Authorization", "Basic " + proxySettings.getUserpass()); - } - - InputStream content = uc.getInputStream(); - BufferedReader in = new BufferedReader(new InputStreamReader(content)); - String line; - - while((line = in.readLine()) != null) - { - htmlContent.append(line); - } - - if(proxySettings != null) - { - System.getProperties().remove("proxyHost"); - System.getProperties().remove("proxyPort"); - } - } - catch(IOException e) - { - throw new NoAccessException("wrong proxysettings?", e); - } - - return htmlContent.toString(); - } - - public static String getWebsiteContent(String website, int port, String pfadAndparameters) - throws NoAccessException - { - return getWebsiteContent(null, website, port, pfadAndparameters); - } -} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java b/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java deleted file mode 100644 index dab4b068..00000000 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java +++ /dev/null @@ -1,76 +0,0 @@ -package de.applejuicenet.client.fassade.shared; - -/** - * $Header: - * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java,v - * 1.1 2004/12/03 07:57:12 maj0r Exp $ - * - *

- * Titel: AppleJuice Client-GUI - *

- *

- * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten - * appleJuice-Core - *

- *

- * Copyright: General Public License - *

- * - * @author: Maj0r - * - */ - -public abstract class ZeichenErsetzer { - - public static String korrigiereUmlaute(String text) { - if (text == null) { - return ""; - } - StringBuffer temp = new StringBuffer(text); - int index; - while ((index = temp.indexOf("\\\"")) != -1) { - temp.replace(index, index + 2, "\""); - } - while ((index = temp.indexOf("ü")) != -1) { - temp.replace(index, index + 6, "ü"); - } - while ((index = temp.indexOf("Ü")) != -1) { - temp.replace(index, index + 6, "Ü"); - } - while ((index = temp.indexOf("ä")) != -1) { - temp.replace(index, index + 6, "ä"); - } - while ((index = temp.indexOf("Ä")) != -1) { - temp.replace(index, index + 6, "Ä"); - } - while ((index = temp.indexOf("ö")) != -1) { - temp.replace(index, index + 6, "ö"); - } - while ((index = temp.indexOf("Ö")) != -1) { - temp.replace(index, index + 6, "Ö"); - } - while ((index = temp.indexOf("ß")) != -1) { - temp.replace(index, index + 7, "ß"); - } - while ((index = temp.indexOf("&")) != -1) { - temp.replace(index, index + 5, ""); - } - while ((index = temp.indexOf("<")) != -1) { - temp.replace(index, index + 4, "<"); - } - while ((index = temp.indexOf(">")) != -1) { - temp.replace(index, index + 4, ">"); - } - while ((index = temp.indexOf("#&")) != -1) { - try { - int decimal = Integer.parseInt(temp.substring(index + 2, - index + 6)); - String test = new String(new char[] { (char) decimal }); - temp.replace(index, index + 7, test); - } catch (Exception e) { - temp.replace(index, index + 7, "!Fehler!"); - } - } - return temp.toString(); - } -} \ No newline at end of file diff --git a/ajcorefassade/tools/gson-2.1.jar b/ajcorefassade/tools/gson-2.1.jar deleted file mode 100644 index b85f091a..00000000 Binary files a/ajcorefassade/tools/gson-2.1.jar and /dev/null differ diff --git a/ajcorefassade/tools/pack.jar b/ajcorefassade/tools/pack.jar deleted file mode 100644 index ca3f1a69..00000000 Binary files a/ajcorefassade/tools/pack.jar and /dev/null differ diff --git a/ajcorefassade/tools/xercesImpl-2.8.1.jar b/ajcorefassade/tools/xercesImpl-2.8.1.jar deleted file mode 100644 index 3b351f6e..00000000 Binary files a/ajcorefassade/tools/xercesImpl-2.8.1.jar and /dev/null differ diff --git a/ajcorefassade/tools/xercesImpl.jar b/ajcorefassade/tools/xercesImpl.jar deleted file mode 100644 index 14c3162c..00000000 Binary files a/ajcorefassade/tools/xercesImpl.jar and /dev/null differ diff --git a/ajcorefassade/tools/xml-apis.jar b/ajcorefassade/tools/xml-apis.jar deleted file mode 100644 index 2dd83771..00000000 Binary files a/ajcorefassade/tools/xml-apis.jar and /dev/null differ diff --git a/ajtray/.classpath b/ajtray/.classpath deleted file mode 100644 index 5792f530..00000000 --- a/ajtray/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/ajtray/.project b/ajtray/.project deleted file mode 100644 index 0a464488..00000000 --- a/ajtray/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - ajtray - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/ajtray/build/build.xml b/ajtray/build/build.xml deleted file mode 100644 index c91ca76f..00000000 --- a/ajtray/build/build.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ajtray/lib/tklcontrols.jar b/ajtray/lib/tklcontrols.jar deleted file mode 100644 index e940ee85..00000000 Binary files a/ajtray/lib/tklcontrols.jar and /dev/null differ diff --git a/assets/linux/AJCoreGUI.png b/assets/linux/AJCoreGUI.png new file mode 100644 index 00000000..0bf9cf9e Binary files /dev/null and b/assets/linux/AJCoreGUI.png differ diff --git a/assets/mac/AJCoreGUI.icns b/assets/mac/AJCoreGUI.icns new file mode 100644 index 00000000..4f8389e9 Binary files /dev/null and b/assets/mac/AJCoreGUI.icns differ diff --git a/assets/mac/Info.plist.vtl b/assets/mac/Info.plist.vtl new file mode 100644 index 00000000..44628cda --- /dev/null +++ b/assets/mac/Info.plist.vtl @@ -0,0 +1,118 @@ + + + + + CFBundleGetInfoString + ${info.displayName} ${info.version} + CFBundleDevelopmentRegion + German + CFBundleExecutable + ${info.executable.name} + CFBundleIconFile + ${info.iconFile.name} + CFBundleIdentifier + ${info.macConfig.appId} + CFBundleDisplayName + ${info.displayName} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${info.displayName} + CFBundlePackageType + BNDL + CFBundleShortVersionString + ${info.version} + CFBundleSignature + ???? + CFBundleVersion + ${info.version} + NSHumanReadableCopyright + ${info.organizationName} + NSHighResolutionCapable + + NSSupportsAutomaticGraphicsSwitching + + NSRequiresAquaSystemAppearance + false + AdministratorRequired +#if ($info.administratorRequired) + +#else + +#end + JavaX + + MainClass + ${info.mainClass} +#if (!$info.bundleJre && $info.jreMinVersion) + JVMVersion + ${info.jreMinVersion} +#end + ClassPath + +#foreach ($classpath in $info.classpaths) + $classpath +#end + +#if (!$info.vmArgs.empty) + VMOptions + +#foreach ($vmArg in $info.vmArgs) + $vmArg +#end + +#end +#if ($info.useResourcesAsWorkingDir) + WorkingDirectory + $APP_PACKAGE/Contents/Resources +#end + JVMOptionsFile + $APP_PACKAGE/Contents/Resources/${info.name}.l4j.ini +#if ($info.scripts.bootstrap) + BootstrapScript + $APP_PACKAGE/Contents/Resources/scripts/${info.bootstrapFile.name} +#end + + LSEnvironment + +#if ($info.bundleJre) + JAVA_HOME + Contents/PlugIns/${info.jreDirectoryName}/Contents/Home +#end +#if($info.envPath) + PATH + ${info.envPath} +#end + + NSAppleEventsUsageDescription + There was an error while launching the application. Please + click OK to display a dialog with more information or cancel and view + the syslog for details. + + CFBundleURLTypes + + + CFBundleURLName + appleJuice Links + CFBundleURLSchemes + + ajfsp + + + + + CFBundleDocumentTypes + + + CFBundleTypeRole + Editor + CFBundleTypeName + appleJuice Link List + CFBundleTypeExtensions + + ajl + + + + + diff --git a/assets/windows/AJCoreGUI.exe b/assets/windows/AJCoreGUI.exe new file mode 100644 index 00000000..457dc7cb Binary files /dev/null and b/assets/windows/AJCoreGUI.exe differ diff --git a/assets/windows/AJCoreGUI.ico b/assets/windows/AJCoreGUI.ico new file mode 100644 index 00000000..d03e2ba0 Binary files /dev/null and b/assets/windows/AJCoreGUI.ico differ diff --git a/assets/windows/AJCoreGUI.lpi b/assets/windows/AJCoreGUI.lpi new file mode 100644 index 00000000..f9cf571b --- /dev/null +++ b/assets/windows/AJCoreGUI.lpi @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + <XPManifest> + <TextName Value="applejuicenet.applejuice.gui"/> + <TextDesc Value="appleJuice GUI"/> + </XPManifest> + <Icon Value="0"/> + </General> + <VersionInfo> + <UseVersionInfo Value="True"/> + <MajorVersionNr Value="1"/> + <Language Value="0407"/> + <StringTable Comments="appleJuiceNETZ" CompanyName="appleJuiceNETZ" FileDescription="JavaGUI" InternalName="JavaGUI" LegalCopyright="appleJuiceNETZ" LegalTrademarks="appleJuiceNETZ" OriginalFilename="AJCoreGUI.exe" ProductName="JavaGUI" ProductVersion="1.0"/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <Units Count="1"> + <Unit0> + <Filename Value="AJCoreGUI.pas"/> + <IsPartOfProject Value="True"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="AJCoreGUI"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <SyntaxMode Value="tp"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <SmartLinkUnit Value="True"/> + <RelocatableUnit Value="True"/> + <TargetCPU Value="i386"/> + <TargetOS Value="win32"/> + <Optimizations> + <OptimizationLevel Value="4"/> + </Optimizations> + <SmallerCode Value="True"/> + </CodeGeneration> + <Linking> + <Debugging> + <GenerateDebugInfo Value="False"/> + <StripSymbols Value="True"/> + </Debugging> + <LinkSmart Value="True"/> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + <Other> + <Verbosity> + <ShowWarn Value="False"/> + <ShowNotes Value="False"/> + <ShowHints Value="False"/> + </Verbosity> + <WriteFPCLogo Value="False"/> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/assets/windows/AJCoreGUI.pas b/assets/windows/AJCoreGUI.pas new file mode 100644 index 00000000..609bf25e --- /dev/null +++ b/assets/windows/AJCoreGUI.pas @@ -0,0 +1,33 @@ +program AJCoreGUI; +uses ShellAPI, SysUtils; + +{$R AJCoreGUI.rc} + +var verzeichnis, argumente, arg: string; + i: integer; + +begin +verzeichnis := ExtractFilePath(ParamStr(0)); +if (fileexists(verzeichnis + '\AJCoreGUI.jar')=true) then +begin + argumente := '-jar AJCoreGUI.jar'; + i := 1; + + for i := 1 to paramCount() do + while ParamStr(i)<>'' do begin + arg:=ParamStr(i); + if copy(arg,0,8)='ajfsp://' then arg:='-link='+arg; + argumente:=argumente+' "'+arg+'"'; + i:=i+1; + end; + + if (fileexists(verzeichnis + '\Java\bin\javaw.exe')=true) then + begin + ShellExecute(0, 'open' ,PChar(verzeichnis + '\Java\bin\javaw.exe'), PChar(argumente), PChar(verzeichnis), 1); + end + else + begin + ShellExecute(0, 'open' ,PChar('javaw.exe'), PChar(argumente), PChar(verzeichnis), 1); + end; + end; +end. diff --git a/assets/windows/AJCoreGUI.rc b/assets/windows/AJCoreGUI.rc new file mode 100644 index 00000000..97499191 --- /dev/null +++ b/assets/windows/AJCoreGUI.rc @@ -0,0 +1 @@ +MAINICON ICON "AJCoreGUI.ico" diff --git a/assets/windows/AJCoreGUI.setup.exe b/assets/windows/AJCoreGUI.setup.exe new file mode 100644 index 00000000..a9c4cb39 Binary files /dev/null and b/assets/windows/AJCoreGUI.setup.exe differ diff --git a/modules/AJCoreGUI/pom.xml b/modules/AJCoreGUI/pom.xml new file mode 100644 index 00000000..88fa8ed9 --- /dev/null +++ b/modules/AJCoreGUI/pom.xml @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>de.applejuicenet.client.gui</groupId> + <artifactId>AJCoreGUI</artifactId> + <packaging>jar</packaging> + <version>0.85.3</version> + + <parent> + <groupId>de.applejuicenet.client</groupId> + <artifactId>AJClientGUI</artifactId> + <version>0.85.3</version> + <relativePath>./../../pom.xml</relativePath> + </parent> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>de.applejuicenet.client.gui</groupId> + <artifactId>ajcorefassade</artifactId> + <version>1.0.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>de.tklsoft</groupId> + <artifactId>tklcontrols</artifactId> + <version>1.0.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.9</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.10</version> + </dependency> + <dependency> + <groupId>net.sf.squirrel-sql.thirdparty-non-maven</groupId> + <artifactId>skinlf</artifactId> + <version>6.7</version> + </dependency> + <dependency> + <groupId>tablelayout</groupId> + <artifactId>TableLayout</artifactId> + <version>20050920</version> + </dependency> + <dependency> + <groupId>com.jgoodies</groupId> + <artifactId>looks</artifactId> + <version>2.2.2</version> + </dependency> + <dependency> + <groupId>org.freeplane.bulenkov</groupId> + <artifactId>darcula</artifactId> + <version>2021.7</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>prepare-package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>../../resources/lib/</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.2.0</version> + <configuration> + <finalName>${project.artifactId}</finalName> + <archive> + <addMavenDescriptor>false</addMavenDescriptor> + <manifestEntries> + <Built-By>appleJuice maintainer</Built-By> + </manifestEntries> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> + <addClasspath>true</addClasspath> + <classpathPrefix>./lib/</classpathPrefix> + <mainClass>de.applejuicenet.client.AppleJuiceClient</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClient.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClient.java new file mode 100644 index 00000000..9acd7d8d --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClient.java @@ -0,0 +1,446 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client; + +import ch.qos.logback.classic.Level; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.VersionChecker; +import de.applejuicenet.client.gui.components.listener.KeyStates; +import de.applejuicenet.client.gui.connect.ConnectFrame; +import de.applejuicenet.client.gui.connect.QuickConnectionSettingsDialog; +import de.applejuicenet.client.gui.controller.*; +import de.applejuicenet.client.gui.handler.ajfspURIHandler; +import de.applejuicenet.client.gui.handler.ajlFileHandler; +import de.applejuicenet.client.gui.wizard.WizardDialog; +import de.applejuicenet.client.shared.ConnectionSettings; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.SoundPlayer; +import de.applejuicenet.client.shared.Splash; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.io.*; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.Socket; +import java.net.URL; +import java.net.URLClassLoader; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClient.java,v 1.109 2009/02/12 13:11:40 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class AppleJuiceClient { + public static Splash splash = null; + private static Logger logger; + private static ApplejuiceFassade ajFassade = null; + private static CoreConnectionSettingsHolder conn = null; + private static String rootDirectory = null; + + public static LinkListener linkListener = null; + + /** + * @return Returns the path of the Client-GUI. + */ + public static String getPath() { + return getRootDirectory(); + } + + public static synchronized ApplejuiceFassade getAjFassade() { + if (ajFassade == null) { + ConnectionSettings rm = OptionsManagerImpl.getInstance().getRemoteSettings(); + + try { + conn = new CoreConnectionSettingsHolder(rm.getHost(), rm.getXmlPort(), rm.getOldPassword(), false); + ajFassade = new ApplejuiceFassade(conn); + } catch (IllegalArgumentException e) { + logger.error("connection failed", e); + } + } + + return ajFassade; + } + + public static CoreConnectionSettingsHolder getCoreConnectionSettingsHolder() { + return conn; + } + + public static void main(String[] args) { + logger = LoggerFactory.getLogger(AppleJuiceClient.class); + + try { + Level logLevel = OptionsManagerImpl.getInstance().getLogLevel(); + AppleJuiceClient.setLogLevel(logLevel); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + if (GraphicsEnvironment.isHeadless()) { + System.out.println("Headless system detected, exiting..."); + System.exit(1); + } + + AppleJuiceClientTG tg = new AppleJuiceClientTG(); + final String[] myargs = args; + Runnable runnable = () -> AppleJuiceClient.runmain(myargs); + + Thread t = new Thread(tg, runnable, "appleJuiceCoreGUI"); + + t.start(); + } + + public static void runmain(String[] args) { + boolean processLink = false; + String link = ""; + boolean doubleInstance = false; + + try { + linkListener = new LinkListener(); + } catch (IOException ex) { + //bereits ein GUI vorhanden, also GUI schliessen + doubleInstance = true; + } + + if (Desktop.getDesktop().isSupported(Desktop.Action.APP_OPEN_FILE)) { + Desktop.getDesktop().setOpenFileHandler(new ajlFileHandler()); + } + + if (Desktop.getDesktop().isSupported(Desktop.Action.APP_OPEN_URI)) { + Desktop.getDesktop().setOpenURIHandler(new ajfspURIHandler()); + } + + if (args != null && args.length > 0) { + try { + for (String curArg : args) { + if (curArg.contains("-path=")) { + System.setProperty("user.dir", curArg.substring(6)); + break; + } + } + + boolean hilfeAusgegeben = false; + + for (String curArg : args) { + if (curArg.compareTo("-help") == 0) { + if (hilfeAusgegeben) { + continue; + } + + System.out.println(); + System.out.println(" -help Diese Übersicht."); + System.out.println(" -path=<pfad> Ausführpfad setzen. Alles im GUI ist relativ zu diesem."); + System.out.println(" -link=<md5Passwort|link> ajfsp-Link ans GUI übergeben. Das GUI wird ggf gestartet."); + System.out.println(); + hilfeAusgegeben = true; + } else if (curArg.contains("-command=")) { + if (linkListener == null) { + try { + linkListener = new LinkListener(); + } catch (IOException ex) { + //bereits ein GUI vorhanden, also GUI schliessen + doubleInstance = true; + } + } + + if (doubleInstance) { + int PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); + String passwort = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); + Socket socket = new Socket("localhost", PORT); + PrintStream out = new PrintStream(socket.getOutputStream()); + DataInputStream in = new DataInputStream(socket.getInputStream()); + + out.println(passwort + "|" + curArg); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line = reader.readLine(); + + System.out.println(line); + socket.close(); + System.exit(1); + } else { + System.out.println("appleJuice-JavaGUI nicht gestartet"); + System.exit(1); + } + } else if (curArg.startsWith("ajfsp://") || (curArg.contains("-link=") && curArg.length() > "-link=".length() + 1)) { + link = curArg.startsWith("ajfsp://") ? curArg : curArg.substring(curArg.indexOf("-link=") + "-link=".length()); + + if (doubleInstance) { + int PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); + String passwort = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); + Socket socket = new Socket("localhost", PORT); + PrintStream out = new PrintStream(socket.getOutputStream()); + + out.println(passwort + "|" + curArg); + socket.close(); + //war nur Linkprocessing, also GUI schliessen + System.exit(1); + } else { + linkListener.processLink(link, ""); + } + } else if (curArg.endsWith(".ajl")) { + logger.info(".ajl Datei argument gefunden: " + curArg); + + File inputFile = new File(curArg); + + if (inputFile.exists() && !inputFile.isDirectory()) { + new AppleJuiceDialog().importAjl(inputFile, ""); + } else { + logger.info("kann .ajl Datei nicht öffnen: " + curArg); + } + } + } + } catch (IOException ioE) { + //Keine bisherige GUI-Instanz vorhanden, also GUI oeffnen + processLink = true; + } catch (Exception e) { + System.exit(1); + } + } + + if (linkListener == null) { + try { + linkListener = new LinkListener(); + } catch (IOException ex) { + //bereits ein GUI vorhanden, also GUI schliessen + doubleInstance = true; + } + } + + if (doubleInstance) { + //bereits ein GUI vorhanden, also GUI schliessen + JOptionPane.showMessageDialog(new Frame(), "Eine Instanz des GUIs ist bereits in Verwendung.", "appleJuice Client", JOptionPane.ERROR_MESSAGE); + System.exit(1); + } + + if (processLink) { + linkListener.processLink(link, ""); + } + + if (System.getProperty("os.name").toLowerCase().contains("linux")) { + try { + Toolkit xToolkit = Toolkit.getDefaultToolkit(); + Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName"); + awtAppClassNameField.setAccessible(true); + awtAppClassNameField.set(xToolkit, "AJCoreGUI"); + } catch (Exception ignored) { + } + } + + try { + String nachricht = "appleJuice-GUI " + AppleJuiceDialog.getVersion() + " wird gestartet..."; + ConnectFrame connectFrame = new ConnectFrame(); + + splash = new Splash(connectFrame, IconManager.getInstance().getIcon("splashscreen").getImage(), 0, 100); + KeyStates ks = new KeyStates(); + + splash.addKeyListener(ks); + splash.setVisible(true); + + splash.setProgress(10, "check system..."); + + try { + if (OptionsManagerImpl.getInstance().isThemesSupported()) { + Method method = JFrame.class.getMethod("setDefaultLookAndFeelDecorated", + new Class[]{boolean.class}); + + method.invoke(null, new Object[]{Boolean.TRUE}); + + method = JDialog.class.getMethod("setDefaultLookAndFeelDecorated", new Class[]{boolean.class}); + method.invoke(null, new Object[]{Boolean.TRUE}); + } + } catch (Exception e) { + if (logger.isErrorEnabled()) { + logger.error("Programmabbruch", e); + } + } + + if (logger.isInfoEnabled()) { + logger.info(nachricht); + } + + System.out.println(nachricht); + + if (logger.isInfoEnabled()) { + nachricht = "erkanntes GUI-OS: " + System.getProperty("os.name"); + logger.info(nachricht); + nachricht = "erkannte Java-Version: " + System.getProperty("java.version"); + logger.info(nachricht); + } + + String titel = null; + LanguageSelector languageSelector = LanguageSelector.getInstance(); + QuickConnectionSettingsDialog remoteDialog; + + splash.setProgress(25, "load themes..."); + AppleJuiceDialog.initThemes(); + + splash.setProgress(50, "test connection..."); + boolean showDialog = OptionsManagerImpl.getInstance().shouldShowConnectionDialogOnStartup(); + boolean keyDown = ks.isKeyDown(KeyEvent.VK_SHIFT); + + if (!showDialog) { + showDialog = keyDown; + } + + boolean firstTry = keyDown ? false : true; + int erreichbarkeit = 2; + + if (ajFassade == null) { + getAjFassade(); + } + while (showDialog || (erreichbarkeit = ajFassade.isCoreAvailable()) != 0) { + splash.setVisible(false); + if (!showDialog) { + if (erreichbarkeit == 2) { + titel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.fehlversuch"); + SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); + JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.ERROR_MESSAGE); + } else { + titel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + nachricht = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext3"); + SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); + JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.ERROR_MESSAGE); + } + } + + showDialog = false; + remoteDialog = new QuickConnectionSettingsDialog(connectFrame); + if (firstTry && OptionsManagerImpl.getInstance().isErsterStart()) { + firstTry = false; + remoteDialog.setNieWiederAnzeigen(); + remoteDialog.pressOK(); + } else { + remoteDialog.setVisible(true); + if (remoteDialog.getResult() == QuickConnectionSettingsDialog.ABGEBROCHEN) { + nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.verbindungsfehler"); + nachricht = nachricht.replaceFirst("%s", OptionsManagerImpl.getInstance().getRemoteSettings().getHost()); + JOptionPane.showMessageDialog(connectFrame, nachricht, titel, JOptionPane.OK_OPTION); + logger.error(nachricht); + System.out.println("Fehler: " + nachricht); + System.exit(-1); + } + } + + splash.setVisible(true); + } + + SoundPlayer.getInstance().playSound(SoundPlayer.ZUGANG_GEWAEHRT); + + splash.setProgress(75, "load GUI..."); + SwingUtilities.invokeLater(() -> { + final AppleJuiceDialog theApp = new AppleJuiceDialog(); + + splash.setProgress(100, "GUI geladen..."); + PositionManager lm = PositionManagerImpl.getInstance(); + + if (lm.isLegal()) { + theApp.setLocation(lm.getMainXY()); + theApp.setSize(lm.getMainDimension()); + } else { + Toolkit tk = Toolkit.getDefaultToolkit(); + Dimension screenSize = tk.getScreenSize(); + Dimension appScreenSize = new Dimension(screenSize.width, screenSize.height); + Insets insets = tk.getScreenInsets(theApp.getGraphicsConfiguration()); + + appScreenSize.width -= (insets.left + insets.right); + appScreenSize.width = appScreenSize.width / 5 * 4; + appScreenSize.height -= (insets.top + insets.bottom); + appScreenSize.height = appScreenSize.height / 5 * 4; + Point location = new Point((screenSize.width - appScreenSize.width) / 2, + (screenSize.height - appScreenSize.height) / 2); + + lm.setMainXY(location); + lm.setMainDimension(appScreenSize); + theApp.setSize(appScreenSize); + theApp.setLocation(location); + } + + theApp.setVisible(true); + String nachricht1 = "appleJuice-GUI gestartet..."; + + logger.info(nachricht1); + + System.out.println(nachricht1); + splash.dispose(); + if (OptionsManagerImpl.getInstance().isErsterStart()) { + showConnectionWizard(theApp); + } + + boolean UpdateInfo = OptionsManagerImpl.getInstance().getUpdateInfo(); + + if (UpdateInfo) { + VersionChecker.check(); + } + }); + + } catch (Exception e) { + logger.error("Programmabbruch", e); + + System.exit(-1); + } + } + + private static String getRootDirectory() { + if (rootDirectory == null) { + rootDirectory = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui"; + } + + return rootDirectory; + } + + public static void showConnectionWizard(JFrame frame) throws HeadlessException { + WizardDialog wizardDialog = new WizardDialog(frame, true); + Dimension appDimension = wizardDialog.getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + wizardDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + wizardDialog.setVisible(true); + } + + public static boolean showConnectionWizard(JDialog dialog, AJSettings ajSettings) + throws HeadlessException { + WizardDialog wizardDialog = new WizardDialog(dialog, true, ajSettings); + Dimension appDimension = wizardDialog.getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + wizardDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + wizardDialog.setVisible(true); + return wizardDialog.isRegularClosed(); + } + + public static String getPropertiesPath() { + String dir = System.getProperty("user.home") + File.separator + "appleJuice"; + File directory = new File(dir); + + if (!directory.isDirectory()) { + directory.mkdir(); + } + + dir += File.separator + "gui"; + directory = new File(dir); + if (!directory.isDirectory()) { + directory.mkdir(); + } + + dir += File.separator + "ajgui.properties"; + return dir; + } + + public static void setLogLevel(Level logLevel) { + ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(logLevel); + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClientTG.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClientTG.java new file mode 100644 index 00000000..cd11965d --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/AppleJuiceClientTG.java @@ -0,0 +1,52 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.exception.CoreLostException; +import de.applejuicenet.client.fassade.exception.WrongPasswordException; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/AppleJuiceClientTG.java,v 1.12 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class AppleJuiceClientTG extends ThreadGroup { + + public AppleJuiceClientTG() { + super("AppleJuiceClientThreadGroup"); + } + + public void uncaughtException(Thread t, Throwable e) { + Logger logger = LoggerFactory.getLogger(getClass()); + if (e.getClass() == ClassCastException.class && e.getMessage().equals("java.awt.TrayIcon cannot be cast to java.awt.Component")) { + + /* + * "insignificantly error in java6 -> ignoring" + */ + } else if (e.getClass() == ArrayIndexOutOfBoundsException.class) { + logger.debug(ApplejuiceFassade.ERROR_MESSAGE, e); + } else if (e.getClass() == WrongPasswordException.class) { + AppleJuiceDialog.getApp().informWrongPassword(); + } else if (e.getClass() == CoreLostException.class) { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + String nachricht = languageSelector.getFirstAttrbuteByTagName("javagui.startup.verbindungsfehler"); + + nachricht = nachricht.replaceFirst("%s", OptionsManagerImpl.getInstance().getRemoteSettings().getHost()); + AppleJuiceDialog.closeWithErrormessage(nachricht, true); + } else { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/AppleJuiceDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/AppleJuiceDialog.java new file mode 100644 index 00000000..ea08d94d --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/AppleJuiceDialog.java @@ -0,0 +1,1406 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ +package de.applejuicenet.client.gui; + +import com.l2fprod.gui.plaf.skin.Skin; +import com.l2fprod.gui.plaf.skin.SkinLookAndFeel; +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.Information; +import de.applejuicenet.client.fassade.entity.Server; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.fassade.shared.NetworkInfo; +import de.applejuicenet.client.gui.about.AboutDialog; +import de.applejuicenet.client.gui.controller.*; +import de.applejuicenet.client.gui.download.DownloadController; +import de.applejuicenet.client.gui.download.DownloadPanel; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.gui.memorymonitor.MemoryMonitorDialog; +import de.applejuicenet.client.gui.options.IncomingDirSelectionDialog; +import de.applejuicenet.client.gui.options.OptionsDialog; +import de.applejuicenet.client.gui.server.ServerPanel; +import de.applejuicenet.client.gui.share.ShareController; +import de.applejuicenet.client.gui.share.SharePanel; +import de.applejuicenet.client.gui.tray.TrayLoader; +import de.applejuicenet.client.gui.upload.UploadController; +import de.applejuicenet.client.gui.upload.UploadPanel; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.LookAFeel; +import de.applejuicenet.client.shared.SoundPlayer; +import de.tklsoft.gui.controls.TKLButton; +import de.tklsoft.gui.controls.TKLFrame; +import de.tklsoft.gui.controls.TKLLabel; +import de.tklsoft.gui.controls.TKLPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.border.BevelBorder; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.DefaultEditorKit; +import java.awt.*; +import java.awt.event.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/AppleJuiceDialog.java,v + * 1.125 2004/06/23 14:56:12 maj0r Exp $ + * + * <p> + * Titel: AppleJuice Client-GUI + * </p> + * <p> + * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + * </p> + * <p> + * Copyright: General Public License + * </p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class AppleJuiceDialog extends TKLFrame implements LanguageListener, DataUpdateListener { + + private static Logger logger; + private static Map<String, Skin> themes = null; + public static boolean rewriteProperties = false; + private static AppleJuiceDialog theApp; + private static boolean themesInitialized = false; + private static boolean useTrayIcon = false; + private static TrayLoader trayLoader = null; + private Information information = null; + private RegisterPanel registerPane; + private TKLLabel[] statusbar = new TKLLabel[6]; + private JMenu sprachMenu; + private JMenu optionenMenu; + private JMenu themesMenu = null; + private JMenu iconsetMenu = null; + private JMenu soundsetMenu = null; + private JMenu coreMenu; + private JMenuItem menuItemOptionen = new JMenuItem(); + private JMenuItem menuItemDateiliste = new JMenuItem(); + private JMenuItem menuItemCheckUpdate = new JMenuItem(); + private JMenuItem menuItemCoreBeenden = new JMenuItem(); + private JMenuItem menuItemUeber = new JMenuItem(); + private JMenuItem menuItemDeaktivieren = new JMenuItem(); + private JMenuItem menuItemAktivieren = new JMenuItem(); + private JMenuItem popupOptionenMenuItem = new JMenuItem(); + private JMenuItem popupAboutMenuItem = new JMenuItem(); + private JMenuItem popupShowHideMenuItem = new JMenuItem(); + private JMenuItem popupCheckUpdateMenuItem = new JMenuItem(); + private TKLButton sound = new TKLButton(); + private TKLButton memory = new TKLButton(); + private String keinServer; + private boolean firstChange = true; + private MemoryMonitorDialog memoryMonitorDialog; + private String neustartTitel; + private String neustartNachricht; + private boolean automaticPwdlEnabled = false; + private String titel; + private String bestaetigung; + private int desktopHeight; + private int desktopWidth; + private boolean maximized = false; + private Dimension lastFrameSize; + private Point lastFrameLocation; + private Icon versteckenIcon = null; + private Icon zeigenIcon = null; + private boolean firewalled = false; + private String firewallWarning; + private String alreadyLoaded; + private String invalidLink; + private String linkFailure; + private String dialogTitel; + private String verbunden; + private String verbinden; + private String nichtVerbunden; + private ImageIcon firewallIcon; + private ImageIcon verbundenIcon; + private ImageIcon nichtVerbundenIcon; + private JPopupMenu popup; + private DownloadlinkPanel linkPane = new DownloadlinkPanel(); + + public AppleJuiceDialog() { + super(); + logger = LoggerFactory.getLogger(getClass()); + try { + enableCloseWindowListener(false); + theApp = this; + init(); + pack(); + LanguageSelector.getInstance().addLanguageListener(this); + initKeyStrokes(); + + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static String getVersion() { + return AppleJuiceDialog.class.getPackage().getImplementationVersion(); + } + + private void initKeyStrokes() { + int tabCount = registerPane.getTabCount(); + + for (int i = 0; i < tabCount; i++) { + int event = i < 9 ? KeyEvent.VK_1 + i : KeyEvent.VK_A + i - 9; + KeyStroke stroke = KeyStroke.getKeyStroke(event, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); + final int index = i; + AbstractAction action = new AbstractAction() { + public void actionPerformed(ActionEvent e) { + registerPane.setSelectedIndex(index); + } + }; + + String commandName = "ctrl_" + ((char) event); + + ((JComponent) getContentPane()).getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, commandName); + ((JComponent) getContentPane()).getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(stroke, commandName); + ((JComponent) getContentPane()).getActionMap().put(commandName, action); + } + } + + public static void initThemes() { + try { + themesInitialized = true; + if (OptionsManagerImpl.getInstance().isThemesSupported()) { + HashSet<URL> themesDateien = new HashSet<>(); + File themesPath = new File(System.getProperty("user.dir") + File.separator + "themes"); + + if (!themesPath.isDirectory()) { + logger.info("Der Ordner" + " fuer die Themes zip-Dateien ist nicht vorhanden." + "\r\nappleJuice wird beendet."); + + closeWithErrormessage("Der Ordner" + " für die Themes zip-Dateien ist nicht vorhanden." + + "\r\nappleJuice wird beendet.", false); + } + + File[] themeFiles = themesPath.listFiles(); + + assert themeFiles != null; + for (File themeFile : themeFiles) { + if (themeFile.isFile() && themeFile.getName().endsWith(".zip")) { + + //testen, ob es wirklich ein skinfile ist + ZipFile jf = new ZipFile(themeFile); + ZipEntry entry = jf.getEntry("skinlf-themepack.xml"); + + if (entry != null) { + themesDateien.add(themeFile.toURL()); + } + } + } + + Skin standardSkin = null; + Skin aSkin = null; + String temp; + String shortName = ""; + String defaultTheme = OptionsManagerImpl.getInstance().getDefaultTheme(); + + themes = new HashMap<>(); + for (URL curSkinURL : themesDateien) { + temp = curSkinURL.getFile(); + int index1 = temp.lastIndexOf('/'); + int index2 = temp.lastIndexOf(".zip"); + + if (index1 == -1 || index2 == -1) { + continue; + } + + shortName = temp.substring(index1 + 1, index2); + aSkin = SkinLookAndFeel.loadThemePack(curSkinURL); + themes.put(shortName, aSkin); + if (shortName.compareToIgnoreCase(defaultTheme) == 0) { + standardSkin = aSkin; + } + } + + if (standardSkin == null) { + standardSkin = aSkin; + } + + SkinLookAndFeel.setSkin(standardSkin); + SkinLookAndFeel.enable(); + } else { + LookAFeel defaultlookandfeel = OptionsManagerImpl.getInstance().getDefaultLookAndFeel(); + + if (defaultlookandfeel != null) { + UIManager.setLookAndFeel(defaultlookandfeel.getClassName()); + + // https://stackoverflow.com/a/7253059 + if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { + InputMap im = (InputMap) UIManager.get("TextField.focusInputMap"); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK), DefaultEditorKit.selectAllAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction); + } + } + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static AppleJuiceDialog getApp() { + return theApp; + } + + private void init() throws Exception { + titel = "appleJuice GUI (" + AppleJuiceDialog.getVersion() + ")"; + IconManager im = IconManager.getInstance(); + + firewallIcon = im.getIcon("firewall"); + verbundenIcon = im.getIcon("serververbunden"); + nichtVerbundenIcon = im.getIcon("serverversuche"); + + Image image = im.getIcon("applejuice").getImage(); + + setTitle(titel); + + setIconImage(image); + menuItemOptionen.setIcon(im.getIcon("optionen")); + menuItemUeber.setIcon(im.getIcon("info")); + menuItemCoreBeenden.setIcon(im.getIcon("skull")); + menuItemDateiliste.setIcon(im.getIcon("speichern")); + menuItemCheckUpdate.setIcon(im.getIcon("update")); + + setJMenuBar(createMenuBar()); + if (OptionsManagerImpl.getInstance().isThemesSupported()) { + SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); + } + + String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; + String sprache = OptionsManagerImpl.getInstance().getSprache(); + + if (null == sprache || sprache.trim().length() == 0) { + sprache = "deutsch"; + } + + path += sprache + ".properties"; + if (AppleJuiceClient.splash != null) { + AppleJuiceClient.splash.setProgress(25, "Initialisiere Sprache..."); + } + + LanguageSelector languageSelector = LanguageSelector.getInstance(path); + + if (AppleJuiceClient.splash != null) { + AppleJuiceClient.splash.setProgress(30, "Erstelle Register..."); + } + + registerPane = new RegisterPanel(this); + languageSelector.fireLanguageChanged(); + if (AppleJuiceClient.splash != null) { + AppleJuiceClient.splash.setProgress(95, "Register erstellt.."); + } + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent evt) { + closeDialog(evt); + } + }); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + desktopWidth = screenSize.width; + desktopHeight = screenSize.height; + addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + int x = getWidth(); + int y = getHeight(); + + if (x == desktopWidth && y == desktopHeight) { + if (maximized) { + demaximize(); + } else { + maximize(); + } + } else { + if (!maximized) { + lastFrameSize = getSize(); + lastFrameLocation = getLocation(); + } + + super.componentResized(e); + } + } + + public void componentMoved(ComponentEvent e) { + if (!maximized) { + lastFrameLocation = getLocation(); + } + + super.componentMoved(e); + } + }); + useTrayIcon = true; + popup = makeSwingPopup(); + try { + TrayLoader trayLoader = new TrayLoader(); + + useTrayIcon = trayLoader.makeTray(titel, this, popupShowHideMenuItem, zeigenIcon, versteckenIcon, popup); + AppleJuiceClient.getAjFassade().addDataUpdateListener(new DataUpdateListener() { + private Map<Integer, Integer> stati = new HashMap<Integer, Integer>(); + private List<Integer> alreadyNotified = new ArrayList<Integer>(); + + public void fireContentChanged(DATALISTENER_TYPE type, Object content) { + Map<Integer, Download> downloads = (Map<Integer, Download>) content; + + for (Download curDownload : downloads.values()) { + Integer oldDownloadStatus = stati.get(curDownload.getId()); + + if (null == oldDownloadStatus) { + // neu + stati.put(curDownload.getId(), curDownload.getStatus()); + } else if (curDownload.getStatus() == Download.FERTIG && oldDownloadStatus != Download.FERTIG && + !alreadyNotified.contains(curDownload.getId())) { + // fertiggestellt und noch nicht benachrichtigt + alreadyNotified.add(curDownload.getId()); + showMessage("Download fertig", curDownload.getFilename() + " abgeschlossen!"); + } + } + + ArrayList<Integer> toRemove = new ArrayList<Integer>(); + + for (Integer curKey : stati.keySet()) { + if (!downloads.containsKey(curKey)) { + // download wurde entfernt + toRemove.add(curKey); + } + } + + for (Integer curKey : toRemove) { + stati.remove(curKey); + } + } + }, DATALISTENER_TYPE.DOWNLOAD_CHANGED); + } catch (Throwable e) { + useTrayIcon = false; + } + + getContentPane().setLayout(new BorderLayout()); + linkPane.getBtnStartDownload().addActionListener(e -> uebernehmeLink()); + + getContentPane().add(linkPane, BorderLayout.NORTH); + getContentPane().add(registerPane, BorderLayout.CENTER); + + TKLPanel panel = new TKLPanel(new GridBagLayout()); + + for (int i = 0; i < statusbar.length; i++) { + statusbar[i] = new TKLLabel(" "); + statusbar[i].setHorizontalAlignment(TKLLabel.RIGHT); + statusbar[i].setBorder(new BevelBorder(BevelBorder.LOWERED)); + statusbar[i].setFont(new java.awt.Font("SansSerif", 0, 11)); + } + + memory.setIcon(IconManager.getInstance().getIcon("mmonitor")); + memory.addActionListener(ae -> { + if (memoryMonitorDialog == null) { + memoryMonitorDialog = new MemoryMonitorDialog(AppleJuiceDialog.this); + Point loc = memory.getLocationOnScreen(); + + loc.setLocation(loc.getX() - memoryMonitorDialog.getWidth(), loc.getY() - memoryMonitorDialog.getHeight()); + memoryMonitorDialog.setLocation(loc); + } + + if (!memoryMonitorDialog.isVisible()) { + memoryMonitorDialog.setVisible(true); + } + }); + + sound.addActionListener(new ActionListener() { + + { + if (OptionsManagerImpl.getInstance().isSoundEnabled()) { + sound.setIcon(IconManager.getInstance().getIcon("soundon")); + } else { + sound.setIcon(IconManager.getInstance().getIcon("soundoff")); + } + } + + public void actionPerformed(ActionEvent ae) { + OptionsManager om = OptionsManagerImpl.getInstance(); + + om.enableSound(!om.isSoundEnabled()); + if (om.isSoundEnabled()) { + sound.setIcon(IconManager.getInstance().getIcon("soundon")); + } else { + sound.setIcon(IconManager.getInstance().getIcon("soundoff")); + } + } + }); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + panel.add(statusbar[0], constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel.add(statusbar[1], constraints); + constraints.weightx = 0; + constraints.gridx = 2; + panel.add(statusbar[2], constraints); + constraints.gridx = 3; + panel.add(statusbar[3], constraints); + constraints.gridx = 4; + panel.add(statusbar[4], constraints); + constraints.gridx = 5; + panel.add(statusbar[5], constraints); + constraints.gridx = 6; + panel.add(memory, constraints); + constraints.gridx = 7; + panel.add(sound, constraints); + getContentPane().add(panel, BorderLayout.SOUTH); + + //Tooltipps einstellen + ToolTipManager.sharedInstance().setInitialDelay(1); + ToolTipManager.sharedInstance().setDismissDelay(50000); + LanguageSelector.getInstance().addLanguageListener(linkPane); + fireLanguageChanged(); + ApplejuiceFassade dm = AppleJuiceClient.getAjFassade(); + + dm.addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); + dm.addDataUpdateListener(this, DATALISTENER_TYPE.NETINFO_CHANGED); + + try { + dm.startXMLCheck(); + + }catch (RuntimeException e) { + String msg = String.format("Core Version %s required!", ApplejuiceFassade.MIN_NEEDED_CORE_VERSION); + AppleJuiceDialog.closeWithErrormessage(msg, false); + System.exit(1); + } + } + + public static synchronized void showMessage(String caption, String message) { + if (null != trayLoader) { + trayLoader.showBallon(caption, message); + } + } + + protected void uebernehmeLink() { + if (linkPane.getTxtDownloadLink().isInvalid()) { + return; + } + + final String link = linkPane.getTxtDownloadLink().getText().replace("%7C", "|"); + Object sel = linkPane.getCmbTargetDir().getSelectedItem(); + String tmp; + + if (sel != null) { + tmp = (String) sel; + } else { + tmp = ""; + } + + final String targetDir = tmp; + + if (link.length() != 0) { + linkPane.getTxtDownloadLink().setText(""); + Thread linkThread = new Thread() { + public void run() { + try { + final String result = AppleJuiceClient.getAjFassade().processLink(link, targetDir); + + SoundPlayer.getInstance().playSound(SoundPlayer.LADEN); + if (result.indexOf("ok") != 0) { + SwingUtilities.invokeLater(() -> { + String message = null; + + if (result.contains("already downloaded")) { + message = alreadyLoaded.replaceAll("%s", link); + } else if (result.contains("incorrect link")) { + message = invalidLink.replaceAll("%s", link); + } else if (result.contains("failure")) { + message = linkFailure; + } + + if (message != null) { + JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message, dialogTitel, JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); + } + }); + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }; + + linkThread.start(); + } + } + + private void demaximize() { + setSize(lastFrameSize); + setLocation(lastFrameLocation); + maximized = false; + } + + private void maximize() { + Toolkit tk = Toolkit.getDefaultToolkit(); + Dimension screenSize = tk.getScreenSize(); + Insets insets = tk.getScreenInsets(getGraphicsConfiguration()); + + screenSize.width -= (insets.left + insets.right); + screenSize.height -= (insets.top + insets.bottom); + setSize(screenSize); + setLocation(insets.left, insets.top); + maximized = true; + } + + private static void einstellungenSpeichern() { + try { + String sprachText = LanguageSelector.getInstance().getFirstAttrbuteByTagName("Languageinfo.name"); + + OptionsManagerImpl.getInstance().setSprache(sprachText); + int[] downloadWidths = ((DownloadPanel) DownloadController.getInstance().getComponent()).getDownloadColumnWidths(); + int[] downloadSourcesWidths = ((DownloadPanel) DownloadController.getInstance().getComponent()).getDownloadSourcesColumnWidths(); + int[] uploadWidths = ((UploadPanel) UploadController.getInstance().getComponent()).getColumnActiveWidths(); + int[] uploadWaitingWidths = ((UploadPanel) UploadController.getInstance().getComponent()).getColumnWaitingWidths(); + int[] serverWidths = ServerPanel.getInstance().getColumnWidths(); + int[] shareWidths = ((SharePanel) ShareController.getInstance().getComponent()).getColumnWidths(); + Dimension dim = AppleJuiceDialog.getApp().getSize(); + Point p = AppleJuiceDialog.getApp().getLocationOnScreen(); + PositionManager pm = PositionManagerImpl.getInstance(); + + pm.setMainXY(p); + pm.setMainDimension(dim); + pm.setDownloadWidths(downloadWidths); + pm.setDownloadSourcesWidths(downloadSourcesWidths); + pm.setUploadWidths(uploadWidths); + pm.setUploadWaitingWidths(uploadWaitingWidths); + pm.setServerWidths(serverWidths); + pm.setShareWidths(shareWidths); + pm.save(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void informAutomaticPwdlEnabled(boolean enabled) { + if (enabled != automaticPwdlEnabled) { + automaticPwdlEnabled = enabled; + setTitle(titel); + repaint(); + } + } + + private void closeDialog(WindowEvent evt) { + AppleJuiceClient.getAjFassade().stopXMLCheck(); + if (rewriteProperties) { + PropertiesManager.restoreProperties(); + } + + String nachricht = "appleJuice-GUI wird beendet..."; + + logger.info(nachricht); + + System.out.println(nachricht); + if (!rewriteProperties) { + einstellungenSpeichern(); + } + + setVisible(false); + + System.exit(0); + } + + public static void closeWithErrormessage(String error, boolean speichereEinstellungen) { + JOptionPane.showMessageDialog(theApp, error, "appleJuice Client", JOptionPane.OK_OPTION); + if (rewriteProperties) { + PropertiesManager.restoreProperties(); + } else { + AppleJuiceClient.getAjFassade().stopXMLCheck(); + } + + String nachricht = "appleJuice-GUI wird beendet..."; + + logger.info(nachricht); + + System.out.println(nachricht); + if (speichereEinstellungen && !rewriteProperties) { + einstellungenSpeichern(); + } + + System.out.println("Fehler: " + error); + + System.exit(-1); + } + + protected JMenuBar createMenuBar() { + try { + if (!themesInitialized) { + AppleJuiceDialog.initThemes(); + } + + String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; + File languagePath = new File(path); + + if (!languagePath.isDirectory()) { + logger.info("Der Ordner " + path + " für die Sprachauswahl properties-Dateien ist nicht vorhanden." + "\r\nappleJuice wird beendet."); + + closeWithErrormessage("Der Ordner " + path + " fuer die Sprachauswahl properties-Dateien ist nicht vorhanden." + + "\r\nappleJuice wird beendet.", false); + } + + String[] tempListe = languagePath.list(); + HashSet<String> sprachDateien = new HashSet<String>(); + + for (int i = 0; i < tempListe.length; i++) { + if (tempListe[i].contains(".properties")) { + sprachDateien.add(tempListe[i]); + } + } + + if (sprachDateien.size() == 0) { + logger.info("Es sind keine properties-Dateien fuer die Sprachauswahl im Ordner " + path + " vorhanden." + + "\r\nappleJuice wird beendet."); + + closeWithErrormessage("Es sind keine properties-Dateien fuer die Sprachauswahl im Ordner " + path + " vorhanden." + + "\r\nappleJuice wird beendet.", false); + } + + JMenuBar menuBar = new JMenuBar(); + + optionenMenu = new JMenu(); + menuItemOptionen.addActionListener(e -> showOptionsDialog()); + menuItemDateiliste.addActionListener(e -> dateiListeImportieren()); + menuItemCheckUpdate.addActionListener(e -> checkAndDisplayUpdate()); + menuItemCoreBeenden.addActionListener(e -> { + int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), bestaetigung, "appleJuice Client", + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + + if (result == JOptionPane.YES_OPTION) { + AppleJuiceClient.getAjFassade().shutdownCore(); + } + }); + menuItemUeber.addActionListener(e -> showAboutDialog()); + optionenMenu.add(menuItemOptionen); + optionenMenu.add(menuItemDateiliste); + optionenMenu.add(menuItemCheckUpdate); + optionenMenu.add(menuItemUeber); + menuBar.add(optionenMenu); + + sprachMenu = new JMenu(); + menuBar.add(sprachMenu); + ButtonGroup lafGroup = new ButtonGroup(); + + for (String curSprachDatei : sprachDateien) { + String sprachText = LanguageSelector.getInstance(path + curSprachDatei) + .getFirstAttrbuteByTagName("Languageinfo.name"); + JCheckBoxMenuItem rb = new JCheckBoxMenuItem(sprachText); + + if (OptionsManagerImpl.getInstance().getSprache().equalsIgnoreCase(sprachText)) { + rb.setSelected(true); + } + + Image img = Toolkit.getDefaultToolkit().getImage(path + sprachText.toLowerCase() + ".gif"); + ImageIcon result = new ImageIcon(); + + result.setImage(img); + rb.setIcon(result); + + sprachMenu.add(rb); + rb.addItemListener(ae -> { + JCheckBoxMenuItem rb2 = (JCheckBoxMenuItem) ae.getSource(); + + if (rb2.isSelected()) { + String path1 = System.getProperty("user.dir") + File.separator + "language" + File.separator; + String dateiName = path1 + rb2.getText().toLowerCase() + ".properties"; + + LanguageSelector.getInstance(dateiName); + } + }); + lafGroup.add(rb); + } + + themesMenu = new JMenu(); + if (OptionsManagerImpl.getInstance().isThemesSupported()) { + HashSet<URL> themesDateien = new HashSet<URL>(); + File themesPath = new File(System.getProperty("user.dir") + File.separator + "themes"); + + if (!themesPath.isDirectory()) { + logger.info("Der Ordner " + path + " fuer die Themes zip-Dateien ist nicht vorhanden." + + "\r\nappleJuice wird beendet."); + + closeWithErrormessage("Der Ordner " + path + " fuer die Themes zip-Dateien ist nicht vorhanden." + + "\r\nappleJuice wird beendet.", false); + } + + File[] themeFiles = themesPath.listFiles(); + + for (int i = 0; i < themeFiles.length; i++) { + if (themeFiles[i].isFile() && themeFiles[i].getName().endsWith(".zip")) { + + //testen, ob es wirklich ein skinfile ist + ZipFile jf = new ZipFile(themeFiles[i]); + ZipEntry entry = jf.getEntry("skinlf-themepack.xml"); + + if (entry != null) { + themesDateien.add(themeFiles[i].toURL()); + } + } + } + + ButtonGroup lafGroup2 = new ButtonGroup(); + String temp; + String shortName; + String defaultTheme = OptionsManagerImpl.getInstance().getDefaultTheme(); + + for (URL curSkinURL : themesDateien) { + temp = curSkinURL.getFile(); + int index1 = temp.lastIndexOf('/'); + int index2 = temp.lastIndexOf(".zip"); + + if (index1 == -1 || index2 == -1) { + continue; + } + + shortName = temp.substring(index1 + 1, index2); + final JCheckBoxMenuItem rb = new JCheckBoxMenuItem(shortName); + + if (shortName.compareToIgnoreCase(defaultTheme) == 0) { + rb.setSelected(true); + } + + rb.addItemListener(ae -> { + if (rb.isSelected()) { + activateLaF(rb.getText()); + } + }); + lafGroup2.add(rb); + themesMenu.add(rb); + } + + themesMenu.add(new JSeparator()); + menuItemDeaktivieren.addActionListener(ce -> activateThemeSupport(false)); + themesMenu.add(menuItemDeaktivieren); + } else { + final LookAFeel[] feels = OptionsManagerImpl.getInstance().getLookAndFeels(); + LookAFeel defaultlookandfeel = OptionsManagerImpl.getInstance().getDefaultLookAndFeel(); + ButtonGroup lafGroup2 = new ButtonGroup(); + + for (LookAFeel feel : feels) { + final JCheckBoxLookAndFeelMenuItem lookAndFeelMenuItem = new JCheckBoxLookAndFeelMenuItem(feel); + + lafGroup2.add(lookAndFeelMenuItem); + themesMenu.add(lookAndFeelMenuItem); + lookAndFeelMenuItem.setSelected(defaultlookandfeel != null && feel.getName().equals(defaultlookandfeel.getName())); + + lookAndFeelMenuItem.addItemListener(ae -> { + if (lookAndFeelMenuItem.isSelected()) { + activateLaF(lookAndFeelMenuItem.getText()); + } + }); + } + + menuItemAktivieren.addActionListener(ce -> activateThemeSupport(true)); + themesMenu.add(new JSeparator()); + themesMenu.add(menuItemAktivieren); + } + menuBar.add(themesMenu); + + iconsetMenu = new JMenu(); + ButtonGroup iconsetGroup = new ButtonGroup(); + String iconsetPath = System.getProperty("user.dir") + File.separator + "icons" + File.separator; + String iconsetDefault = OptionsManagerImpl.getInstance().getIconSetName(); + + File iconsetPathFile = new File(iconsetPath); + File[] iconsetDirectoryListing = iconsetPathFile.listFiles(); + if (iconsetDirectoryListing != null) { + for (File iconSet : iconsetDirectoryListing) { + if (iconSet.isDirectory()) { + final iconsetFeelMenuItem iconsetMenuItem = new iconsetFeelMenuItem(iconSet.getName()); + iconsetMenuItem.setSelected(iconSet.getName().equals(iconsetDefault)); + iconsetMenuItem.addActionListener(ce -> changeIconOrSoundSet()); + iconsetMenu.add(iconsetMenuItem); + iconsetGroup.add(iconsetMenuItem); + } + } + } + + soundsetMenu = new JMenu(); + ButtonGroup soundsetGroup = new ButtonGroup(); + + String soundsetPath = System.getProperty("user.dir") + File.separator + "sounds" + File.separator; + String soundsetDefault = OptionsManagerImpl.getInstance().getSoundSetName(); + + File soundsetPathFile = new File(soundsetPath); + File[] soundsetDirectoryListing = soundsetPathFile.listFiles(); + if (soundsetDirectoryListing != null) { + for (File soundSet : soundsetDirectoryListing) { + if (soundSet.isDirectory()) { + final soundsetFeelMenuItem soundsetMenuItem = new soundsetFeelMenuItem(soundSet.getName()); + soundsetMenuItem.setSelected(soundSet.getName().equals(soundsetDefault)); + soundsetMenu.add(soundsetMenuItem); + soundsetGroup.add(soundsetMenuItem); + + soundsetMenuItem.addActionListener(ce -> changeIconOrSoundSet()); + } + } + } + + menuBar.add(iconsetMenu); + menuBar.add(soundsetMenu); + + coreMenu = new JMenu(); + coreMenu.add(menuItemCoreBeenden); + menuBar.add(coreMenu); + coreMenu.setText("Core"); + return menuBar; + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + return null; + } + } + + private void showOptionsDialog() { + OptionsDialog od = new OptionsDialog(getApp()); + Dimension optDimension = od.getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + od.setLocation((screenSize.width - optDimension.width) / 2, (screenSize.height - optDimension.height) / 2); + od.setVisible(true); + } + + private void showAboutDialog() { + AboutDialog aboutDialog = new AboutDialog(getApp(), true); + Dimension appDimension = aboutDialog.getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + aboutDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + aboutDialog.setVisible(true); + } + + private void activateThemeSupport(boolean enable) { + int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.this, neustartNachricht, "appleJuice Client", JOptionPane.YES_NO_OPTION); + + if (result == JOptionPane.YES_OPTION) { + OptionsManagerImpl.getInstance().enableThemeSupport(enable); + closeDialog(null); + } + } + + private void changeIconOrSoundSet() { + int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.this, neustartNachricht, "appleJuice Client", JOptionPane.YES_NO_OPTION); + + if (result == JOptionPane.YES_OPTION) { + closeDialog(null); + } + } + + private void activateLaF(String laf) { + try { + + // theme??? + if (themes != null) { + Skin aSkin = (Skin) themes.get(laf); + + if (aSkin != null) { + SkinLookAndFeel.setSkin(aSkin); + SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); + OptionsManagerImpl.getInstance().setDefaultTheme(laf); + return; + } + } + + // laf??? + final LookAFeel[] feels = OptionsManagerImpl.getInstance().getLookAndFeels(); + + if (feels != null && laf != null) { + for (LookAFeel feel : feels) { + if (laf.equals(feel.getName())) { + OptionsManagerImpl.getInstance().setDefaultLookAndFeel(feel); + return; + } + } + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void setTitle(String newTitle) { + if (!automaticPwdlEnabled) { + super.setTitle(newTitle); + } else { + super.setTitle(newTitle + " - Autopilot"); + } + + titel = newTitle; + } + + private void dateiListeImportieren() { + JFileChooser fileChooser = new JFileChooser(); + + fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); + fileChooser.setFileFilter(new TxtFileFilter()); + fileChooser.setDialogTitle(menuItemDateiliste.getText()); + fileChooser.setMultiSelectionEnabled(false); + int i = fileChooser.showOpenDialog(this); + + if (i == JFileChooser.APPROVE_OPTION) { + final File file = fileChooser.getSelectedFile(); + + if (file.isFile()) { + String[] dirs = AppleJuiceClient.getAjFassade().getCurrentIncomingDirs(); + IncomingDirSelectionDialog incomingDirSelectionDialog = new IncomingDirSelectionDialog(AppleJuiceDialog.getApp(), dirs, + null); + + incomingDirSelectionDialog.setVisible(true); + String directory = incomingDirSelectionDialog.getSelectedIncomingDir(); + + if (directory != null) { + directory = directory.trim(); + if (directory.indexOf(File.separator) == 0 || directory.indexOf(ApplejuiceFassade.separator) == 0) { + directory = directory.substring(1); + } + } else { + directory = ""; + } + + final String targetDir = directory; + + new Thread(() -> importAjl(file, targetDir)).start(); + } + } + } + + public void fireLanguageChanged() { + try { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + verbunden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.verbunden"); + verbinden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.verbinden"); + nichtVerbunden = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.nichtverbunden"); + keinServer = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.keinserver"); + neustartTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + neustartNachricht = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.neustartnachricht"); + sprachMenu.setText(languageSelector.getFirstAttrbuteByTagName("einstform.languagesheet.caption")); + menuItemOptionen.setText(languageSelector.getFirstAttrbuteByTagName("mainform.optbtn.caption")); + menuItemOptionen.setToolTipText(languageSelector.getFirstAttrbuteByTagName("mainform.optbtn.hint")); + menuItemCoreBeenden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.corebeenden")); + menuItemCoreBeenden.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.corebeendenhint")); + menuItemUeber.setText(languageSelector.getFirstAttrbuteByTagName("mainform.aboutbtn.caption")); + menuItemCheckUpdate.setText(languageSelector.getFirstAttrbuteByTagName("mainform.checkupdate.caption")); + menuItemCheckUpdate.setToolTipText(languageSelector.getFirstAttrbuteByTagName("mainform.checkupdate.hint")); + optionenMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.extras")); + menuItemDateiliste.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.dateiliste")); + menuItemDateiliste.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.dateilistehint")); + themesMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.themes")); + iconsetMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.icons")); + soundsetMenu.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.sound")); + bestaetigung = languageSelector.getFirstAttrbuteByTagName("javagui.menu.bestaetigung"); + menuItemAktivieren.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.aktivieren")); + menuItemDeaktivieren.setText(languageSelector.getFirstAttrbuteByTagName("javagui.menu.deaktivieren")); + + firewallWarning = languageSelector.getFirstAttrbuteByTagName("mainform.firewallwarning.caption"); + alreadyLoaded = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.bereitsgeladen"); + invalidLink = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.falscherlink"); + linkFailure = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.sonstigerlinkfehlerkurz"); + dialogTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + if (firewalled) { + statusbar[0].setToolTipText(firewallWarning); + } + + if (useTrayIcon && null != trayLoader) { + trayLoader.setTextVerstecken(languageSelector.getFirstAttrbuteByTagName("javagui.menu.verstecken")); + trayLoader.setTextZeigen(languageSelector.getFirstAttrbuteByTagName("javagui.menu.zeigen")); + popupAboutMenuItem.setText(menuItemUeber.getText()); + popupAboutMenuItem.setToolTipText(menuItemUeber.getToolTipText()); + popupOptionenMenuItem.setText(menuItemOptionen.getText()); + popupOptionenMenuItem.setToolTipText(menuItemOptionen.getToolTipText()); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void fireContentChanged(DATALISTENER_TYPE type, final Object content) { + if (type == DATALISTENER_TYPE.NETINFO_CHANGED) { + SwingUtilities.invokeLater(() -> { + try { + NetworkInfo netInfo = (NetworkInfo) content; + + if (netInfo.isFirewalled() != firewalled) { + firewalled = !firewalled; + updateFirewall(); + if (firewalled) { + statusbar[0].setToolTipText(firewallWarning); + } else { + statusbar[0].setToolTipText(null); + } + + updateFirewall(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + }); + } else if (type == DATALISTENER_TYPE.INFORMATION_CHANGED) { + SwingUtilities.invokeLater(() -> { + try { + information = (Information) content; + statusbar[0].setText(getVerbindungsStatusAsString(information)); + if (information.getVerbindungsStatus() == Information.NICHT_VERBUNDEN) { + statusbar[1].setText(keinServer); + } else { + String tmp = information.getServerName(); + + if (tmp == null || tmp.length() == 0) { + Server server = information.getServer(); + + if (server != null) { + tmp = server.getHost() + ":" + server.getPort(); + } + } + + statusbar[1].setText(tmp); + } + + statusbar[2].setText(information.getUpDownAsString()); + statusbar[3].setText(information.getUpDownSessionAsString()); + statusbar[4].setText(information.getExterneIP()); + statusbar[5].setText(information.getCreditsAsString()); + updateFirewall(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + }); + } + } + + protected void updateFirewall() { + if (information != null && information.getVerbindungsStatus() != Information.VERBUNDEN) { + statusbar[0].setIcon(nichtVerbundenIcon); + } else { + if (firewalled) { + statusbar[0].setIcon(firewallIcon); + } else { + statusbar[0].setIcon(verbundenIcon); + } + } + } + + public JPopupMenu makeSwingPopup() { + final JPopupMenu popup = new JPopupMenu(); + + popupShowHideMenuItem.addActionListener(ae -> { + if (!isVisible()) { + setVisible(true); + setAlwaysOnTop(true); + setAlwaysOnTop(false); + requestFocus(); + } else { + if (popup.isVisible()) { + popup.setVisible(false); + } + + setVisible(false); + } + }); + popup.add(popupShowHideMenuItem); + popupOptionenMenuItem.addActionListener(ae -> showOptionsDialog()); + + popup.add(popupOptionenMenuItem); + IconManager im = IconManager.getInstance(); + + versteckenIcon = im.getIcon("hide"); + zeigenIcon = im.getIcon("applejuice"); + Icon aboutIcon = im.getIcon("about"); + + popupOptionenMenuItem.setIcon(im.getIcon("optionen")); + popupAboutMenuItem.setIcon(aboutIcon); + popupAboutMenuItem.addActionListener(ae -> showAboutDialog()); + popup.add(popupAboutMenuItem); + new Thread() { + public void run() { + final AJSettings ajSettings = AppleJuiceClient.getAjFassade().getAJSettings(); + + if (ajSettings != null) { + long maxUpload = 50; + + if (ajSettings.getMaxUploadInKB() > maxUpload) { + maxUpload = ajSettings.getMaxUploadInKB() + 20; + } + + final JSlider uploadSlider = new JSlider(JSlider.VERTICAL, 0, (int) maxUpload, (int) ajSettings.getMaxUploadInKB()); + long maxDownload = 300; + + if (ajSettings.getMaxDownloadInKB() > maxDownload) { + maxDownload = ajSettings.getMaxDownloadInKB() + 20; + } + + final JSlider downloadSlider = new JSlider(JSlider.VERTICAL, 0, (int) maxDownload, + (int) ajSettings.getMaxDownloadInKB()); + + uploadSlider.setPaintLabels(true); + uploadSlider.setPaintTicks(true); + uploadSlider.setPaintTrack(true); + uploadSlider.setSnapToTicks(true); + downloadSlider.setPaintLabels(true); + downloadSlider.setPaintTicks(true); + downloadSlider.setPaintTrack(true); + downloadSlider.setSnapToTicks(true); + final JMenu uploadMenu = new JMenu("Upload"); + final JMenu downloadMenu = new JMenu("Download"); + TKLPanel uploadPanel = new TKLPanel(new BorderLayout()); + TKLPanel downloadPanel = new TKLPanel(new BorderLayout()); + final TKLLabel label1 = new TKLLabel("50 kb/s"); + final TKLLabel label2 = new TKLLabel("50 kb/s"); + + label1.setText(ajSettings.getMaxUploadInKB() + " kb/s"); + label2.setText(ajSettings.getMaxDownloadInKB() + " kb/s"); + uploadPanel.add(label1, BorderLayout.NORTH); + uploadPanel.add(uploadSlider, BorderLayout.SOUTH); + uploadMenu.add(uploadPanel); + downloadPanel.add(label2, BorderLayout.NORTH); + downloadPanel.add(downloadSlider, BorderLayout.SOUTH); + downloadMenu.add(downloadPanel); + uploadSlider.addChangeListener(e -> { + JSlider slider = (JSlider) e.getSource(); + + label1.setText(slider.getValue() + " kb/s"); + }); + downloadSlider.addChangeListener(e -> { + JSlider slider = (JSlider) e.getSource(); + + label2.setText(slider.getValue() + " kb/s"); + }); + uploadSlider.addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if (uploadSlider.getValue() < uploadSlider.getMaximum() && uploadSlider.getValue() > 0) { + Long down = (long) (downloadSlider.getValue() * 1024); + Long up = (long) (uploadSlider.getValue() * 1024); + + try { + AppleJuiceClient.getAjFassade().setMaxUpAndDown(up, down); + } catch (IllegalArgumentException e1) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e1); + } + } else { + uploadSlider.setValue((int) ajSettings.getMaxUploadInKB()); + } + } + }); + downloadSlider.addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if (downloadSlider.getValue() < downloadSlider.getMaximum() && downloadSlider.getValue() > 0) { + Long down = (long) (downloadSlider.getValue() * 1024); + Long up = (long) (uploadSlider.getValue() * 1024); + + try { + AppleJuiceClient.getAjFassade().setMaxUpAndDown(up, down); + } catch (IllegalArgumentException e1) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e1); + } + } else { + downloadSlider.setValue((int) ajSettings.getMaxDownloadInKB()); + } + } + }); + SwingUtilities.invokeLater(() -> { + popup.add(uploadMenu); + popup.add(downloadMenu); + }); + } + } + }.start(); + return popup; + } + + public void importAjl(File file, String targetDir) { + BufferedReader reader = null; + + try { + reader = new BufferedReader(new FileReader(file)); + String line = ""; + + while ((line = reader.readLine()) != null) { + if (line.compareTo("100") == 0) { + break; + } + } + + String size = ""; + String filename = ""; + String checksum = ""; + String link = ""; + ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); + final StringBuffer returnValues = new StringBuffer(); + boolean somethingAdded = false; + + while ((line = reader.readLine()) != null) { + filename = line; + checksum = reader.readLine(); + size = reader.readLine(); + if (size != null && checksum != null) { + link = "ajfsp://file|" + filename + "|" + checksum + "|" + size + "/"; + String result; + + try { + result = af.processLink(link, targetDir); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + return; + } + + if (result.indexOf("ok") == 0) { + returnValues.append("'" + link + "' OK\n"); + somethingAdded = true; + } else if (result.contains("already downloaded")) { + returnValues.append(alreadyLoaded.replaceAll("%s", link) + "\n"); + somethingAdded = true; + } else if (result.contains("incorrect link")) { + returnValues.append(invalidLink.replaceAll("%s", link) + "\n"); + somethingAdded = true; + } else if (result.contains("failure")) { + returnValues.append(linkFailure + "\n"); + somethingAdded = true; + } + } + } + + if (somethingAdded) { + SwingUtilities.invokeLater(() -> { + JTextPane textArea = new JTextPane(); + + textArea.setPreferredSize(new Dimension(550, 300)); + textArea.setMaximumSize(new Dimension(550, 300)); + textArea.setEditable(false); + textArea.setBackground(new TKLLabel().getBackground()); + textArea.setText(returnValues.toString()); + JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), new JScrollPane(textArea), + dialogTitel, + JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); + }); + } + } catch (IOException ex) { + ; //nix zu tun + } + } + + public static void showInformation(String information) { + JOptionPane.showMessageDialog(theApp, information, "appleJuice Client", JOptionPane.OK_OPTION); + } + + private String getVerbindungsStatusAsString(Information information) { + switch (information.getVerbindungsStatus()) { + + case Information.VERBUNDEN: + return verbunden; + + case Information.NICHT_VERBUNDEN: + return nichtVerbunden; + + case Information.VERSUCHE_ZU_VERBINDEN: + return verbinden; + + default: + return ""; + } + } + + private void checkAndDisplayUpdate() { + VersionChecker.check(); + } + + public void informWrongPassword() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + String nachricht = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext3"); + + SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT); + closeWithErrormessage(nachricht, true); + } + + private class TxtFileFilter extends FileFilter { + public boolean accept(File file) { + if (!file.isFile()) { + return true; + } else { + String name = file.getName(); + + return (name.toLowerCase().endsWith(".ajl")); + } + } + + public String getDescription() { + return "AJL-Dateien"; + } + } + + + private class JCheckBoxLookAndFeelMenuItem extends JCheckBoxMenuItem { + private final LookAFeel lookAFeel; + + public JCheckBoxLookAndFeelMenuItem(LookAFeel lookAFeelToUse) { + super(lookAFeelToUse.getName()); + this.lookAFeel = lookAFeelToUse; + addItemListener(ae -> { + if (isSelected()) { + try { + UIManager.setLookAndFeel(lookAFeel.getClassName()); + SwingUtilities.updateComponentTreeUI(AppleJuiceDialog.this); + + // https://stackoverflow.com/a/7253059 + if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { + InputMap im = (InputMap) UIManager.get("TextField.focusInputMap"); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK), DefaultEditorKit.selectAllAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction); + } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + }); + } + } + + private static class iconsetFeelMenuItem extends JCheckBoxMenuItem { + public iconsetFeelMenuItem(String name) { + super(name); + addItemListener(ae -> { + if (isSelected()) { + try { + OptionsManagerImpl.getInstance().setIconSetName(name); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + }); + } + } + + private static class soundsetFeelMenuItem extends JCheckBoxMenuItem { + public soundsetFeelMenuItem(String name) { + super(name); + addItemListener(ae -> { + if (isSelected()) { + try { + OptionsManagerImpl.getInstance().setSoundSetName(name); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + }); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/DownloadlinkPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/DownloadlinkPanel.java similarity index 64% rename from AJClientGUI/src/de/applejuicenet/client/gui/DownloadlinkPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/DownloadlinkPanel.java index c252a2bd..fac09fc7 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/DownloadlinkPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/DownloadlinkPanel.java @@ -4,28 +4,21 @@ package de.applejuicenet.client.gui; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -import java.io.File; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; - import de.tklsoft.gui.controls.InvalidRule; -import de.tklsoft.gui.controls.ModifyableComponent; import de.tklsoft.gui.controls.StatusHolder.STATUSFLAG; import de.tklsoft.gui.controls.TKLComboBox; import de.tklsoft.gui.controls.TKLTextField; - import info.clearthought.layout.TableLayout; +import javax.swing.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.File; + public class DownloadlinkPanel extends JPanel implements LanguageListener { private JLabel lblLink = new JLabel(); @@ -38,7 +31,7 @@ public DownloadlinkPanel() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[][] sizes = + double[][] sizes = { {5, p, 5, f, 5, p, 5}, {5, p} @@ -56,54 +49,50 @@ public void keyPressed(KeyEvent ke) }; txtDownloadLink.addKeyListener(keyListener); - InvalidRule downloadloadlinkRule = new InvalidRule() - { - public boolean isInvalid(ModifyableComponent component) - { - String text = ((TKLTextField) component).getText().toLowerCase(); - - if(text.length() == 0) - { - return false; - } + InvalidRule downloadloadlinkRule = component -> { + String text = ((TKLTextField) component).getText().replace("%7C", "|").toLowerCase(); - if(!text.startsWith("ajfsp://")) - { - return true; - } + if(text.length() == 0) + { + return false; + } - text = text.substring("ajfsp://".length()); - if(!text.startsWith("file") && !text.startsWith("server")) - { - return true; - } + if(!text.startsWith("ajfsp://")) + { + return true; + } - int count; + text = text.substring("ajfsp://".length()); + if(!text.startsWith("file") && !text.startsWith("server")) + { + return true; + } - if(text.startsWith("file")) - { - count = 3; - } - else - { - count = 2; - } + int count; - for(int i = 0; i < text.length(); i++) - { - if(text.charAt(i) == '|') - { - count--; - } - } + if(text.startsWith("file")) + { + count = 3; + } + else + { + count = 2; + } - if(count > 0) + for(int i = 0; i < text.length(); i++) + { + if(text.charAt(i) == '|') { - return true; + count--; } + } - return false; + if(count > 0) + { + return true; } + + return false; }; txtDownloadLink.ignoreStatus(STATUSFLAG.MODIFIED, true); @@ -111,27 +100,18 @@ public boolean isInvalid(ModifyableComponent component) txtDownloadLink.ignoreInvalidRules(false); cmbTargetDir.ignoreStatus(STATUSFLAG.MODIFIED, true); - InvalidRule targetDirRule = new InvalidRule() - { - public boolean isInvalid(ModifyableComponent component) - { - Object obj = ((TKLComboBox) component).getSelectedItem(); - - if(obj == null) - { - return false; - } - - String subdir = (String) obj; - - if(subdir.indexOf(File.separator) != -1 || subdir.indexOf(ApplejuiceFassade.separator) != -1 || - subdir.indexOf("..") != -1 || subdir.indexOf(":") != -1) - { - return true; - } + InvalidRule targetDirRule = component -> { + Object obj = ((TKLComboBox) component).getSelectedItem(); + if(obj == null) + { return false; } + + String subdir = (String) obj; + + return subdir.contains(File.separator) || subdir.indexOf(ApplejuiceFassade.separator) != -1 || + subdir.contains("..") || subdir.contains(":"); }; cmbTargetDir.addInvalidRule(targetDirRule); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/RegisterI.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterI.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/RegisterI.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterI.java index da875745..78c21aae 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/RegisterI.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterI.java @@ -7,7 +7,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ @@ -15,4 +15,4 @@ public interface RegisterI { public void registerSelected(); public void lostSelection(); -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/RegisterPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterPanel.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/RegisterPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterPanel.java index 4f4332ae..1a46eb55 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/RegisterPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/RegisterPanel.java @@ -4,16 +4,6 @@ package de.applejuicenet.client.gui; -import java.awt.event.KeyEvent; - -import java.util.Set; - -import javax.swing.DefaultSingleSelectionModel; -import javax.swing.ImageIcon; -import javax.swing.JTabbedPane; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.controller.LanguageSelector; @@ -28,6 +18,12 @@ import de.applejuicenet.client.gui.start.StartController; import de.applejuicenet.client.gui.upload.UploadController; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.event.KeyEvent; +import java.util.Set; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/RegisterPanel.java,v 1.65 2009/01/14 17:05:33 maj0r Exp $ @@ -36,7 +32,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class RegisterPanel extends JTabbedPane implements LanguageListener @@ -48,12 +44,12 @@ public class RegisterPanel extends JTabbedPane implements LanguageListener private ServerPanel serverPanel; private ShareController shareController; private AppleJuiceDialog parent; - private Logger logger; + private Logger logger; public RegisterPanel(AppleJuiceDialog parent) { super(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); try { this.parent = parent; diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/UpdateInformationDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/UpdateInformationDialog.java new file mode 100644 index 00000000..93aaeacb --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/UpdateInformationDialog.java @@ -0,0 +1,123 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.shared.DesktopTools; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URI; + +/** + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class UpdateInformationDialog extends JDialog { + private String aktuellsteVersion; + private final JButton schliessen = new JButton(); + private String releaseLink = ""; + private final Logger logger; + + public UpdateInformationDialog(JFrame parentFrame, String aktuellsteVersion, String releaseLink) { + super(parentFrame, true); + logger = LoggerFactory.getLogger(getClass()); + try { + this.aktuellsteVersion = aktuellsteVersion; + this.releaseLink = releaseLink; + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + LanguageSelector ls = LanguageSelector.getInstance(); + + schliessen.addActionListener(ae -> UpdateInformationDialog.this.dispose()); + + String titel = ls.getFirstAttrbuteByTagName("javagui.startup.newversiontitel"); + String nachricht = ls.getFirstAttrbuteByTagName("javagui.startup.newversionnachricht"); + + nachricht = nachricht.replaceFirst("%s", aktuellsteVersion); + schliessen.setText(ls.getFirstAttrbuteByTagName("javagui.options.plugins.schliessen")); + setTitle(titel); + JPanel panel1 = new JPanel(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = 3; + constraints.insets.left = 5; + constraints.insets.top = 5; + constraints.insets.right = 5; + panel1.add(new JLabel(nachricht), constraints); + constraints.insets.right = 0; + constraints.gridwidth = 1; + constraints.gridy = 1; + JLabel label1 = new JLabel(); + + label1.setText(ls.getFirstAttrbuteByTagName("javagui.startup.newversion") + ": "); + JLabel linkWin = new JLabel("<html><font><u>" + releaseLink + "</u></font></html>"); + + panel1.add(label1, constraints); + constraints.gridx = 1; + panel1.add(linkWin, constraints); + constraints.gridx = 2; + constraints.weightx = 1; + constraints.insets.right = 5; + panel1.add(new JLabel(), constraints); + constraints.insets.right = 0; + constraints.weightx = 0; + constraints.gridx = 0; + constraints.gridy = 2; + constraints.insets.bottom = 5; + + linkWin.setForeground(Color.blue); + linkWin.addMouseListener(new MouseAdapter() { + public void mouseExited(MouseEvent e) { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + + public void mouseEntered(MouseEvent e) { + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public void mouseClicked(MouseEvent e) { + executeLink(releaseLink); + } + }); + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(panel1, BorderLayout.CENTER); + JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + + southPanel.add(schliessen); + getContentPane().add(southPanel, BorderLayout.SOUTH); + pack(); + Dimension appDimension = getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + } + + private void executeLink(String link) { + try { + DesktopTools.browse(new URI(link)); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/VersionChecker.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/VersionChecker.java new file mode 100644 index 00000000..f1ec8ec2 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/VersionChecker.java @@ -0,0 +1,80 @@ +package de.applejuicenet.client.gui; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class VersionChecker { + + private static final Logger logger = LoggerFactory.getLogger(VersionChecker.class); + + public static void check() { + Thread versionWorker = new Thread("VersionChecker") { + public void run() { + logger.debug("VersionWorkerThread gestartet."); + + try { + String updateServer = OptionsManagerImpl.getInstance().getUpdateServerURL(); + logger.debug(String.format("GET %s", updateServer)); + String downloadData = WebsiteContentLoader.getWebsiteContent(updateServer); + + if (downloadData.length() > 0) { + JsonObject jsonObject = JsonParser.parseString(downloadData).getAsJsonObject(); + String aktuellsteVersion = jsonObject.get("tag_name").getAsString(); + + logger.info("aktuelle Version " + AppleJuiceDialog.getVersion() + " | letzte veröffentlichte Version: " + aktuellsteVersion); + + if (AppleJuiceDialog.getVersion() != null && compareVersion(aktuellsteVersion, AppleJuiceDialog.getVersion()) == 1) { + String releaseLink = jsonObject.get("html_url").getAsString(); + SwingUtilities.invokeLater(() -> { + UpdateInformationDialog updateInformationDialog = new UpdateInformationDialog(AppleJuiceDialog.getApp(), aktuellsteVersion, releaseLink); + updateInformationDialog.setVisible(true); + }); + } + + } + } catch (Exception e) { + logger.info("Aktualisierungsinformationen konnten nicht geladen werden.", e); + } + + logger.debug("VersionWorkerThread beendet."); + } + }; + + versionWorker.start(); + } + + public static int compareVersion(String A, String B) { + List<String> strList1 = Arrays.stream(A.split("\\.")) + .map(s -> s.replaceAll("^0+(?!$)", "")) + .collect(Collectors.toList()); + List<String> strList2 = Arrays.stream(B.split("\\.")) + .map(s -> s.replaceAll("^0+(?!$)", "")) + .collect(Collectors.toList()); + int len1 = strList1.size(); + int len2 = strList2.size(); + int i = 0; + while (i < len1 && i < len2) { + if (strList1.get(i).length() > strList2.get(i).length()) return 1; + if (strList1.get(i).length() < strList2.get(i).length()) return -1; + int result = Long.valueOf(strList1.get(i)).compareTo(Long.valueOf(strList2.get(i))); + if (result != 0) return result; + i++; + } + while (i < len1) { + if (!strList1.get(i++).equals("0")) return 1; + } + while (i < len2) { + if (!strList2.get(i++).equals("0")) return -1; + } + return 0; + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/about/AboutDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/about/AboutDialog.java new file mode 100644 index 00000000..6cf95bd0 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/about/AboutDialog.java @@ -0,0 +1,302 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.about; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.shared.IconManager; +import de.tklsoft.gui.controls.TKLLabel; +import de.tklsoft.gui.controls.TKLPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.CropImageFilter; +import java.awt.image.FilteredImageSource; +import java.awt.image.ImageFilter; +import java.util.ArrayList; +import java.util.List; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/about/AboutDialog.java,v 1.14 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class AboutDialog extends JDialog { + private Logger logger; + private WorkerThread worker = null; + private BackPanel backPanel = new BackPanel(); + + public AboutDialog(Frame parent, boolean modal) { + super(parent, modal); + logger = LoggerFactory.getLogger(getClass()); + try { + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent evt) { + if (worker != null) { + worker.interrupt(); + worker = null; + } + } + }); + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public Dimension getPreferredSize() { + if (backPanel != null) { + return backPanel.getPreferredSize(); + } else { + return super.getPreferredSize(); + } + } + + private void init() { + setResizable(false); + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + setTitle(languageSelector.getFirstAttrbuteByTagName("mainform.aboutbtn.caption")); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(backPanel, BorderLayout.CENTER); + pack(); + } + + class BackPanel extends TKLPanel { + private Image backgroundImage; + private Image flagge; + private TKLLabel version = new TKLLabel(); + private List<CreditsEntry> credits = new ArrayList<CreditsEntry>(); + private Logger logger; + + public BackPanel() { + super(); + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + worker = new WorkerThread(backgroundImage, this, credits); + worker.start(); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent me) { + if (worker != null) { + worker.toggleRunStatus(); + } + } + }); + } + + private void init() { + credits.add(new CreditsEntry(true, "Programmierung")); + credits.add(new CreditsEntry(false, "Maj0r")); + credits.add(new CreditsEntry(false, "(tkrall@tkl-soft.de)")); + credits.add(new CreditsEntry(false, "loevenwong")); + credits.add(new CreditsEntry(false, "(tloevenich@tkl-soft.de)")); + credits.add(new CreditsEntry(false, "red171")); + credits.add(new CreditsEntry(false, "(red171@applejuicenet.cc)")); + credits.add(new CreditsEntry(true, "Besonderen Dank an")); + credits.add(new CreditsEntry(false, "muhviehstarr")); + credits.add(new CreditsEntry(true, "Banner & Bilder")); + credits.add(new CreditsEntry(false, "saschxd")); + credits.add(new CreditsEntry(true, "Übersetzung")); + credits.add(new CreditsEntry(false, "BlueTiger")); + credits.add(new CreditsEntry(false, "nurseppel")); + credits.add(new CreditsEntry(true, "Kontakt")); + credits.add(new CreditsEntry(false, "applejuicenet.cc")); + + backgroundImage = IconManager.getInstance().getIcon("applejuiceinfobanner").getImage(); + flagge = IconManager.getInstance().getIcon("deutsch").getImage(); + MediaTracker mt = new MediaTracker(this); + + mt.addImage(backgroundImage, 0); + try { + mt.waitForAll(); + } catch (InterruptedException x) { + + //kein Bild da, dann kack drauf ;-) + } + + version.setText("Version " + AppleJuiceDialog.getVersion()); + Font font = version.getFont(); + + font = new Font(font.getName(), Font.PLAIN, font.getSize()); + version.setFont(font); + setLayout(new BorderLayout()); + TKLPanel panel1 = new TKLPanel(new FlowLayout(FlowLayout.RIGHT)); + + panel1.add(version); + panel1.setOpaque(false); + add(panel1, BorderLayout.SOUTH); + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + + Color saved = g.getColor(); + + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(saved); + + if (backgroundImage != null) { + int imageX = (getWidth() - backgroundImage.getWidth(this)) / 2; + int imageY = (getHeight() - backgroundImage.getHeight(this)) / 2; + + g.drawImage(backgroundImage, imageX, imageY, this); + if (flagge != null) { + g.drawImage(flagge, backgroundImage.getWidth(this) - flagge.getWidth(this), 0, this); + } + } + } + + public Dimension getPreferredSize() { + if (backgroundImage != null) { + int width = backgroundImage.getWidth(this) + 3; + int height = backgroundImage.getHeight(this) + 3; + + return new Dimension(width, height); + } else { + return super.getPreferredSize(); + } + } + } + + + class CreditsEntry { + private boolean ueberschrift; + private String ausgabetext; + + public CreditsEntry(boolean ueberschrift, String ausgabetext) { + this.ueberschrift = ueberschrift; + this.ausgabetext = ausgabetext; + } + + public boolean isUeberschrift() { + return ueberschrift; + } + + public void setUeberschrift(boolean ueberschrift) { + this.ueberschrift = ueberschrift; + } + + public String getAusgabetext() { + return ausgabetext; + } + + public void setAusgabetext(String ausgabetext) { + this.ausgabetext = ausgabetext; + } + } + + + private class WorkerThread extends Thread { + private Image backgroundImage; + private BackPanel backPanel; + private List<CreditsEntry> credits; + private boolean run = true; + private Logger logger; + + public WorkerThread(Image backgroundImage, BackPanel backPanel, List<CreditsEntry> credits) { + logger = LoggerFactory.getLogger(getClass()); + this.backgroundImage = backgroundImage; + this.backPanel = backPanel; + this.credits = credits; + } + + public void toggleRunStatus() { + run = !run; + } + + public void run() { + logger.debug("About-Workerthread gestartet. " + this); + + Image new_img; + Image toDraw; + ImageFilter filter = new ImageFilter(); + int creditsHoehe = 60; + int creditsBreite = 135; + int imageX = backgroundImage.getWidth(backPanel) / 2 + 20; + int imageY = backgroundImage.getHeight(backPanel) / 2 - 15; + + filter = new CropImageFilter(imageX, imageY, creditsBreite, creditsHoehe); + new_img = createImage(new FilteredImageSource(backgroundImage.getSource(), filter)); + filter = new CropImageFilter(0, 0, creditsBreite, creditsHoehe); + int y = creditsHoehe; + + try { + sleep(1000); + Graphics g = backPanel.getGraphics(); + + g.setColor(Color.BLACK); + Graphics toDrawGraphics; + FontMetrics fm; + int strWidth; + Font fontBold = new Font("Arial", Font.BOLD, 12); + Font fontPlain = new Font("Arial", Font.PLAIN, 12); + boolean draw = false; + + while (!isInterrupted()) { + if (run) { + toDraw = createImage(creditsBreite, creditsHoehe); + toDrawGraphics = toDraw.getGraphics(); + toDrawGraphics.drawImage(new_img, 0, 0, backPanel); + y--; + int abstand = -15; + + for (CreditsEntry curEntry : credits) { + if (curEntry.isUeberschrift()) { + abstand += 20; + toDrawGraphics.setFont(fontBold); + toDrawGraphics.setColor(Color.BLUE); + } else { + abstand += 15; + toDrawGraphics.setFont(fontPlain); + toDrawGraphics.setColor(Color.BLACK); + } + + fm = toDrawGraphics.getFontMetrics(); + strWidth = fm.stringWidth(curEntry.getAusgabetext()); + toDrawGraphics.drawString(curEntry.getAusgabetext(), (creditsBreite - strWidth) / 2, y + abstand); + } + + if (draw) { + g.drawImage(toDraw, imageX - 1, imageY - 11, backPanel); + } else { + draw = true; + } + + if (y == -5 - credits.size() * 15) { + y = creditsHoehe; + } + } + + try { + sleep(100); + } catch (InterruptedException iE) { + interrupt(); + } + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + logger.debug("About-Workerthread beendet. " + this); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiController.java new file mode 100644 index 00000000..ca615288 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiController.java @@ -0,0 +1,62 @@ +package de.applejuicenet.client.gui.components; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.gui.components.util.Value; +import de.applejuicenet.client.gui.listener.LanguageListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiController.java,v 1.8 2005/01/19 16:22:19 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ + +public abstract class GuiController implements LanguageListener, DataUpdateListener { + protected final Logger logger; + + public GuiController() { + logger = LoggerFactory.getLogger(getClass()); + } + + public abstract void fireAction(int actionId, Object source); + + public abstract JComponent getComponent(); + + public abstract void componentSelected(); + + public abstract void componentLostSelection(); + + public abstract Value[] getCustomizedValues(); + + public final String getName() { + return getClass().getName(); + } + + public final void fireLanguageChanged() { + try { + languageChanged(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public final void fireContentChanged(DATALISTENER_TYPE type, Object content) { + try { + contentChanged(type, content); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + protected abstract void languageChanged(); + + protected abstract void contentChanged(DATALISTENER_TYPE type, Object content); +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiControllerActionListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiControllerActionListener.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/GuiControllerActionListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiControllerActionListener.java index b9ed104e..fb9f875f 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/GuiControllerActionListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/GuiControllerActionListener.java @@ -10,7 +10,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/TklPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/TklPanel.java similarity index 85% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/TklPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/TklPanel.java index 6b08b8b9..39ef23bf 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/TklPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/TklPanel.java @@ -1,10 +1,10 @@ package de.applejuicenet.client.gui.components; -import javax.swing.JPanel; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.gui.RegisterI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/TklPanel.java,v 1.3 2004/11/22 16:25:26 maj0r Exp $ @@ -13,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ @@ -26,7 +26,7 @@ public TklPanel(GuiController guiController){ if (null == guiController){ throw new RuntimeException("Ungueltiger GuiController"); } - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); this.guiController = guiController; } diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java similarity index 85% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java index 29fab48c..4e90fd8f 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java @@ -1,11 +1,6 @@ package de.applejuicenet.client.gui.components.dragndrop; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDragEvent; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceEvent; -import java.awt.dnd.DragSourceListener; +import java.awt.dnd.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndSourceAdapter.java,v 1.1 2004/10/29 11:58:43 maj0r Exp $ @@ -14,7 +9,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java index 5230576e..dd6d83b0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/dragndrop/DndTargetAdapter.java @@ -1,6 +1,6 @@ package de.applejuicenet.client.gui.components.dragndrop; -import java.awt.Point; +import java.awt.*; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; @@ -13,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/listener/KeyStates.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/listener/KeyStates.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/listener/KeyStates.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/listener/KeyStates.java diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java index f405b087..f12abc86 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java @@ -1,10 +1,7 @@ package de.applejuicenet.client.gui.components.table; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import javax.swing.Icon; -import javax.swing.UIManager; +import javax.swing.*; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BevelArrowIcon.java,v 1.1 2004/10/29 11:58:43 maj0r Exp $ @@ -13,7 +10,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BlankIcon.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BlankIcon.java similarity index 88% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/BlankIcon.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BlankIcon.java index 4acf50f4..b7b9a598 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BlankIcon.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/BlankIcon.java @@ -1,9 +1,7 @@ package de.applejuicenet.client.gui.components.table; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import javax.swing.Icon; +import javax.swing.*; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/table/BlankIcon.java,v 1.1 2004/10/29 11:58:43 maj0r Exp $ @@ -12,7 +10,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/HeaderListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/HeaderListener.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/HeaderListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/HeaderListener.java index 358187a8..1cfbc785 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/HeaderListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/HeaderListener.java @@ -4,11 +4,10 @@ package de.applejuicenet.client.gui.components.table; +import javax.swing.table.JTableHeader; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.table.JTableHeader; - /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/table/HeaderListener.java,v 1.5 2009/02/12 13:03:34 maj0r Exp $ * @@ -16,7 +15,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class HeaderListener extends MouseAdapter diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java similarity index 87% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java index 2568afaa..d38065c0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java @@ -4,13 +4,9 @@ package de.applejuicenet.client.gui.components.table; -import java.awt.Component; -import java.awt.Font; -import java.awt.Insets; - -import javax.swing.JButton; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.table.TableCellRenderer; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/table/NormalHeaderRenderer.java,v 1.3 2009/01/21 14:45:10 maj0r Exp $ @@ -19,7 +15,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class NormalHeaderRenderer extends JButton implements TableCellRenderer diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java index 5f4edaf3..10ba5f35 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java @@ -4,13 +4,9 @@ package de.applejuicenet.client.gui.components.table; -import java.awt.Component; -import java.awt.Font; -import java.awt.Insets; - -import javax.swing.JButton; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.table.TableCellRenderer; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortButtonRenderer.java,v 1.4 2009/02/12 13:03:34 maj0r Exp $ @@ -19,7 +15,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class SortButtonRenderer extends JButton implements TableCellRenderer diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortableTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortableTableModel.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortableTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortableTableModel.java index 793d150d..6cebc6a9 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/SortableTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/SortableTableModel.java @@ -13,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public interface SortableTableModel<T> diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/TableSorter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/TableSorter.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/table/TableSorter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/TableSorter.java index f9532dc2..b25cf548 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/table/TableSorter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/table/TableSorter.java @@ -14,7 +14,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class TableSorter<T> diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java index a4b21229..19e08fa1 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/ApplejuiceNode.java @@ -9,7 +9,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/tree/WaitNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/WaitNode.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/tree/WaitNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/WaitNode.java index 64d8c154..2ac36d78 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/tree/WaitNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/tree/WaitNode.java @@ -4,13 +4,13 @@ package de.applejuicenet.client.gui.components.tree; -import javax.swing.Icon; -import javax.swing.tree.DefaultMutableTreeNode; - import de.applejuicenet.client.gui.components.treetable.Node; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/tree/WaitNode.java,v 1.5 2009/01/12 09:19:20 maj0r Exp $ * @@ -18,7 +18,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class WaitNode extends DefaultMutableTreeNode implements Node diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java index 977d4a7f..1df939f4 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java @@ -1,11 +1,10 @@ package de.applejuicenet.client.gui.components.treetable; -import java.util.EventObject; - -import javax.swing.CellEditor; +import javax.swing.*; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.EventListenerList; +import java.util.EventObject; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractCellEditor.java,v 1.1 2004/10/29 11:58:43 maj0r Exp $ @@ -14,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java index 401b4056..b2c7bbe2 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/AbstractTreeTableModel.java @@ -16,7 +16,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public abstract class AbstractTreeTableModel implements TreeTableModel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java index 3a632270..4eba434a 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultIconNodeRenderer.java @@ -1,12 +1,10 @@ package de.applejuicenet.client.gui.components.treetable; -import java.awt.Component; +import de.applejuicenet.client.gui.components.util.IconGetter; -import javax.swing.Icon; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; - -import de.applejuicenet.client.gui.components.util.IconGetter; +import java.awt.*; public class DefaultIconNodeRenderer extends DefaultTreeCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java index c1dee5d1..be986977 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/DefaultTreeTableCellRenderer.java @@ -1,15 +1,11 @@ package de.applejuicenet.client.gui.components.treetable; -import java.awt.Component; -import java.awt.Graphics; - -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.table.TableCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeModel; +import java.awt.*; public class DefaultTreeTableCellRenderer extends JTree implements diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/JTreeTable.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/JTreeTable.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/JTreeTable.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/JTreeTable.java index c9aaaf8e..06b4cc44 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/JTreeTable.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/JTreeTable.java @@ -1,18 +1,14 @@ package de.applejuicenet.client.gui.components.treetable; -import java.util.EventObject; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.MouseEvent; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.ListSelectionModel; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.TableCellEditor; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreePath; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.EventObject; /** @@ -22,7 +18,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/Node.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/Node.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/Node.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/Node.java index 00f77367..1173dd8d 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/Node.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/Node.java @@ -4,7 +4,7 @@ package de.applejuicenet.client.gui.components.treetable; -import javax.swing.Icon; +import javax.swing.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/Node.java,v 1.2 2009/01/12 07:45:46 maj0r Exp $ @@ -13,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface Node diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java index 4cfadd08..e1e64616 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModel.java @@ -13,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface TreeTableModel extends TreeModel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java index 24bdb97a..952051ba 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/treetable/TreeTableModelAdapter.java @@ -18,8 +18,8 @@ * it only in accordance with the terms of the license agreement * you entered into with Sun. */ -import javax.swing.JTree; -import javax.swing.SwingUtilities; + +import javax.swing.*; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.event.TreeModelEvent; @@ -34,7 +34,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class TreeTableModelAdapter extends AbstractTableModel @@ -143,13 +143,7 @@ public void setValueAt(Object value, int row, int column) protected void delayedFireTableDataChanged() { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - fireTableDataChanged(); - } - }); + SwingUtilities.invokeLater(this::fireTableDataChanged); } public void expandOrCollapseRow(int row) diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/util/IconGetter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/IconGetter.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/util/IconGetter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/IconGetter.java index 29400696..425828e8 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/util/IconGetter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/IconGetter.java @@ -1,12 +1,12 @@ package de.applejuicenet.client.gui.components.util; -import javax.swing.ImageIcon; - import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.fassade.entity.Upload; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/components/util/IconGetter.java,v 1.4 2005/01/19 11:03:56 maj0r Exp $ * @@ -14,7 +14,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/util/MergeSort.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/MergeSort.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/util/MergeSort.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/MergeSort.java index 3555d7fb..11f3130c 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/components/util/MergeSort.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/MergeSort.java @@ -7,7 +7,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/components/util/Value.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/Value.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/components/util/Value.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/components/util/Value.java diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/connect/ConnectFrame.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/ConnectFrame.java similarity index 59% rename from AJClientGUI/src/de/applejuicenet/client/gui/connect/ConnectFrame.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/ConnectFrame.java index 6930ee2f..fa3bf0e4 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/connect/ConnectFrame.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/ConnectFrame.java @@ -1,14 +1,12 @@ package de.applejuicenet.client.gui.connect; -import java.awt.Dimension; -import java.awt.Toolkit; -import javax.swing.JFrame; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/connect/ConnectFrame.java,v 1.3 2005/01/18 17:35:29 maj0r Exp $ @@ -17,25 +15,21 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> - * + * @author Maj0r <aj@tkl-soft.de> */ public class ConnectFrame - extends JFrame { + extends JFrame { - private Logger logger; + private Logger logger; public ConnectFrame() { super(); - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); try { init(); - } - catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); } } @@ -44,11 +38,11 @@ private void init() { IconManager im = IconManager.getInstance(); setIconImage(im.getIcon("applejuice").getImage()); Dimension screenSize = Toolkit.getDefaultToolkit(). - getScreenSize(); + getScreenSize(); Dimension appDimension = getSize(); - setLocation( (screenSize.width - - appDimension.width) / 2, - (screenSize.height - - appDimension.height) / 2); + setLocation((screenSize.width - + appDimension.width) / 2, + (screenSize.height - + appDimension.height) / 2); } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java index 0e1ff197..cfc1164b 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java @@ -4,34 +4,6 @@ package de.applejuicenet.client.gui.connect; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.ArrayList; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; @@ -39,6 +11,15 @@ import de.applejuicenet.client.gui.controller.OptionsManagerImpl; import de.applejuicenet.client.gui.options.ODConnectionPanel; import de.applejuicenet.client.shared.ConnectionSettings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/connect/QuickConnectionSettingsDialog.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ @@ -47,7 +28,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class QuickConnectionSettingsDialog extends JDialog @@ -60,14 +41,14 @@ public class QuickConnectionSettingsDialog extends JDialog private JButton abbrechen = new JButton("Abbrechen"); private JCheckBox cmbNieWiederZeigen = new JCheckBox(); private JComboBox connectionListe = new JComboBox(); - private Logger logger; + private Logger logger; private boolean dirty = false; private int result = 0; public QuickConnectionSettingsDialog(Frame parent) { super(parent, true); - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); try { init(); diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LanguageSelector.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LanguageSelector.java new file mode 100644 index 00000000..cc169a56 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LanguageSelector.java @@ -0,0 +1,156 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.controller; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.gui.plugins.PluginConnector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.CharArrayWriter; +import java.io.File; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/LanguageSelector.java,v 1.30 2009/01/12 09:02:56 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI f\uFFFDr den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class LanguageSelector extends XMLValueHolder { + private static LanguageSelector instance = null; + private static final Logger logger = LoggerFactory.getLogger(LanguageSelector.class); + private Set<LanguageListener> languageListener = new HashSet<LanguageListener>(); + private CharArrayWriter contents = new CharArrayWriter(); + private StringBuffer key = new StringBuffer(); + @SuppressWarnings("unchecked") + private Set pluginsToWatch = null; + + private LanguageSelector(String path) { + super(); + try { + parseProperties(new File(path)); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public static LanguageSelector getInstance() { + if (instance == null) { + String path = System.getProperty("user.dir") + File.separator + "language" + File.separator; + OptionsManager om = OptionsManagerImpl.getInstance(); + String datei = om.getSprache(); + + if (null == datei || datei.length() == 0) { + datei = "deutsch"; + } + + path += datei + ".properties"; + + //zZ werden die Header der TableModel nicht aktualisiert, deshalb hier schon + return new LanguageSelector(path); + } + + return instance; + } + + @SuppressWarnings("unchecked") + public void addPluginsToWatch(Set plugins) { + pluginsToWatch = plugins; + } + + private void init(File languageFile) { + try { + if (key.length() > 0) { + key.delete(0, key.length() - 1); + } + + parseProperties(languageFile); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static LanguageSelector getInstance(String path) { + if (instance == null) { + instance = new LanguageSelector(path); + } else { + File sprachDatei = new File(path); + + if (!sprachDatei.isFile()) { + logger.info("Die in der ajgui.properties hinterlegte Sprachdatei wurde nicht gefunden."); + AppleJuiceDialog.closeWithErrormessage("Die in der ajgui.properties hinterlegte Sprachdatei wurde nicht gefunden. appleJuice wird beendet.", false); + } + + instance.init(sprachDatei); + instance.informLanguageListener(); + } + + return instance; + } + + public void fireLanguageChanged() { + informLanguageListener(); + } + + public void addLanguageListener(LanguageListener listener) { + if (!(languageListener.contains(listener))) { + languageListener.add(listener); + } + } + + public void removeLanguageListener(LanguageListener listener) { + if (languageListener.contains(listener)) { + languageListener.remove(listener); + } + } + + public String getFirstAttrbuteByTagName(String[] pathToValue) { + StringBuffer path = new StringBuffer(); + + path.append("."); + path.append("root"); + for (int i = 0; i < pathToValue.length; i++) { + path.append("."); + path.append(pathToValue[i]); + } + + return getFirstAttrbuteByTagName(path.toString()); + } + + public String getFirstAttrbuteByTagName(String identifier) { + if (values.containsKey(identifier)) { + return values.getProperty(identifier); + } else { + return ""; + } + } + + @SuppressWarnings("unchecked") + private void informLanguageListener() { + Iterator it = languageListener.iterator(); + + while (it.hasNext()) { + ((LanguageListener) it.next()).fireLanguageChanged(); + } + + if (pluginsToWatch != null) { + it = pluginsToWatch.iterator(); + String language = getFirstAttrbuteByTagName("Languageinfo.name").toLowerCase(); + + while (it.hasNext()) { + ((PluginConnector) it.next()).setLanguage(language); + } + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LinkListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LinkListener.java new file mode 100644 index 00000000..44bf9413 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/LinkListener.java @@ -0,0 +1,214 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.controller; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.listener.CoreStatusListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.HashSet; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/LinkListener.java,v 1.15 2009/01/12 14:53:08 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class LinkListener extends Thread implements CoreStatusListener { + private static Logger logger; + private final int PORT; + private ServerSocket listen; + private ApplejuiceFassade applejuiceFassade = null; + private HashSet<Link> linkCache = null; + + public LinkListener() throws IOException { + PORT = OptionsManagerImpl.getInstance().getLinkListenerPort(); + logger = LoggerFactory.getLogger(getClass()); + try { + listen = new ServerSocket(PORT); + setName("LinkListenerThread"); + setDaemon(true); + start(); + ApplejuiceFassade.addCoreStatusListener(this); + } catch (IOException ioE) { + throw ioE; + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void run() { + try { + while (true) { + Socket client = listen.accept(); + + if (client.getInetAddress().getHostAddress().compareTo(InetAddress.getByName("localhost").getHostAddress()) == 0) { + try { + DataInputStream in = new DataInputStream(client.getInputStream()); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line = reader.readLine(); + + if (line.contains("-link=")) { + String link = getLinkFromReadLine(line); + link = link.replaceAll("%7C", "|"); + + if (link != null) { + Link aLink = new Link(link, ""); + + if (applejuiceFassade != null) { + processLink(aLink); + } else { + if (linkCache == null) { + linkCache = new HashSet<Link>(); + } + + linkCache.add(aLink); + } + } + } + + //todo + /* else if (line.indexOf("-command=") != -1) { + String command = line.substring(line.indexOf( + "-command=") + 9).toLowerCase(); + if (command.startsWith("getajstats")) { + PrintStream out = new PrintStream(client. + getOutputStream()); + out.println(AppleJuiceClient.getAjFassade(). + getStats()); + } + else if (command.startsWith("getajinfo")) { + PrintStream out = new PrintStream(client. + getOutputStream()); + out.println(ApplejuiceFassade.getInstance().getVersionInformation()); + } + }*/ + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + client.close(); + return; + } + } else { + DataInputStream in = new DataInputStream(client.getInputStream()); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + + reader.readLine(); + PrintStream out = new PrintStream(client.getOutputStream()); + + out.println("Fuck you, little bastard !!!"); + } + + client.close(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private boolean isValidAjLink(String line) { + try { + if (line == null) { + return false; + } + + String password = OptionsManagerImpl.getInstance().getRemoteSettings().getOldPassword(); + + if (line.substring(0, password.length()).compareTo(password) != 0) { + return false; + } + + if (line.indexOf("ajfsp://") == -1) { + return false; + } + } catch (Exception e) { + return false; + } + + return true; + } + + private String getLinkFromReadLine(String line) { + if (!isValidAjLink(line)) { + return null; + } else { + return line.substring(line.indexOf("ajfsp://")); + } + } + + public void fireStatusChanged(STATUS newStatus) { + if (newStatus == STATUS.STARTED) { + ApplejuiceFassade.removeCoreStatusListener(this); + applejuiceFassade = AppleJuiceClient.getAjFassade(); + processCache(); + } + } + + private void processCache() { + if (linkCache == null) { + return; + } + + for (Link curLink : linkCache) { + processLink(curLink); + } + + linkCache.clear(); + linkCache = null; + } + + public void processLink(String link, String directory) { + link = link.replaceAll("%7C", "|"); + link = link.replaceAll("%20", "."); + + Link aLink = new Link(link, ""); + + if (applejuiceFassade == null) { + if (linkCache == null) { + linkCache = new HashSet<Link>(); + } + + linkCache.add(aLink); + } else { + processLink(aLink); + } + } + + private void processLink(Link aLink) { + try { + applejuiceFassade.processLink(aLink.getLink(), aLink.getDirectory()); + } catch (IllegalArgumentException e) { + // an dieser Stelle unterbuttern + logger.warn(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private class Link { + private final String link; + private final String directory; + + public Link(String link, String directory) { + this.link = link; + this.directory = directory; + } + + public String getDirectory() { + return directory; + } + + public String getLink() { + return link; + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManager.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManager.java similarity index 85% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManager.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManager.java index 9f8aa159..59b8e0bb 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManager.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManager.java @@ -4,8 +4,8 @@ package de.applejuicenet.client.gui.controller; -import org.apache.log4j.Level; +import ch.qos.logback.classic.Level; import de.applejuicenet.client.fassade.listener.DataUpdateListener; import de.applejuicenet.client.fassade.shared.AJSettings; import de.applejuicenet.client.shared.ConnectionSettings; @@ -20,7 +20,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface OptionsManager @@ -31,9 +31,9 @@ public interface OptionsManager String getSprache(); - int getVersionsinfoModus(); + boolean getUpdateInfo(); - void setVersionsinfoModus(int versionsinfoModus); + void setUpdateInfo(boolean UpdateInfo); boolean isErsterStart(); @@ -47,7 +47,7 @@ public interface OptionsManager Level getLogLevel(); - void setLogLevel(Level level); + void setLogLevel(String level); Settings getSettings(); @@ -65,6 +65,20 @@ public interface OptionsManager void setDefaultTheme(String themeShortName); + String getNewsURL(); + + String getServerListURL(); + + String getUpdateServerURL(); + + String getIconSetName(); + + String getSoundSetName(); + + void setIconSetName(String name); + + void setSoundSetName(String name); + boolean isThemesSupported(); void enableThemeSupport(boolean enable); @@ -79,10 +93,6 @@ public interface OptionsManager void setLinkListenerPort(int port); - String getStandardBrowser(); - - void setStandardBrowser(String browser); - void loadPluginsOnStartup(boolean loadPluginsOnStartup); boolean shouldLoadPluginsOnStartup(); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java similarity index 82% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java index b7b7d3df..fffe46fb 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java @@ -1,13 +1,11 @@ package de.applejuicenet.client.gui.controller; -import org.apache.log4j.Level; - +import ch.qos.logback.classic.Level; import de.applejuicenet.client.fassade.listener.DataUpdateListener; import de.applejuicenet.client.fassade.shared.AJSettings; import de.applejuicenet.client.shared.ConnectionSettings; import de.applejuicenet.client.shared.LookAFeel; import de.applejuicenet.client.shared.Settings; -import de.applejuicenet.client.shared.exception.InvalidPasswordException; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/OptionsManagerImpl.java,v 1.6 2005/01/18 17:35:28 maj0r Exp $ @@ -16,7 +14,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * **/ @@ -47,12 +45,12 @@ public String getSprache() { return propertiesManager.getSprache(); } - public int getVersionsinfoModus() { - return propertiesManager.getVersionsinfoModus(); + public boolean getUpdateInfo() { + return propertiesManager.getUpdateInfo(); } - public void setVersionsinfoModus(int versionsInfoModus) { - propertiesManager.setVersionsinfoModus(versionsInfoModus); + public void setUpdateInfo(boolean UpdateInfo) { + propertiesManager.setUpdateInfo(UpdateInfo); } public boolean isErsterStart() { @@ -79,7 +77,7 @@ public Level getLogLevel() { return propertiesManager.getLogLevel(); } - public void setLogLevel(Level level) { + public void setLogLevel(String level) { propertiesManager.setLogLevel(level); } @@ -95,7 +93,7 @@ public ConnectionSettings getRemoteSettings() { return propertiesManager.getRemoteSettings(); } - public void saveRemote(ConnectionSettings remote) throws InvalidPasswordException{ + public void saveRemote(ConnectionSettings remote) { propertiesManager.saveRemote(remote); } @@ -111,6 +109,34 @@ public String getDefaultTheme() { return propertiesManager.getDefaultTheme(); } + public String getNewsURL() { + return propertiesManager.getNewsURL(); + } + + public String getServerListURL() { + return propertiesManager.getServerListURL(); + } + + public String getUpdateServerURL() { + return propertiesManager.getUpdateServerURL(); + } + + public String getIconSetName() { + return propertiesManager.getIconSetName(); + } + + public String getSoundSetName() { + return propertiesManager.getSoundSetName(); + } + + public void setIconSetName(String name) { + propertiesManager.setIconSetName(name); + } + + public void setSoundSetName(String name) { + propertiesManager.setSoundSetName(name); + } + public void setDefaultTheme(String themeShortName) { propertiesManager.setDefaultTheme(themeShortName); } @@ -143,14 +169,6 @@ public void setLinkListenerPort(int port) { propertiesManager.setLinkListenerPort(port); } - public String getStandardBrowser() { - return propertiesManager.getStandardBrowser(); - } - - public void setStandardBrowser(String browser) { - propertiesManager.setStandardBrowser(browser); - } - public void setOpenProgram(String path) { propertiesManager.setOpenProgram(path); } diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManager.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManager.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManager.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManager.java index 63a28678..50037785 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManager.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManager.java @@ -4,8 +4,7 @@ package de.applejuicenet.client.gui.controller; -import java.awt.Dimension; -import java.awt.Point; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManager.java,v 1.12 2009/02/12 13:03:34 maj0r Exp $ @@ -14,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface PositionManager diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManagerImpl.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManagerImpl.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManagerImpl.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManagerImpl.java index 6e37319e..35adcc2d 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManagerImpl.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PositionManagerImpl.java @@ -4,8 +4,7 @@ package de.applejuicenet.client.gui.controller; -import java.awt.Dimension; -import java.awt.Point; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/controller/PositionManagerImpl.java,v 1.5 2009/02/12 13:03:34 maj0r Exp $ @@ -14,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * **/ public class PositionManagerImpl implements PositionManager diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertiesManager.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertiesManager.java new file mode 100644 index 00000000..af47e6a8 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertiesManager.java @@ -0,0 +1,1139 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.controller; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.fassade.shared.ProxySettings; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.download.table.DownloadSourcesTableModel; +import de.applejuicenet.client.gui.download.table.DownloadsTableModel; +import de.applejuicenet.client.gui.search.table.SearchTableModel; +import de.applejuicenet.client.gui.server.table.ServerTableModel; +import de.applejuicenet.client.gui.share.table.ShareTableModel; +import de.applejuicenet.client.gui.upload.table.UploadActiveTableModel; +import de.applejuicenet.client.gui.upload.table.UploadWaitingTableModel; +import de.applejuicenet.client.shared.ConnectionSettings; +import de.applejuicenet.client.shared.LookAFeel; +import de.applejuicenet.client.shared.Settings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import ch.qos.logback.classic.Level; + +import javax.swing.*; +import javax.swing.UIManager.LookAndFeelInfo; +import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/controller/PropertiesManager.java,v + * 1.49 2004/07/09 11:34:00 loevenwong Exp $ + * + * <p> + * Titel: AppleJuice Client-GUI + * </p> + * <p> + * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + * </p> + * <p> + * Copyright: General Public License + * </p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class PropertiesManager implements OptionsManager, PositionManager, ProxyManager { + private static PropertiesManager instance = null; + private static final String PROPERTIES_ERROR = "Fehler beim Zugriff auf die ajgui.properties. Die Datei wird neu erstellt."; + private static final String PROPERTIES_ERROR_MESSAGE = "ajgui.properties neu erstellt"; + private static Logger logger; + private static String path; + private static final int DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH = 90; + private static final int DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH = 90; + private static final int DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH = 80; + private static final int DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH = 80; + private static final int DEFAULT_SHARE_TABLE_COLUMN_WIDTH = 194; + private static final int DEFAULT_SERVER_TABLE_COLUMN_WIDTH = 175; + private static final int DEFAULT_SEARCH_TABLE_COLUMN_WIDTH = 103; + private final Set<DataUpdateListener> settingsListener = new HashSet<DataUpdateListener>(); + private final Set<DataUpdateListener> connectionSettingsListener = new HashSet<DataUpdateListener>(); + private Point mainXY; + private Dimension mainDimension; + private ProxySettings proxySettings; + private ConnectionSettings connectionSettings = null; + private int[] downloadWidths; + private int[] downloadSourcesWidths; + private int[] uploadWidths; + private int[] serverWidths; + private int[] shareWidths; + private boolean[] downloadVisibilities; + private boolean[] downloadSourcesVisibilities; + private boolean[] uploadVisibilities; + private boolean[] uploadWaitingVisibilities; + private int[] downloadIndex; + private int[] downloadSourcesIndex; + private int[] uploadIndex; + private int[] uploadWaitingIndex; + private Settings settings = null; + private boolean firstReadError = true; + private boolean legal = false; + private PropertyHandler propertyHandler; + private int[] uploadWaitingWidths; + private int[] downloadSort; + private int[] uploadSort; + private int[] searchSort; + private int[] downloadSourcesSort; + private int[] uploadWaitingSort; + private int[] serverSort; + + private final ArrayList<LookAFeel> lookAndFeels = new ArrayList<>(); + + private PropertiesManager(String propertiesPath) { + PropertiesManager.path = propertiesPath; + logger = LoggerFactory.getLogger(getClass()); + init(); + } + + static PropertiesManager getInstance() { + if (instance == null) { + instance = new PropertiesManager(AppleJuiceClient.getPropertiesPath()); + } + + return instance; + } + + private void saveFile() { + try { + propertyHandler.save(); + } catch (IllegalArgumentException e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(e.getMessage(), e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + } + } + + //ProxyManager-Interface + public ProxySettings getProxySettings() { + return proxySettings; + } + + public void saveProxySettings(ProxySettings proxySettings) { + this.proxySettings = proxySettings; + propertyHandler.put("options_proxy_use", proxySettings.isUse()); + propertyHandler.put("options_proxy_host", proxySettings.getHost()); + propertyHandler.put("options_proxy_port", proxySettings.getPort()); + propertyHandler.put("options_proxy_userpass", proxySettings.getUserpass()); + saveFile(); + } + + //OptionsManager-Interface + public void addSettingsListener(DataUpdateListener listener) { + if (!(settingsListener.contains(listener))) { + settingsListener.add(listener); + } + } + + public void addConnectionSettingsListener(DataUpdateListener listener) { + if (!(connectionSettingsListener.contains(listener))) { + connectionSettingsListener.add(listener); + } + } + + @SuppressWarnings("unchecked") + private void informSettingsListener(Settings settings) { + + for (DataUpdateListener dataUpdateListener : settingsListener) { + dataUpdateListener.fireContentChanged(DATALISTENER_TYPE.SETTINGS_CHANGED, settings); + } + } + + @SuppressWarnings("unchecked") + private void informConnectionSettingsListener(ConnectionSettings settings) { + + for (DataUpdateListener dataUpdateListener : connectionSettingsListener) { + dataUpdateListener.fireContentChanged(DATALISTENER_TYPE.CONNECTION_SETTINGS_CHANGED, settings); + } + } + + public String getSprache() { + try { + return propertyHandler.get("options_sprache", "deutsch"); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return null; + } + } + + public String getDefaultTheme() { + try { + String temp = propertyHandler.get("options_defaulttheme", "toxicthemepack"); + + if (temp.length() == 0) { + throw new Exception("Kein Defaulttheme vorhanden."); + } + + return temp; + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return ""; + } + } + + public void setDefaultTheme(String themeShortName) { + propertyHandler.put("options_defaulttheme", themeShortName); + } + + public String getNewsURL() { + return propertyHandler.get("options_news_url", "https://applejuicenetz.github.io/news/%s.html"); + } + + public String getServerListURL() { + return propertyHandler.get("options_server_list_url", "http://www.applejuicenet.cc/serverlist/xmllist.php"); + } + + public String getUpdateServerURL() { + return propertyHandler.get("options_update_server_url", "https://api.github.com/repos/applejuicenetz/gui-java/releases/latest"); + } + + public String getIconSetName() { + return propertyHandler.get("options_icon_set", "modern"); + } + + public String getSoundSetName() { + return propertyHandler.get("options_sound_set", "classic"); + } + + public void setIconSetName(String name) { + propertyHandler.put("options_icon_set", name); + } + + public void setSoundSetName(String name) { + propertyHandler.put("options_sound_set", name); + } + + public LookAFeel[] getLookAndFeels() { + + if (lookAndFeels.size() == 0) { + try { + lookAndFeels.add(new LookAFeel("JGoodies Plastic", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel")); + + if (System.getProperty("os.name").toLowerCase().contains("win")) { + lookAndFeels.add(new LookAFeel("JGoodies Windows", "com.jgoodies.looks.windows.WindowsLookAndFeel")); + } + + LookAndFeelInfo[] feels = UIManager.getInstalledLookAndFeels(); + + for (LookAndFeelInfo feel : feels) { + try { + lookAndFeels.add(new LookAFeel(feel.getName(), feel.getClassName())); + } catch (Exception e) { + //unsupported + } + } + + lookAndFeels.add(new LookAFeel("Darcula", "com.bulenkov.darcula.DarculaLaf")); + + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + } + } + + return lookAndFeels.toArray(new LookAFeel[0]); + } + + public LookAFeel getDefaultLookAndFeel() { + try { + LookAFeel[] looks = this.getLookAndFeels(); + String temp = propertyHandler.get("options_lookandfeels_default_name", "JGoodies Plastic"); + for (LookAFeel look : looks) { + if (temp.equals(look.getName())) { + return look; + } + } + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + } + + return null; + } + + public void setDefaultLookAndFeel(LookAFeel lookAFeel) { + propertyHandler.put("options_lookandfeels_default_name", lookAFeel.getName()); + } + + public void setOpenProgram(String path) { + if (path == null || path.length() == 0) { + path = "-1"; + } + + propertyHandler.put("options_program_file", path); + String temp = getOpenProgram(); + + if (temp.compareTo(path) != 0) { + AppleJuiceDialog.rewriteProperties = true; + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + } + } + + public String getOpenProgram() { + try { + String temp = propertyHandler.get("options_program_file", "-1"); + + if (temp.compareTo("-1") == 0) { + return ""; + } else if (temp.length() == 0) { + return null; + } else { + return temp; + } + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return ""; + } + } + + public boolean isErsterStart() { + try { + return propertyHandler.getAsBoolean("options_firststart", true); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return false; + } + } + + public void setErsterStart(boolean ersterStart) { + propertyHandler.put("options_firststart", ersterStart); + } + + public boolean shouldLoadPluginsOnStartup() { + try { + return propertyHandler.getAsBoolean("options_loadplugins", true); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return false; + } + } + + public void loadPluginsOnStartup(boolean loadPluginsOnStartup) { + propertyHandler.put("options_loadplugins", loadPluginsOnStartup); + shouldLoadPluginsOnStartup(); + } + + public boolean isThemesSupported() { + try { + return propertyHandler.getAsBoolean("options_themes", false); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return false; + } + } + + public void enableThemeSupport(boolean enable) { + propertyHandler.put("options_themes", enable); + } + + public boolean getUpdateInfo() { + return propertyHandler.getAsBoolean("options_updateinfo", true); + } + + public void setUpdateInfo(boolean UpdateInfo) { + propertyHandler.put("options_updateinfo", UpdateInfo); + } + + public int getLinkListenerPort() { + return propertyHandler.getAsInt("options_linklistenerport", 8768); + } + + public void setLinkListenerPort(int port) { + propertyHandler.put("options_linklistenerport", port); + } + + public boolean isSoundEnabled() { + try { + return propertyHandler.getAsBoolean("options_sound", true); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return false; + } + } + + public void enableSound(boolean enable) { + propertyHandler.put("options_sound", enable); + } + + public void setSprache(String sprache) { + propertyHandler.put("options_sprache", sprache.toLowerCase()); + } + + public boolean shouldShowConnectionDialogOnStartup() { + try { + return propertyHandler.getAsBoolean("options_dialogzeigen", true); + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return false; + } + } + + public void showConnectionDialogOnStartup(boolean show) { + propertyHandler.put("options_dialogzeigen", show); + } + + public Level getLogLevel() { + try { + String temp = propertyHandler.get("options_logging_level", "INFO"); + Level result = Level.INFO; + + if (temp.compareToIgnoreCase("INFO") == 0) { + return Level.INFO; + } else if (temp.compareToIgnoreCase("TRACE") == 0) { + return Level.TRACE; + } else if (temp.compareToIgnoreCase("DEBUG") == 0) { + return Level.DEBUG; + } else if (temp.compareToIgnoreCase("WARN") == 0) { + return Level.WARN; + } else if (temp.compareToIgnoreCase("ALL") == 0) { + return Level.INFO; + } else if (temp.compareToIgnoreCase("OFF") == 0) { + return null; + } + + logger.debug("Aktueller Loglevel: " + result); + + return result; + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return null; + } + } + + public void setLogLevel(String level) { + AppleJuiceClient.setLogLevel(Level.toLevel(level)); + propertyHandler.put("options_logging_level", level); + } + + public Settings getSettings() { + try { + if (settings == null) { + settings = new Settings(); + } + + Color downloadFertigHintergrundColor = null; + Color quelleHintergrundColor = null; + boolean farbenAktiv; + boolean downloadUebersicht; + boolean loadPlugins; + boolean enableToolTip; + String temp; + + farbenAktiv = propertyHandler.get("options_farben_aktiv", "true").equals("true"); + temp = propertyHandler.get("options_farben_hintergrund_downloadFertig", "-13382656"); + if (temp.length() != 0) { + downloadFertigHintergrundColor = new Color(Integer.parseInt(temp)); + } + + temp = propertyHandler.get("options_farben_hintergrund_quelle", "-205"); + if (temp.length() != 0) { + quelleHintergrundColor = new Color(Integer.parseInt(temp)); + } + + downloadUebersicht = propertyHandler.getAsBoolean("options_download_uebersicht", true); + loadPlugins = propertyHandler.getAsBoolean("options_loadplugins", true); + enableToolTip = propertyHandler.getAsBoolean("options_enableToolTip", true); + settings.setFarbenAktiv(farbenAktiv); + settings.setDownloadFertigHintergrundColor(downloadFertigHintergrundColor); + settings.setQuelleHintergrundColor(quelleHintergrundColor); + settings.loadPluginsOnStartup(loadPlugins); + settings.enableToolTipEnabled(enableToolTip); + settings.setDownloadUebersicht(downloadUebersicht); + return settings; + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return null; + } + } + + public void saveSettings(Settings settings) { + propertyHandler.put("options_farben_aktiv", settings.isFarbenAktiv()); + propertyHandler.put("options_farben_hintergrund_downloadFertig", settings.getDownloadFertigHintergrundColor().getRGB()); + propertyHandler.put("options_farben_hintergrund_quelle", settings.getQuelleHintergrundColor().getRGB()); + propertyHandler.put("options_loadplugins", settings.shouldLoadPluginsOnStartup()); + propertyHandler.put("options_enableToolTip", settings.isToolTipEnabled()); + propertyHandler.put("options_download_uebersicht", settings.isDownloadUebersicht()); + propertyHandler.save(); + informSettingsListener(settings); + } + + public ConnectionSettings getRemoteSettings() { + try { + if (connectionSettings == null) { + connectionSettings = new ConnectionSettings(); + } + + String host; + String passwort; + int xmlPort; + + host = propertyHandler.get("options_remote_host", "localhost"); + passwort = propertyHandler.get("options_remote_passwort", ""); + xmlPort = Integer.parseInt(propertyHandler.get("options_remote_port", "9851")); + connectionSettings.setHost(host); + if (passwort.length() == 0) { + connectionSettings.setOldPassword(""); + } else { + connectionSettings.setOldMD5Password(passwort); + } + + connectionSettings.setXmlPort(xmlPort); + return connectionSettings; + } catch (Exception e) { + AppleJuiceDialog.rewriteProperties = true; + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + return null; + } + } + + public void saveRemote(ConnectionSettings remote) { + propertyHandler.put("options_remote_host", remote.getHost()); + try { + AppleJuiceClient.getAjFassade().setPassword(remote.getNewPassword(), false); + } catch (de.applejuicenet.client.fassade.exception.IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + propertyHandler.put("options_remote_passwort", remote.getNewPassword()); + propertyHandler.put("options_remote_port", remote.getXmlPort()); + informConnectionSettingsListener(getRemoteSettings()); + } + + public void onlySaveRemote(ConnectionSettings remote) { + propertyHandler.put("options_remote_host", remote.getHost()); + propertyHandler.put("options_remote_passwort", remote.getNewPassword()); + propertyHandler.put("options_remote_port", remote.getXmlPort()); + connectionSettings = remote; + } + + public void saveAJSettings(AJSettings ajSettings) { + AppleJuiceClient.getAjFassade().saveAJSettings(ajSettings); + } + + private boolean isVeraltet() { + return false; + } + + public static void restoreProperties() { + PropertyHandler aPropertyHandler = null; + + try { + aPropertyHandler = new PropertyHandler(AppleJuiceClient.getPropertiesPath(), "appleJuice-Java-GUI Propertyfile", false); + aPropertyHandler.put("options_dialogzeigen", true); + aPropertyHandler.put("options_firststart", true); + aPropertyHandler.put("options_sound", true); + aPropertyHandler.put("options_sprache", "deutsch"); + aPropertyHandler.put("options_themes", false); + aPropertyHandler.put("options_defaulttheme", "toxicthemepack"); + aPropertyHandler.put("options_loadplugins", true); + aPropertyHandler.put("options_enableToolTip", true); + aPropertyHandler.put("options_linklistenerport", 8768); + aPropertyHandler.put("options_updateinfo", true); + aPropertyHandler.put("options_remote_host", "localhost"); + aPropertyHandler.put("options_remote_passwort", ""); + aPropertyHandler.put("options_remote_port", 9851); + + aPropertyHandler.put("options_logging_level", "INFO"); + aPropertyHandler.put("options_download_uebersicht", true); + aPropertyHandler.put("options_farben_aktiv", true); + + aPropertyHandler.put("options_farben_hintergrund_downloadFertig", -13382656); + aPropertyHandler.put("options_farben_hintergrund_quelle", -205); + + aPropertyHandler.put("options_lookandfeels_default_name", "JGoodies Plastic"); + aPropertyHandler.put("options_location_height", ""); + aPropertyHandler.put("options_location_width", ""); + aPropertyHandler.put("options_location_x", ""); + aPropertyHandler.put("options_location_y", ""); + aPropertyHandler.put("options_columns_download_column0_width", DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_download_column0_index", 0); + for (int i = 1; i < DownloadsTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_download_column" + i + "_width", DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_download_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_download_column" + i + "_index", i); + } + + aPropertyHandler.put("options_download_sort_column", "0"); + aPropertyHandler.put("options_download_sort_order", "1"); + + aPropertyHandler.put("options_download_sources_sort_column", "0"); + aPropertyHandler.put("options_download_sources_sort_order", "1"); + + aPropertyHandler.put("options_upload_sort_column", "0"); + aPropertyHandler.put("options_upload_sort_order", "1"); + + aPropertyHandler.put("options_search_sort_column", "0"); + aPropertyHandler.put("options_search_sort_order", "1"); + + aPropertyHandler.put("options_upload_waiting_sort_column", "0"); + aPropertyHandler.put("options_upload_waiting_sort_order", "1"); + + aPropertyHandler.put("options_server_sort_column", "0"); + aPropertyHandler.put("options_server_sort_order", "1"); + + aPropertyHandler.put("options_columns_downloadsources_column0_width", DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_downloadsources_column0_index", 0); + for (int i = 1; i < DownloadSourcesTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_downloadsources_column" + i + "_width", DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_downloadsources_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_downloadsources_column" + i + "_index", i); + } + + aPropertyHandler.put("options_columns_upload_column0_width", DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_upload_column0_index", 0); + for (int i = 1; i < UploadActiveTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_upload_column" + i + "_width", DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_upload_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_upload_column" + i + "_index", i); + } + + aPropertyHandler.put("options_columns_uploadwaiting_column0_width", DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_uploadwaiting_column0_index", 0); + for (int i = 1; i < UploadWaitingTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_width", DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_uploadwaiting_column" + i + "_index", i); + } + + aPropertyHandler.put("options_columns_server_column0_width", DEFAULT_SERVER_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_server_column0_index", 0); + for (int i = 1; i < ServerTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_server_column" + i + "_width", DEFAULT_SERVER_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_server_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_server_column" + i + "_index", i); + } + + aPropertyHandler.put("options_columns_search_column0_width", DEFAULT_SEARCH_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_search_column0_index", 0); + for (int i = 1; i < SearchTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_search_column" + i + "_width", DEFAULT_SEARCH_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_search_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_search_column" + i + "_index", i); + } + + aPropertyHandler.put("options_columns_share_column0_width", DEFAULT_SHARE_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_share_column0_index", 0); + for (int i = 1; i < ShareTableModel.CLASS_TYPES.length; i++) { + aPropertyHandler.put("options_columns_share_column" + i + "_width", DEFAULT_SHARE_TABLE_COLUMN_WIDTH); + aPropertyHandler.put("options_columns_share_column" + i + "_visibility", true); + aPropertyHandler.put("options_columns_share_column" + i + "_index", i); + } + + aPropertyHandler.put("options_browser_file", ""); + aPropertyHandler.put("options_program_file", -1); + aPropertyHandler.put("options_proxy_host", ""); + aPropertyHandler.put("options_proxy_port", ""); + aPropertyHandler.put("options_proxy_use", false); + aPropertyHandler.put("options_proxy_userpass", ""); + aPropertyHandler.save(); + } catch (IllegalArgumentException e1) { + // sollte eigentlich nie passieren + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e1); + } + } + + protected void init() { + try { + propertyHandler = new PropertyHandler(path, "appleJuice-Java-GUI Propertyfile", true); + if (isVeraltet()) { + throw new Exception("ajgui.properties hat altes Format. Wird neu erstellt."); + } + + String temp = propertyHandler.get("options_location_x", ""); + + if (temp.length() != 0) { + legal = true; + + int mainX = propertyHandler.getAsInt("options_location_x", 1); + int mainY = propertyHandler.getAsInt("options_location_y", 1); + + mainXY = new Point(mainX, mainY); + int mainWidth = propertyHandler.getAsInt("options_location_width", 400); + int mainHeight = propertyHandler.getAsInt("options_location_height", 400); + + mainDimension = new Dimension(mainWidth, mainHeight); + } + + downloadWidths = new int[DownloadsTableModel.CLASS_TYPES.length]; + for (int i = 0; i < downloadWidths.length; i++) { + downloadWidths[i] = propertyHandler.getAsInt("options_columns_download_column" + i + "_width", DEFAULT_DOWNLOADS_TABLE_COLUMN_WIDTH); + } + + downloadSort = new int[2]; + downloadSort[0] = propertyHandler.getAsInt("options_download_sort_column", 0); + downloadSort[1] = propertyHandler.getAsInt("options_download_sort_order", 1); + + downloadSourcesSort = new int[2]; + downloadSourcesSort[0] = propertyHandler.getAsInt("options_download_sources_sort_column", 0); + downloadSourcesSort[1] = propertyHandler.getAsInt("options_download_sources_sort_order", 1); + + uploadSort = new int[2]; + uploadSort[0] = propertyHandler.getAsInt("options_upload_sort_column", 0); + uploadSort[1] = propertyHandler.getAsInt("options_upload_sort_order", 1); + + searchSort = new int[2]; + searchSort[0] = propertyHandler.getAsInt("options_search_sort_column", 0); + searchSort[1] = propertyHandler.getAsInt("options_search_sort_order", 1); + + uploadWaitingSort = new int[2]; + uploadWaitingSort[0] = propertyHandler.getAsInt("options_upload_waiting_sort_column", 0); + uploadWaitingSort[1] = propertyHandler.getAsInt("options_upload_waiting_sort_order", 1); + + serverSort = new int[2]; + serverSort[0] = propertyHandler.getAsInt("options_server_sort_column", 0); + serverSort[1] = propertyHandler.getAsInt("options_server_sort_order", 1); + + downloadSourcesWidths = new int[DownloadSourcesTableModel.CLASS_TYPES.length]; + for (int i = 0; i < downloadSourcesWidths.length; i++) { + downloadSourcesWidths[i] = propertyHandler.getAsInt("options_columns_downloadsources_column" + i + "_width", DEFAULT_DOWNLOADSOURCES_TABLE_COLUMN_WIDTH); + } + + uploadWidths = new int[UploadActiveTableModel.CLASS_TYPES.length]; + for (int i = 0; i < uploadWidths.length; i++) { + uploadWidths[i] = propertyHandler.getAsInt("options_columns_upload_column" + i + "_width", DEFAULT_UPLOADS_ACTIVE_TABLE_COLUMN_WIDTH); + } + + uploadWaitingWidths = new int[UploadWaitingTableModel.CLASS_TYPES.length]; + for (int i = 0; i < uploadWaitingWidths.length; i++) { + uploadWaitingWidths[i] = propertyHandler.getAsInt("options_columns_uploadwaiting_column" + i + "_width", DEFAULT_UPLOADS_WAITING_TABLE_COLUMN_WIDTH); + } + + uploadWaitingVisibilities = new boolean[UploadWaitingTableModel.CLASS_TYPES.length]; + uploadWaitingVisibilities[0] = true; + for (int i = 1; i < uploadWaitingVisibilities.length; i++) { + uploadWaitingVisibilities[i] = propertyHandler.getAsBoolean("options_columns_uploadwaiting_column" + i + "_visibility", true); + } + + serverWidths = new int[ServerTableModel.CLASS_TYPES.length]; + for (int i = 0; i < serverWidths.length; i++) { + serverWidths[i] = propertyHandler.getAsInt("options_columns_server_column" + i + "_width", DEFAULT_SERVER_TABLE_COLUMN_WIDTH); + } + + shareWidths = new int[ShareTableModel.CLASS_TYPES.length]; + for (int i = 0; i < shareWidths.length; i++) { + shareWidths[i] = propertyHandler.getAsInt("options_columns_share_column" + i + "_width", DEFAULT_SHARE_TABLE_COLUMN_WIDTH); + } + + downloadVisibilities = new boolean[DownloadsTableModel.CLASS_TYPES.length]; + downloadVisibilities[0] = true; + for (int i = 1; i < downloadVisibilities.length; i++) { + downloadVisibilities[i] = propertyHandler.getAsBoolean("options_columns_download_column" + i + "_visibility", true); + } + + downloadSourcesVisibilities = new boolean[DownloadSourcesTableModel.CLASS_TYPES.length]; + downloadSourcesVisibilities[0] = true; + for (int i = 1; i < downloadSourcesVisibilities.length; i++) { + downloadSourcesVisibilities[i] = propertyHandler.getAsBoolean("options_columns_downloadsources_column" + i + "_visibility", true); + } + + uploadVisibilities = new boolean[UploadActiveTableModel.CLASS_TYPES.length]; + uploadVisibilities[0] = true; + for (int i = 1; i < uploadVisibilities.length; i++) { + uploadVisibilities[i] = propertyHandler.getAsBoolean("options_columns_upload_column" + i + "_visibility", true); + } + + downloadIndex = new int[DownloadsTableModel.CLASS_TYPES.length]; + for (int i = 0; i < downloadIndex.length; i++) { + downloadIndex[i] = propertyHandler.getAsInt("options_columns_download_column" + i + "_index", i); + } + + downloadSourcesIndex = new int[DownloadSourcesTableModel.CLASS_TYPES.length]; + for (int i = 0; i < downloadSourcesIndex.length; i++) { + downloadSourcesIndex[i] = propertyHandler.getAsInt("options_columns_downloadsources_column" + i + "_index", i); + } + + uploadIndex = new int[UploadActiveTableModel.CLASS_TYPES.length]; + for (int i = 1; i < uploadIndex.length; i++) { + uploadIndex[i] = propertyHandler.getAsInt("options_columns_upload_column" + i + "_index", i); + } + + uploadWaitingIndex = new int[UploadWaitingTableModel.CLASS_TYPES.length]; + for (int i = 1; i < uploadWaitingIndex.length; i++) { + uploadWaitingIndex[i] = propertyHandler.getAsInt("options_columns_uploadwaiting_column" + i + "_index", i); + } + + boolean use = propertyHandler.getAsBoolean("options_proxy_use", false); + int port = propertyHandler.getAsInt("options_proxy_port", -1); + + String userpass = propertyHandler.get("options_proxy_userpass", ""); + String host = propertyHandler.get("options_proxy_host", ""); + + proxySettings = new ProxySettings(use, host, port, userpass); + } catch (Exception e) { + logger.error(PROPERTIES_ERROR_MESSAGE, e); + + if (firstReadError) { + PropertiesManager.restoreProperties(); + AppleJuiceDialog.showInformation(PROPERTIES_ERROR); + firstReadError = false; + init(); + } else { + AppleJuiceDialog.rewriteProperties = true; + AppleJuiceDialog.closeWithErrormessage(PROPERTIES_ERROR, false); + } + } + } + + public void save() { + try { + propertyHandler.put("options_location_x", mainXY.x); + propertyHandler.put("options_location_y", mainXY.y); + propertyHandler.put("options_location_width", mainDimension.width); + propertyHandler.put("options_location_height", mainDimension.height); + + propertyHandler.put("options_download_sort_column", downloadSort[0]); + propertyHandler.put("options_download_sort_order", downloadSort[1]); + + propertyHandler.put("options_download_sources_sort_column", downloadSourcesSort[0]); + propertyHandler.put("options_download_sources_sort_order", downloadSourcesSort[1]); + + propertyHandler.put("options_upload_sort_column", uploadSort[0]); + propertyHandler.put("options_upload_sort_order", uploadSort[1]); + + propertyHandler.put("options_search_sort_column", searchSort[0]); + propertyHandler.put("options_search_sort_order", searchSort[1]); + + propertyHandler.put("options_upload_waiting_sort_column", uploadWaitingSort[0]); + propertyHandler.put("options_upload_waiting_sort_order", uploadWaitingSort[1]); + + propertyHandler.put("options_server_sort_column", serverSort[0]); + propertyHandler.put("options_server_sort_order", serverSort[1]); + + for (int i = 0; i < downloadWidths.length; i++) { + propertyHandler.put("options_columns_download_column" + i + "_width", downloadWidths[i]); + } + + for (int i = 0; i < downloadSourcesWidths.length; i++) { + propertyHandler.put("options_columns_downloadsources_column" + i + "_width", downloadSourcesWidths[i]); + } + + for (int i = 0; i < uploadWidths.length; i++) { + propertyHandler.put("options_columns_upload_column" + i + "_width", uploadWidths[i]); + } + + for (int i = 0; i < uploadWaitingWidths.length; i++) { + propertyHandler.put("options_columns_uploadwaiting_column" + i + "_width", uploadWaitingWidths[i]); + } + + for (int i = 0; i < serverWidths.length; i++) { + propertyHandler.put("options_columns_server_column" + i + "_width", serverWidths[i]); + } + + for (int i = 0; i < shareWidths.length; i++) { + propertyHandler.put("options_columns_share_column" + i + "_width", shareWidths[i]); + } + + for (int i = 0; i < downloadVisibilities.length; i++) { + propertyHandler.put("options_columns_download_column" + i + "_visibility", downloadVisibilities[i]); + } + + for (int i = 0; i < downloadSourcesVisibilities.length; i++) { + propertyHandler.put("options_columns_downloadsources_column" + i + "_visibility", downloadSourcesVisibilities[i]); + } + + for (int i = 0; i < uploadVisibilities.length; i++) { + propertyHandler.put("options_columns_upload_column" + i + "_visibility", uploadVisibilities[i]); + } + + for (int i = 0; i < uploadWaitingVisibilities.length; i++) { + propertyHandler.put("options_columns_uploadwaiting_column" + i + "_visibility", uploadWaitingVisibilities[i]); + } + + for (int i = 0; i < downloadIndex.length; i++) { + propertyHandler.put("options_columns_download_column" + i + "_index", downloadIndex[i]); + } + + for (int i = 0; i < downloadSourcesIndex.length; i++) { + propertyHandler.put("options_columns_downloadsources_column" + i + "_index", downloadSourcesIndex[i]); + } + + for (int i = 0; i < uploadWaitingIndex.length; i++) { + propertyHandler.put("options_columns_uploadwaiting_column" + i + "_index", uploadWaitingIndex[i]); + } + + saveFile(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void setMainXY(Point p) { + mainXY = p; + } + + public Point getMainXY() { + return mainXY; + } + + public void setMainDimension(Dimension dimension) { + mainDimension = dimension; + } + + public Dimension getMainDimension() { + return mainDimension; + } + + public void setDownloadWidths(int[] widths) { + downloadWidths = widths; + } + + public boolean isLegal() { + return legal; + } + + public int[] getDownloadWidths() { + return downloadWidths; + } + + public int[] getUploadWidths() { + return uploadWidths; + } + + public void setUploadWidths(int[] uploadWidths) { + this.uploadWidths = uploadWidths; + } + + public int[] getUploadWaitingWidths() { + return uploadWaitingWidths; + } + + public void setUploadWaitingWidths(int[] uploadWaitingWidths) { + this.uploadWaitingWidths = uploadWaitingWidths; + } + + public int[] getServerWidths() { + return serverWidths; + } + + public void setServerWidths(int[] serverWidths) { + this.serverWidths = serverWidths; + } + + public int[] getShareWidths() { + return shareWidths; + } + + public void setShareWidths(int[] shareWidths) { + this.shareWidths = shareWidths; + } + + public void setDownloadColumnVisible(int column, boolean visible) { + if (column != 0) { + downloadVisibilities[column] = visible; + } + } + + public boolean[] getDownloadColumnVisibilities() { + return downloadVisibilities; + } + + public void setDownloadColumnIndex(int column, int index) { + downloadIndex[column] = index; + } + + public int[] getDownloadSort() { + return downloadSort; + } + + public void setDownloadSort(int column, boolean ascent) { + downloadSort = new int[]{column, ascent ? 1 : 0}; + + } + + public int[] getDownloadSourcesSort() { + return downloadSourcesSort; + } + + public int[] getSearchSort() { + return searchSort; + } + + public int[] getUploadSort() { + return uploadSort; + } + + public void setDownlodSourcesSort(int column, boolean ascent) { + downloadSourcesSort = new int[]{column, ascent ? 1 : 0}; + + } + + public void setSearchSort(int column, boolean ascent) { + searchSort = new int[]{column, ascent ? 1 : 0}; + + } + + public void setUploadSort(int column, boolean ascent) { + uploadSort = new int[]{column, ascent ? 1 : 0}; + + } + + public int[] getServerSort() { + return serverSort; + } + + public int[] getUploadWaitingSort() { + return uploadWaitingSort; + } + + public void setServerSort(int column, boolean ascent) { + serverSort = new int[]{column, ascent ? 1 : 0}; + + } + + public void setUploadWaitingSort(int column, boolean ascent) { + uploadWaitingSort = new int[]{column, ascent ? 1 : 0}; + + } + + public int[] getDownloadColumnIndizes() { + return downloadIndex; + } + + public void setUploadColumnIndex(int column, int index) { + uploadIndex[column] = index; + } + + public int[] getUploadColumnIndizes() { + return uploadIndex; + } + + public void setUploadColumnVisible(int column, boolean visible) { + if (column != 0) { + uploadVisibilities[column] = visible; + } + } + + public boolean[] getUploadColumnVisibilities() { + return uploadVisibilities; + } + + public ConnectionSettings[] getConnectionsSet() { + ArrayList<ConnectionSettings> connectionSet = new ArrayList<ConnectionSettings>(); + + for (int i = 0; ; i++) { + ConnectionSettings temp = new ConnectionSettings(); + + temp.setHost(propertyHandler.get("options_remote" + i + "_host", "")); + if (temp.getHost().length() == 0) { + break; + } + + int port = propertyHandler.getAsInt("options_remote" + i + "_port", -1); + + temp.setXmlPort(port); + connectionSet.add(temp); + } + + return connectionSet.toArray(new ConnectionSettings[]{}); + } + + public void setConnectionsSet(ConnectionSettings[] set) { + for (int i = 0; i < set.length; i++) { + if ((set.length - 1 < i) || ("".equals(set[i].getHost()))) { + propertyHandler.put("options_remote" + i + "_host", ""); + propertyHandler.put("options_remote" + i + "_port", 0); + } else { + propertyHandler.put("options_remote" + i + "_host", set[i].getHost()); + propertyHandler.put("options_remote" + i + "_port", set[i].getXmlPort()); + } + } + } + + public int[] getUploadWaitingColumnIndizes() { + return uploadWaitingIndex; + } + + public boolean[] getUploadWaitingColumnVisibilities() { + return uploadWaitingVisibilities; + } + + public void setUploadWaitingColumnIndex(int column, int index) { + uploadWaitingIndex[column] = index; + } + + public void setUploadWaitingColumnVisible(int column, boolean visible) { + if (column != 0) { + uploadWaitingVisibilities[column] = visible; + } + } + + public int[] getDownloadSourcesColumnIndizes() { + return downloadSourcesIndex; + } + + public boolean[] getDownloadSourcesColumnVisibilities() { + return downloadSourcesVisibilities; + } + + public int[] getDownloadSourcesWidths() { + return downloadSourcesWidths; + } + + public void setDownloadSourcesColumnIndex(int column, int index) { + downloadSourcesIndex[column] = index; + + } + + public void setDownloadSourcesColumnVisible(int column, boolean visible) { + if (column != 0) { + downloadSourcesVisibilities[column] = visible; + } + } + + public void setDownloadSourcesWidths(int[] widths) { + downloadSourcesWidths = widths; + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertyHandler.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertyHandler.java new file mode 100644 index 00000000..f91fd60f --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/PropertyHandler.java @@ -0,0 +1,170 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.controller; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.*; +import java.util.HashSet; +import java.util.Properties; + +public class PropertyHandler { + private final Logger logger; + private HashSet<PropertyChangeListener> listeners = null; + private String path; + private Properties props; + private String beschreibung; + private boolean inform = true; + + public PropertyHandler(String propertiesLocation, String beschreibung, boolean load) + throws IllegalArgumentException { + logger = LoggerFactory.getLogger(getClass()); + try { + path = propertiesLocation; + if (beschreibung == null) { + this.beschreibung = ""; + } else { + this.beschreibung = beschreibung; + } + + if (load) { + reload(); + } else { + props = new Properties(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void informListener(String identifier, String oldValue, String newValue) { + if (listeners != null && inform) { + PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, identifier, oldValue, newValue); + + for (PropertyChangeListener curListener : listeners) { + curListener.propertyChange(propertyChangeEvent); + } + } + } + + public void allowInform(boolean shouldInform) { + inform = shouldInform; + } + + public void put(String identifier, String value) { + try { + String oldValue = get(identifier, null); + + props.put(identifier, value); + informListener(identifier, oldValue, value); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void put(String identifier, int value) { + put(identifier, Integer.toString(value)); + } + + public void put(String identifier, boolean value) { + put(identifier, Boolean.toString(value)); + } + + public String get(String identifier, String defaultValue) { + Object obj = props.get(identifier); + + if (obj == null) { + return defaultValue; + } else { + return obj.toString(); + } + } + + public Boolean getAsBoolean(String identifier, Boolean defaultValue) { + String obj = (String) props.get(identifier); + + if (null == obj) { + return defaultValue; + } + + if ("true".equalsIgnoreCase(obj) || "false".equalsIgnoreCase(obj)) { + return Boolean.valueOf(obj); + } else { + return defaultValue; + } + } + + public Integer getAsInt(String identifier, int defaultValue) { + String obj = (String) props.get(identifier); + + try { + return new Integer(Integer.parseInt(obj)); + } catch (NumberFormatException nfE) { + return defaultValue; + } + } + + public void reload() throws IllegalArgumentException { + try { + props = new Properties(); + FileInputStream inputStream = null; + + try { + inputStream = new FileInputStream(path); + } catch (FileNotFoundException e) { + throw new IllegalArgumentException("PropertyDatei konnte nicht gefunden werden."); + + } + + props = new Properties(); + try { + props.load(inputStream); + inputStream.close(); + } catch (IOException e2) { + throw new IllegalArgumentException("Ungueltige PropertyDatei."); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void save() throws IllegalArgumentException { + try { + File aFile = new File(path); + + try { + aFile.createNewFile(); + FileOutputStream outputStream = new FileOutputStream(aFile); + + props.store(outputStream, beschreibung); + outputStream.close(); + } catch (IOException e) { + throw new IllegalArgumentException("PropertyDatei konnte nicht gespeichert werden."); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public boolean addPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + if (listeners == null) { + listeners = new HashSet<PropertyChangeListener>(); + } + + return listeners.add(propertyChangeListener); + } + + public boolean removePropertyChangeListener(PropertyChangeListener propertyChangeListener) { + if (listeners == null) { + return false; + } + + return listeners.remove(propertyChangeListener); + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/ProxyManager.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/ProxyManager.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/ProxyManager.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/ProxyManager.java diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java index 40a99ea4..6a789615 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/controller/ProxyManagerImpl.java @@ -9,7 +9,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadController.java new file mode 100644 index 00000000..cb7e8189 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadController.java @@ -0,0 +1,988 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.download; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.*; +import de.applejuicenet.client.fassade.event.DownloadDataPropertyChangeEvent; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.GuiControllerActionListener; +import de.applejuicenet.client.gui.components.table.HeaderListener; +import de.applejuicenet.client.gui.components.util.Value; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.gui.download.table.DownloadSourcesTableModel; +import de.applejuicenet.client.gui.download.table.DownloadsTableModel; +import de.applejuicenet.client.gui.options.IncomingDirSelectionDialog; +import de.applejuicenet.client.gui.upload.HeaderPopupListener; +import de.applejuicenet.client.gui.upload.UploadMouseMotionListener; +import de.applejuicenet.client.shared.DesktopTools; +import de.applejuicenet.client.shared.ReleaseInfo; +import de.applejuicenet.client.shared.SoundPlayer; + +import javax.swing.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.*; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class DownloadController extends GuiController { + private static DownloadController instance = null; + private static final int ABBRECHEN = 0; + private static final int COPY_TO_CLIPBOARD = 1; + private static final int COPY_TO_CLIPBOARD_WITH_SOURCES = 2; + private static final int OPEN_WITH_PROGRAM = 3; + private static final int OPEN_WITH_DEFAULT_PROGRAM = 16; + private static final int PAUSE = 4; + private static final int FORTSETZEN = 5; + private static final int UMBENENNEN = 6; + private static final int ZIELORDNER_AENDERN = 7; + private static final int FERTIGE_ENTFERNEN = 8; + private static final int PARTLISTE_ANZEIGEN = 9; + private static final int START_DOWNLOAD = 10; + private static final int PARTLISTE_ANZEIGEN_PER_BUTTON = 11; + private static final int START_POWERDOWNLOAD = 12; + private static final int HEADER_DOWNLOAD_POPUP = 13; + private static final int HEADER_DOWNLOAD_SOURCES_POPUP = 14; + private static final int HEADER_DOWNLOAD_DRAGGED = 15; + private static final int HEADER_DOWNLOAD_SOURCES_DRAGGED = 17; + private static final int RELEASE_INFO = 18; + private DownloadPanel downloadPanel; + private boolean initialized = false; + private String dialogTitel; + private String downloadAbbrechen; + private DownloadPartListWatcher downloadPartListWatcher; + private boolean firstUpdate = true; + private boolean isFirstDownloadPropertyChanged = true; + private boolean selected = false; + private String alreadyLoaded; + private String invalidLink; + private String linkFailure; + + private DownloadController() { + super(); + downloadPanel = new DownloadPanel(this); + try { + init(); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); + + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static synchronized DownloadController getInstance() { + if (null == instance) { + instance = new DownloadController(); + } + + return instance; + } + + private void init() { + downloadPanel.getMnuAbbrechen().addActionListener(new GuiControllerActionListener(this, ABBRECHEN)); + downloadPanel.getMnuCopyToClipboard().addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD)); + downloadPanel.getMnuCopyToClipboardWithSources() + .addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD_WITH_SOURCES)); + downloadPanel.getMnuPause().addActionListener(new GuiControllerActionListener(this, PAUSE)); + downloadPanel.getMnuFortsetzen().addActionListener(new GuiControllerActionListener(this, FORTSETZEN)); + downloadPanel.getMnuUmbenennen().addActionListener(new GuiControllerActionListener(this, UMBENENNEN)); + downloadPanel.getMnuZielordner().addActionListener(new GuiControllerActionListener(this, ZIELORDNER_AENDERN)); + downloadPanel.getMnuFertigeEntfernen().addActionListener(new GuiControllerActionListener(this, FERTIGE_ENTFERNEN)); + downloadPanel.getMnuReleaseInfo().addActionListener(new GuiControllerActionListener(this, RELEASE_INFO)); + downloadPanel.getBtnPowerDownload().addActionListener(new GuiControllerActionListener(this, START_POWERDOWNLOAD)); + if (AppleJuiceClient.getAjFassade().isLocalhost()) { + downloadPanel.getMnuOpenWithProgram().addActionListener(new GuiControllerActionListener(this, OPEN_WITH_PROGRAM)); + downloadPanel.getMnuOpenWithProgram().setVisible(true); + if (DesktopTools.isAdvancedSupported()) { + downloadPanel.getMnuOpenWithDefaultProgram() + .addActionListener(new GuiControllerActionListener(this, OPEN_WITH_DEFAULT_PROGRAM)); + } else { + downloadPanel.getMnuOpenWithDefaultProgram().setVisible(false); + } + } else { + downloadPanel.getMnuOpenWithProgram().setEnabled(false); + downloadPanel.getMnuOpenWithDefaultProgram().setVisible(false); + } + + downloadPanel.getDownloadTable().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + int selected = downloadPanel.getDownloadTable().getSelectedRow(); + + if (selected == -1) { + return; + } + + Download download = downloadPanel.getDownloadTableModel().getRow(selected); + + downloadClicked(download); + if (downloadPanel.getDownloadSourcesTableModel().setDownload(download)) { + downloadPanel.getDownloadSourcesTableModel().fireTableDataChanged(); + } + } else if (SwingUtilities.isRightMouseButton(e)) { + int row = downloadPanel.getDownloadTable().rowAtPoint(e.getPoint()); + + if (!downloadPanel.getDownloadTable().getSelectionModel().isSelectedIndex(row)) { + downloadPanel.getDownloadTable().getSelectionModel().setSelectionInterval(row, row); + } + + maybeShowDownloadPopup(e); + } + } + }); + downloadPanel.getDownloadTable().addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent ke) { + switch (ke.getKeyCode()) { + + case KeyEvent.VK_F2: { + renameDownload(); + break; + } + + case KeyEvent.VK_F3: { + changeTargetDir(); + break; + } + + case KeyEvent.VK_F5: { + pausieren(); + break; + } + + case KeyEvent.VK_F6: { + fortsetzen(); + break; + } + + default: + break; + } + } + }); + downloadPanel.getDownloadSourceTable().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + int selected = downloadPanel.getDownloadSourceTable().getSelectedRow(); + + if (selected == -1) { + return; + } + + DownloadSource downloadSource = downloadPanel.getDownloadSourcesTableModel().getRow(selected); + + downloadSourceClicked(downloadSource); + } + } + }); + downloadPartListWatcher = new DownloadPartListWatcher(this); + + JTableHeader header = downloadPanel.getDownloadTable().getTableHeader(); + + header.addMouseListener(new HeaderPopupListener(this, HEADER_DOWNLOAD_POPUP)); + header.addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DOWNLOAD_DRAGGED)); + + header = downloadPanel.getDownloadSourceTable().getTableHeader(); + + header.addMouseListener(new HeaderPopupListener(this, HEADER_DOWNLOAD_SOURCES_POPUP)); + header.addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DOWNLOAD_SOURCES_DRAGGED)); + + LanguageSelector.getInstance().addLanguageListener(this); + } + + public Value[] getCustomizedValues() { + return new Value[0]; + } + + public void fireAction(int actionId, Object source) { + switch (actionId) { + + case HEADER_DOWNLOAD_DRAGGED: { + headerDownloadsDragged(); + break; + } + + case HEADER_DOWNLOAD_SOURCES_DRAGGED: { + headerDownloadSourcesDragged(); + break; + } + + case HEADER_DOWNLOAD_POPUP: { + headerDownloadsPopup((MouseEvent) source); + break; + } + + case HEADER_DOWNLOAD_SOURCES_POPUP: { + headerDownloadSourcesPopup((MouseEvent) source); + break; + } + + case ABBRECHEN: { + downloadAbbrechen(); + break; + } + + case COPY_TO_CLIPBOARD: { + copyDownloadLinkToClipboard(); + break; + } + + case COPY_TO_CLIPBOARD_WITH_SOURCES: { + copyDownloadLinkToClipboardWithSources(); + break; + } + + case OPEN_WITH_PROGRAM: { + openWithProgram(); + break; + } + + case OPEN_WITH_DEFAULT_PROGRAM: { + openWithDefaultProgram(); + break; + } + + case PAUSE: { + pausieren(); + break; + } + + case FORTSETZEN: { + fortsetzen(); + break; + } + + case UMBENENNEN: { + renameDownload(); + break; + } + + case ZIELORDNER_AENDERN: { + changeTargetDir(); + break; + } + + case FERTIGE_ENTFERNEN: { + clearReadyDownloads(); + break; + } + + case START_POWERDOWNLOAD: { + startPowerDownload(); + break; + } + + case RELEASE_INFO: { + showReleaseInfo(); + break; + } + + default: + logger.error("Unregistrierte EventId " + actionId); + } + } + + private void showReleaseInfo() { + Download[] selectedItems = getSelectedDownloads(); + + if (selectedItems == null || selectedItems.length < 1) { + return; + } + + Download curDownload = selectedItems[0]; + + ReleaseInfo.handle(curDownload.getFilename(), curDownload.getHash(), (long) curDownload.getGroesse()); + } + + private void headerDownloadsDragged() { + PositionManager pm = PositionManagerImpl.getInstance(); + TableColumnModel columnModel = downloadPanel.getDownloadTable().getColumnModel(); + TableColumn[] columns = downloadPanel.getDownloadTableColumns(); + + for (int i = 0; i < columns.length; i++) { + pm.setDownloadColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); + } + } + + private void headerDownloadSourcesDragged() { + PositionManager pm = PositionManagerImpl.getInstance(); + TableColumnModel columnModel = downloadPanel.getDownloadSourceTable().getColumnModel(); + TableColumn[] columns = downloadPanel.getDownloadSourcesTableColumns(); + + for (int i = 0; i < columns.length; i++) { + pm.setDownloadSourcesColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); + } + } + + private void headerDownloadsPopup(MouseEvent e) { + TableColumn[] columns = downloadPanel.getDownloadTableColumns(); + JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadPopupItems(); + TableColumnModel tableColumnModel = downloadPanel.getDownloadTable().getColumnModel(); + + for (int i = 1; i < columns.length; i++) { + try { + tableColumnModel.getColumnIndex(columns[i].getIdentifier()); + columnPopupItems[i].setSelected(true); + } catch (java.lang.IllegalArgumentException iaE) { + columnPopupItems[i].setSelected(false); + } + } + + downloadPanel.getColumnDownloadPopup().show(downloadPanel.getDownloadTable().getTableHeader(), e.getX(), e.getY()); + } + + private void headerDownloadSourcesPopup(MouseEvent e) { + TableColumn[] columns = downloadPanel.getDownloadSourcesTableColumns(); + JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadSourcesPopupItems(); + TableColumnModel tableColumnModel = downloadPanel.getDownloadSourceTable().getColumnModel(); + + for (int i = 1; i < columns.length; i++) { + try { + tableColumnModel.getColumnIndex(columns[i].getIdentifier()); + columnPopupItems[i].setSelected(true); + } catch (java.lang.IllegalArgumentException iaE) { + columnPopupItems[i].setSelected(false); + } + } + + downloadPanel.getColumnDownloadSourcesPopup().show(downloadPanel.getDownloadSourceTable().getTableHeader(), e.getX(), e.getY()); + } + + public JComponent getComponent() { + return downloadPanel; + } + + private boolean handleDownloadDataPropertyChangeEvent(DownloadDataPropertyChangeEvent event) { + return false; + } + + private void clearReadyDownloads() { + new Thread() { + @Override + public void run() { + AppleJuiceClient.getAjFassade().cleanDownloadList(); + } + }.start(); + downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(false); + downloadPanel.getPowerDownloadPanel().setPwdlValue(0); + downloadPanel.getDownloadTable().getSelectionModel().clearSelection(); + } + + private void downloadSourceClicked(DownloadSource downloadSource) { + tryGetPartList(downloadSource); + } + + private void downloadClicked(Download download) { + tryGetPartList(download); + + if (!downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) { + downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(true); + if (download.getStatus() == Download.SUCHEN_LADEN || download.getStatus() == Download.PAUSIERT) { + downloadPanel.getPowerDownloadPanel().setPwdlValue(download.getPowerDownload()); + } else { + downloadPanel.getPowerDownloadPanel().getBtnPdl().setEnabled(false); + downloadPanel.getPowerDownloadPanel().setPwdlValue(0); + } + } + } + + private void startPowerDownload() { + try { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads != null && selectedDownloads.length != 0) { + int powerDownload = 0; + + if (!downloadPanel.getBtnPowerDownloadInaktiv().isSelected()) { + String temp = downloadPanel.getRatioField().getText(); + double power = 2.2; + + try { + power = Double.parseDouble(temp); + } catch (NumberFormatException nfE) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, nfE); + + downloadPanel.getRatioField().setText("2.2"); + } + + powerDownload = (int) (power * 10 - 10); + } + + List<Download> temp = new ArrayList<Download>(); + + for (Download curDownload : selectedDownloads) { + if (curDownload.getStatus() == Download.PAUSIERT || curDownload.getStatus() == Download.SUCHEN_LADEN) { + temp.add(curDownload); + } + } + + AppleJuiceClient.getAjFassade().setPowerDownload(temp, new Integer(powerDownload)); + if (downloadPanel.getBtnPowerDownloadAktiv().isSelected()) { + SoundPlayer.getInstance().playSound(SoundPlayer.POWER); + } + } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + private void maybeShowDownloadPopup(MouseEvent e) { + int[] selected = downloadPanel.getDownloadTable().getSelectedRows(); + + if (null == selected || selected.length == 0) { + return; + } + + Download[] selectedDownloads = new Download[selected.length]; + + for (int i = 0; i < selected.length; i++) { + selectedDownloads[i] = downloadPanel.getDownloadTableModel().getRow(selected[i]); + } + + boolean pausiert = false; + boolean laufend = false; + + downloadPanel.getMnuZielordner().setEnabled(true); + for (Download curDownload : selectedDownloads) { + if (curDownload.getStatus() == Download.SUCHEN_LADEN) { + laufend = true; + } else if (curDownload.getStatus() == Download.PAUSIERT) { + pausiert = true; + } + } + + downloadPanel.getMnuUmbenennen().setEnabled(selected.length == 1); + downloadPanel.getMnuCopyToClipboard().setEnabled(selected.length == 1); + downloadPanel.getMnuCopyToClipboardWithSources().setEnabled(selected.length == 1); + downloadPanel.getMnuPause().setEnabled(laufend); + downloadPanel.getMnuFortsetzen().setEnabled(pausiert); + downloadPanel.getPopup().show(downloadPanel.getDownloadTable(), e.getX(), e.getY()); + } + + private void tryGetPartList(DownloadSource downloadSource) { + downloadPartListWatcher.setDownloadNode(downloadSource); + } + + private void tryGetPartList(Download download) { + downloadPartListWatcher.setDownloadNode(download); + } + + private Download[] getSelectedDownloads() { + try { + int[] selected = downloadPanel.getDownloadTable().getSelectedRows(); + + if (null == selected || selected.length == 0) { + return new Download[0]; + } + + Download[] selectedDownloads = new Download[selected.length]; + + for (int i = 0; i < selected.length; i++) { + selectedDownloads[i] = downloadPanel.getDownloadTableModel().getRow(selected[i]); + } + + return selectedDownloads; + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + + return new Download[0]; + } + } + + private void renameDownload() { + Download[] selectedItems = getSelectedDownloads(); + + if (selectedItems != null && selectedItems.length == 1) { + Download curDownload = selectedItems[0]; + RenameDownloadDialog renameDownloadDialog = new RenameDownloadDialog(AppleJuiceDialog.getApp(), curDownload); + + renameDownloadDialog.setVisible(true); + String neuerName = renameDownloadDialog.getNewName(); + + if (neuerName == null) { + return; + } else { + if (curDownload.getFilename().compareTo(neuerName) != 0) { + try { + AppleJuiceClient.getAjFassade().renameDownload(curDownload, neuerName); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + } + } + + private void pausieren() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads != null && selectedDownloads.length != 0 && + !downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) { + final List<Download> pausieren = new ArrayList<Download>(); + + for (Download curDownload : selectedDownloads) { + if (curDownload.getStatus() == Download.SUCHEN_LADEN) { + pausieren.add(curDownload); + } + } + + if (pausieren.size() > 0) { + new Thread() { + public void run() { + try { + AppleJuiceClient.getAjFassade().pauseDownload(pausieren); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }.start(); + } + } + } + + private void fortsetzen() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads != null && selectedDownloads.length != 0 && + !downloadPanel.getPowerDownloadPanel().isAutomaticPwdlActive()) { + final List<Download> fortsetzen = new ArrayList<Download>(); + + for (Download curDownload : selectedDownloads) { + if (curDownload.getStatus() == Download.PAUSIERT) { + fortsetzen.add(curDownload); + } + } + + if (fortsetzen.size() > 0) { + new Thread() { + public void run() { + try { + AppleJuiceClient.getAjFassade().resumeDownload(fortsetzen); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }.start(); + } + } + } + + private void changeTargetDir() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads == null || selectedDownloads.length == 0) { + return; + } + + String selectedDir = null; + + for (Download curDownload : selectedDownloads) { + selectedDir = curDownload.getTargetDirectory(); + if (null != selectedDir && selectedDir.trim().length() > 0) { + break; + } + } + + String[] dirs = AppleJuiceClient.getAjFassade().getCurrentIncomingDirs(); + IncomingDirSelectionDialog incomingDirSelectionDialog = new IncomingDirSelectionDialog(AppleJuiceDialog.getApp(), dirs, + selectedDir); + + incomingDirSelectionDialog.setVisible(true); + String neuerName = incomingDirSelectionDialog.getSelectedIncomingDir(); + + if (neuerName == null) { + return; + } else { + neuerName = neuerName.trim(); + if (neuerName.indexOf(File.separator) == 0 || neuerName.indexOf(ApplejuiceFassade.separator) == 0) { + neuerName = neuerName.substring(1); + } + } + + List<Download> toChange = new ArrayList<Download>(); + + for (Download curDownload : selectedDownloads) { + if (!neuerName.equals(curDownload.getTargetDirectory())) { + toChange.add(curDownload); + } + } + + if (toChange.size() > 0) { + try { + AppleJuiceClient.getAjFassade().setTargetDir(toChange, neuerName); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + + private void openWithProgram() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads != null && selectedDownloads.length == 1) { + String programToExecute = OptionsManagerImpl.getInstance().getOpenProgram(); + + if (programToExecute.length() != 0) { + for (Download curDownload : selectedDownloads) { + Integer shareId = new Integer(curDownload.getShareId()); + + try { + Share share = (Share) AppleJuiceClient.getAjFassade().getObjectById(shareId); + + if (share != null) { + String filename = share.getFilename(); + + try { + Runtime.getRuntime().exec(new String[]{programToExecute, filename}); + } catch (Exception ex) { + + //nix zu tun + } + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + } + } + + private void openWithDefaultProgram() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads.length == 1) { + for (Download curDownload : selectedDownloads) { + Integer shareId = curDownload.getShareId(); + + try { + Share share = (Share) AppleJuiceClient.getAjFassade().getObjectById(shareId); + + if (share != null) { + String filename = share.getFilename(); + + DesktopTools.open(new File(filename)); + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + } + + private void copyDownloadLinkToClipboardWithSources() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads.length == 1) { + Download curDownload = selectedDownloads[0]; + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuffer toCopy = new StringBuffer(); + + toCopy.append("ajfsp://file|"); + boolean copyToClipboard = false; + + toCopy.append(curDownload.getFilename() + "|" + curDownload.getHash() + "|" + curDownload.getGroesse()); + copyToClipboard = true; + + if (copyToClipboard) { + long port = AppleJuiceClient.getAjFassade().getAJSettings().getPort(); + Information information = AppleJuiceClient.getAjFassade().getInformation(); + + toCopy.append("|"); + toCopy.append(information.getExterneIP()); + toCopy.append(":"); + toCopy.append(port); + if (information.getVerbindungsStatus() == Information.VERBUNDEN) { + Server server = information.getServer(); + + if (server != null) { + toCopy.append(":"); + toCopy.append(server.getHost()); + toCopy.append(":"); + toCopy.append(server.getPort()); + } + } + + toCopy.append("/"); + StringSelection contents = new StringSelection(toCopy.toString()); + + cb.setContents(contents, null); + } + } + } + + private void copyDownloadLinkToClipboard() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads.length == 1) { + Download curDownload = selectedDownloads[0]; + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuffer toCopy = new StringBuffer(); + + toCopy.append("ajfsp://file|"); + toCopy.append(curDownload.getFilename() + "|" + curDownload.getHash() + "|" + curDownload.getGroesse() + "/"); + StringSelection contents = new StringSelection(toCopy.toString()); + + cb.setContents(contents, null); + } + } + + private void downloadAbbrechen() { + Download[] selectedDownloads = getSelectedDownloads(); + + if (selectedDownloads.length != 0) { + int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), downloadAbbrechen, dialogTitel, + JOptionPane.YES_NO_OPTION); + + if (result == JOptionPane.YES_OPTION) { + final List<Download> abbrechen = new ArrayList<Download>(); + + Collections.addAll(abbrechen, selectedDownloads); + + if (abbrechen.size() > 0) { + new Thread() { + public void run() { + try { + AppleJuiceClient.getAjFassade().cancelDownload(abbrechen); + SoundPlayer.getInstance().playSound(SoundPlayer.ABGEBROCHEN); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }.start(); + } + } + } + } + + public void componentSelected() { + try { + selected = true; + if (!initialized) { + initialized = true; + firstUpdate = false; + int width = downloadPanel.getScrollPane().getWidth() - 18; + PositionManager pm = PositionManagerImpl.getInstance(); + + TableColumn[] columnsDownload = downloadPanel.getDownloadTableColumns(); + TableColumn[] columnsDownloadSources = downloadPanel.getDownloadSourcesTableColumns(); + int[] sortDownloads = null; + int[] sortDownloadSources = null; + + if (pm.isLegal()) { + int[] widths = pm.getDownloadWidths(); + boolean[] visibilies = pm.getDownloadColumnVisibilities(); + int[] indizes = pm.getDownloadColumnIndizes(); + ArrayList<TableColumn> visibleColumns = new ArrayList<TableColumn>(); + + for (int i = 0; i < columnsDownload.length; i++) { + columnsDownload[i].setPreferredWidth(widths[i]); + downloadPanel.getDownloadTable().removeColumn(columnsDownload[i]); + if (visibilies[i]) { + visibleColumns.add(columnsDownload[i]); + } + } + + int pos = -1; + + for (int i = 0; i < visibleColumns.size(); i++) { + for (int x = 0; x < columnsDownload.length; x++) { + if (visibleColumns.contains(columnsDownload[x]) && indizes[x] == pos + 1) { + downloadPanel.getDownloadTable().addColumn(columnsDownload[x]); + pos++; + break; + } + } + } + + widths = pm.getDownloadSourcesWidths(); + visibilies = pm.getDownloadSourcesColumnVisibilities(); + indizes = pm.getDownloadSourcesColumnIndizes(); + sortDownloads = pm.getDownloadSort(); + + visibleColumns = new ArrayList<TableColumn>(); + + for (int i = 0; i < columnsDownloadSources.length; i++) { + columnsDownloadSources[i].setPreferredWidth(widths[i]); + downloadPanel.getDownloadSourceTable().removeColumn(columnsDownloadSources[i]); + if (visibilies[i]) { + visibleColumns.add(columnsDownloadSources[i]); + } + } + + pos = -1; + + sortDownloadSources = pm.getDownloadSourcesSort(); + for (int i = 0; i < visibleColumns.size(); i++) { + for (int x = 0; x < columnsDownloadSources.length; x++) { + if (visibleColumns.contains(columnsDownloadSources[x]) && indizes[x] == pos + 1) { + downloadPanel.getDownloadSourceTable().addColumn(columnsDownloadSources[x]); + pos++; + break; + } + } + } + } else { + for (int i = 0; i < columnsDownload.length; i++) { + columnsDownload[i].setPreferredWidth(width / columnsDownload.length); + } + + for (int i = 0; i < columnsDownloadSources.length; i++) { + columnsDownloadSources[i].setPreferredWidth(width / columnsDownloadSources.length); + } + } + + downloadPanel.getDownloadTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + downloadPanel.getDownloadSourceTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + int loc = (int) ((downloadPanel.getSplitPane().getHeight() - downloadPanel.getSplitPane().getDividerSize() - + downloadPanel.getPowerDownloadPanel().getPreferredSize().height)); + + downloadPanel.getSplitPane().setDividerLocation(loc); + if (null != sortDownloads) { + for (MouseListener curMl : downloadPanel.getDownloadTable().getTableHeader().getMouseListeners()) { + if (curMl instanceof HeaderListener) { + ((HeaderListener) curMl).sort(sortDownloads[0], sortDownloads[1] == 1); + } + } + } + + if (null != sortDownloadSources) { + for (MouseListener curMl : downloadPanel.getDownloadSourceTable().getTableHeader().getMouseListeners()) { + if (curMl instanceof HeaderListener) { + ((HeaderListener) curMl).sort(sortDownloadSources[0], sortDownloadSources[1] == 1); + } + } + } + } + + downloadPanel.getDownloadTable().updateUI(); + if (downloadPanel.getDownloadSourcesScrollPane().isVisible()) { + downloadPanel.getDownloadSourceTable().updateUI(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void componentLostSelection() { + selected = false; + downloadPartListWatcher.setDownloadNode((Download) null); + } + + protected void languageChanged() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + String text = languageSelector.getFirstAttrbuteByTagName("mainform.Label14.caption"); + + dialogTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + downloadAbbrechen = languageSelector.getFirstAttrbuteByTagName("mainform.msgdlgtext5"); + String[] tableColumns = new String[DownloadsTableModel.CLASS_TYPES.length]; + + tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col0caption"); + tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col1caption"); + tableColumns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col2caption"); + tableColumns[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col3caption"); + tableColumns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col4caption"); + tableColumns[5] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col5caption"); + tableColumns[6] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); + tableColumns[7] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col7caption"); + tableColumns[8] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col8caption"); + tableColumns[9] = "Zielverzeichnis"; + TableColumn[] columns = downloadPanel.getDownloadTableColumns(); + JCheckBoxMenuItem[] columnPopupItems = downloadPanel.getColumnDownloadPopupItems(); + + for (int i = 0; i < columns.length; i++) { + columns[i].setHeaderValue(tableColumns[i]); + columnPopupItems[i].setText(tableColumns[i]); + } + + tableColumns = new String[DownloadSourcesTableModel.CLASS_TYPES.length]; + + tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col0caption"); + tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col1caption"); + tableColumns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); + tableColumns[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col2caption"); + tableColumns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col3caption"); + tableColumns[5] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col4caption"); + tableColumns[6] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col5caption"); + tableColumns[7] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); + tableColumns[8] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col7caption"); + tableColumns[9] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col8caption"); + tableColumns[10] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col9caption"); + + columns = downloadPanel.getDownloadSourcesTableColumns(); + columnPopupItems = downloadPanel.getColumnDownloadSourcesPopupItems(); + for (int i = 0; i < columns.length; i++) { + columns[i].setHeaderValue(tableColumns[i]); + columnPopupItems[i].setText(tableColumns[i]); + } + + downloadPanel.getMnuReleaseInfo().setText(languageSelector.getFirstAttrbuteByTagName("releaseinfo.menu")); + downloadPanel.getMnuAbbrechen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.canceldown.caption")); + downloadPanel.getMnuPause().setText(languageSelector.getFirstAttrbuteByTagName("mainform.pausedown.caption") + " [F5]"); + downloadPanel.getMnuFortsetzen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.resumedown.caption") + " [F6]"); + downloadPanel.getMnuUmbenennen().setText(languageSelector.getFirstAttrbuteByTagName("mainform.renamefile.caption") + " [F2]"); + downloadPanel.getMnuZielordner().setText(languageSelector.getFirstAttrbuteByTagName("mainform.changetarget.caption") + + " [F3]"); + downloadPanel.getMnuFertigeEntfernen() + .setText(languageSelector.getFirstAttrbuteByTagName("mainform.Clearfinishedentries1.caption")); + downloadPanel.getMnuCopyToClipboard().setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); + downloadPanel.getMnuCopyToClipboardWithSources() + .setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.getlinkwithsources")); + downloadPanel.getMnuOpenWithProgram().setText("VLC"); + downloadPanel.getMnuOpenWithDefaultProgram() + .setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.startemitstandard")); + alreadyLoaded = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.bereitsgeladen"); + invalidLink = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.falscherlink"); + linkFailure = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.sonstigerlinkfehlerlang"); + } + + @SuppressWarnings("unchecked") + protected void contentChanged(DATALISTENER_TYPE type, final Object content) { + Map<Integer, Download> downloads = (Map<Integer, Download>) content; + + final boolean downloadChanged = downloadPanel.getDownloadTableModel().setDownloads(downloads); + Download curDownload = downloadPanel.getDownloadSourcesTableModel().getDownload(); + + boolean sourcesChangedTmp = false; + + if (null != curDownload) { + Download freshDownload = downloads.get(curDownload.getId()); + + sourcesChangedTmp = downloadPanel.getDownloadSourcesTableModel().setDownload(freshDownload); + } + + final boolean sourcesChanged = sourcesChangedTmp; + + if (selected && (downloadChanged || sourcesChanged)) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (downloadChanged) { + downloadPanel.getDownloadTableModel().forceResort(); + downloadPanel.getDownloadTable().updateUI(); + } + + if (sourcesChanged) { + downloadPanel.getDownloadSourcesTableModel().forceResort(); + downloadPanel.getDownloadSourceTable().updateUI(); + } + } + }); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java new file mode 100644 index 00000000..280e915e --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java @@ -0,0 +1,338 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ +package de.applejuicenet.client.gui.download; + + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadOverviewPanel.java,v 1.8 2009/02/01 14:49:17 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.DownloadSource; +import de.applejuicenet.client.fassade.entity.PartList; +import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.shared.Settings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.DecimalFormat; + +public class DownloadOverviewPanel extends JPanel implements LanguageListener { + private DownloadPartListPanel actualDlOverviewTable; + private JLabel actualDLDateiName = new JLabel(); + private JLabel label5 = new JLabel(); + private JLabel label4 = new JLabel(); + private JLabel label3 = new JLabel(); + private JLabel label2 = new JLabel(); + private JLabel label1 = new JLabel(); + private final Logger logger; + private JCheckBox holeListe = new JCheckBox(); + private PartListWorkerThread partListWorkerThread = null; + private DownloadPanel downloadPanel; + private String verfuegbar; + private DecimalFormat decimalFormat = new DecimalFormat("#.##"); + private Object lastPartlistObject = null; + + public DownloadOverviewPanel(DownloadPanel parent) { + logger = LoggerFactory.getLogger(getClass()); + try { + downloadPanel = parent; + actualDlOverviewTable = DownloadPartListPanel.getInstance(); + init(); + LanguageSelector.getInstance().addLanguageListener(this); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + holeListe.setSelected(Settings.getSettings().isDownloadUebersicht()); + holeListe.addActionListener(e -> { + if (!holeListe.isSelected() && null != partListWorkerThread) { + partListWorkerThread.interrupt(); + partListWorkerThread = null; + actualDLDateiName.setText(null); + actualDlOverviewTable.setPartList(null, null); + } else if (holeListe.isSelected() && null != lastPartlistObject) { + if (lastPartlistObject instanceof Download) { + setDownload((Download) lastPartlistObject); + } else { + setDownloadSource((DownloadSource) lastPartlistObject); + } + } + + Settings settings = Settings.getSettings(); + + settings.setDownloadUebersicht(holeListe.isSelected()); + settings.save(); + }); + setLayout(new BorderLayout()); + JPanel tempPanel1 = new JPanel(); + + tempPanel1.setLayout(new FlowLayout()); + + JLabel gelb = new JLabel(" "); + + gelb.setOpaque(true); + gelb.setBackground(Color.YELLOW); + tempPanel1.add(gelb); + tempPanel1.add(label5); + + JLabel blau = new JLabel(" "); + + blau.setOpaque(true); + blau.setBackground(Color.BLUE); + tempPanel1.add(blau); + tempPanel1.add(label4); + + JLabel red = new JLabel(" "); + + red.setOpaque(true); + red.setBackground(Color.RED); + tempPanel1.add(red); + tempPanel1.add(label3); + + JLabel black = new JLabel(" "); + + black.setOpaque(true); + black.setBackground(Color.BLACK); + tempPanel1.add(black); + tempPanel1.add(label2); + + JLabel green = new JLabel(" "); + + green.setOpaque(true); + green.setBackground(Color.GREEN); + tempPanel1.add(green); + tempPanel1.add(label1); + + JPanel panel3 = new JPanel(new BorderLayout()); + + panel3.add(holeListe, BorderLayout.WEST); + panel3.add(tempPanel1, BorderLayout.CENTER); + + add(panel3, BorderLayout.NORTH); + actualDLDateiName.setPreferredSize(new Dimension(actualDLDateiName.getPreferredSize().width, 17)); + JPanel panel1 = new JPanel(new BorderLayout()); + + panel1.add(actualDLDateiName, BorderLayout.NORTH); + panel1.add(actualDlOverviewTable, BorderLayout.CENTER); + add(panel1, BorderLayout.CENTER); + } + + public void setDownload(Download download) { + lastPartlistObject = download; + if (!holeListe.isSelected()) { + return; + } + + try { + if (partListWorkerThread != null) { + if (partListWorkerThread.isInterrupted()) { + partListWorkerThread = null; + } else { + if (partListWorkerThread.getObjectDO() == download) { + return; + } else { + partListWorkerThread.cancel(); + partListWorkerThread = null; + } + } + } + + partListWorkerThread = new PartListWorkerThread(); + partListWorkerThread.setDownload(download); + partListWorkerThread.start(); + } catch (Exception e) { + if (partListWorkerThread != null) { + partListWorkerThread.cancel(); + partListWorkerThread = null; + } + + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void setDownloadSource(DownloadSource downloadSource) { + lastPartlistObject = downloadSource; + if (!holeListe.isSelected()) { + return; + } + + try { + if (partListWorkerThread != null) { + if (partListWorkerThread.isInterrupted()) { + partListWorkerThread = null; + } else { + partListWorkerThread.cancel(); + partListWorkerThread = null; + } + } + + partListWorkerThread = new PartListWorkerThread(); + partListWorkerThread.setDownloadSourceDO(downloadSource); + partListWorkerThread.start(); + } catch (Exception e) { + if (partListWorkerThread != null) { + partListWorkerThread.cancel(); + partListWorkerThread = null; + } + + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void fireLanguageChanged() { + try { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + label5.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.aktiveuebertragung")); + label4.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label4.caption")); + label3.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label3.caption")); + label2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label2.caption")); + label1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label1.caption")); + holeListe.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.partlisteanzeigen")); + verfuegbar = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.verfuegbar"); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private class PartListWorkerThread extends Thread { + private Object objectDO = null; + private boolean firstRun = true; + + public void run() { + while (!interrupted()) { + if (objectDO == null) { + break; + } + + boolean shortPause = false; + + if (objectDO instanceof Download) { + if (((Download) objectDO).getStatus() == Download.PAUSIERT || + ((Download) objectDO).getStatus() == Download.SUCHEN_LADEN) { + shortPause = workDownloadDO((Download) objectDO); + } else { + objectDO = null; + break; + } + } else { + shortPause = workDownloadSourceDO((DownloadSource) objectDO); + } + + if (shortPause) { + try { + sleep(5000); + firstRun = false; + continue; + } catch (InterruptedException iE) { + interrupt(); + } + } else { + break; + } + } + } + + public Object getObjectDO() { + return objectDO; + } + + private boolean workDownloadDO(Download download) { + if (download.getStatus() != Download.FERTIGSTELLEN && download.getStatus() != Download.FERTIG) { + String dateiNameText = " " + download.getFilename() + " (" + download.getTemporaryFileNumber() + ".data) "; + + if (firstRun) { + actualDLDateiName.setText(dateiNameText); + } + + PartList partList = null; + + try { + partList = AppleJuiceClient.getAjFassade().getPartList(download); + } catch (WebSiteNotFoundException wsnfE) { + // Core ist wahrscheinlich zurzeit ueberlastet + partList = null; + } + + if (partList != null && !isInterrupted()) { + String tmp = verfuegbar.replaceFirst("%s", decimalFormat.format(partList.getProzentVerfuegbar())); + + actualDLDateiName.setText(dateiNameText + " - " + tmp); + actualDlOverviewTable.setPartList(partList, new Integer(download.getId())); + } + + return true; + } else { + return false; + } + } + + private boolean workDownloadSourceDO(DownloadSource downloadSoure) { + PartList partList; + String tmp = downloadSoure.getFilename() + " (" + downloadSoure.getNickname() + ")"; + + actualDLDateiName.setText(tmp); + try { + partList = AppleJuiceClient.getAjFassade().getPartList(downloadSoure); + } catch (WebSiteNotFoundException ex) { + // Core ist wahrscheinlich zurzeit ueberlastet + partList = null; + } + + if (partList != null && !isInterrupted()) { + actualDLDateiName.setText(tmp + " - " + + verfuegbar.replaceFirst("%s", decimalFormat.format(partList.getProzentVerfuegbar()))); + actualDlOverviewTable.setPartList(partList, new Integer(downloadSoure.getId())); + } + + return false; + } + + public void setDownload(Download download) { + if (download == null) { + objectDO = null; + clear(); + } else if (objectDO != download) { + objectDO = download; + clear(); + } + } + + public void setDownloadSourceDO(DownloadSource downloadSoure) { + if (downloadSoure == null) { + objectDO = null; + clear(); + } else if (objectDO != downloadSoure) { + objectDO = downloadSoure; + clear(); + } + } + + private void clear() { + actualDLDateiName.setText(""); + actualDlOverviewTable.setPartList(null, null); + } + + public void cancel() { + interrupt(); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPanel.java new file mode 100644 index 00000000..f9c6e6b6 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPanel.java @@ -0,0 +1,450 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.download; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.TklPanel; +import de.applejuicenet.client.gui.components.table.HeaderListener; +import de.applejuicenet.client.gui.components.table.SortButtonRenderer; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.gui.download.table.*; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.tablecellrenderer.*; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; + +import javax.swing.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.awt.*; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/DownloadPanel.java,v + * 1.109 2004/06/23 12:39:15 maj0r Exp $ + * + * <p> + * Titel: AppleJuice Client-GUI + * </p> + * <p> + * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + * </p> + * <p> + * Copyright: General Public License + * </p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class DownloadPanel extends TklPanel { + private DownloadOverviewPanel downloadOverviewPanel; + private PowerDownloadPanel powerDownloadPanel; + private DownloadsTableModel downloadActiveTableModel; + private JTable downloadActiveTable; + private DownloadSourcesTableModel downloadSourceTableModel; + private JTable downloadSourceTable; + private JPopupMenu popup = new JPopupMenu(); + private JScrollPane aScrollPane; + private JMenuItem abbrechen; + private JMenuItem pause; + private JMenuItem fortsetzen; + private JMenuItem umbenennen; + private JMenuItem zielordner; + private JMenuItem fertigEntfernen; + private JMenuItem itemReleaseInfo = new JMenuItem(); + private JMenuItem itemCopyToClipboard = new JMenuItem(); + private JMenuItem itemCopyToClipboardWithSources = new JMenuItem(); + private JMenuItem itemOpenWithProgram = new JMenuItem(); + private JMenuItem itemOpenWithDefaultProgram = new JMenuItem(); + private JSplitPane splitPane; + private Logger logger; + private TableColumn[] downloadColumns = new TableColumn[DownloadsTableModel.CLASS_TYPES.length]; + private TableColumn[] downloadSourceColumns = new TableColumn[DownloadSourcesTableModel.CLASS_TYPES.length]; + private JPopupMenu columnDownloadPopup = new JPopupMenu(); + private JCheckBoxMenuItem[] columnDownloadPopupItems = new JCheckBoxMenuItem[downloadColumns.length]; + private JPopupMenu columnDownloadSourcesPopup = new JPopupMenu(); + private JCheckBoxMenuItem[] columnDownloadSourcesPopupItems = new JCheckBoxMenuItem[downloadSourceColumns.length]; + private JPopupMenu menu; + private JScrollPane downloadSourcesScrollPane; + + public DownloadPanel(GuiController guiController) { + super(guiController); + try { + downloadOverviewPanel = new DownloadOverviewPanel(this); + powerDownloadPanel = new PowerDownloadPanel((DownloadController) guiController); + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public JTable getDownloadTable() { + return downloadActiveTable; + } + + public JTable getDownloadSourceTable() { + return downloadSourceTable; + } + + public TableColumn[] getDownloadTableColumns() { + return downloadColumns; + } + + public TableColumn[] getDownloadSourcesTableColumns() { + return downloadSourceColumns; + } + + public DownloadOverviewPanel getDownloadOverviewPanel() { + return downloadOverviewPanel; + } + + public JScrollPane getScrollPane() { + return aScrollPane; + } + + public JSplitPane getSplitPane() { + return splitPane; + } + + public PowerDownloadPanel getPowerDownloadPanel() { + return powerDownloadPanel; + } + + public DownloadsTableModel getDownloadTableModel() { + return downloadActiveTableModel; + } + + public DownloadSourcesTableModel getDownloadSourcesTableModel() { + return downloadSourceTableModel; + } + + public JButton getBtnPowerDownload() { + return powerDownloadPanel.getBtnPdl(); + } + + public JRadioButton getBtnPowerDownloadInaktiv() { + return powerDownloadPanel.btnInaktiv; + } + + public JRadioButton getBtnPowerDownloadAktiv() { + return powerDownloadPanel.btnAktiv; + } + + public TKLTextField getRatioField() { + return powerDownloadPanel.ratio; + } + + public JMenuItem getMnuAbbrechen() { + return abbrechen; + } + + public JMenuItem getMnuPause() { + return pause; + } + + public JMenuItem getMnuFortsetzen() { + return fortsetzen; + } + + public JMenuItem getMnuUmbenennen() { + return umbenennen; + } + + public JMenuItem getMnuZielordner() { + return zielordner; + } + + public JMenuItem getMnuFertigeEntfernen() { + return fertigEntfernen; + } + + public JMenuItem getMnuReleaseInfo() { + return itemReleaseInfo; + } + + public JMenuItem getMnuOpenWithProgram() { + return itemOpenWithProgram; + } + + public JMenuItem getMnuOpenWithDefaultProgram() { + return itemOpenWithDefaultProgram; + } + + public JMenuItem getMnuCopyToClipboard() { + return itemCopyToClipboard; + } + + public JMenuItem getMnuCopyToClipboardWithSources() { + return itemCopyToClipboardWithSources; + } + + public JPopupMenu getPopup() { + return popup; + } + + private void init() throws Exception { + setLayout(new BorderLayout()); + JPanel topPanel = new JPanel(); + + topPanel.setLayout(new GridBagLayout()); + JPanel bottomPanel = new JPanel(); + + bottomPanel.setLayout(new BorderLayout()); + + abbrechen = new JMenuItem(); + pause = new JMenuItem(); + fortsetzen = new JMenuItem(); + umbenennen = new JMenuItem(); + zielordner = new JMenuItem(); + fertigEntfernen = new JMenuItem(); + + menu = new JPopupMenu(); + + IconManager im = IconManager.getInstance(); + + abbrechen.setIcon(im.getIcon("abbrechen")); + pause.setIcon(im.getIcon("pause")); + umbenennen.setIcon(im.getIcon("umbenennen")); + zielordner.setIcon(im.getIcon("zielordner")); + fertigEntfernen.setIcon(im.getIcon("bereinigen")); + fortsetzen.setIcon(im.getIcon("pause")); + itemReleaseInfo.setIcon(im.getIcon("hint")); + itemCopyToClipboard.setIcon(im.getIcon("clipboard")); + itemCopyToClipboardWithSources.setIcon(im.getIcon("clipboard")); + + popup.add(fortsetzen); + popup.add(pause); + popup.add(abbrechen); + popup.add(new JSeparator()); + popup.add(umbenennen); + popup.add(zielordner); + popup.add(new JSeparator()); + popup.add(fertigEntfernen); + popup.add(new JSeparator()); + popup.add(itemCopyToClipboard); + popup.add(itemCopyToClipboardWithSources); + popup.add(new JSeparator()); + popup.add(itemReleaseInfo); + popup.add(itemOpenWithProgram); + itemOpenWithProgram.setIcon(im.getIcon("vlc")); + popup.add(itemOpenWithDefaultProgram); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = 3; + constraints.gridheight = 1; + + GridBagConstraints constraints2 = new GridBagConstraints(); + + constraints2.anchor = GridBagConstraints.NORTH; + constraints2.fill = GridBagConstraints.BOTH; + constraints2.gridx = 0; + constraints2.gridy = 0; + + constraints.gridwidth = 3; + constraints.gridx = 0; + constraints.gridy = 1; + constraints.weighty = 0.4; + constraints.weightx = 1; + + downloadActiveTableModel = new DownloadsTableModel(); + downloadActiveTable = new JTable(downloadActiveTableModel); + downloadActiveTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(0).setCellRenderer(new DownloadTableDownloadFilenameCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(2).setCellRenderer(new SizeTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(3).setCellRenderer(new SizeTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(4).setCellRenderer(new SpeedTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(6).setCellRenderer(new ProgressTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(7).setCellRenderer(new SizeTableCellRenderer()); + downloadActiveTable.getColumnModel().getColumn(8).setCellRenderer(new DownloadTablePowerdownloadCellRenderer()); + + TableColumnModel model = downloadActiveTable.getColumnModel(); + SortButtonRenderer renderer = new SortButtonRenderer(); + + JTableHeader header = downloadActiveTable.getTableHeader(); + + header.setDefaultRenderer(renderer); + header.addMouseListener(new HeaderListener(header, renderer) { + private PositionManager pm = PositionManagerImpl.getInstance(); + + @Override + public void internalSort(int column, boolean ascent) { + pm.setDownloadSort(column, ascent); + + super.internalSort(column, ascent); + } + }); + for (int i = 0; i < model.getColumnCount(); i++) { + downloadColumns[i] = model.getColumn(i); + columnDownloadPopupItems[i] = new JCheckBoxMenuItem((String) downloadColumns[i].getHeaderValue()); + final int x = i; + + columnDownloadPopupItems[i].addActionListener(ae -> { + if (columnDownloadPopupItems[x].isSelected()) { + downloadActiveTable.getColumnModel().addColumn(downloadColumns[x]); + PositionManagerImpl.getInstance().setDownloadColumnVisible(x, true); + PositionManagerImpl.getInstance() + .setDownloadColumnIndex(x, + downloadActiveTable.getColumnModel().getColumnIndex(downloadColumns[x].getIdentifier())); + } else { + downloadActiveTable.getColumnModel().removeColumn(downloadColumns[x]); + PositionManagerImpl.getInstance().setDownloadColumnVisible(x, false); + for (int y = 0; y < downloadColumns.length; y++) { + try { + PositionManagerImpl.getInstance() + .setDownloadColumnIndex(y, + downloadActiveTable.getColumnModel() + .getColumnIndex(downloadColumns[y].getIdentifier())); + } catch (IllegalArgumentException niaE) { + //nix zu tun + } + } + } + }); + columnDownloadPopup.add(columnDownloadPopupItems[i]); + } + + columnDownloadPopupItems[0].setEnabled(false); + + aScrollPane = new JScrollPane(downloadActiveTable); + aScrollPane.setBackground(downloadActiveTable.getBackground()); + downloadActiveTable.getTableHeader().setBackground(downloadActiveTable.getBackground()); + aScrollPane.getViewport().setOpaque(false); + topPanel.add(aScrollPane, constraints); + + downloadSourceTableModel = new DownloadSourcesTableModel(); + downloadSourceTable = new JTable(downloadSourceTableModel); + downloadSourceTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(0).setCellRenderer(new DownloadTableFilenameCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(3).setCellRenderer(new SizeTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(4).setCellRenderer(new SizeTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(5).setCellRenderer(new SpeedTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(7).setCellRenderer(new ProgressTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(8).setCellRenderer(new SizeTableCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(9).setCellRenderer(new DownloadTablePowerdownloadCellRenderer()); + downloadSourceTable.getColumnModel().getColumn(10).setCellRenderer(new VersionTableCellRenderer()); + + renderer = new SortButtonRenderer(); + + header = downloadSourceTable.getTableHeader(); + + header.setDefaultRenderer(renderer); + header.addMouseListener(new HeaderListener(header, renderer) { + private PositionManager pm = PositionManagerImpl.getInstance(); + + @Override + public void internalSort(int column, boolean ascent) { + pm.setDownlodSourcesSort(column, ascent); + + super.internalSort(column, ascent); + } + }); + model = downloadSourceTable.getColumnModel(); + for (int i = 0; i < model.getColumnCount(); i++) { + downloadSourceColumns[i] = model.getColumn(i); + columnDownloadSourcesPopupItems[i] = new JCheckBoxMenuItem((String) downloadSourceColumns[i].getHeaderValue()); + final int x = i; + + columnDownloadSourcesPopupItems[i].addActionListener(ae -> { + if (columnDownloadSourcesPopupItems[x].isSelected()) { + downloadSourceTable.getColumnModel().addColumn(downloadSourceColumns[x]); + PositionManagerImpl.getInstance().setDownloadSourcesColumnVisible(x, true); + PositionManagerImpl.getInstance() + .setDownloadSourcesColumnIndex(x, + downloadSourceTable.getColumnModel() + .getColumnIndex(downloadSourceColumns[x].getIdentifier())); + } else { + downloadSourceTable.getColumnModel().removeColumn(downloadSourceColumns[x]); + PositionManagerImpl.getInstance().setDownloadSourcesColumnVisible(x, false); + for (int y = 0; y < downloadSourceColumns.length; y++) { + try { + PositionManagerImpl.getInstance() + .setDownloadSourcesColumnIndex(y, + downloadSourceTable.getColumnModel() + .getColumnIndex(downloadSourceColumns[y].getIdentifier())); + } catch (IllegalArgumentException niaE) { + //nix zu tun + } + } + } + }); + columnDownloadSourcesPopup.add(columnDownloadSourcesPopupItems[i]); + } + + downloadSourcesScrollPane = new JScrollPane(downloadSourceTable); + + downloadSourcesScrollPane.setBackground(downloadSourceTable.getBackground()); + downloadSourceTable.getTableHeader().setBackground(downloadSourceTable.getBackground()); + downloadSourcesScrollPane.getViewport().setOpaque(false); + + constraints.gridwidth = 3; + constraints.gridx = 0; + constraints.gridy = 2; + constraints.weighty = 0.6; + constraints.weightx = 1; + + topPanel.add(downloadSourcesScrollPane, constraints); + + constraints.gridx = 0; + constraints.gridy = 0; + constraints.weighty = 1; + + bottomPanel.add(powerDownloadPanel, BorderLayout.WEST); + bottomPanel.add(downloadOverviewPanel, BorderLayout.CENTER); + + splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); + splitPane.setBorder(null); + add(splitPane, BorderLayout.CENTER); + + downloadActiveTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + } + + public JScrollPane getDownloadSourcesScrollPane() { + return downloadSourcesScrollPane; + } + + public int[] getDownloadColumnWidths() { + int[] widths = new int[downloadColumns.length]; + + for (int i = 0; i < downloadColumns.length; i++) { + widths[i] = downloadColumns[i].getWidth(); + } + + return widths; + } + + public int[] getDownloadSourcesColumnWidths() { + int[] widths = new int[downloadSourceColumns.length]; + + for (int i = 0; i < downloadSourceColumns.length; i++) { + widths[i] = downloadSourceColumns[i].getWidth(); + } + + return widths; + } + + public JCheckBoxMenuItem[] getColumnDownloadPopupItems() { + return columnDownloadPopupItems; + } + + public JPopupMenu getColumnDownloadPopup() { + return columnDownloadPopup; + } + + public JPopupMenu getColumnDownloadSourcesPopup() { + return columnDownloadSourcesPopup; + } + + public JCheckBoxMenuItem[] getColumnDownloadSourcesPopupItems() { + return columnDownloadSourcesPopupItems; + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPartListPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPartListPanel.java new file mode 100644 index 00000000..83676ab5 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPartListPanel.java @@ -0,0 +1,457 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.download; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.DownloadSource; +import de.applejuicenet.client.fassade.entity.Part; +import de.applejuicenet.client.fassade.entity.PartList; +import de.applejuicenet.client.fassade.shared.ZeichenErsetzer; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.listener.LanguageListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; +import java.awt.image.BufferedImage; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/DownloadPartListPanel.java,v + * 1.33 2004/07/09 12:42:01 loevenwong Exp $ + * + * <p> + * Titel: AppleJuice Client-GUI + * </p> + * <p> + * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + * </p> + * <p> + * Copyright: General Public License + * </p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class DownloadPartListPanel extends JPanel implements MouseMotionListener, LanguageListener { + private static DownloadPartListPanel instance = null; + private PartList partList; + private Logger logger; + private BufferedImage image = null; + private int width; + private int height; + private long fertigSeit = -1; + private boolean miniFile = false; + private String ueberprueft; + private String nichtVorhanden; + private String vorhanden; + private String quellen; + private String uebertragen; + private MouseEvent savedMouseEvent = null; + private Integer id = null; + private int zeilenHoehe; + private int pixelSize; + private BufferedImage lineImage; + + private DownloadPartListPanel() { + super(new BorderLayout()); + logger = LoggerFactory.getLogger(getClass()); + addMouseMotionListener(this); + LanguageSelector.getInstance().addLanguageListener(this); + } + + public static synchronized DownloadPartListPanel getInstance() { + if (instance == null) { + instance = new DownloadPartListPanel(); + } + + return instance; + } + + public void paintComponent(Graphics g) { + if (partList != null && image != null) { + if (height != (int) getSize().height || width != (int) getSize().width) { + setPartList(partList, id); + } + + g.setColor(getBackground()); + g.fillRect(0, 0, width, height); + if (image != null) { + g.drawImage(image, 0, 0, null); + } + } else { + super.paintComponent(g); + } + } + + private void updatePanel() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + updateUI(); + } + }); + } + + public synchronized void setPartList(PartList newPartList, Integer newId) { + try { + if (newPartList == null || newId == null) { + partList = null; + lineImage = null; + image = null; + savedMouseEvent = null; + updatePanel(); + return; + } + + boolean idChanged = false; + + if (id == null) { + idChanged = true; + id = newId; + } + + if (id.longValue() != newId.longValue()) { + idChanged = true; + } + + boolean redraw = false; + + if (idChanged) { + id = newId; + partList = null; + } else if (partList != null && newPartList != null) { + if (height != getSize().height || width != getSize().width) { + redraw = true; + } + + if (!redraw) { + Part[] parts = partList.getParts(); + Part[] newParts = newPartList.getParts(); + + if (parts.length == newParts.length) { + boolean sameParts = true; + + for (int i = 0; i < parts.length; i++) { + if (!parts[i].equals(newParts[i])) { + sameParts = false; + break; + } + } + + if (sameParts) { + insertSources(partList, lineImage); + updatePanel(); + return; + } + } + } + } + + partList = newPartList; + height = getSize().height; + width = getSize().width; + if (partList != null && partList.getGroesse() > 0 && partList.getParts().length > 0) { + Part[] parts = partList.getParts(); + + zeilenHoehe = 15; + int zeilen = height / zeilenHoehe; + + miniFile = false; + pixelSize = (int) (partList.getGroesse() / (zeilen * width)); + if (pixelSize == 0) { + pixelSize = (int) ((zeilen * width) / partList.getGroesse()); + miniFile = true; + } + + lineImage = new BufferedImage(width * zeilen, 15, BufferedImage.TYPE_INT_ARGB); + Graphics graphics = lineImage.getGraphics(); + int obenLinks = 0; + int breite = 0; + + fertigSeit = -1; + for (int i = 0; i < parts.length - 1; i++) { + drawPart(false, (partList.getPartListType() == PartList.MAIN_PARTLIST), graphics, pixelSize, parts[i].getType(), + zeilenHoehe, parts[i].getFromPosition(), parts[i + 1].getFromPosition()); + } + + drawPart(true, (partList.getPartListType() == PartList.MAIN_PARTLIST), graphics, pixelSize, + parts[parts.length - 1].getType(), zeilenHoehe, parts[parts.length - 1].getFromPosition(), + partList.getGroesse()); + BufferedImage imgWithSources = insertSources(partList, lineImage); + + if (savedMouseEvent != null) { + processMouseMotionEvent(savedMouseEvent); + } + } else { + image = null; + savedMouseEvent = null; + } + } catch (Exception e) { + logger.debug(ApplejuiceFassade.ERROR_MESSAGE, e); + partList = null; + lineImage = null; + image = null; + savedMouseEvent = null; + } + + updatePanel(); + } + + private BufferedImage insertSources(PartList partList, BufferedImage sourceImage) { + BufferedImage imageWithSources = new BufferedImage(sourceImage.getWidth(), 15, BufferedImage.TYPE_INT_ARGB); + Graphics graphics = imageWithSources.getGraphics(); + + graphics.drawImage(sourceImage.getSubimage(0, 0, sourceImage.getWidth(), zeilenHoehe), 0, 0, null); + int obenLinks; + int breite; + + if (partList.getPartListType() == PartList.MAIN_PARTLIST) { + Download download = (Download) partList.getValueObject(); + + if (download.getStatus() == Download.SUCHEN_LADEN) { + for (DownloadSource curSource : download.getSources()) { + if (curSource.getStatus() == DownloadSource.UEBERTRAGUNG) { + if (!miniFile) { + obenLinks = curSource.getDownloadFrom() / pixelSize; + breite = (curSource.getDownloadTo() / pixelSize) - obenLinks; + } else { + obenLinks = curSource.getDownloadFrom() * pixelSize; + breite = (curSource.getDownloadTo() * pixelSize) - obenLinks; + } + + graphics.setColor(getColorByPercent(curSource.getReadyPercent())); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + } + } + } + } else { + DownloadSource downloadSource = (DownloadSource) partList.getValueObject(); + + if (downloadSource.getStatus() == DownloadSource.UEBERTRAGUNG) { + if (!miniFile) { + obenLinks = downloadSource.getDownloadFrom() / pixelSize; + breite = (downloadSource.getDownloadTo() / pixelSize) - obenLinks; + } else { + obenLinks = downloadSource.getDownloadFrom() * pixelSize; + breite = (downloadSource.getDownloadTo() * pixelSize) - obenLinks; + } + + graphics.setColor(getColorByPercent(downloadSource.getReadyPercent())); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + } + } + + image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); + Graphics g = image.getGraphics(); + int x = 0; + int zeilen = height / zeilenHoehe; + + for (int i = 0; i < zeilen; i++) { + g.drawImage(imageWithSources.getSubimage(x, 0, width, zeilenHoehe), 0, i * zeilenHoehe, null); + x += width; + } + + return imageWithSources; + } + + private void drawPart(boolean forceDraw, boolean isMainList, Graphics graphics, int pixelSize, int partType, int zeilenHoehe, + long currentFrom, long nextFrom) { + int obenLinks = 0; + int breite = 0; + + if (isMainList) { + if (partType == -1 && !forceDraw) { + if (fertigSeit != -1) { + return; + } else { + fertigSeit = currentFrom; + } + } else { + if (fertigSeit != -1) { + obenLinks = (int) (fertigSeit / pixelSize); + int mbCount = (int) (currentFrom - fertigSeit) / 1048576; + + breite = mbCount * 1048576 / pixelSize; + graphics.setColor(PartList.COLOR_TYPE_UEBERPRUEFT); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + obenLinks += breite; + breite = (int) (currentFrom / pixelSize) - obenLinks; + if (partType == -1 || forceDraw) { + graphics.setColor(PartList.COLOR_TYPE_UEBERPRUEFT); + } else { + graphics.setColor(PartList.COLOR_TYPE_OK); + } + + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + obenLinks = (int) currentFrom / pixelSize; + breite = (int) (nextFrom / pixelSize) - obenLinks; + graphics.setColor(getColorByType(partType)); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + fertigSeit = -1; + } else { + if (!miniFile) { + obenLinks = (int) (currentFrom / pixelSize); + breite = (int) (nextFrom / pixelSize) - obenLinks; + } else { + obenLinks = (int) (currentFrom * pixelSize); + breite = (int) (nextFrom * pixelSize) - obenLinks; + } + + graphics.setColor(getColorByType(partType)); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + } + } + } else { + if (!miniFile) { + obenLinks = (int) (currentFrom / pixelSize); + breite = (int) (nextFrom / pixelSize) - obenLinks; + } else { + obenLinks = (int) (currentFrom * pixelSize); + breite = (int) (nextFrom * pixelSize) - obenLinks; + } + + graphics.setColor(getColorByType(partType)); + graphics.fillRect(obenLinks, 0, breite, zeilenHoehe); + } + } + + private Color getColorByType(int type) { + switch (type) { + + case -1: + return PartList.COLOR_TYPE_OK; + + case 0: + return PartList.COLOR_TYPE_0; + + case 1: + return PartList.COLOR_TYPE_1; + + case 2: + return PartList.COLOR_TYPE_2; + + case 3: + return PartList.COLOR_TYPE_3; + + case 4: + return PartList.COLOR_TYPE_4; + + case 5: + return PartList.COLOR_TYPE_5; + + case 6: + return PartList.COLOR_TYPE_6; + + case 7: + return PartList.COLOR_TYPE_7; + + case 8: + return PartList.COLOR_TYPE_8; + + case 9: + return PartList.COLOR_TYPE_9; + + case 10: + return PartList.COLOR_TYPE_10; + + default: + return PartList.COLOR_TYPE_10; + } + } + + private Color getColorByPercent(double percent) { + if (percent < 10) { + return PartList.COLOR_READY_10; + } else if (percent < 30) { + return PartList.COLOR_READY_30; + } else if (percent < 50) { + return PartList.COLOR_READY_50; + } else if (percent < 70) { + return PartList.COLOR_READY_70; + } else if (percent < 90) { + return PartList.COLOR_READY_90; + } else { + return PartList.COLOR_READY_100; + } + } + + public void mouseDragged(MouseEvent mouseEvent) { + } + + public void mouseMoved(MouseEvent mouseEvent) { + if (image != null) { + savedMouseEvent = mouseEvent; + Point p = mouseEvent.getPoint(); + + try { + int rgb = image.getRGB((int) p.getX(), (int) p.getY()); + + if (rgb == PartList.COLOR_TYPE_UEBERPRUEFT.getRGB()) { + setToolTipText(ueberprueft); + } else if (rgb == PartList.COLOR_TYPE_0.getRGB()) { + setToolTipText(nichtVorhanden); + } else if (rgb == PartList.COLOR_TYPE_OK.getRGB()) { + setToolTipText(vorhanden); + } else if (rgb == PartList.COLOR_TYPE_1.getRGB()) { + setToolTipText("1" + quellen); + } else if (rgb == PartList.COLOR_TYPE_2.getRGB()) { + setToolTipText("2" + quellen); + } else if (rgb == PartList.COLOR_TYPE_3.getRGB()) { + setToolTipText("3" + quellen); + } else if (rgb == PartList.COLOR_TYPE_4.getRGB()) { + setToolTipText("4" + quellen); + } else if (rgb == PartList.COLOR_TYPE_5.getRGB()) { + setToolTipText("5" + quellen); + } else if (rgb == PartList.COLOR_TYPE_6.getRGB()) { + setToolTipText("6" + quellen); + } else if (rgb == PartList.COLOR_TYPE_7.getRGB()) { + setToolTipText("7" + quellen); + } else if (rgb == PartList.COLOR_TYPE_8.getRGB()) { + setToolTipText("8" + quellen); + } else if (rgb == PartList.COLOR_TYPE_9.getRGB()) { + setToolTipText("9" + quellen); + } else if (rgb == PartList.COLOR_TYPE_10.getRGB()) { + setToolTipText("10+" + quellen); + } else if (rgb == PartList.COLOR_READY_10.getRGB()) { + setToolTipText("0-10" + uebertragen); + } else if (rgb == PartList.COLOR_READY_30.getRGB()) { + setToolTipText("10-30" + uebertragen); + } else if (rgb == PartList.COLOR_READY_50.getRGB()) { + setToolTipText("30-50" + uebertragen); + } else if (rgb == PartList.COLOR_READY_70.getRGB()) { + setToolTipText("50-70" + uebertragen); + } else if (rgb == PartList.COLOR_READY_90.getRGB()) { + setToolTipText("70-90" + uebertragen); + } else if (rgb == PartList.COLOR_READY_100.getRGB()) { + setToolTipText("90-100" + uebertragen); + } else { + setToolTipText(null); + } + } catch (ArrayIndexOutOfBoundsException aoobE) { + setToolTipText(null); + } + } else { + setToolTipText(null); + } + } + + public void fireLanguageChanged() { + try { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + vorhanden = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label4.caption")); + nichtVorhanden = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label3.caption")); + ueberprueft = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("mainform.Label1.caption")); + quellen = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.quellen")); + uebertragen = ZeichenErsetzer.korrigiereUmlaute(languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.uebertragen")); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPartListWatcher.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPartListWatcher.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPartListWatcher.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPartListWatcher.java diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPropertyChangeListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPropertyChangeListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/DownloadPropertyChangeListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/DownloadPropertyChangeListener.java diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/PowerDownloadPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/PowerDownloadPanel.java new file mode 100644 index 00000000..4fbdbfc0 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/PowerDownloadPanel.java @@ -0,0 +1,668 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.download; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.Information; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.gui.powerdownload.AutomaticPowerdownloadPolicy; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.MultiLineToolTip; +import de.applejuicenet.client.shared.NumberInputVerifier; +import de.applejuicenet.client.shared.PolicyJarClassLoader; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.lang.reflect.Constructor; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/download/PowerDownloadPanel.java,v 1.20 2009/01/26 13:31:36 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class PowerDownloadPanel extends JPanel implements LanguageListener, DataUpdateListener { + private final Color BLUE_BACKGROUND = new Color(118, 112, 148); + public JRadioButton btnInaktiv = new JRadioButton(); + public JRadioButton btnAktiv = new JRadioButton(); + private JRadioButton btnAutoInaktiv = new JRadioButton(); + private JRadioButton btnAutoAktiv = new JRadioButton(); + private JLabel btnHint; + private JLabel btnHint2; + private JLabel btnHint3; + private JLabel btnPdlUp; + private JLabel btnPdlDown; + private float ratioWert = 2.2f; + public TKLTextField ratio = new TKLTextField("2.2"); + private TKLTextField autoAb = new TKLTextField(); + private TKLTextField autoBis = new TKLTextField(); + private JButton btnPdl = new JButton(); + private JButton btnAutoPdl = new JButton(); + private JLabel powerdownload = new JLabel(); + private JLabel label6 = new JLabel(); + private JLabel label7 = new JLabel(); + private JLabel label8 = new JLabel(); + private JLabel label9 = new JLabel(); + private JLabel label10 = new JLabel(); + private JLabel label11 = new JLabel(); + private Logger logger; + private RatioFocusAdapter ratioFocusAdapter; + private JComboBox pwdlPolicies = new JComboBox(); + private JButton autoPwdlEinstellungen = new JButton(); + private int standardAutomaticPwdlAb = 200; + private int standardAutomaticPwdlBis = 30; + private DownloadController downloadController; + private AutomaticPowerdownloadPolicy autoPwdlThread; + private Information lastInformation; + private JPanel backPanel = new JPanel(); + + public PowerDownloadPanel(DownloadController downloadController) { + logger = LoggerFactory.getLogger(getClass()); + try { + this.downloadController = downloadController; + btnPdl.setEnabled(false); + init(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + private void init() throws Exception { + ratio.disableDirtyComponent(true); + autoAb.disableDirtyComponent(true); + autoBis.disableDirtyComponent(true); + setLayout(new BorderLayout()); + LanguageSelector.getInstance().addLanguageListener(this); + backPanel.setLayout(new GridBagLayout()); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridheight = 1; + constraints.gridwidth = 3; + JPanel tempPanel = new JPanel(); + + tempPanel.setLayout(new BorderLayout()); + powerdownload.setForeground(Color.white); + powerdownload.setOpaque(true); + powerdownload.setBackground(BLUE_BACKGROUND); + ratioFocusAdapter = new RatioFocusAdapter(); + ratio.addFocusListener(ratioFocusAdapter); + ratio.setBackground(Color.white); + ratio.setMinimumSize(new Dimension(50, 21)); + ratio.setPreferredSize(new Dimension(50, 21)); + ratio.setHorizontalAlignment(SwingConstants.RIGHT); + KeyAdapter ratioKlicker = new KeyAdapter() { + public void keyPressed(KeyEvent ke) { + switch (ke.getKeyCode()) { + + case KeyEvent.VK_ENTER: { + ratioFocusAdapter.focusLost(null); + btnPdl.doClick(); + break; + } + + case KeyEvent.VK_UP: { + btnAktiv.setSelected(true); + alterRatio(true); + break; + } + + case KeyEvent.VK_DOWN: { + btnAktiv.setSelected(true); + alterRatio(false); + break; + } + + default: + break; + } + } + }; + + btnInaktiv.addKeyListener(ratioKlicker); + btnAktiv.addKeyListener(ratioKlicker); + ratio.addKeyListener(ratioKlicker); + + tempPanel.add(powerdownload, BorderLayout.CENTER); + + IconManager im = IconManager.getInstance(); + ImageIcon icon = im.getIcon("hint"); + + btnHint = new JLabel(icon) { + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + }; + btnHint.setOpaque(true); + btnHint.setBackground(BLUE_BACKGROUND); + tempPanel.add(btnHint, BorderLayout.EAST); + backPanel.add(tempPanel, constraints); + constraints.insets.left = 5; + constraints.insets.right = 5; + constraints.gridy = 1; + backPanel.add(label6, constraints); + constraints.gridwidth = 1; + constraints.gridy = 2; + ButtonGroup buttonGroup = new ButtonGroup(); + + buttonGroup.add(btnInaktiv); + buttonGroup.add(btnAktiv); + btnInaktiv.setSelected(true); + backPanel.add(btnInaktiv, constraints); + constraints.gridy = 3; + backPanel.add(btnAktiv, constraints); + + JPanel tempPanel3 = new JPanel(new GridBagLayout()); + GridBagConstraints constraints2 = new GridBagConstraints(); + + constraints2.anchor = GridBagConstraints.NORTH; + constraints2.fill = GridBagConstraints.BOTH; + constraints2.gridx = 0; + constraints2.gridy = 0; + + tempPanel3.add(label7, constraints2); + ImageIcon icon2 = im.getIcon("increase"); + + btnPdlUp = new JLabel(icon2); + ImageIcon icon3 = im.getIcon("decrease"); + + btnPdlDown = new JLabel(icon3); + + btnPdlUp.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + btnAktiv.setSelected(true); + alterRatio(true); + } + }); + btnPdlDown.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + btnAktiv.setSelected(true); + alterRatio(false); + } + }); + constraints2.gridx = 1; + tempPanel3.add(btnPdlDown, constraints2); + constraints2.gridx = 2; + tempPanel3.add(ratio, constraints2); + constraints2.gridx = 3; + tempPanel3.add(btnPdlUp, constraints2); + constraints2.gridx = 4; + constraints2.insets.left = 5; + tempPanel3.add(label8, constraints2); + + constraints.gridy = 4; + backPanel.add(tempPanel3, constraints); + constraints.gridy = 5; + constraints.gridwidth = 3; + backPanel.add(btnPdl, constraints); + + constraints.gridy = 6; + backPanel.add(new JLabel(" "), constraints); + constraints.gridx = 0; + constraints.gridy = 7; + constraints.gridheight = 1; + constraints.gridwidth = 3; + JPanel tempPanel2 = new JPanel(); + + tempPanel2.setLayout(new BorderLayout()); + label9.setForeground(Color.white); + label9.setOpaque(true); + label9.setBackground(BLUE_BACKGROUND); + tempPanel2.add(label9, BorderLayout.CENTER); + btnHint2 = new JLabel(icon) { + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + }; + btnHint2.setOpaque(true); + btnHint2.setBackground(BLUE_BACKGROUND); + btnHint3 = new JLabel(icon) { + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + }; + tempPanel2.add(btnHint2, BorderLayout.EAST); + constraints.insets.left = 0; + constraints.insets.right = 0; + backPanel.add(tempPanel2, constraints); + constraints.insets.left = 5; + constraints.insets.right = 5; + + constraints.gridwidth = 1; + constraints.gridy = 8; + ButtonGroup buttonGroup2 = new ButtonGroup(); + + buttonGroup2.add(btnAutoInaktiv); + buttonGroup2.add(btnAutoAktiv); + btnAutoInaktiv.setSelected(true); + pwdlPolicies.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + AutomaticPowerdownloadPolicy policy = (AutomaticPowerdownloadPolicy) pwdlPolicies.getSelectedItem(); + StringBuffer text = new StringBuffer(policy.getDescription()); + int i = 0; + + while (i < text.length()) { + if (text.charAt(i) == '.') { + text.insert(i + 1, '|'); + i++; + } + + i++; + } + + text.insert(0, policy.toString() + "|" + "Autor: " + policy.getAuthor() + "|" + "Beschreibung:|"); + btnHint3.setToolTipText(text.toString()); + } + }); + fillPwdlPolicies(); + JPanel panel1 = new JPanel(new FlowLayout()); + + panel1.add(pwdlPolicies); + panel1.add(btnHint3); + backPanel.add(panel1, constraints); + constraints.insets.left = 0; + constraints.insets.right = 0; + JPanel panel2 = new JPanel(new GridBagLayout()); + + constraints.gridy = 0; + panel2.add(btnAutoInaktiv, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel2.add(new JLabel(), constraints); + constraints.weightx = 0; + constraints.gridx = 2; + panel2.add(autoPwdlEinstellungen, constraints); + constraints.gridx = 0; + constraints.gridy = 9; + constraints.insets.left = 5; + constraints.insets.right = 5; + backPanel.add(panel2, constraints); + constraints.gridy = 10; + backPanel.add(btnAutoAktiv, constraints); + constraints.gridy = 11; + JPanel panel = new JPanel(new FlowLayout()); + + panel.add(label10); + autoAb.setDocument(new NumberInputVerifier()); + autoAb.setPreferredSize(new Dimension(40, 21)); + autoAb.setText(Integer.toString(standardAutomaticPwdlAb)); + autoBis.setDocument(new NumberInputVerifier()); + autoBis.setPreferredSize(new Dimension(40, 21)); + autoBis.setText(Integer.toString(standardAutomaticPwdlBis)); + autoAb.addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent fe) { + int eingegeben = Integer.parseInt(autoAb.getText()); + + if (eingegeben < Integer.parseInt(autoBis.getText())) { + autoAb.setText(Integer.toString(standardAutomaticPwdlAb)); + } + } + }); + autoBis.addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent fe) { + int eingegeben = Integer.parseInt(autoBis.getText()); + + if (eingegeben < standardAutomaticPwdlBis || eingegeben > Integer.parseInt(autoAb.getText())) { + autoBis.setText(Integer.toString(standardAutomaticPwdlBis)); + } + } + }); + panel.add(autoAb); + panel.add(new JLabel("MB ")); + panel.add(label11); + panel.add(autoBis); + panel.add(new JLabel("MB ")); + backPanel.add(panel, constraints); + constraints.gridy = 12; + constraints.gridwidth = 3; + constraints.insets.bottom = 5; + backPanel.add(btnAutoPdl, constraints); + btnAutoPdl.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + alterAutoPwdl(); + } + }); + + JScrollPane sp = new JScrollPane(backPanel); + + sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + add(sp, BorderLayout.NORTH); + autoPwdlEinstellungen.setVisible(false); + autoPwdlEinstellungen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + oeffneAutomPwdlEinstellungen(); + } + }); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); + } + + public void setPwdlValue(int pwdlValue) { + if (pwdlValue < 12) { + ratio.setText("2.2"); + ratioWert = 2.2f; + btnInaktiv.setSelected(true); + } else { + float wert = (float) ((float) (pwdlValue + 10) / 10); + + ratio.setText(Float.toString(wert)); + ratioWert = wert; + btnAktiv.setSelected(true); + } + } + + private void alterAutoPwdl() { + if (btnAutoAktiv.isSelected()) { + if (pwdlPolicies.isEnabled()) { + pwdlPolicies.setEnabled(false); + autoAb.setEnabled(false); + autoBis.setEnabled(false); + btnPdl.setEnabled(false); + AutomaticPowerdownloadPolicy selectedPolicy = (AutomaticPowerdownloadPolicy) pwdlPolicies.getSelectedItem(); + + manageAutoPwdl(selectedPolicy); + AppleJuiceDialog.getApp().informAutomaticPwdlEnabled(true); + } + } else { + if (!pwdlPolicies.isEnabled()) { + pwdlPolicies.setEnabled(true); + autoAb.setEnabled(true); + autoBis.setEnabled(true); + if (autoPwdlThread != null) { + autoPwdlThread.interrupt(); + autoPwdlThread = null; + } + } + } + } + + public boolean isAutomaticPwdlActive() { + return (!pwdlPolicies.isEnabled() && autoPwdlThread != null); + } + + @SuppressWarnings("unchecked") + private void manageAutoPwdl(final AutomaticPowerdownloadPolicy selectedPolicy) { + if (autoPwdlThread != null) { + autoPwdlThread.interrupt(); + autoPwdlThread = null; + } + + AutomaticPowerdownloadPolicy policy = null; + + try { + Constructor con = selectedPolicy.getClass().getConstructor(new Class[]{ApplejuiceFassade.class}); + + policy = (AutomaticPowerdownloadPolicy) con.newInstance(new Object[]{AppleJuiceClient.getAjFassade()}); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + autoPwdlThread = policy; + autoPwdlThread.setParentToInform(this); + checkForPause(autoPwdlThread); + autoPwdlThread.start(); + autoPwdlEinstellungen.setVisible(autoPwdlThread.hasPropertiesDialog()); + } + + private void checkForPause(AutomaticPowerdownloadPolicy pwdlThread) { + long eingegebenBis = Integer.parseInt(autoBis.getText()) * 1048576L; + long eingegebenAb = Integer.parseInt(autoAb.getText()) * 1048576L; + + if (lastInformation == null) { + lastInformation = AppleJuiceClient.getAjFassade().getInformation(); + } + + if (lastInformation.getCredits() < eingegebenBis) { + pwdlThread.setPaused(true); + } + } + + private void oeffneAutomPwdlEinstellungen() { + if (autoPwdlThread != null && autoPwdlThread.hasPropertiesDialog()) { + try { + autoPwdlThread.showPropertiesDialog(AppleJuiceDialog.getApp()); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + } + } + + public void autoPwdlFinished() { + autoPwdlEinstellungen.setVisible(false); + autoPwdlThread = null; + btnAutoInaktiv.setSelected(true); + btnAutoPdl.doClick(); + AppleJuiceDialog.getApp().informAutomaticPwdlEnabled(false); + } + + public Dimension getPreferredSize() { + return backPanel.getPreferredSize(); + } + + private void fillPwdlPolicies() { + AutomaticPowerdownloadPolicy[] policies = loadPolicies(); + + for (int i = 0; i < policies.length; i++) { + pwdlPolicies.addItem(policies[i]); + } + + if (pwdlPolicies.getItemCount() > 0) { + pwdlPolicies.setSelectedIndex(0); + } + } + + private AutomaticPowerdownloadPolicy[] loadPolicies() { + try { + String path = System.getProperty("user.dir") + File.separator + "pwdlpolicies" + File.separator; + File policyPath = new File(path); + + if (!policyPath.isDirectory()) { + logger.info("Warnung: Kein Verzeichnis 'pwdlpolicies' vorhanden!"); + + return new AutomaticPowerdownloadPolicy[0]; + } + + String[] tempListe = policyPath.list(); + PolicyJarClassLoader jarLoader = null; + ArrayList<AutomaticPowerdownloadPolicy> policies = new ArrayList<AutomaticPowerdownloadPolicy>(); + + for (int i = 0; i < tempListe.length; i++) { + if (tempListe[i].toLowerCase().endsWith(".jar")) { + URL url = null; + + try { + url = new URL("file://" + path + tempListe[i]); + jarLoader = new PolicyJarClassLoader(url); + AutomaticPowerdownloadPolicy aPolicy = jarLoader.getPolicy(path + tempListe[i]); + + if (aPolicy != null) { + policies.add(aPolicy); + } + } catch (Exception e) { + //Von einer Policy lassen wir uns nicht beirren! ;-) + logger.error("Eine PowerdownloadPolicy konnte nicht instanziert werden", e); + continue; + } + } + } + + return (AutomaticPowerdownloadPolicy[]) policies.toArray(new AutomaticPowerdownloadPolicy[policies.size()]); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + return new AutomaticPowerdownloadPolicy[0]; + } + } + + private void alterRatio(boolean increase) { + try { + String temp = ratio.getText(); + int pos = temp.indexOf('.'); + int ganzZahl; + int nachKomma; + + if (pos == -1) { + ganzZahl = Integer.parseInt(temp); + nachKomma = 0; + } else { + ganzZahl = Integer.parseInt(temp.substring(0, pos)); + nachKomma = Integer.parseInt(temp.substring(pos + 1)); + } + + if (increase) { + if (ratioWert < 50f) { + if (nachKomma == 9) { + nachKomma = 0; + ganzZahl += 1; + } else { + nachKomma += 1; + } + } else { + return; + } + } else { + if (ratioWert > 2.2f) { + if (nachKomma == 0) { + nachKomma = 9; + ganzZahl -= 1; + } else { + nachKomma -= 1; + } + } else { + return; + } + } + + ratio.setText(ganzZahl + "." + nachKomma); + ratioWert = Float.parseFloat(ratio.getText()); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public void fireLanguageChanged() { + try { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + powerdownload.setText(" " + languageSelector.getFirstAttrbuteByTagName("mainform.powerdownload.caption")); + label6.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label6.caption")); + btnInaktiv.setText(languageSelector.getFirstAttrbuteByTagName("mainform.powerinactive.caption")); + btnAktiv.setText(languageSelector.getFirstAttrbuteByTagName("mainform.poweractive.caption")); + label7.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label7.caption")); + label8.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label8.caption")); + label9.setText(" " + languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.label1")); + btnAutoInaktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.rbInaktiv")); + btnAutoAktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.rbAktiv")); + label10.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.pdlAb")); + label11.setText(languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.pdlBis")); + String ok = languageSelector.getFirstAttrbuteByTagName("javagui.downloadtab.btnOK"); + + btnAutoPdl.setText(ok); + btnPdl.setText(ok); + btnHint.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.tooltipps.powerdownload")); + btnHint2.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.tooltipps.autopowerdownload")); + autoPwdlEinstellungen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.einstellungen")); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + @SuppressWarnings("unchecked") + public void fireContentChanged(DATALISTENER_TYPE type, Object content) { + try { + if (type == DATALISTENER_TYPE.INFORMATION_CHANGED) { + lastInformation = (Information) content; + if (autoPwdlThread != null && lastInformation != null) { + long eingegebenBis = Long.parseLong(autoBis.getText()) * 1048576L; + long eingegebenAb = Long.parseLong(autoAb.getText()) * 1048576L; + + if (lastInformation.getCredits() > eingegebenAb) { + autoPwdlThread.setPaused(false); + } else if (lastInformation.getCredits() < eingegebenBis) { + autoPwdlThread.setPaused(true); + } + } + } else if (type == DATALISTENER_TYPE.DOWNLOAD_CHANGED && autoPwdlThread != null && autoPwdlThread.isPaused()) { + HashMap<String, Download> downloads = (HashMap<String, Download>) content; + + synchronized (downloads) { + List<Download> toPause = new Vector<Download>(); + + for (Download curDownload : downloads.values()) { + if (curDownload.getStatus() == Download.SUCHEN_LADEN) { + toPause.add(curDownload); + } + } + + AppleJuiceClient.getAjFassade().pauseDownload(toPause); + } + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public JButton getBtnPdl() { + return btnPdl; + } + + private class RatioFocusAdapter extends FocusAdapter { + public void focusLost(FocusEvent fe) { + try { + String temp = ratio.getText(); + + temp = temp.replaceAll(",", "."); + int pos = temp.lastIndexOf('.'); + + if (pos != -1) { + temp = temp.substring(0, pos + 2); + } + + double pwdl = new Double(temp).doubleValue(); + + if (pwdl < 2.2 || pwdl > 50) { + ratio.setText("2.2"); + } else { + ratio.setText(temp); + } + + btnAktiv.setSelected(true); + } catch (Exception ex) { + ratio.setText("2.2"); + } + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/RenameDownloadDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/RenameDownloadDialog.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/RenameDownloadDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/RenameDownloadDialog.java index f2229a8e..b37634d7 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/RenameDownloadDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/RenameDownloadDialog.java @@ -4,32 +4,20 @@ package de.applejuicenet.client.gui.download; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.HashSet; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.tklsoft.gui.controls.TKLComboBox; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.HashSet; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/download/RenameDownloadDialog.java,v 1.10 2009/01/12 09:19:20 maj0r Exp $ * @@ -37,7 +25,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class RenameDownloadDialog extends JDialog diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java index c5444755..43e9f254 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadMouseMotionListener.java @@ -4,11 +4,11 @@ package de.applejuicenet.client.gui.download.table; +import de.applejuicenet.client.gui.components.GuiController; + import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -import de.applejuicenet.client.gui.components.GuiController; - public class DownloadMouseMotionListener extends MouseMotionAdapter { private GuiController guiController; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java index 1d3cfc49..bd923e39 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadSourcesTableModel.java @@ -4,12 +4,6 @@ package de.applejuicenet.client.gui.download.table; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.table.AbstractTableModel; - import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.fassade.entity.Version; @@ -18,6 +12,11 @@ import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; +import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class DownloadSourcesTableModel extends AbstractTableModel implements LanguageListener, SortableTableModel<DownloadSource> { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java index fcc49af1..12223a31 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableDownloadFilenameCellRenderer.java @@ -4,17 +4,14 @@ package de.applejuicenet.client.gui.download.table; -import java.awt.Color; -import java.awt.Component; - -import javax.swing.JLabel; -import javax.swing.JTable; - import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.listener.DataUpdateListener; import de.applejuicenet.client.gui.controller.OptionsManagerImpl; import de.applejuicenet.client.shared.Settings; +import javax.swing.*; +import java.awt.*; + public class DownloadTableDownloadFilenameCellRenderer extends DownloadTableFilenameCellRenderer implements DataUpdateListener { private Settings settings; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java similarity index 89% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java index db7d06f7..63c4e0bd 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableFilenameCellRenderer.java @@ -4,16 +4,13 @@ package de.applejuicenet.client.gui.download.table; -import java.awt.Component; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.shared.FileType; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + public class DownloadTableFilenameCellRenderer extends DefaultTableCellRenderer { @Override diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java similarity index 92% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java index 40dfe1db..51f22b77 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTablePowerdownloadCellRenderer.java @@ -4,11 +4,9 @@ package de.applejuicenet.client.gui.download.table; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; public class DownloadTablePowerdownloadCellRenderer extends DefaultTableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java index 7aa4bd04..eb3fe01f 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadTableStatusCellRenderer.java @@ -4,16 +4,15 @@ package de.applejuicenet.client.gui.download.table; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + public class DownloadTableStatusCellRenderer extends DefaultTableCellRenderer implements LanguageListener { public static String suchen = ""; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java similarity index 92% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java index 4ba59504..f350ca5e 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadToolTipUI.java @@ -4,20 +4,13 @@ package de.applejuicenet.client.gui.download.table; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; - +import javax.swing.*; +import javax.swing.plaf.metal.MetalToolTipUI; +import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import javax.swing.JComponent; -import javax.swing.JToolTip; -import javax.swing.SwingUtilities; -import javax.swing.plaf.metal.MetalToolTipUI; - public class DownloadToolTipUI extends MetalToolTipUI { private String[] strs; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java index a48589b1..1a40032b 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/download/table/DownloadsTableModel.java @@ -3,12 +3,6 @@ */ package de.applejuicenet.client.gui.download.table; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.table.AbstractTableModel; - import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.gui.components.table.SortableTableModel; @@ -16,6 +10,11 @@ import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; +import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class DownloadsTableModel extends AbstractTableModel implements LanguageListener, SortableTableModel<Download> { diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajfspURIHandler.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajfspURIHandler.java new file mode 100644 index 00000000..151ff533 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajfspURIHandler.java @@ -0,0 +1,20 @@ +package de.applejuicenet.client.gui.handler; + +import de.applejuicenet.client.AppleJuiceClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.desktop.OpenURIEvent; +import java.awt.desktop.OpenURIHandler; + +public class ajfspURIHandler implements OpenURIHandler { + + @Override + public void openURI(OpenURIEvent e) { + String ajfsp = e.getURI().toString(); + Logger logger = LoggerFactory.getLogger(getClass()); + logger.debug("ajfsp Link gefunden: " + ajfsp); + + AppleJuiceClient.linkListener.processLink(ajfsp, ""); + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajlFileHandler.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajlFileHandler.java new file mode 100644 index 00000000..4c26eb84 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/handler/ajlFileHandler.java @@ -0,0 +1,26 @@ +package de.applejuicenet.client.gui.handler; + +import de.applejuicenet.client.gui.AppleJuiceDialog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.desktop.OpenFilesEvent; +import java.awt.desktop.OpenFilesHandler; +import java.io.File; + +public class ajlFileHandler implements OpenFilesHandler { + + @Override + public void openFiles(OpenFilesEvent e) { + Logger logger = LoggerFactory.getLogger(getClass()); + + for (File inputFile : e.getFiles()) { + if (inputFile.getName().endsWith(".ajl")) { + logger.debug("AJL Datei " + inputFile.getName() + " gefunden"); + new AppleJuiceDialog().importAjl(inputFile, ""); + } else { + logger.debug("Die Datei " + inputFile.getName() + " ist keine .ajl Datei"); + } + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/listener/LanguageListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/listener/LanguageListener.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/listener/LanguageListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/listener/LanguageListener.java index d9919591..e8eb146c 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/listener/LanguageListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/listener/LanguageListener.java @@ -7,10 +7,10 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface LanguageListener { public void fireLanguageChanged(); -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java index bd2a2424..5dbca192 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java @@ -39,19 +39,13 @@ package de.applejuicenet.client.gui.memorymonitor; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import javax.swing.JPanel; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitor.java,v 1.2 2004/11/22 16:25:26 maj0r Exp $ @@ -61,7 +55,7 @@ * <p> modifizierte, gekuerzte Sun-Source</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java similarity index 89% rename from AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java index 559a013d..32ebd302 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java @@ -1,12 +1,9 @@ package de.applejuicenet.client.gui.memorymonitor; -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; +import javax.swing.*; +import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import javax.swing.JDialog; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/memorymonitor/MemoryMonitorDialog.java,v 1.2 2004/11/22 16:25:26 maj0r Exp $ @@ -15,7 +12,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java index 8cccaf6d..651969e7 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPRequest.java @@ -6,9 +6,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; - import java.net.Socket; - import java.util.Hashtable; import java.util.StringTokenizer; @@ -26,7 +24,7 @@ public class HTTPRequest * * @param so der Socket, zum Lesen des Requests * @param log ein Logger-Objekt, damit pro Client unterschiedliche - * Log-Levels definiert werden können + * Log-Levels definiert werden können */ public HTTPRequest(Socket so) { @@ -39,7 +37,7 @@ public HTTPRequest(Socket so) /** * Liefert den Parameter-Wert zu n * @param n Name des Parameters - * @return der zugehörige Wert oder null + * @return der zugehörige Wert oder null */ public String getParameter(String n) { @@ -49,7 +47,7 @@ public String getParameter(String n) /** * Liefert das Header-Feld zu h * @param h Name des Headers - * @return das zugehörige Headerfeld. + * @return das zugehörige Headerfeld. */ public String getHeader(String h) { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java index de8819c4..1faf0793 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/HTTPResponse.java @@ -4,17 +4,8 @@ package de.applejuicenet.client.gui.mobileproxy; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - +import java.io.*; import java.text.SimpleDateFormat; - import java.util.Date; import java.util.Hashtable; import java.util.Locale; @@ -30,7 +21,7 @@ public class HTTPResponse public final static int HTTP_InternalServerError = 5; public final static int HTTP_NotImplemented = 6; - /** String-Konstante für HTTP-Repsonse-Code */ + /** String-Konstante für HTTP-Repsonse-Code */ public final static String[] ResponseCodes = { "200 OK", "301 Moved Permanently", "400 Bad Request", "403 Forbidden", @@ -38,7 +29,7 @@ public class HTTPResponse }; /** - * Der Dateinamen für die Default-Datei, die verwendet wird, wenn nur ein + * Der Dateinamen für die Default-Datei, die verwendet wird, wenn nur ein * Verzeichnis abgefragt wird. */ public static String DefaultFile = "index.html"; @@ -54,18 +45,18 @@ public class HTTPResponse public static String FileNotFound = "not_found.html"; /** - * Zeitraum für das Cachen HTTP-Antworten<br> - * unsere Daten können einen Tag gecacht werden: + * Zeitraum für das Cachen HTTP-Antworten<br> + * unsere Daten können einen Tag gecacht werden: */ public static String CacheControlSeconds = (3600 * 24) + ""; /** - * Der Mime-Typ für unbekannte Dateien + * Der Mime-Typ für unbekannte Dateien */ public static final String DefaultMimeType = "application/octet-stream"; /** - * Der Mime-Typ für einfache Text-Dateien, wird auch für das Senden von + * Der Mime-Typ für einfache Text-Dateien, wird auch für das Senden von * Fehlermeldungen verwendet. */ public static final String PlainMimeType = "text/plain"; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java index 23c0cdbb..38c4a6dd 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/mobileproxy/MobileProxy.java @@ -1,13 +1,13 @@ package de.applejuicenet.client.gui.mobileproxy; -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Information; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; + public class MobileProxy extends Thread { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java index 8380ab9e..5c695f8b 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java @@ -4,25 +4,14 @@ package de.applejuicenet.client.gui.options; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; - import de.applejuicenet.client.gui.controller.LanguageSelector; import de.tklsoft.gui.controls.TKLButton; import de.tklsoft.gui.controls.TKLComboBox; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/IncomingDirSelectionDialog.java,v 1.7 2009/01/12 09:19:20 maj0r Exp $ * @@ -30,7 +19,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class IncomingDirSelectionDialog extends JDialog diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODAnsichtPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODAnsichtPanel.java new file mode 100644 index 00000000..248f14a8 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODAnsichtPanel.java @@ -0,0 +1,331 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManager; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.MultiLineToolTip; +import de.applejuicenet.client.shared.Settings; +import de.tklsoft.gui.controls.TKLCheckBox; +import de.tklsoft.gui.controls.TKLLabel; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODAnsichtPanel.java,v 1.12 2009/01/26 13:31:36 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODAnsichtPanel extends JPanel implements OptionsRegister { + private TKLLabel farbeFertigerDownload = new TKLLabel(" "); + private TKLLabel farbeQuelle = new TKLLabel(" "); + private Settings settings; + private TKLCheckBox cmbAktiv = new TKLCheckBox(); + private TKLCheckBox enableToolTip = new TKLCheckBox(); + private TKLCheckBox cmbStartscreenZeigen = new TKLCheckBox(); + private final Logger logger; + private Icon menuIcon; + private String menuText; + private boolean dirty = false; + private TKLTextField openProgram = new TKLTextField(); + private TKLLabel program = new TKLLabel("VLC "); + private Border emptyBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1); + + public ODAnsichtPanel() { + logger = LoggerFactory.getLogger(getClass()); + try { + settings = Settings.getSettings(); + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + IconManager im = IconManager.getInstance(); + + menuIcon = im.getIcon("opt_ansicht"); + cmbAktiv.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.aktiv")); + cmbStartscreenZeigen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.zeigestartscreen")); + enableToolTip.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.zeigetooltipps")); + + setLayout(new BorderLayout()); + farbeFertigerDownload.setOpaque(true); + farbeFertigerDownload.setBorder(emptyBorder); + farbeFertigerDownload.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + farbeFertigerDownload.addMouseListener(new ColorChooserMouseAdapter()); + farbeQuelle.setOpaque(true); + farbeQuelle.setBorder(emptyBorder); + farbeQuelle.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + farbeQuelle.addMouseListener(new ColorChooserMouseAdapter()); + OptionsManager om = OptionsManagerImpl.getInstance(); + + cmbStartscreenZeigen.setSelected(om.shouldShowConnectionDialogOnStartup()); + cmbStartscreenZeigen.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent ce) { + dirty = true; + } + }); + cmbAktiv.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent ce) { + dirty = true; + settings.setFarbenAktiv(cmbAktiv.isSelected()); + } + }); + enableToolTip.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + dirty = true; + settings.enableToolTipEnabled(enableToolTip.isSelected()); + } + }); + + ImageIcon icon = im.getIcon("hint"); + TKLLabel hint1 = new TKLLabel(icon) { + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + }; + + TKLLabel hint2 = new TKLLabel(icon) { + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + }; + + String tooltipp = languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.ttipp_farbewaehlen"); + + hint1.setToolTipText(tooltipp); + hint2.setToolTipText(tooltipp); + + openProgram.setEditable(false); + openProgram.setBackground(Color.WHITE); + openProgram.setText(om.getOpenProgram()); + openProgram.ignoreInvalidRules(false); + Icon icon2 = im.getIcon("folderopen"); + Icon icon3 = im.getIcon("vlc"); + + program.setIcon(icon3); + TKLLabel selectProgram = new TKLLabel(icon2); + + selectProgram.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + selectProgram.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent e) { + TKLLabel source = (TKLLabel) e.getSource(); + + source.setBorder(BorderFactory.createLineBorder(Color.black)); + } + + public void mouseClicked(MouseEvent e) { + TKLLabel source = (TKLLabel) e.getSource(); + JFileChooser fileChooser = new JFileChooser(); + + fileChooser.setDialogType(JFileChooser.FILES_ONLY); + fileChooser.setDialogTitle(program.getText()); + if (openProgram.getText().length() != 0) { + File tmpFile = new File(openProgram.getText()); + + if (tmpFile.isFile()) { + fileChooser.setCurrentDirectory(tmpFile); + } + } + + int returnVal = fileChooser.showOpenDialog(source); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File browserFile = fileChooser.getSelectedFile(); + + if (browserFile.isFile()) { + openProgram.setText(browserFile.getPath()); + dirty = true; + openProgram.fireCheckRules(); + } + } + } + + public void mouseExited(MouseEvent e) { + TKLLabel source = (TKLLabel) e.getSource(); + + source.setBorder(null); + } + }); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.WEST; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.bottom = 5; + + JPanel panel4 = new JPanel(new GridBagLayout()); + + panel4.add(program, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel4.add(openProgram, constraints); + constraints.weightx = 0; + constraints.gridx = 2; + panel4.add(selectProgram, constraints); + + JPanel panel1 = new JPanel(); + + constraints.gridx = 0; + constraints.gridy = 0; + panel1.setLayout(new GridBagLayout()); + panel1.setBorder(BorderFactory.createTitledBorder(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.hintergrundfarben"))); + panel1.add(cmbAktiv, constraints); + constraints.gridy = 1; + constraints.insets.left = 5; + constraints.insets.right = 5; + panel1.add(new TKLLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.fertigerdownload")), constraints); + constraints.gridy = 2; + panel1.add(new TKLLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.quelle")), constraints); + menuText = languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.caption"); + constraints.gridx = 1; + constraints.gridy = 1; + panel1.add(farbeFertigerDownload, constraints); + constraints.gridy = 2; + panel1.add(farbeQuelle, constraints); + constraints.gridx = 2; + constraints.gridy = 1; + panel1.add(hint1, constraints); + constraints.gridy = 2; + panel1.add(hint2, constraints); + JPanel panel2 = new JPanel(new BorderLayout()); + + panel2.add(panel1, BorderLayout.NORTH); + JPanel panel3 = new JPanel(new GridBagLayout()); + + constraints.insets.bottom = 0; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.weightx = 1; + constraints.weighty = 0; + panel3.add(panel4, constraints); + constraints.gridy = 1; + panel3.add(cmbStartscreenZeigen, constraints); + constraints.gridy = 2; + panel3.add(enableToolTip, constraints); + panel2.add(panel3, BorderLayout.SOUTH); + + add(panel2, BorderLayout.WEST); + + reloadSettings(); + + cmbAktiv.confirmNewValue(); + enableToolTip.confirmNewValue(); + cmbStartscreenZeigen.confirmNewValue(); + } + + public boolean save() { + try { + boolean bRet = false; + OptionsManager om = OptionsManagerImpl.getInstance(); + + if (om.shouldShowConnectionDialogOnStartup() != shouldShowStartcreen()) { + om.showConnectionDialogOnStartup(shouldShowStartcreen()); + bRet = true; + } + + if (!om.getOpenProgram().equals(getProgramPfad())) { + om.setOpenProgram(getProgramPfad()); + bRet = true; + } + + if (settings.save()) { + bRet = true; + } + + return bRet; + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + + return false; + } + } + + public boolean isDirty() { + return dirty; + } + + public boolean shouldShowStartcreen() { + return cmbStartscreenZeigen.isSelected(); + } + + public Icon getIcon() { + return menuIcon; + } + + public String getMenuText() { + return menuText; + } + + public String getProgramPfad() { + return openProgram.getText(); + } + + public void reloadSettings() { + settings = Settings.getSettings(); + farbeQuelle.setBackground(settings.getQuelleHintergrundColor()); + farbeFertigerDownload.setBackground(settings.getDownloadFertigHintergrundColor()); + cmbAktiv.setSelected(settings.isFarbenAktiv()); + enableToolTip.setSelected(settings.isToolTipEnabled()); + } + + class ColorChooserMouseAdapter extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + TKLLabel source = (TKLLabel) e.getSource(); + + source.setBorder(BorderFactory.createLineBorder(Color.black)); + } + + public void mouseClicked(MouseEvent e) { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + TKLLabel source = (TKLLabel) e.getSource(); + Color newColor = JColorChooser.showDialog(null, + languageSelector.getFirstAttrbuteByTagName("javagui.options.ansicht.hintergrundfarbewaehlen"), + source.getBackground()); + + if (newColor != null && newColor.getRGB() != source.getBackground().getRGB()) { + source.setBackground(newColor); + if (source == farbeQuelle) { + settings.setQuelleHintergrundColor(newColor); + } else { + settings.setDownloadFertigHintergrundColor(newColor); + } + } + } + + public void mouseExited(MouseEvent e) { + TKLLabel source = (TKLLabel) e.getSource(); + + source.setBorder(emptyBorder); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODConnectionPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODConnectionPanel.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/ODConnectionPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODConnectionPanel.java index bd3b1892..e22c4501 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODConnectionPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODConnectionPanel.java @@ -4,22 +4,6 @@ package de.applejuicenet.client.gui.options; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPasswordField; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.connect.QuickConnectionSettingsDialog; import de.applejuicenet.client.gui.controller.LanguageSelector; @@ -27,6 +11,15 @@ import de.applejuicenet.client.shared.IconManager; import de.applejuicenet.client.shared.NumberInputVerifier; import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODConnectionPanel.java,v 1.10 2009/01/12 09:19:20 maj0r Exp $ @@ -35,7 +28,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class ODConnectionPanel extends JPanel implements OptionsRegister @@ -48,7 +41,6 @@ public class ODConnectionPanel extends JPanel implements OptionsRegister private TKLTextField port = new TKLTextField(); private JPasswordField passwortNeu = new JPasswordField(); private ConnectionSettings remote; - private Logger logger; private boolean showPort = false; private QuickConnectionSettingsDialog quickConnectionSettingsDialog; private Icon menuIcon; @@ -56,7 +48,7 @@ public class ODConnectionPanel extends JPanel implements OptionsRegister public ODConnectionPanel(ConnectionSettings remote, QuickConnectionSettingsDialog quickConnectionSettingsDialog, boolean showPort) { - logger = Logger.getLogger(getClass()); + Logger logger = LoggerFactory.getLogger(getClass()); try { this.showPort = showPort; @@ -75,8 +67,7 @@ public ODConnectionPanel(ConnectionSettings remote, QuickConnectionSettingsDialo this(remote, quickConnectionSettingsDialog, false); } - private void init() throws Exception - { + private void init() { setLayout(new BorderLayout()); IconManager im = IconManager.getInstance(); diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODDirectoryChooser.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODDirectoryChooser.java new file mode 100644 index 00000000..8052b87c --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODDirectoryChooser.java @@ -0,0 +1,114 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.components.tree.WaitNode; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserNode; +import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserTreeCellRenderer; +import de.applejuicenet.client.gui.options.directorytree.DirectoryChooserTreeModel; +import de.applejuicenet.client.shared.SwingWorker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.tree.DefaultTreeModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODDirectoryChooser.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODDirectoryChooser extends JDialog { + private JTree folderTree = new JTree(); + private JButton uebernehmen = new JButton(); + private JButton abbrechen = new JButton(); + private boolean change = false; + private String path; + private Logger logger; + + public ODDirectoryChooser(JDialog parent, String title) { + super(parent, true); + logger = LoggerFactory.getLogger(getClass()); + try { + setTitle(title); + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(new JScrollPane(folderTree), BorderLayout.CENTER); + folderTree.setModel(new DefaultTreeModel(new WaitNode())); + folderTree.setCellRenderer(new DirectoryChooserTreeCellRenderer()); + uebernehmen.setEnabled(false); + final SwingWorker worker = new SwingWorker() { + public Object construct() { + DirectoryChooserTreeModel treeModel = new DirectoryChooserTreeModel(); + + folderTree.setModel(treeModel); + folderTree.setRootVisible(false); + uebernehmen.setEnabled(true); + return null; + } + }; + + worker.start(); + JPanel aPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + aPanel.add(uebernehmen); + aPanel.add(abbrechen); + uebernehmen.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Button1.caption")); + uebernehmen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + uebernehmen(); + } + }); + abbrechen.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Button2.caption")); + abbrechen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + getContentPane().add(aPanel, BorderLayout.SOUTH); + pack(); + setSize(getWidth() * 2, getHeight()); + } + + public boolean isNewPathSelected() { + return change; + } + + public String getSelectedPath() { + return path; + } + + private void uebernehmen() { + try { + if (folderTree.getSelectionCount() != 0) { + change = true; + DirectoryChooserNode node = (DirectoryChooserNode) folderTree.getLastSelectedPathComponent(); + + path = node.getDirectory().getPath(); + } + + dispose(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java new file mode 100644 index 00000000..a26e22d5 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java @@ -0,0 +1,63 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.plugins.PluginConnector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginOptionsDialog.java,v 1.6 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODPluginOptionsDialog extends JDialog { + private PluginConnector pluginConnector; + private final JButton schliessen = new JButton(); + private Logger logger; + + public ODPluginOptionsDialog(JDialog parent, PluginConnector pluginConnector) { + super(parent, true); + try { + this.pluginConnector = pluginConnector; + logger = LoggerFactory.getLogger(getClass()); + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + schliessen.addActionListener(ae -> ODPluginOptionsDialog.this.dispose()); + + String title = pluginConnector.getTitle() + " - "; + + title += languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.einstellungen"); + schliessen.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.plugins.schliessen")); + setTitle(title); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(pluginConnector.getOptionPanel(), BorderLayout.CENTER); + JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + southPanel.add(schliessen); + getContentPane().add(southPanel, BorderLayout.SOUTH); + pack(); + Dimension appDimension = getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginPanel.java similarity index 79% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginPanel.java index a884b3d3..dffe84de 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODPluginPanel.java @@ -4,34 +4,20 @@ package de.applejuicenet.client.gui.options; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Set; -import java.util.Vector; - -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.AppleJuiceDialog; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.plugincontrol.PluginFactory; import de.applejuicenet.client.gui.plugins.PluginConnector; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import java.awt.*; +import java.util.Set; +import java.util.Vector; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODPluginPanel.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ @@ -40,7 +26,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class ODPluginPanel extends JPanel implements OptionsRegister @@ -54,7 +40,7 @@ public class ODPluginPanel extends JPanel implements OptionsRegister private String version; private String autor; private String erlaeuterung; - private Logger logger; + private Logger logger; private PluginConnector selectedPluginConnector = null; private JDialog parentDialog; private Icon menuIcon; @@ -62,7 +48,7 @@ public class ODPluginPanel extends JPanel implements OptionsRegister public ODPluginPanel(JDialog parent) { - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); try { theApp = AppleJuiceDialog.getApp(); @@ -71,15 +57,11 @@ public ODPluginPanel(JDialog parent) } catch(Exception e) { - if(logger.isEnabledFor(Level.ERROR)) - { logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } } } - private void init() throws Exception - { + private void init() { IconManager im = IconManager.getInstance(); menuIcon = im.getIcon("opt_plugins"); @@ -102,13 +84,7 @@ private void init() throws Exception beschreibung.setWrapStyleWord(true); pluginList = new JList(v); pluginList.setPreferredSize(new Dimension(190, pluginList.getPreferredSize().height)); - pluginList.addListSelectionListener(new ListSelectionListener() - { - public void valueChanged(ListSelectionEvent e) - { - pluginList_valueChanged(e); - } - }); + pluginList.addListSelectionListener(e -> pluginList_valueChanged(e)); setLayout(new BorderLayout()); LanguageSelector languageSelector = LanguageSelector.getInstance(); @@ -131,19 +107,15 @@ public void valueChanged(ListSelectionEvent e) panel1.add(sp, BorderLayout.CENTER); panel1.add(panel2, BorderLayout.SOUTH); add(panel1, BorderLayout.CENTER); - einstellungen.addActionListener(new ActionListener() + einstellungen.addActionListener(ae -> { + if(selectedPluginConnector != null) { - public void actionPerformed(ActionEvent ae) - { - if(selectedPluginConnector != null) - { - ODPluginOptionsDialog pluginOptionsDialog = new ODPluginOptionsDialog(parentDialog, selectedPluginConnector); - - pluginOptionsDialog.setResizable(true); - pluginOptionsDialog.setVisible(true); - } - } - }); + ODPluginOptionsDialog pluginOptionsDialog = new ODPluginOptionsDialog(parentDialog, selectedPluginConnector); + + pluginOptionsDialog.setResizable(true); + pluginOptionsDialog.setVisible(true); + } + }); } void pluginList_valueChanged(ListSelectionEvent e) diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODProxyPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODProxyPanel.java new file mode 100644 index 00000000..a8d4adc8 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODProxyPanel.java @@ -0,0 +1,205 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.ProxySettings; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.ProxyManagerImpl; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.NumberInputVerifier; +import de.tklsoft.gui.controls.TKLCheckBox; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODProxyPanel.java,v 1.7 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODProxyPanel extends JPanel implements OptionsRegister { + private boolean dirty = false; + private JLabel label1; + private JLabel label2; + private JLabel label3; + private JLabel label4; + private TKLTextField host = new TKLTextField(); + private TKLTextField port = new TKLTextField(); + private TKLTextField user = new TKLTextField(); + private JPasswordField passwort = new JPasswordField(); + private TKLCheckBox use = new TKLCheckBox(); + private ProxySettings proxySettings; + private Logger logger; + private Icon menuIcon; + private String menuText; + + public ODProxyPanel() { + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + IconManager im = IconManager.getInstance(); + + menuIcon = im.getIcon("opt_proxy"); + setLayout(new BorderLayout()); + JPanel panel1 = new JPanel(new GridBagLayout()); + FlowLayout flowL = new FlowLayout(); + + flowL.setAlignment(FlowLayout.RIGHT); + JPanel panel2 = new JPanel(flowL); + + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + proxySettings = ProxyManagerImpl.getInstance().getProxySettings(); + + label1 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.host")); + label2 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.port")); + label3 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.benutzername")); + label4 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.passwort")); + use.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.verwenden")); + menuText = languageSelector.getFirstAttrbuteByTagName("javagui.options.proxy.caption"); + host.setText(proxySettings.getHost()); + host.addFocusListener(new HostFocusListener()); + port.setDocument(new NumberInputVerifier()); + if (proxySettings.getPort() != -1) { + port.setText(Integer.toString(proxySettings.getPort())); + } + + port.addFocusListener(new PortFocusListener()); + user.addFocusListener(new UserFocusListener()); + passwort.addFocusListener(new PasswortFocusListener()); + use.setSelected(proxySettings.isUse()); + use.addChangeListener(e -> dirty = true); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.top = 5; + constraints.insets.left = 5; + + panel1.add(label1, constraints); + + constraints.gridy = 1; + panel1.add(label2, constraints); + + constraints.gridy = 2; + panel1.add(label3, constraints); + + constraints.gridy = 3; + panel1.add(label4, constraints); + + constraints.insets.right = 5; + constraints.gridy = 0; + constraints.gridx = 1; + constraints.weightx = 1; + panel1.add(host, constraints); + + constraints.gridy = 1; + panel1.add(port, constraints); + + constraints.gridy = 2; + panel1.add(user, constraints); + + constraints.gridy = 3; + panel1.add(passwort, constraints); + + constraints.gridy = 4; + constraints.gridx = 0; + constraints.gridwidth = 2; + panel2.add(use); + panel1.add(panel2, constraints); + + add(panel1, BorderLayout.NORTH); + + host.confirmNewValue(); + port.confirmNewValue(); + user.confirmNewValue(); + use.confirmNewValue(); + } + + public ProxySettings getProxySettings() { + if (dirty) { + proxySettings.setUse(use.isSelected()); + proxySettings.setHost(host.getText()); + String tmpPort = port.getText(); + + if (tmpPort.length() == 0) { + proxySettings.setPort(-1); + } else { + proxySettings.setPort(Integer.parseInt(tmpPort)); + } + + proxySettings.setUserpass(user.getText(), new String(passwort.getPassword())); + } + + return proxySettings; + } + + public boolean isDirty() { + return dirty; + } + + public Icon getIcon() { + return menuIcon; + } + + public String getMenuText() { + return menuText; + } + + public void reloadSettings() { + + // nothing to do... + } + + class PasswortFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + dirty = true; + } + } + + + class UserFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + dirty = true; + } + } + + + class PortFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + if (Integer.toString(proxySettings.getPort()).compareTo(host.getText()) != 0) { + dirty = true; + } + } + } + + + class HostFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + if (proxySettings.getHost().compareTo(host.getText()) != 0) { + dirty = true; + } + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODStandardPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODStandardPanel.java new file mode 100644 index 00000000..dc7d2d12 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODStandardPanel.java @@ -0,0 +1,429 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import ch.qos.logback.classic.Level; +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManager; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import de.applejuicenet.client.shared.ConnectionSettings; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.MultiLineToolTip; +import de.applejuicenet.client.shared.NumberInputVerifier; +import de.tklsoft.gui.controls.TKLCheckBox; +import de.tklsoft.gui.controls.TKLComboBox; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODStandardPanel.java,v 1.10 2009/01/14 15:54:31 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODStandardPanel extends JPanel implements OptionsRegister { + private boolean dirty = false; + private boolean xmlPortDirty = false; + private JLabel label1 = new JLabel(); + private JLabel label2 = new JLabel(); + private JLabel label3 = new JLabel(); + private JLabel label4 = new JLabel(); + private JLabel label6 = new JLabel(); + private JLabel openTemp; + private JLabel openIncoming; + private TKLTextField temp = new TKLTextField(); + private TKLTextField incoming = new TKLTextField(); + private TKLTextField port = new TKLTextField(); + private TKLTextField xmlPort = new TKLTextField(); + private TKLTextField nick = new TKLTextField(); + private TKLTextField browser = new TKLTextField(); + private JLabel hint1; + private JLabel hint2; + private JLabel hint3; + private JLabel hint4; + private JLabel hint5; + private JLabel hint6; + private JDialog parent; + private AJSettings ajSettings; + private TKLComboBox cmbLog; + private TKLCheckBox updateNotification = new TKLCheckBox(); + private TKLCheckBox loadPlugins = new TKLCheckBox(); + private ConnectionSettings remote; + private Icon menuIcon; + private String menuText; + + public ODStandardPanel(JDialog parent, AJSettings ajSettings, ConnectionSettings remote) { + Logger logger = LoggerFactory.getLogger(getClass()); + try { + this.remote = remote; + this.parent = parent; + this.ajSettings = ajSettings; + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public boolean isDirty() { + return dirty; + } + + public String getLogLevel() { + return cmbLog.getSelectedItem().toString(); + } + + public boolean getUpdateInfo() { + return updateNotification.isSelected(); + } + + public boolean shouldLoadPluginsOnStartup() { + return loadPlugins.isSelected(); + } + + private void init() { + OptionsManager optionsManager = OptionsManagerImpl.getInstance(); + IconManager im = IconManager.getInstance(); + + menuIcon = im.getIcon("opt_standard"); + port.setDocument(new NumberInputVerifier()); + xmlPort.setDocument(new NumberInputVerifier()); + temp.setEditable(false); + temp.setBackground(Color.WHITE); + incoming.setEditable(false); + incoming.setBackground(Color.WHITE); + port.addFocusListener(new PortFocusListener()); + xmlPort.addFocusListener(new XmlPortFocusListener()); + nick.addFocusListener(new NickFocusListener()); + + JPanel panel8 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + panel8.add(new JLabel("Logging: ")); + LanguageSelector languageSelector = LanguageSelector.getInstance(); + Level logLevel = optionsManager.getLogLevel(); + + LevelItem[] levelItems = new LevelItem[5]; // {"Info", "Warn", "Error", "Debug", "Off"}; + + levelItems[0] = new LevelItem("INFO", "Info"); + levelItems[1] = new LevelItem("WARN", "Warn"); + levelItems[2] = new LevelItem("ERROR", "Error"); + levelItems[3] = new LevelItem("DEBUG", "Debug"); + levelItems[4] = new LevelItem("OFF", "Off"); + menuText = languageSelector.getFirstAttrbuteByTagName("einstform.standardsheet.caption"); + cmbLog = new TKLComboBox(levelItems); + cmbLog.addItemListener(e -> dirty = true); + + int index; + + if(logLevel == Level.INFO) { + index = 0; + }else if (logLevel == Level.WARN) { + index = 1; + }else if (logLevel == Level.ERROR) { + index = 2; + }else if (logLevel == Level.DEBUG) { + index = 3; + }else if (logLevel == Level.OFF) { + index = 4; + }else{ + index = 0; + } + + cmbLog.setSelectedIndex(index); + + panel8.add(cmbLog); + + updateNotification.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.updateinfotext")); + updateNotification.setSelected(optionsManager.getUpdateInfo()); + updateNotification.addItemListener(e -> dirty = true); + + setLayout(new BorderLayout()); + port.setHorizontalAlignment(JLabel.RIGHT); + xmlPort.setHorizontalAlignment(JLabel.RIGHT); + reloadSettings(); + JPanel panel6 = new JPanel(new GridBagLayout()); + + label1.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label2.caption")); + label2.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label7.caption")); + label3.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label3.caption")); + label4.setText(languageSelector.getFirstAttrbuteByTagName("einstform.Label8.caption")); + label6.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.xmlport")); + loadPlugins.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ladeplugins")); + + loadPlugins.setSelected(optionsManager.shouldLoadPluginsOnStartup()); + + ImageIcon icon = im.getIcon("hint"); + + hint1 = new HintLabel(icon); + hint2 = new HintLabel(icon); + hint3 = new HintLabel(icon); + hint4 = new HintLabel(icon); + hint5 = new HintLabel(icon); + hint6 = new HintLabel(icon); + hint1.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_temp")); + hint2.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_port")); + hint3.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_nick")); + hint4.setToolTipText(languageSelector.getFirstAttrbuteByTagName("einstform.Label1.caption")); + hint5.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.logging.ttip")); + hint6.setToolTipText(languageSelector.getFirstAttrbuteByTagName("javagui.options.standard.ttipp_xmlport")); + + Icon icon2 = im.getIcon("folderopen"); + DirectoryChooserMouseAdapter dcMouseAdapter = new DirectoryChooserMouseAdapter(); + + openTemp = new JLabel(icon2); + openTemp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + openTemp.addMouseListener(dcMouseAdapter); + openIncoming = new JLabel(icon2); + openIncoming.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + openIncoming.addMouseListener(dcMouseAdapter); + + loadPlugins.addChangeListener(e -> dirty = true); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.top = 5; + + JPanel panel1 = new JPanel(new GridBagLayout()); + JPanel panel2 = new JPanel(new GridBagLayout()); + JPanel panel3 = new JPanel(new GridBagLayout()); + JPanel panel4 = new JPanel(new GridBagLayout()); + JPanel panel7 = new JPanel(new GridBagLayout()); + JPanel panel10 = new JPanel(new GridBagLayout()); + JPanel panel9 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + JPanel panel11 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + panel9.add(updateNotification); + panel11.add(loadPlugins); + + constraints.insets.right = 5; + constraints.insets.left = 4; + panel1.add(label1, constraints); + panel2.add(label2, constraints); + panel3.add(label3, constraints); + panel4.add(label4, constraints); + panel7.add(label6, constraints); + + constraints.insets.left = 0; + constraints.insets.right = 2; + constraints.gridx = 1; + constraints.weightx = 1; + panel1.add(temp, constraints); + panel2.add(incoming, constraints); + panel3.add(port, constraints); + panel7.add(xmlPort, constraints); + panel4.add(nick, constraints); + constraints.gridx = 2; + constraints.weightx = 0; + panel1.add(openTemp, constraints); + panel2.add(openIncoming, constraints); + + constraints.gridx = 0; + constraints.gridy = 0; + constraints.weightx = 1; + panel6.add(panel1, constraints); + constraints.gridy = 1; + panel6.add(panel2, constraints); + constraints.gridy = 2; + panel6.add(panel3, constraints); + constraints.gridy = 3; + panel6.add(panel7, constraints); + constraints.gridy = 4; + panel6.add(panel4, constraints); + constraints.gridy = 5; + panel6.add(panel10, constraints); + + constraints.insets.top = 10; + constraints.gridx = 1; + constraints.gridy = 0; + constraints.weightx = 0; + panel6.add(hint1, constraints); + constraints.gridy = 2; + panel6.add(hint2, constraints); + constraints.gridy = 3; + panel6.add(hint6, constraints); + constraints.gridy = 4; + panel6.add(hint3, constraints); + + constraints.gridy = 6; + constraints.gridx = 0; + constraints.gridwidth = 1; + panel6.add(panel8, constraints); + constraints.gridx = 1; + panel6.add(hint5, constraints); + constraints.gridy = 7; + constraints.gridx = 0; + constraints.gridwidth = 5; + panel6.add(panel9, constraints); + constraints.gridy = 8; + constraints.gridx = 0; + panel6.add(panel11, constraints); + + add(panel6, BorderLayout.NORTH); + + temp.confirmNewValue(); + incoming.confirmNewValue(); + port.confirmNewValue(); + xmlPort.confirmNewValue(); + nick.confirmNewValue(); + cmbLog.confirmNewValue(); + updateNotification.confirmNewValue(); + loadPlugins.confirmNewValue(); + } + + public boolean isXmlPortDirty() { + return xmlPortDirty; + } + + public Icon getIcon() { + return menuIcon; + } + + public String getMenuText() { + return menuText; + } + + public void reloadSettings() { + AJSettings ajSettings2 = AppleJuiceClient.getAjFassade().getAJSettings(); + + temp.setText(ajSettings2.getTempDir()); + incoming.setText(ajSettings2.getIncomingDir()); + port.setText(Long.toString(ajSettings2.getPort())); + xmlPort.setText(Long.toString(ajSettings2.getXMLPort())); + nick.setText(ajSettings2.getNick()); + } + + class PortFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + int portNr = Integer.parseInt(port.getText()); + + if (ajSettings.getPort() != portNr) { + if (portNr > 1024 && portNr <= 32000) { + dirty = true; + ajSettings.setPort(Integer.parseInt(port.getText())); + } else { + port.setText(Long.toString(ajSettings.getPort())); + } + } + } + } + + class NickFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + if (ajSettings.getNick().compareTo(nick.getText()) != 0) { + dirty = true; + ajSettings.setNick(nick.getText()); + } + } + } + + class XmlPortFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + int xmlPortNr = Integer.parseInt(xmlPort.getText()); + + if (ajSettings.getXMLPort() != Long.parseLong(xmlPort.getText())) { + if (xmlPortNr > 1024 && xmlPortNr <= 32000) { + dirty = true; + xmlPortDirty = true; + remote.setXmlPort(Integer.parseInt(xmlPort.getText())); + ajSettings.setXMLPort(Long.parseLong(xmlPort.getText())); + } else { + xmlPort.setText(Long.toString(ajSettings.getXMLPort())); + } + } + } + } + + class HintLabel extends JLabel { + HintLabel(Icon image) { + super(image); + } + + public JToolTip createToolTip() { + MultiLineToolTip tip = new MultiLineToolTip(); + + tip.setComponent(this); + return tip; + } + } + + class DirectoryChooserMouseAdapter extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + + source.setBorder(BorderFactory.createLineBorder(Color.black)); + } + + public void mouseClicked(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + String title = ""; + + if (source == openTemp) { + title = label1.getText(); + } else { + title = label2.getText(); + } + + ODDirectoryChooser chooser = new ODDirectoryChooser(parent, title); + + chooser.setLocation(parent.getLocation()); + chooser.setVisible(true); + if (chooser.isNewPathSelected()) { + dirty = true; + String path = chooser.getSelectedPath(); + + if (source == openTemp) { + temp.setText(path); + temp.fireCheckRules(); + ajSettings.setTempDir(path); + } else { + incoming.setText(path); + incoming.fireCheckRules(); + ajSettings.setIncomingDir(path); + } + } + } + + public void mouseExited(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + + source.setBorder(null); + } + } + + static class LevelItem { + private final String level; + private final String bezeichnung; + + public LevelItem(String level, String bezeichnung) { + this.level = level; + this.bezeichnung = bezeichnung; + } + + public String getLevel() { + return level; + } + + public String toString() { + return bezeichnung; + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODVerbindungPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODVerbindungPanel.java new file mode 100644 index 00000000..582fc9cc --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/ODVerbindungPanel.java @@ -0,0 +1,357 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.options; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.NumberInputVerifier; +import de.tklsoft.gui.controls.TKLButton; +import de.tklsoft.gui.controls.TKLCheckBox; +import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/ODVerbindungPanel.java,v 1.7 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class ODVerbindungPanel extends JPanel implements OptionsRegister { + private boolean dirty = false; + private JLabel label1; + private JLabel label2; + private JLabel label3; + private JLabel label4; + private JLabel label5; + private JLabel label6; + private JLabel kbSlot; + private TKLCheckBox automaticConnect; + private TKLTextField maxSourcesPerFile = new TKLTextField(); + private TKLTextField maxVerbindungen = new TKLTextField(); + private TKLTextField maxUpload = new TKLTextField(); + private TKLTextField maxDownload = new TKLTextField(); + private JSlider kbSlider; + private TKLTextField maxVerbindungenProTurn = new TKLTextField(); + private AJSettings ajSettings; + private Icon menuIcon; + private String menuText; + private TKLButton wizzard = new TKLButton(); + private OptionsDialog parent; + + public ODVerbindungPanel(OptionsDialog parent, AJSettings ajSettings) { + Logger logger = LoggerFactory.getLogger(getClass()); + this.parent = parent; + this.ajSettings = ajSettings; + try { + init(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public boolean isDirty() { + return dirty; + } + + private void init() throws Exception { + IconManager im = IconManager.getInstance(); + + menuIcon = im.getIcon("opt_verbindung"); + setLayout(new BorderLayout()); + JPanel panel1 = new JPanel(new GridBagLayout()); + + JPanel panel2 = new JPanel(new GridBagLayout()); + JPanel panel3 = new JPanel(new GridBagLayout()); + JPanel panel4 = new JPanel(new GridBagLayout()); + JPanel panel5 = new JPanel(new GridBagLayout()); + JPanel panel6 = new JPanel(new GridBagLayout()); + JPanel panel7 = new JPanel(new GridBagLayout()); + JPanel panel8 = new JPanel(new GridBagLayout()); + JPanel panel10 = new JPanel(new GridBagLayout()); + JPanel panel12 = new JPanel(new GridBagLayout()); + FlowLayout flowL = new FlowLayout(); + + flowL.setAlignment(FlowLayout.RIGHT); + JPanel panel9 = new JPanel(flowL); + + maxVerbindungen.setDocument(new NumberInputVerifier()); + maxVerbindungen.setHorizontalAlignment(JLabel.RIGHT); + maxVerbindungen.addFocusListener(new MaxVerbindungenFocusListener()); + maxUpload.setDocument(new NumberInputVerifier()); + maxUpload.setHorizontalAlignment(JLabel.RIGHT); + maxUpload.addFocusListener(new MaxUploadFocusListener()); + maxDownload.setDocument(new NumberInputVerifier()); + maxDownload.setHorizontalAlignment(JLabel.RIGHT); + maxDownload.addFocusListener(new MaxDownloadFocusListener()); + maxSourcesPerFile.setDocument(new NumberInputVerifier()); + maxSourcesPerFile.setHorizontalAlignment(JLabel.RIGHT); + maxSourcesPerFile.addFocusListener(new MaxSourcesPerFileFocusListener()); + maxVerbindungenProTurn.setDocument(new NumberInputVerifier()); + maxVerbindungenProTurn.setHorizontalAlignment(JLabel.RIGHT); + maxVerbindungenProTurn.addFocusListener(new MaxVerbindungenProTurnFocusListener()); + + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + label1 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label4.caption")); + label2 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label5.caption")); + label3 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label3")); + label4 = new JLabel(languageSelector.getFirstAttrbuteByTagName("einstform.Label13.caption")); + label5 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label5")); + label6 = new JLabel(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.label6")); + menuText = languageSelector.getFirstAttrbuteByTagName("einstform.connectionsheet.caption"); + wizzard.setText(languageSelector.getFirstAttrbuteByTagName("javagui.options.verbindung.labelwizard")); + kbSlot = new JLabel(); + + int untereGrenze = (int) Math.pow((double) ajSettings.getMaxUploadInKB(), 0.2); + int obereGrenze = (int) Math.pow((double) ajSettings.getMaxUploadInKB(), 0.6); + + kbSlider = new JSlider(untereGrenze, obereGrenze); + kbSlider.setMajorTickSpacing(1); + kbSlider.setMinorTickSpacing(1); + kbSlider.setSnapToTicks(true); + kbSlider.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + JSlider slider = (JSlider) e.getSource(); + + kbSlot.setText(Integer.toString(slider.getValue()) + " kb/s"); + dirty = true; + ajSettings.setSpeedPerSlot(slider.getValue()); + } + }); + automaticConnect = new TKLCheckBox(languageSelector.getFirstAttrbuteByTagName("einstform.autoconn.caption")); + automaticConnect.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + dirty = true; + ajSettings.setAutoConnect(automaticConnect.isSelected()); + } + }); + wizzard.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + displayConnectionWizard(); + } + }); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.top = 5; + + constraints.insets.left = 5; + panel2.add(label1, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel2.add(maxVerbindungen, constraints); + constraints.weightx = 0; + + constraints.gridx = 0; + panel3.add(label2, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel3.add(maxUpload, constraints); + constraints.weightx = 0; + + constraints.gridx = 0; + panel4.add(label3, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel4.add(kbSlider, constraints); + constraints.gridx = 2; + constraints.weightx = 0; + panel4.add(kbSlot, constraints); + + constraints.gridx = 0; + panel5.add(label4, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel5.add(maxDownload, constraints); + constraints.weightx = 0; + + constraints.gridx = 0; + panel10.add(label5, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel10.add(maxVerbindungenProTurn, constraints); + constraints.weightx = 0; + + constraints.gridx = 0; + panel12.add(label6, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel12.add(maxSourcesPerFile, constraints); + constraints.weightx = 0; + + panel9.add(automaticConnect); + + constraints.gridx = 0; + constraints.weightx = 1; + constraints.gridy = 0; + constraints.insets.right = 5; + panel1.add(panel2, constraints); + constraints.gridy = 1; + panel1.add(panel3, constraints); + constraints.gridy = 2; + panel1.add(panel4, constraints); + constraints.gridy = 3; + panel1.add(panel5, constraints); + constraints.gridy = 4; + panel1.add(panel6, constraints); + constraints.gridy = 5; + panel1.add(panel7, constraints); + constraints.gridy = 6; + panel1.add(panel8, constraints); + constraints.gridy = 7; + panel1.add(panel10, constraints); + constraints.gridy = 8; + panel1.add(panel12, constraints); + constraints.gridy = 9; + panel1.add(panel9, constraints); + + constraints.gridy = 10; + JPanel panel11 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + panel11.add(wizzard); + panel1.add(panel11, constraints); + + add(panel1, BorderLayout.NORTH); + + reloadSettings(); + + maxSourcesPerFile.confirmNewValue(); + maxVerbindungen.confirmNewValue(); + maxUpload.confirmNewValue(); + maxDownload.confirmNewValue(); + maxVerbindungenProTurn.confirmNewValue(); + automaticConnect.confirmNewValue(); + } + + public Icon getIcon() { + return menuIcon; + } + + public String getMenuText() { + return menuText; + } + + public void displayConnectionWizard() { + boolean regularClosed = AppleJuiceClient.showConnectionWizard(parent, ajSettings); + + if (regularClosed) { + parent.reloadSettings(); + } + } + + public void reloadSettings() { + AJSettings ajSettings2 = AppleJuiceClient.getAjFassade().getAJSettings(); + + /* + ajSettings.setAutoConnect(ajSettings2.isAutoConnect()); + ajSettings.setIncomingDir(ajSettings2.getIncomingDir()); + ajSettings.setMaxConnections(ajSettings2.getMaxConnections()); + ajSettings.setMaxDownload(ajSettings2.getMaxDownload()); + ajSettings.setMaxNewConnectionsPerTurn(ajSettings2.getMaxNewConnectionsPerTurn()); + ajSettings.setMaxSourcesPerFile(ajSettings2.getMaxSourcesPerFile()); + ajSettings.setMaxUpload(ajSettings2.getMaxUpload()); + ajSettings.setNick(ajSettings2.getNick()); + ajSettings.setPort(ajSettings2.getPort()); + ajSettings.setShareDirs(ajSettings2.getShareDirs()); + ajSettings.setSpeedPerSlot(ajSettings2.getSpeedPerSlot()); + ajSettings.setTempDir(ajSettings2.getTempDir()); + ajSettings.setXMLPort(ajSettings2.getXMLPort()); + */ + maxUpload.setText(Long.toString(ajSettings2.getMaxUploadInKB())); + maxDownload.setText(Long.toString(ajSettings2.getMaxDownloadInKB())); + maxVerbindungen.setText(Long.toString(ajSettings2.getMaxConnections())); + kbSlider.setValue(ajSettings2.getSpeedPerSlot()); + kbSlot.setText(Integer.toString(kbSlider.getValue()) + " kb/s"); + automaticConnect.setSelected(ajSettings2.isAutoConnect()); + maxVerbindungenProTurn.setText(Long.toString(ajSettings2.getMaxNewConnectionsPerTurn())); + maxSourcesPerFile.setText(Long.toString(ajSettings2.getMaxSourcesPerFile())); + } + + class MaxVerbindungenProTurnFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + long wert = Long.parseLong(maxVerbindungenProTurn.getText()); + + if (wert != ajSettings.getMaxNewConnectionsPerTurn()) { + if (wert < 1 || wert > 200) { + maxVerbindungenProTurn.setText(Long.toString(ajSettings.getMaxNewConnectionsPerTurn())); + } else { + dirty = true; + ajSettings.setMaxNewConnectionsPerTurn(Long.parseLong(maxVerbindungenProTurn.getText())); + } + } + } + } + + + class MaxSourcesPerFileFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + long wert = Long.parseLong(maxSourcesPerFile.getText()); + + if (wert != ajSettings.getMaxSourcesPerFile()) { + if (wert < 1) { + maxSourcesPerFile.setText(Long.toString(ajSettings.getMaxSourcesPerFile())); + } else { + dirty = true; + ajSettings.setMaxSourcesPerFile(Long.parseLong(maxSourcesPerFile.getText())); + } + } + } + } + + + class MaxDownloadFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + if (Long.parseLong(maxDownload.getText()) != ajSettings.getMaxDownloadInKB()) { + dirty = true; + ajSettings.setMaxDownload(Long.parseLong(maxDownload.getText()) * 1024); + } + } + } + + + class MaxUploadFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + int untereGrenze = (int) Math.pow(Double.parseDouble(maxUpload.getText()), 0.2); + int obereGrenze = (int) Math.pow(Double.parseDouble(maxUpload.getText()), 0.6); + + kbSlider.setMinimum(untereGrenze); + kbSlider.setMaximum(obereGrenze); + if (Long.parseLong(maxUpload.getText()) != ajSettings.getMaxUploadInKB()) { + dirty = true; + ajSettings.setMaxUpload(Long.parseLong(maxUpload.getText()) * 1024); + } + } + } + + + class MaxVerbindungenFocusListener extends FocusAdapter { + public void focusLost(FocusEvent e) { + if (Long.parseLong(maxVerbindungen.getText()) != ajSettings.getMaxConnections()) { + dirty = true; + ajSettings.setMaxConnections(Long.parseLong(maxVerbindungen.getText())); + } + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsDialog.java similarity index 79% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsDialog.java index 009e21cb..473adef8 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsDialog.java @@ -4,30 +4,6 @@ package de.applejuicenet.client.gui.options; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.HeadlessException; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ListCellRenderer; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.shared.AJSettings; @@ -38,6 +14,11 @@ import de.applejuicenet.client.shared.ConnectionSettings; import de.applejuicenet.client.shared.SoundPlayer; import de.applejuicenet.client.shared.exception.InvalidPasswordException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsDialog.java,v 1.9 2009/01/12 09:19:20 maj0r Exp $ @@ -46,16 +27,16 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class OptionsDialog extends JDialog { + private static final Logger logger = LoggerFactory.getLogger(OptionsDialog.class); private JFrame parent; private JButton speichern; private JButton abbrechen; private AJSettings ajSettings; - private Logger logger; private ConnectionSettings remote; private JList menuList; private OptionsRegister[] optionPanels; @@ -65,7 +46,6 @@ public class OptionsDialog extends JDialog public OptionsDialog(JFrame parent) throws HeadlessException { super(parent, true); - logger = Logger.getLogger(getClass()); try { this.parent = parent; @@ -99,32 +79,16 @@ private void init() throws Exception registerPanel.add(optionPanels[i].getMenuText(), (JPanel) optionPanels[i]); } - menuList.addListSelectionListener(new ListSelectionListener() - { - public void valueChanged(ListSelectionEvent listSelectionEvent) - { - Object selected = menuList.getSelectedValue(); + menuList.addListSelectionListener(listSelectionEvent -> { + Object selected = menuList.getSelectedValue(); - registerLayout.show(registerPanel, ((OptionsRegister) selected).getMenuText()); - } - }); + registerLayout.show(registerPanel, ((OptionsRegister) selected).getMenuText()); + }); menuList.setSelectedValue(optionPanels[0], true); speichern = new JButton(languageSelector.getFirstAttrbuteByTagName("einstform.Button1.caption")); abbrechen = new JButton(languageSelector.getFirstAttrbuteByTagName("einstform.Button2.caption")); - abbrechen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - speichern.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - speichern(); - } - }); + abbrechen.addActionListener(e -> dispose()); + speichern.addActionListener(e -> speichern()); JPanel panel = new JPanel(); FlowLayout flowL = new FlowLayout(); @@ -156,12 +120,11 @@ private void speichern() if(((ODStandardPanel) optionPanels[0]).isDirty() || ((ODVerbindungPanel) optionPanels[1]).isDirty()) { om.saveAJSettings(ajSettings); - om.setStandardBrowser(((ODStandardPanel) optionPanels[0]).getBrowserPfad()); om.loadPluginsOnStartup(((ODStandardPanel) optionPanels[0]).shouldLoadPluginsOnStartup()); + om.setUpdateInfo(((ODStandardPanel) optionPanels[0]).getUpdateInfo()); if(((ODStandardPanel) optionPanels[0]).isDirty()) { om.setLogLevel(((ODStandardPanel) optionPanels[0]).getLogLevel()); - om.setVersionsinfoModus(((ODStandardPanel) optionPanels[0]).getVersionsinfoModus()); } etwasGeaendert = true; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsRegister.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsRegister.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsRegister.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsRegister.java index 43134f3b..90ac35e6 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsRegister.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/OptionsRegister.java @@ -1,6 +1,6 @@ package de.applejuicenet.client.gui.options; -import javax.swing.Icon; +import javax.swing.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/OptionsRegister.java,v 1.2 2006/05/03 14:52:00 maj0r Exp $ @@ -9,7 +9,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public interface OptionsRegister diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java index ede8b3a3..b818b77b 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java @@ -1,12 +1,5 @@ package de.applejuicenet.client.gui.options.directorytree; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.Icon; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.entity.Directory; import de.applejuicenet.client.fassade.exception.IllegalArgumentException; @@ -14,6 +7,12 @@ import de.applejuicenet.client.gui.components.treetable.Node; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import java.util.ArrayList; +import java.util.List; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserNode.java,v 1.7 2006/05/03 14:52:22 maj0r Exp $ * @@ -21,7 +20,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class DirectoryChooserNode extends DefaultMutableTreeNode implements Node, ApplejuiceNode diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java index 850fe2ce..d98ec706 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java @@ -1,12 +1,10 @@ package de.applejuicenet.client.gui.options.directorytree; -import java.awt.Component; +import de.applejuicenet.client.gui.components.treetable.Node; -import javax.swing.Icon; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; - -import de.applejuicenet.client.gui.components.treetable.Node; +import java.awt.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeCellRenderer.java,v 1.3 2006/05/03 14:52:22 maj0r Exp $ @@ -15,7 +13,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class DirectoryChooserTreeCellRenderer extends DefaultTreeCellRenderer diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java index afd62b6e..8a0867e0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java @@ -1,12 +1,11 @@ package de.applejuicenet.client.gui.options.directorytree; -import java.util.List; -import java.util.Vector; - import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import java.util.List; +import java.util.Vector; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/options/directorytree/DirectoryChooserTreeModel.java,v 1.3 2006/05/03 14:52:22 maj0r Exp $ @@ -15,7 +14,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class DirectoryChooserTreeModel implements TreeModel diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java new file mode 100644 index 00000000..63c28eeb --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/PluginFactory.java @@ -0,0 +1,126 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugincontrol; + +import de.applejuicenet.client.gui.plugins.PluginConnector; +import de.applejuicenet.client.shared.PluginJarClassLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public abstract class PluginFactory { + private static Set<PluginConnector> plugins = null; + private static final Logger logger = LoggerFactory.getLogger(PluginFactory.class); + + public static Set<PluginConnector> getPlugins() { + if (null == plugins) { + boolean isDebugPlugins = System.getProperty("Plugins") != null; + + if (isDebugPlugins) { + plugins = loadPluginsFromClasspath(); + return plugins; + } + + plugins = new HashSet<>(); + + Map<String, File> tempListe = new HashMap<>(); + + String shippedPath = System.getProperty("user.dir") + File.separator + "plugins" + File.separator; + String userPath = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui" + File.separator + "plugins" + File.separator; + + File userPathFile = new File(userPath); + File shippedPathFile = new File(shippedPath); + + File[] userPathFiles = userPathFile.listFiles(); + if (userPathFiles != null) { + for (File pathFile : userPathFiles) { + if (pathFile.isFile() && pathFile.getName().endsWith(".jar")) { + tempListe.put(pathFile.getName(), pathFile); + } + } + } + + File[] shippedPathFiles = shippedPathFile.listFiles(); + if (shippedPathFiles != null) { + for (File pathFile : shippedPathFiles) { + if (pathFile.isFile() && pathFile.getName().endsWith(".jar")) { + if (!tempListe.containsKey(pathFile.getName())) { + tempListe.put(pathFile.getName(), pathFile); + } + } + } + } + + PluginJarClassLoader jarLoader; + + for (Map.Entry<String, File> pluginFile : tempListe.entrySet()) { + try { + ZipFile jf = new ZipFile(pluginFile.getValue()); + ZipEntry entry = jf.getEntry("plugin.properties"); + + if (entry == null) { + continue; + } + + jarLoader = new PluginJarClassLoader(); + PluginConnector aPlugin = jarLoader.getPlugin(pluginFile.getValue()); + + if (aPlugin != null) { + plugins.add(aPlugin); + logger.info(String.format("Plugin %s (%s) geladen ...", aPlugin.getTitle(), aPlugin.getVersion())); + } + } catch (Exception e) { + //Von einem Plugin lassen wir uns nicht beirren! ;-) + logger.error("Ein Plugin konnte nicht instanziert werden", e); + } + } + } + + return plugins; + } + + private static Set<PluginConnector> loadPluginsFromClasspath() { + Set<PluginConnector> thePlugins = new HashSet<PluginConnector>(); + String[] which = new String[]{ + "de.applejuicenet.client.gui.plugins.logviewer.LogViewerPluginTestLoader", + "de.applejuicenet.client.gui.plugins.speedgraph.SpeedGraphPluginTestLoader", + "de.applejuicenet.client.gui.plugins.versionchecker.VersioncheckerPluginTestLoader", + }; + + for (String curWhich : which) { + PluginConnector plugin = loadPlugin(curWhich); + + if (null != plugin) { + thePlugins.add(plugin); + String nachricht = "Plugin " + plugin.getTitle() + " geladen..."; + + logger.info(nachricht); + } + } + + return thePlugins; + } + + private static PluginConnector loadPlugin(String which) { + try { + Class<?> pluginClass = Class.forName(which); + TestLoader testLoader = (TestLoader) pluginClass.newInstance(); + + return testLoader.getPlugin(); + } catch (Throwable e) { + //Von einem Plugin lassen wir uns nicht beirren! ;-) + logger.error("Ein Plugin konnte nicht instanziert werden", e); + } + + return null; + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/TestLoader.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/TestLoader.java similarity index 78% rename from AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/TestLoader.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/TestLoader.java index 259eab28..e017eec7 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/plugincontrol/TestLoader.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugincontrol/TestLoader.java @@ -4,23 +4,15 @@ package de.applejuicenet.client.gui.plugincontrol; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FilenameFilter; -import java.io.IOException; +import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; +import de.applejuicenet.client.gui.plugins.PluginConnector; +import javax.swing.*; +import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import javax.swing.ImageIcon; - -import de.applejuicenet.client.fassade.controller.xml.XMLValueHolder; -import de.applejuicenet.client.gui.plugins.PluginConnector; - public abstract class TestLoader { private String path = System.getProperty("user.dir") + File.separator + "plugin_src" + File.separator + getPath(); @@ -49,13 +41,7 @@ public final PluginConnector getPlugin() throws IOException private Map<String, Properties> getLanguageFiles() throws IOException { Map<String, Properties> languageProperties = new HashMap<String, Properties>(); - String[] filenames = new File(path).list(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - return name.startsWith("language_") && name.endsWith(".properties"); - } - }); + String[] filenames = new File(path).list((dir, name) -> name.startsWith("language_") && name.endsWith(".properties")); if(null != filenames) { @@ -81,7 +67,7 @@ public boolean accept(File dir, String name) private ImageIcon getIcon() { - ImageIcon icon = new ImageIcon(path + File.separator + "icons" + File.separator + "icon.gif"); + ImageIcon icon = new ImageIcon(path + File.separator + "icons" + File.separator + "icon.png"); return icon; } @@ -90,14 +76,9 @@ private Map<String, ImageIcon> getAvailableIcons() { Map<String, ImageIcon> availableIcons = new HashMap<String, ImageIcon>(); File aFile = new File(path + File.separator + "icons" + File.separator); - String[] names = aFile.list(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - return name.endsWith(".gif") || name.endsWith(".png"); - } - }); + String[] names = aFile.list((dir, name) -> name.endsWith(".png")); + assert names != null; for(String curName : names) { String key = curName.substring(0, curName.length() - 4); @@ -120,8 +101,8 @@ public MyXMLValueHolder(String fileName) BufferedReader reader; reader = new BufferedReader(new FileReader(fullPath)); - String line = ""; - StringBuffer read = new StringBuffer(); + String line; + StringBuilder read = new StringBuilder(); while(null != (line = reader.readLine())) { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/plugins/PluginConnector.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugins/PluginConnector.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/plugins/PluginConnector.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugins/PluginConnector.java index 498a4857..8129c40e 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/plugins/PluginConnector.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/plugins/PluginConnector.java @@ -4,18 +4,16 @@ package de.applejuicenet.client.gui.plugins; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.gui.RegisterI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import javax.swing.ImageIcon; -import javax.swing.JPanel; - -import org.apache.log4j.Logger; - -import de.applejuicenet.client.fassade.listener.DataUpdateListener; -import de.applejuicenet.client.gui.RegisterI; - /** * <p>Titel: AppleJuice Core-GUI</p> * @@ -27,7 +25,7 @@ * <p>Diese Klasse darf nicht veraendert werden! * Um ein Plugin zu erstellen, muss diese Klasse ueberschrieben werden.</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] */ public abstract class PluginConnector extends JPanel implements DataUpdateListener, RegisterI { @@ -36,7 +34,6 @@ public abstract class PluginConnector extends JPanel implements DataUpdateListen private final Map<String, Properties> languageFiles; private Properties currentLanguageFile; private Map<String, ImageIcon> availableIcons; - private final Logger logger = Logger.getLogger(getClass()); protected PluginConnector(Properties properties, Map<String, Properties> languageFiles, ImageIcon icon, Map<String, ImageIcon> availableIcons) @@ -58,8 +55,9 @@ protected PluginConnector(Properties properties, Map<String, Properties> languag if(null == availableIcons) { + Logger logger = LoggerFactory.getLogger(getClass()); logger.info("Map availableIcons nicht uebergeben"); - availableIcons = new HashMap<String, ImageIcon>(); + availableIcons = new HashMap<>(); } this.properties = properties; @@ -160,7 +158,7 @@ public JPanel getOptionPanel() } /** - * Liefert ein Icon zurueck, welches in der Lasche angezeigt werden soll. Es muss als icon.gif im Plugin-Unterordner /icons gespeichert + * Liefert ein Icon zurueck, welches in der Lasche angezeigt werden soll. Es muss als icon.png im Plugin-Unterordner /icons gespeichert * werden, damit es spaeter an die richtige Stelle im jar-Archiv wandert (ca. 16x16) * * @return ImageIcon: LaschenIcon @@ -212,7 +210,7 @@ public final String getLanguageString(String identifier) * @param type int: Typ des angesprochenen Listeners * @param content Object: Geaenderte Werte, Typ abhaengig vom * angesprochenen Listener - * @see DataUpdateListener.class + * @see DataUpdateListener */ public abstract void fireContentChanged(DATALISTENER_TYPE type, Object content); diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java new file mode 100644 index 00000000..15bd2d00 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java @@ -0,0 +1,214 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.powerdownload; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.gui.download.PowerDownloadPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.*; +import java.util.List; +import java.util.*; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/powerdownload/AutomaticPowerdownloadPolicy.java,v 1.23 2009/01/28 09:44:09 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public abstract class AutomaticPowerdownloadPolicy extends Thread { + private Set<Thread> threads = new HashSet<Thread>(); + private Logger logger = LoggerFactory.getLogger(getClass()); + private PowerDownloadPanel parentToInformEnde = null; + private boolean paused = false; + + //diese Variable auf false setzen, um das automatische Pausieren von Dateien zu verhindern + protected boolean shouldPause = true; + protected final ApplejuiceFassade applejuiceFassade; + + public AutomaticPowerdownloadPolicy(ApplejuiceFassade applejuiceFassade) { + this.applejuiceFassade = applejuiceFassade; + } + + public final void run() { + try { + if (initAction()) { + while (!isInterrupted()) { + if (!paused) { + doAction(); + sleep(getSleeptime()); + } + + sleep(1000); + } + } + } catch (InterruptedException iE) { + if (shouldPause) { + pauseAllDownloads(); + } + + interrupt(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + + if (parentToInformEnde != null) { + parentToInformEnde.autoPwdlFinished(); + parentToInformEnde = null; + } + + if (threads != null) { + threads.clear(); + } + + logger = null; + } + + protected int getSleeptime() { + return 30000; + } + + public final void setParentToInform(PowerDownloadPanel parentToInformEnde) { + this.parentToInformEnde = parentToInformEnde; + } + + public final boolean shouldPause() { + return shouldPause; + } + + public final void interrupt() { + try { + for (Thread curThread : threads) { + try { + curThread.interrupt(); + } catch (Exception ex) { + logger.error("Fehler beim Beenden eines Threads in " + toString(), ex); + } + } + + super.interrupt(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public final synchronized void setPaused(boolean pause) { + if (pause == paused) { + return; + } + + paused = !paused; + if (paused) { + pauseAllDownloads(); + try { + informPaused(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + } + + private final void pauseAllDownloads() { + try { + Map<Integer, Download> downloads = applejuiceFassade.getDownloadsSnapshot(); + + synchronized (downloads) { + List<Download> dos = new ArrayList<Download>(); + + for (Download curDownload : downloads.values()) { + dos.add(curDownload); + } + + applejuiceFassade.pauseDownload(dos); + applejuiceFassade.setPowerDownload(dos, new Integer(0)); + } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public final boolean isPaused() { + return paused; + } + + /** + * Zur Instanzierung muss der Standardkonstruktor vorhanden sein!!!!! + * Ansonsten funktioniert der ganze Krams nicht!!!!! + * Laesst sich natuerlich nicht in einer abstrakten Klasse vorbauen, folglich + * muss der Entwickler dran denken!!!!! + **/ + + // public AutomaticPowerdownloadPolicy(); + + /** + * Initialisierung + * Hier koennen Initialisierungen fuer die doAction()-Methode vorgenommen werden, + * sie gehoeren nicht in den Konstruktor. + **/ + public abstract boolean initAction() throws Exception; + + /** + * Umsetzung der Powerdownloadverarbeitung + * Es wird nur EIN Durchlauf mit abschlieszender sleep(ms)-Anweisung(!!!) implementiert. + * Die Schleife ergibt sich durch die run()-Methode des Threads. + **/ + public abstract void doAction() throws Exception; + + /** + * Alle eigenen verwendeten Threads sollten mittels dieser Methode registriert werden. + * So ist sichergestellt, dass diese beim Beenden des Autom. Pwdl beendet werden. + **/ + protected final void addThreadToWatch(Thread aThread) { + if (aThread != null) { + threads.add(aThread); + } + } + + /** + * Wird aufgerufen um zu informieren, dass aktuell nicht mehr genug Credits + * vorhanden sind. + * So kann falls noetig darauf reagiert werden. + **/ + public abstract void informPaused() throws Exception; + + /** + * Versions-String + */ + public abstract String getVersion(); + + /** + * kurze Beschreibung der PowerdownloadPolicy + */ + public abstract String getDescription(); + + /** + * Name des Autors + */ + public abstract String getAuthor(); + + /** + * toString wird fuer die Ausgabe in der Combobox verwendet + */ + public abstract String toString(); + + /** + * Diese Methode ueberschreiben, wenn bei aktivierten Autom. Pwdl ein Button + * fuer Einstellungen eingeblendet werden soll + */ + public boolean hasPropertiesDialog() { + return false; + } + + /** + * Diese Methode mit dem Öffnen und Auswerten des Einstellungendialogs ueberschreiben. + */ + public void showPropertiesDialog(Frame parent) { + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchController.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/SearchController.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchController.java index caf4980b..e3a5b3be 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchController.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchController.java @@ -4,14 +4,6 @@ package de.applejuicenet.client.gui.search; -import java.awt.Component; - -import java.util.HashMap; -import java.util.Map; - -import javax.swing.JComponent; -import javax.swing.SwingUtilities; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Download; @@ -27,9 +19,13 @@ import de.applejuicenet.client.gui.download.DownloadPropertyChangeListener; import de.applejuicenet.client.gui.search.table.SearchEntryIconRenderer; import de.applejuicenet.client.shared.SoundPlayer; - import de.tklsoft.gui.controls.TKLTextField; +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + public class SearchController extends GuiController { private static SearchController instance = null; @@ -112,7 +108,7 @@ private void startStop() } catch(IllegalArgumentException e) { - logger.error(e); + logger.error(ApplejuiceFassade.ERROR_MESSAGE,e); } } } diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchPanel.java similarity index 92% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/SearchPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchPanel.java index c8136135..68866027 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchPanel.java @@ -4,27 +4,6 @@ package de.applejuicenet.client.gui.search; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.RegisterI; import de.applejuicenet.client.gui.components.GuiController; @@ -35,6 +14,15 @@ import de.tklsoft.gui.controls.TKLButton; import de.tklsoft.gui.controls.TKLLabel; import de.tklsoft.gui.controls.TKLTextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.event.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchPanel.java,v 1.16 2009/02/12 09:11:24 maj0r Exp $ @@ -43,7 +31,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class SearchPanel extends TklPanel implements LanguageListener, RegisterI @@ -55,12 +43,12 @@ public class SearchPanel extends TklPanel implements LanguageListener, RegisterI private TKLLabel bearbeitung = new TKLLabel(); private JMenuItem einfuegen; private JPopupMenu menu; - private Logger logger; + private final Logger logger; public SearchPanel(GuiController guiController) { super(guiController); - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); try { init(); diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultPanel.java new file mode 100644 index 00000000..f833ed54 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultPanel.java @@ -0,0 +1,415 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.search; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Search; +import de.applejuicenet.client.fassade.entity.SearchEntry; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.shared.FileType; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.components.table.SortButtonRenderer; +import de.applejuicenet.client.gui.components.table.SortableTableModel; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.gui.search.table.SearchEntryIconRenderer; +import de.applejuicenet.client.gui.search.table.SearchEntrySizeRenderer; +import de.applejuicenet.client.gui.search.table.SearchTableModel; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.ReleaseInfo; +import de.applejuicenet.client.shared.SoundPlayer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultPanel.java,v 1.19 2009/02/12 13:03:34 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r <aj@tkl-soft.de> + */ +public class SearchResultPanel extends JPanel { + private static String offeneSuchen = "%i offene Suchen"; + private static String gefundeneDateien = "%i gefundene Dateien"; + private static String durchsuchteClients = "%i durchsuchte Clients"; + private static String linkLaden = "Link"; + private static String sucheStoppen = "Suche stoppen"; + private static String alreadyLoaded; + private static String invalidLink; + private static String linkFailure; + private static String dialogTitel; + private static String releaseInfo; + private static String[] columns; + private final Logger logger; + private JTable searchResultTable; + private SearchTableModel searchResultTableModel; + private Search search; + private JButton sucheAbbrechen = new JButton(); + private JLabel label1 = new JLabel(); + private JLabel label2 = new JLabel(); + private JLabel label3 = new JLabel(); + private JPopupMenu popup = new JPopupMenu(); + private JMenuItem item1 = new JMenuItem(); + private JMenuItem mnuReleaseInfo = new JMenuItem(); + private JToggleButton[] filterButtons; + private TableColumn[] tableColumns = new TableColumn[3]; + + public SearchResultPanel(Search aSearch) { + search = aSearch; + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public Search getSearch() { + return search; + } + + private void init() throws Exception { + IconManager im = IconManager.getInstance(); + + item1.setText(linkLaden); + item1.setIcon(im.getIcon("download")); + sucheAbbrechen.setText(sucheStoppen); + sucheAbbrechen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + sucheAbbrechen.setEnabled(false); + try { + AppleJuiceClient.getAjFassade().cancelSearch(search); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }); + popup.add(item1); + + mnuReleaseInfo.setIcon(im.getIcon("hint")); + mnuReleaseInfo.setText(releaseInfo); + mnuReleaseInfo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + int[] sel = searchResultTable.getSelectedRows(); + + if (null == sel || sel.length < 1) { + return; + } + + SearchEntry curSearchEntry = searchResultTableModel.getRow(sel[0]); + + ReleaseInfo.handle(curSearchEntry.getFileNames()[0].getDateiName(), curSearchEntry.getChecksumme(), curSearchEntry.getGroesse()); + } + }); + popup.add(mnuReleaseInfo); + setLayout(new BorderLayout()); + updateZahlen(); + JPanel buttonPanel = new JPanel(new FlowLayout()); + JButton all = new JButton(IconManager.getInstance().getIcon("abbrechen")); + + buttonPanel.add(all); + + FileType[] allTypes = FileType.values(); + + filterButtons = new JToggleButton[allTypes.length]; + for (int i = 0; i < allTypes.length; i++) { + filterButtons[i] = new JToggleButton(IconManager.getInstance().getIcon(allTypes[i].toString())); + filterButtons[i].addActionListener(new FilterAdapter(allTypes[i])); + buttonPanel.add(filterButtons[i]); + } + + all.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + for (int i = 0; i < filterButtons.length; i++) { + filterButtons[i].setSelected(false); + } + + search.clearFilter(); + searchResultTableModel.fireTableDataChanged(); + } + }); + + add(buttonPanel, BorderLayout.NORTH); + searchResultTableModel = new SearchTableModel(search); + searchResultTable = new JTable(searchResultTableModel); + + searchResultTable.setDefaultRenderer(SearchEntry.class, new SearchEntryIconRenderer()); + searchResultTable.setDefaultRenderer(Long.class, new SearchEntrySizeRenderer()); + + add(new JScrollPane(searchResultTable), BorderLayout.CENTER); + JPanel southPanel = new JPanel(new BorderLayout()); + JPanel textPanel = new JPanel(new FlowLayout()); + + textPanel.add(label1); + textPanel.add(label2); + textPanel.add(label3); + + JPanel panel1 = new JPanel(new FlowLayout()); + + panel1.add(sucheAbbrechen); + southPanel.add(panel1, BorderLayout.WEST); + southPanel.add(textPanel, BorderLayout.CENTER); + add(southPanel, BorderLayout.SOUTH); + MouseAdapter popupMouseAdapter = new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (SwingUtilities.isRightMouseButton(me)) { + Point p = me.getPoint(); + int row = searchResultTable.rowAtPoint(p); + + if (row != -1 && !searchResultTable.getSelectionModel().isSelectedIndex(row)) { + searchResultTable.getSelectionModel().setSelectionInterval(row, row); + } + } + + maybeShowPopup(me); + } + + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + int[] sel = searchResultTable.getSelectedRows(); + + if (null != sel && sel.length > 0) { + popup.show(searchResultTable, e.getX(), e.getY()); + } + } + } + }; + + searchResultTable.addMouseListener(popupMouseAdapter); + item1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + int[] sel = searchResultTable.getSelectedRows(); + + if (null != sel && sel.length > 0) { + SearchEntry curSearchEntry; + + for (int curRow : sel) { + curSearchEntry = searchResultTableModel.getRow(curRow); + StringBuilder toCopy = new StringBuilder(); + + toCopy.append("ajfsp://file|"); + toCopy.append(curSearchEntry.getFileNames()[0].getDateiName() + "|" + curSearchEntry.getChecksumme() + "|" + + curSearchEntry.getGroesse() + "/"); + String link = toCopy.toString(); + + processLink(link); + } + } + } + }); + + TableColumnModel model = searchResultTable.getColumnModel(); + SortButtonRenderer renderer = new SortButtonRenderer(); + + for (int i = 0; i < tableColumns.length; i++) { + tableColumns[i] = model.getColumn(i); + tableColumns[i].setHeaderRenderer(renderer); + } + + JTableHeader header = searchResultTable.getTableHeader(); + + SortMouseAdapter sortMouseAdapter = new SortMouseAdapter(header, renderer); + + header.addMouseListener(sortMouseAdapter); + + PositionManager pm = PositionManagerImpl.getInstance(); + int[] sort = pm.getSearchSort(); + + sortMouseAdapter.sort(sort[0], sort[1] == 1); + if (!search.isRunning()) { + sucheAbbrechen.setEnabled(false); + } + } + + private void processLink(final String link) { + new Thread() { + public void run() { + try { + final String result = AppleJuiceClient.getAjFassade().processLink(link, ""); + + SoundPlayer.getInstance().playSound(SoundPlayer.LADEN); + if (result.indexOf("ok") != 0) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + String message = null; + + if (result.indexOf("already downloaded") != -1) { + message = alreadyLoaded.replaceAll("%s", link); + } else if (result.indexOf("incorrect link") != -1) { + message = invalidLink.replaceAll("%s", link); + } else if (result.indexOf("failure") != -1) { + message = linkFailure; + } + + if (message != null) { + JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), message, dialogTitel, + JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE); + } + } + }); + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }.start(); + } + + public static void setTexte(String[] texte, String[] tableColumns) { + offeneSuchen = texte[0]; + gefundeneDateien = texte[1]; + durchsuchteClients = texte[2]; + linkLaden = texte[3]; + sucheStoppen = texte[4]; + alreadyLoaded = texte[5]; + invalidLink = texte[6]; + linkFailure = texte[7]; + dialogTitel = texte[8]; + releaseInfo = texte[9]; + columns = tableColumns; + } + + public void updateSearchContent() { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + updateSearchContent(); + + } + }); + return; + } + + try { + searchResultTableModel.forceResort(); + searchResultTable.updateUI(); + updateZahlen(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void updateZahlen() { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + updateZahlen(); + + } + }); + return; + } + + List<SearchEntry> searchEntries = search.getAllSearchEntries(); + + label1.setText(offeneSuchen.replaceFirst("%i", Integer.toString(search.getOffeneSuchen()))); + label2.setText(gefundeneDateien.replaceFirst("%i", Integer.toString(searchEntries.size()))); + label3.setText(durchsuchteClients.replaceFirst("%i", Integer.toString(search.getDurchsuchteClients()))); + } + + public void aendereSprache() { + try { + item1.setText(linkLaden); + mnuReleaseInfo.setText(releaseInfo); + sucheAbbrechen.setText(sucheStoppen); + label1.setText(offeneSuchen.replaceFirst("%i", Integer.toString(search.getOffeneSuchen()))); + label2.setText(gefundeneDateien.replaceFirst("%i", Long.toString(search.getEntryCount()))); + label3.setText(durchsuchteClients.replaceFirst("%i", Integer.toString(search.getDurchsuchteClients()))); + TableColumnModel tcm = searchResultTable.getColumnModel(); + + for (int i = 0; i < tcm.getColumnCount(); i++) { + tcm.getColumn(i).setHeaderValue(columns[i]); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + class SortMouseAdapter extends MouseAdapter { + private JTableHeader header; + private SortButtonRenderer renderer; + private PositionManager pm = PositionManagerImpl.getInstance(); + + public SortMouseAdapter(JTableHeader header, SortButtonRenderer renderer) { + this.header = header; + this.renderer = renderer; + header.repaint(); + } + + public void mouseClicked(MouseEvent e) { + if (e.getButton() != MouseEvent.BUTTON1) { + return; + } + + int col = header.columnAtPoint(e.getPoint()); + int curSelectedColumn = renderer.getSelectedColumn(); + boolean ascent; + + if (col == curSelectedColumn) { + ascent = !renderer.getState(); + } else { + ascent = true; + } + + pm.setSearchSort(col, ascent); + sort(col, ascent); + } + + @SuppressWarnings("unchecked") + public void sort(int column, boolean ascent) { + renderer.setSelectedColumn(column, ascent); + header.repaint(); + + if (header.getTable().isEditing()) { + header.getTable().getCellEditor().stopCellEditing(); + } + + int sortCol = header.getTable().convertColumnIndexToModel(column); + + ((SortableTableModel) header.getTable().getModel()).sortByColumn(sortCol, ascent); + header.repaint(); + } + } + + + private class FilterAdapter implements ActionListener { + private FileType filter; + + public FilterAdapter(FileType newFilter) { + filter = newFilter; + } + + public void actionPerformed(ActionEvent ae) { + JToggleButton source = (JToggleButton) ae.getSource(); + + if (source.isSelected()) { + search.removeFilter(filter); + } else { + search.addFilter(filter); + } + + searchResultTableModel.fireTableDataChanged(); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java similarity index 89% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java index 78087b3c..137535ee 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java @@ -4,22 +4,18 @@ package de.applejuicenet.client.gui.search; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.Icon; -import javax.swing.JTabbedPane; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Search; import de.applejuicenet.client.fassade.exception.IllegalArgumentException; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/search/SearchResultTabbedPane.java,v 1.7 2009/01/28 09:44:09 maj0r Exp $ @@ -28,13 +24,13 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class SearchResultTabbedPane extends JTabbedPane implements MouseListener { - private static Icon icon = IconManager.getInstance().getIcon("abbrechen"); - private static Logger logger = Logger.getLogger(SearchResultTabbedPane.class); + private static final Icon icon = IconManager.getInstance().getIcon("abbrechen"); + private static final Logger logger = LoggerFactory.getLogger(SearchResultTabbedPane.class); public SearchResultTabbedPane() { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java index f6e9d054..8755d177 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntryIconRenderer.java @@ -4,18 +4,15 @@ package de.applejuicenet.client.gui.search.table; -import java.awt.Color; -import java.awt.Component; -import java.util.HashSet; - -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.FileName; import de.applejuicenet.client.fassade.entity.SearchEntry; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; +import java.util.HashSet; + public class SearchEntryIconRenderer extends DefaultTableCellRenderer { private static HashSet<String> md5Sums = new HashSet<String>(); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java similarity index 87% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java index dc5b034c..ef8c240c 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchEntrySizeRenderer.java @@ -4,14 +4,11 @@ package de.applejuicenet.client.gui.search.table; -import java.awt.Component; +import de.applejuicenet.client.gui.download.table.DownloadsTableModel; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; - -import de.applejuicenet.client.gui.download.table.DownloadsTableModel; +import java.awt.*; public class SearchEntrySizeRenderer extends DefaultTableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchTableModel.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchTableModel.java index e0f4cceb..8a54cb0e 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/search/table/SearchTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/search/table/SearchTableModel.java @@ -4,24 +4,21 @@ package de.applejuicenet.client.gui.search.table; -import java.util.List; - -import javax.swing.table.AbstractTableModel; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.entity.FileName; import de.applejuicenet.client.fassade.entity.Search; import de.applejuicenet.client.fassade.entity.SearchEntry; import de.applejuicenet.client.gui.components.table.SortableTableModel; import de.applejuicenet.client.gui.components.table.TableSorter; +import org.slf4j.Logger; + +import javax.swing.table.AbstractTableModel; +import java.util.List; public class SearchTableModel extends AbstractTableModel implements SortableTableModel<SearchEntry> { final static String[] COL_NAMES = {"Dateiname", "Groesze", "Anzahl"}; @SuppressWarnings("unchecked") public static final Class[] CLASS_TYPES = {SearchEntry.class, Long.class, Integer.class}; - private Logger logger; private final Search search; private TableSorter<SearchEntry> sorter; diff --git a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/NewServerDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/NewServerDialog.java similarity index 50% rename from AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/NewServerDialog.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/NewServerDialog.java index 4b6caf14..9943d8c5 100644 --- a/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/NewServerDialog.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/NewServerDialog.java @@ -1,38 +1,45 @@ -package de.applejuicenet.client.gui.plugins.serverwatcher; +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.server; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.shared.NumberInputVerifier; +import de.applejuicenet.client.shared.SoundPlayer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; -import java.awt.event.WindowEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; +import java.awt.event.*; /** - * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/serverwatcher/src/de/applejuicenet/client/gui/plugins/serverwatcher/NewServerDialog.java,v 1.2 2004/10/14 08:57:55 maj0r Exp $ + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/server/NewServerDialog.java,v 1.5 2009/01/12 09:19:20 maj0r Exp $ * * <p>Titel: AppleJuice Core-GUI</p> - * <p>Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> - * + * @author Maj0r <aj@tkl-soft.de> */ - public class NewServerDialog extends JDialog { - private JButton ok = new JButton("OK"); - private JButton abbrechen = new JButton("Abbrechen"); + private JButton ok = new JButton(); private JTextField dyn = new JTextField(); private JTextField port = new JTextField(); - private JTextField user = new JTextField(); - private JTextField pass = new JTextField(); - private boolean save = false; - private ServerConfig serverConfig; + private boolean legal = false; + private String link = ""; + private Logger logger; public NewServerDialog(Frame parent, boolean modal) { super(parent, modal); - init(); + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } } private void init() { @@ -41,70 +48,66 @@ public void windowClosing(WindowEvent evt) { close(); } }); - setTitle("Neuer Server"); + + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + setTitle(languageSelector.getFirstAttrbuteByTagName("addserverform.caption")); + ok.setText(languageSelector.getFirstAttrbuteByTagName("addserverform.okbtn.caption")); dyn.setColumns(15); port.setColumns(5); port.setDocument(new NumberInputVerifier()); - user.setColumns(15); - pass.setColumns(15); getContentPane().setLayout(new BorderLayout()); JPanel panel2 = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.NORTH; constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0; constraints.gridy = 0; constraints.insets.left = 5; - panel2.add(new JLabel("Ip: "), constraints); + panel2.add(new JLabel(languageSelector.getFirstAttrbuteByTagName("addserverform.serverlbl.caption") + ": "), constraints); constraints.gridy = 1; - panel2.add(new JLabel("Port: "), constraints); - constraints.gridy = 2; - panel2.add(new JLabel("User: "), constraints); - constraints.gridy = 3; - panel2.add(new JLabel("Passwort: "), constraints); + panel2.add(new JLabel(languageSelector.getFirstAttrbuteByTagName("addserverform.portlbl.caption") + ": "), constraints); constraints.insets.left = 0; constraints.gridx = 1; constraints.gridy = 0; panel2.add(dyn, constraints); constraints.gridy = 1; panel2.add(port, constraints); - constraints.gridy = 2; - panel2.add(user, constraints); - constraints.gridy = 3; - panel2.add(pass, constraints); getContentPane().add(panel2, BorderLayout.CENTER); JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + panel1.add(ok); - panel1.add(abbrechen); getContentPane().add(panel1, BorderLayout.SOUTH); pack(); - ok.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - if (dyn.getText().length() > 0 && port.getText().length() > 0 - && user.getText().length() > 0 && pass.getText().length() > 0) - { - serverConfig = new ServerConfig(dyn.getText(), port.getText(), user.getText() + ":" + pass.getText()); - save = true; - close(); + port.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent ke) { + if (ke.getKeyCode() == KeyEvent.VK_ENTER) { + ok.doClick(); } } }); - abbrechen.addActionListener(new ActionListener() { + ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - close(); + if (dyn.getText().length() > 0 && port.getText().length() > 0) { + legal = true; + link = "ajfsp://server|" + dyn.getText() + "|" + port.getText(); + close(); + } } }); + SoundPlayer.getInstance().playSound(SoundPlayer.KONKRETISIEREN); } private void close() { dispose(); } - public boolean isSave() { - return save; + public String getLink() { + return link; } - public ServerConfig getServerConfig() { - return serverConfig; + public boolean isLegal() { + return legal; } } diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/ServerPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/ServerPanel.java new file mode 100644 index 00000000..ffd8878d --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/ServerPanel.java @@ -0,0 +1,493 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.server; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Information; +import de.applejuicenet.client.fassade.entity.Server; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.fassade.shared.NetworkInfo; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.RegisterI; +import de.applejuicenet.client.gui.components.table.HeaderListener; +import de.applejuicenet.client.gui.components.table.SortButtonRenderer; +import de.applejuicenet.client.gui.components.table.SortableTableModel; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.gui.server.table.ServerTableCellRenderer; +import de.applejuicenet.client.gui.server.table.ServerTableDateCellRenderer; +import de.applejuicenet.client.gui.server.table.ServerTableModel; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.SoundPlayer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.*; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/ServerPanel.java,v + * 1.57 2004/06/11 09:24:30 maj0r Exp $ + * + * <p> + * Titel: AppleJuice Client-GUI + * </p> + * <p> + * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + * </p> + * <p> + * Copyright: General Public License + * </p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class ServerPanel extends JPanel implements LanguageListener, DataUpdateListener, RegisterI { + private static ServerPanel instance; + private JTable serverTable; + private JButton sucheServer = new JButton(); + private JPopupMenu popup = new JPopupMenu(); + private JPopupMenu popup2 = new JPopupMenu(); + private JPopupMenu popup3 = new JPopupMenu(); + private JMenuItem verbinden; + private JMenuItem loeschen1; + private JMenuItem hinzufuegen2; + private JMenuItem hinzufuegen3; + private JMenuItem hinzufuegen1; + private JMenuItem loeschen2; + private JMenuItem itemCopyToClipboard; + private JLabel verbunden = new JLabel(); + private JLabel versucheZuVerbinden = new JLabel(); + private JLabel aelter24h = new JLabel(); + private JLabel juenger24h = new JLabel(); + private Logger logger; + private boolean initialized = false; + private String warnungTitel; + private String warnungNachricht; + private boolean tabSelected; + + private ServerPanel() { + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static synchronized ServerPanel getInstance() { + if (instance == null) { + instance = new ServerPanel(); + } + + return instance; + } + + private void init() throws Exception { + setLayout(new BorderLayout()); + LanguageSelector.getInstance().addLanguageListener(this); + + sucheServer.setForeground(Color.BLUE); + IconManager im = IconManager.getInstance(); + + verbinden = new JMenuItem(); + verbinden.setIcon(im.getIcon("serververbinden")); + hinzufuegen1 = new JMenuItem(); + hinzufuegen1.setIcon(im.getIcon("serverneu")); + loeschen1 = new JMenuItem(); + loeschen1.setIcon(im.getIcon("serverloeschen")); + hinzufuegen2 = new JMenuItem(); + hinzufuegen2.setIcon(im.getIcon("serverneu")); + hinzufuegen3 = new JMenuItem(); + hinzufuegen3.setIcon(im.getIcon("serverneu")); + loeschen2 = new JMenuItem(); + loeschen2.setIcon(im.getIcon("serverloeschen")); + itemCopyToClipboard = new JMenuItem(); + itemCopyToClipboard.setIcon(im.getIcon("clipboard")); + + popup.add(verbinden); + popup.add(hinzufuegen3); + popup.add(itemCopyToClipboard); + popup.add(loeschen1); + popup2.add(hinzufuegen2); + popup3.add(hinzufuegen1); + popup3.add(loeschen2); + verbinden.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + int selected = serverTable.getSelectedRow(); + Server server = (Server) ((ServerTableModel) serverTable.getModel()).getRow(selected); + ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); + + if (af.getInformation().getVerbindungsStatus() == Information.VERBUNDEN) { + NetworkInfo netInfo = af.getNetworkInfo(); + long timestamp = af.getLastCoreTimestamp().longValue(); + + if (timestamp == 0) { + /* + * Es wurden noch keine Referenzdaten geholt. Wir nehmen + * die eigene Zeit, in der Hoffnung, dass die + * uebereinstimmen. + */ + timestamp = System.currentTimeMillis(); + } + + long timeDiff = timestamp - netInfo.getConnectionTime(); + int minuten = (int) (timeDiff / 60000); + + if (minuten < 0) { + minuten = 0; + } + + if (minuten <= 30) { + String tmp = warnungNachricht.replaceAll("%s", Integer.toString(minuten)); + int result = JOptionPane.showConfirmDialog(AppleJuiceDialog.getApp(), tmp, warnungTitel, + JOptionPane.YES_NO_OPTION); + + if (result != JOptionPane.YES_OPTION) { + return; + } + } + } + + try { + AppleJuiceClient.getAjFassade().connectToServer(server); + SoundPlayer.getInstance().playSound(SoundPlayer.VERBINDEN); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }); + + ActionListener loescheServerListener = new ActionListener() { + public void actionPerformed(ActionEvent ae) { + int[] selected = serverTable.getSelectedRows(); + + if (selected.length > 0) { + Server server = null; + List<Server> toRemove = new Vector<Server>(); + + for (int j : selected) { + server = ((ServerTableModel) serverTable.getModel()).getRow(j); + if (server != null) { + toRemove.add(server); + } + } + + try { + AppleJuiceClient.getAjFassade().entferneServer(toRemove); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + }; + + ActionListener clipboardListener = ae -> { + int[] selectedItems = serverTable.getSelectedRows(); + + if (selectedItems.length == 1) { + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuffer toCopy = new StringBuffer(); + + toCopy.append("ajfsp://server|"); + Server server = ((ServerTableModel) serverTable.getModel()).getRow(selectedItems[0]); + + toCopy.append(server.getHost()); + toCopy.append("|"); + toCopy.append(server.getPort()); + toCopy.append("/"); + StringSelection contents = new StringSelection(toCopy.toString()); + + cb.setContents(contents, null); + } + }; + + itemCopyToClipboard.addActionListener(clipboardListener); + loeschen1.addActionListener(loescheServerListener); + loeschen2.addActionListener(loescheServerListener); + ActionListener newServerListener = new ActionListener() { + public void actionPerformed(ActionEvent ae) { + NewServerDialog newServerDialog = new NewServerDialog(AppleJuiceDialog.getApp(), true); + Dimension appDimension = newServerDialog.getSize(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + newServerDialog.setLocation((screenSize.width - appDimension.width) / 2, (screenSize.height - appDimension.height) / 2); + newServerDialog.setVisible(true); + if (newServerDialog.isLegal()) { + final String link = newServerDialog.getLink(); + + new Thread() { + public void run() { + try { + AppleJuiceClient.getAjFassade().processLink(link, ""); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }.start(); + } + } + }; + + hinzufuegen2.addActionListener(newServerListener); + hinzufuegen3.addActionListener(newServerListener); + hinzufuegen1.addActionListener(newServerListener); + + JPanel panel1 = new JPanel(); + + panel1.setLayout(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + + sucheServer.addActionListener(ae -> { + Thread worker = new Thread() { + public void run() { + String ServerListURL = OptionsManagerImpl.getInstance().getServerListURL(); + ApplejuiceFassade af = AppleJuiceClient.getAjFassade(); + String[] server = af.getNetworkKnownServers(ServerListURL); + + if (server == null || server.length == 0) { + return; + } + + for (int i = 0; i < server.length; i++) { + try { + af.processLink(server[i], ""); + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + } + }; + + worker.start(); + }); + panel1.add(sucheServer, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + panel1.add(new JLabel(), constraints); + add(panel1, BorderLayout.NORTH); + serverTable = new JTable(); + serverTable.setModel(new ServerTableModel()); + serverTable.setShowGrid(false); + serverTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + SortButtonRenderer renderer = new SortButtonRenderer(); + TableColumnModel model = serverTable.getColumnModel(); + int n = model.getColumnCount(); + + for (int i = 0; i < n; i++) { + model.getColumn(i).setHeaderRenderer(renderer); + model.getColumn(i).setPreferredWidth(model.getColumn(i).getWidth()); + } + + JTableHeader header = serverTable.getTableHeader(); + + header.addMouseListener(new HeaderListener(header, renderer) { + private PositionManager pm = PositionManagerImpl.getInstance(); + + @Override + public void internalSort(int column, boolean ascent) { + pm.setServerSort(column, ascent); + + super.internalSort(column, ascent); + } + }); + + serverTable.setDefaultRenderer(Server.class, new ServerTableCellRenderer()); + serverTable.setDefaultRenderer(Date.class, new ServerTableDateCellRenderer()); + final JScrollPane aScrollPane = new JScrollPane(serverTable); + + aScrollPane.setBackground(serverTable.getBackground()); + serverTable.getTableHeader().setBackground(serverTable.getBackground()); + aScrollPane.getViewport().setOpaque(false); + MouseAdapter popupMouseAdapter = new MouseAdapter() { + public void mousePressed(MouseEvent me) { + super.mouseReleased(me); + maybeShowPopup(me); + } + + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + int selectedRow = serverTable.rowAtPoint(e.getPoint()); + + if (selectedRow != -1) { + if (serverTable.getSelectedRowCount() == 0) { + serverTable.setRowSelectionInterval(selectedRow, selectedRow); + } else { + int[] currentSelectedRows = serverTable.getSelectedRows(); + + for (int i = 0; i < currentSelectedRows.length; i++) { + if (currentSelectedRows[i] == selectedRow) { + selectedRow = -1; + break; + } + } + + if (selectedRow != -1) { + serverTable.setRowSelectionInterval(selectedRow, selectedRow); + } + } + } + + if (serverTable.getSelectedRowCount() == 1) { + popup.show(serverTable, e.getX(), e.getY()); + } else if (serverTable.getSelectedRowCount() > 1) { + popup3.show(serverTable, e.getX(), e.getY()); + } else { + popup2.show(serverTable, e.getX(), e.getY()); + } + } + } + }; + + aScrollPane.addMouseListener(popupMouseAdapter); + serverTable.addMouseListener(popupMouseAdapter); + add(aScrollPane, BorderLayout.CENTER); + JPanel legende = new JPanel(new FlowLayout()); + ImageIcon icon1 = im.getIcon("serververbunden"); + ImageIcon icon2 = im.getIcon("serverversuche"); + ImageIcon icon3 = im.getIcon("aelter24h"); + ImageIcon icon4 = im.getIcon("juenger24h"); + JLabel label1 = new JLabel(icon1); + JLabel label2 = new JLabel(icon2); + JLabel label3 = new JLabel(icon3); + JLabel label4 = new JLabel(icon4); + + legende.add(label1); + legende.add(verbunden); + legende.add(label2); + legende.add(versucheZuVerbinden); + legende.add(label3); + legende.add(aelter24h); + legende.add(label4); + legende.add(juenger24h); + add(legende, BorderLayout.SOUTH); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.SERVER_CHANGED); + } + + public void registerSelected() { + tabSelected = true; + try { + if (!initialized) { + initialized = true; + TableColumnModel headerModel = serverTable.getTableHeader().getColumnModel(); + int columnCount = headerModel.getColumnCount(); + PositionManager pm = PositionManagerImpl.getInstance(); + int[] sort = pm.getServerSort(); + + if (pm.isLegal()) { + int[] widths = pm.getServerWidths(); + + for (int i = 0; i < columnCount; i++) { + headerModel.getColumn(i).setPreferredWidth(widths[i]); + } + } else { + for (int i = 0; i < columnCount; i++) { + headerModel.getColumn(i).setPreferredWidth(serverTable.getWidth() / columnCount); + } + } + + if (null != sort) { + for (MouseListener curMl : serverTable.getTableHeader().getMouseListeners()) { + if (curMl instanceof HeaderListener) { + ((HeaderListener) curMl).sort(sort[0], sort[1] == 1); + } + } + } + + serverTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + @SuppressWarnings("unchecked") + public void fireContentChanged(DATALISTENER_TYPE type, final Object content) { + if (type == DATALISTENER_TYPE.SERVER_CHANGED) { + boolean changed = ((ServerTableModel) serverTable.getModel()).setTable((HashMap<String, Server>) content); + + if (changed && tabSelected) { + ((SortableTableModel) serverTable.getModel()).forceResort(); + SwingUtilities.invokeLater(() -> serverTable.updateUI()); + } + } + } + + public void fireLanguageChanged() { + try { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + sucheServer.setText(languageSelector.getFirstAttrbuteByTagName("mainform.Label11.caption")); + String[] columns = new String[5]; + + columns[0] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col0caption"); + columns[1] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col1caption"); + columns[2] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col3caption"); + columns[3] = languageSelector.getFirstAttrbuteByTagName("javagui.serverform.col4caption"); + columns[4] = languageSelector.getFirstAttrbuteByTagName("mainform.serverlist.col5caption"); + verbinden.setText(languageSelector.getFirstAttrbuteByTagName("mainform.connserv.caption")); + loeschen1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.delserv.caption")); + hinzufuegen2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); + hinzufuegen3.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); + hinzufuegen1.setText(languageSelector.getFirstAttrbuteByTagName("mainform.addserv.caption")); + loeschen2.setText(languageSelector.getFirstAttrbuteByTagName("mainform.delserv.caption")); + verbunden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.verbunden")); + versucheZuVerbinden.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.verbinden")); + aelter24h.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.aelter24h")); + juenger24h.setText(languageSelector.getFirstAttrbuteByTagName("javagui.serverform.juenger24h")); + warnungTitel = languageSelector.getFirstAttrbuteByTagName("mainform.caption"); + warnungNachricht = languageSelector.getFirstAttrbuteByTagName("javagui.serverform.warnungnachricht"); + itemCopyToClipboard.setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); + + TableColumnModel tcm = serverTable.getColumnModel(); + + for (int i = 0; i < tcm.getColumnCount(); i++) { + tcm.getColumn(i).setHeaderValue(columns[i]); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public int[] getColumnWidths() { + TableColumnModel tcm = serverTable.getColumnModel(); + int[] widths = new int[tcm.getColumnCount()]; + + for (int i = 0; i < tcm.getColumnCount(); i++) { + widths[i] = tcm.getColumn(i).getWidth(); + } + + return widths; + } + + public void lostSelection() { + tabSelected = false; + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java index 428d4724..29d181dc 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java @@ -3,16 +3,13 @@ */ package de.applejuicenet.client.gui.server.table; -import java.awt.Component; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.Server; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableCellRenderer.java,v 1.4 2009/01/22 22:18:23 maj0r Exp $ * @@ -20,7 +17,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r <aj@tkl-soft.de> + * @author Maj0r <aj@tkl-soft.de> * */ public class ServerTableCellRenderer extends DefaultTableCellRenderer diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java index 4a62a909..89d81ca3 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableDateCellRenderer.java @@ -3,16 +3,12 @@ */ package de.applejuicenet.client.gui.server.table; -import java.awt.Component; - +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; import java.text.SimpleDateFormat; - import java.util.Date; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.DefaultTableCellRenderer; - public class ServerTableDateCellRenderer extends DefaultTableCellRenderer { private static final SimpleDateFormat FORMATER_LONG = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableModel.java index d1306583..2837c8b4 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/server/table/ServerTableModel.java @@ -4,17 +4,16 @@ package de.applejuicenet.client.gui.server.table; +import de.applejuicenet.client.fassade.entity.Server; +import de.applejuicenet.client.gui.components.table.SortableTableModel; +import de.applejuicenet.client.gui.components.table.TableSorter; + +import javax.swing.table.AbstractTableModel; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import javax.swing.table.AbstractTableModel; - -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.gui.components.table.SortableTableModel; -import de.applejuicenet.client.gui.components.table.TableSorter; - /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/server/table/ServerTableModel.java,v 1.11 2009/01/27 07:55:56 maj0r Exp $ * @@ -22,7 +21,7 @@ * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> * <p>Copyright: General Public License</p> * - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class ServerTableModel extends AbstractTableModel implements SortableTableModel<Server> diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/DateiListeDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/DateiListeDialog.java new file mode 100644 index 00000000..9ae2b5be --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/DateiListeDialog.java @@ -0,0 +1,330 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.share; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Share; +import de.applejuicenet.client.gui.components.dragndrop.DndTargetAdapter; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.share.table.DateiListeTableModel; +import de.applejuicenet.client.gui.share.table.ShareNode; +import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.event.*; +import java.io.File; +import java.io.FileWriter; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/DateiListeDialog.java,v 1.8 2009/01/12 09:19:20 maj0r Exp $ + * + * <p>Titel: AppleJuice Client-GUI</p> + * <p>Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core</p> + * <p>Copyright: General Public License</p> + * + * @author Maj0r [aj@tkl-soft.de] + */ +public class DateiListeDialog extends JDialog { + private JLabel speicherTxt = new JLabel(); + private JLabel speicherHtml = new JLabel(); + private JTable table = new JTable(); + private JLabel text = new JLabel(); + private JPopupMenu popup = new JPopupMenu(); + private final Logger logger; + + public DateiListeDialog(Frame parent, boolean modal) { + super(parent, modal); + logger = LoggerFactory.getLogger(getClass()); + init(); + } + + private void removeSelectedColumn() { + int[] selected = table.getSelectedRows(); + + if (selected.length > 0) { + DateiListeTableModel model = (DateiListeTableModel) table.getModel(); + + for (int i = selected.length - 1; i >= 0; i--) { + model.removeRow(selected[i]); + } + } + } + + private void init() { + try { + JMenuItem entfernen = new JMenuItem(); + + entfernen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + removeSelectedColumn(); + } + }); + popup.add(entfernen); + table.setModel(new DateiListeTableModel()); + table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + getContentPane().setLayout(new GridBagLayout()); + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + IconManager im = IconManager.getInstance(); + + speicherTxt.setIcon(im.getIcon("speichern")); + speicherTxt.addMouseListener(new SpeichernMouseAdapter()); + speicherHtml.setIcon(im.getIcon("web")); + speicherHtml.addMouseListener(new SpeichernMouseAdapter()); + panel1.add(speicherTxt); + panel1.add(speicherHtml); + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.weightx = 1; + getContentPane().add(panel1, constraints); + constraints.weightx = 0; + constraints.gridy = 1; + getContentPane().add(text, constraints); + constraints.gridy = 2; + constraints.weighty = 1; + JScrollPane scroll = new JScrollPane(table); + + scroll.setDropTarget(new DropTarget(scroll, new ListeDndTargetAdapter())); + table.setDropTarget(new DropTarget(table, new ListeDndTargetAdapter())); + table.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent ke) { + if (ke.getKeyCode() == KeyEvent.VK_DELETE) { + removeSelectedColumn(); + } else { + super.keyPressed(ke); + } + } + }); + table.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (SwingUtilities.isRightMouseButton(me)) { + Point p = me.getPoint(); + int iRow = table.rowAtPoint(p); + int iCol = table.columnAtPoint(p); + + table.setRowSelectionInterval(iRow, iRow); + table.setColumnSelectionInterval(iCol, iCol); + } + + maybeShowPopup(me); + } + + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) { + if (e.isPopupTrigger() && table.getSelectedRowCount() > 0) { + popup.show(table, e.getX(), e.getY()); + } + } + }); + getContentPane().add(scroll, constraints); + constraints.weighty = 0; + initLanguage(); + pack(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public void initLanguage() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + setTitle(languageSelector.getFirstAttrbuteByTagName("linklist.caption")); + text.setText(languageSelector.getFirstAttrbuteByTagName("linklist.Label1.caption")); + String[] tableColumns = new String[2]; + + tableColumns[0] = languageSelector.getFirstAttrbuteByTagName("linklist.files.col0caption"); + tableColumns[1] = languageSelector.getFirstAttrbuteByTagName("linklist.files.col1caption"); + TableColumnModel tcm = table.getColumnModel(); + + for (int i = 0; i < tableColumns.length; i++) { + tcm.getColumn(i).setHeaderValue(tableColumns[i]); + } + } + + class SpeichernMouseAdapter extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + + source.setBorder(BorderFactory.createLineBorder(Color.black)); + } + + public void mouseClicked(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + JFileChooser fileChooser = new JFileChooser(); + + fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); + if (source == speicherTxt) { + fileChooser.setFileFilter(new TxtFileFilter()); + } else { + fileChooser.setFileFilter(new HtmlFileFilter()); + } + + int i = fileChooser.showSaveDialog(DateiListeDialog.this); + + if (i == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + StringBuffer text = new StringBuffer(); + Share[] share = ((DateiListeTableModel) table.getModel()).getShares(); + + if (source != speicherTxt) { + if (!file.getPath().toLowerCase().endsWith(".htm") && !file.getPath().toLowerCase().endsWith(".html")) { + file = new File(file.getPath() + ".html"); + } + + text.append("<html><head><title>appleJuice Linklist
" + + "\r\n"); + Share[] sortedShareDOs = sortShares(share); + + for (int x = 0; x < share.length; x++) { + text.append("" + "\r\n"); + } + + text.append("
appleJuice Dateien
"); + text.append(sortedShareDOs[x].getShortfilename()); + text.append("
"); + } else { + if (!file.getPath().toLowerCase().endsWith(".ajl")) { + file = new File(file.getPath() + ".ajl"); + } + + text.append("\r\n" + "Du benoetigst ein appleJuice-GUI, um diese Datei zu oeffnen. Das gibts z.B. hier " + + "http://developer.berlios.de/projects/applejuicejava/" + "\r\n\r\n"); + text.append("Diese Datei darf nicht modifiziert werden!" + "\r\n" + "-----\r\n100\r\n"); + Share[] sortedShares = sortShares(share); + + for (int x = 0; x < sortedShares.length; x++) { + text.append(sortedShares[x].getShortfilename() + "\r\n"); + text.append(sortedShares[x].getCheckSum() + "\r\n"); + text.append(sortedShares[x].getSize() + "\r\n"); + } + } + + try { + FileWriter fileWriter = new FileWriter(file); + + fileWriter.write(text.toString()); + fileWriter.close(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + } + + private Share[] sortShares(Share[] share) { + Share[] sortedDOs = share; + int n = sortedDOs.length; + Share tmp; + + for (int i = 0; i < n - 1; i++) { + int k = i; + + for (int j = i + 1; j < n; j++) { + if (sortedDOs[j].getShortfilename().compareToIgnoreCase(sortedDOs[k].getShortfilename()) < 0) { + k = j; + } + } + + tmp = sortedDOs[i]; + sortedDOs[i] = sortedDOs[k]; + sortedDOs[k] = tmp; + } + + return sortedDOs; + } + + public void mouseExited(MouseEvent e) { + JLabel source = (JLabel) e.getSource(); + + source.setBorder(null); + } + } + + + class TxtFileFilter extends FileFilter { + public boolean accept(File file) { + if (!file.isFile()) { + return true; + } else { + String name = file.getName(); + + return (name.toLowerCase().endsWith(".ajl")); + } + } + + public String getDescription() { + return "AJL-Dateien"; + } + } + + + class HtmlFileFilter extends FileFilter { + public boolean accept(File file) { + if (!file.isFile()) { + return true; + } else { + String name = file.getName(); + + return (name.toLowerCase().endsWith(".htm") || name.toLowerCase().endsWith(".html")); + } + } + + public String getDescription() { + return "HTML-Dateien"; + } + } + + + private class ListeDndTargetAdapter extends DndTargetAdapter { + protected Object getTarget(Point point) { + return this; + } + + public void drop(DropTargetDropEvent event) { + Transferable tr = event.getTransferable(); + + if (tr.isDataFlavorSupported(new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, "ShareNodesTransferer"))) { + try { + event.acceptDrop(DnDConstants.ACTION_COPY); + Object[] transfer = (Object[]) tr.getTransferData(new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, + "ShareNodesTransferer")); + + if (transfer != null && transfer.length != 0) { + DateiListeTableModel model = (DateiListeTableModel) table.getModel(); + + for (int i = 0; i < transfer.length; i++) { + model.addNodes((ShareNode) transfer[i]); + } + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + + event.getDropTargetContext().dropComplete(false); + } + } + + event.getDropTargetContext().dropComplete(true); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareController.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/ShareController.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareController.java index b686cd82..58c6b126 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareController.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareController.java @@ -4,23 +4,6 @@ package de.applejuicenet.client.gui.share; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.text.DecimalFormat; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import javax.swing.JComponent; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableColumnModel; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Information; @@ -41,9 +24,23 @@ import de.applejuicenet.client.gui.share.tree.DirectoryNode; import de.applejuicenet.client.gui.share.tree.ShareSelectionTreeModel; import de.applejuicenet.client.shared.DesktopTools; -import de.applejuicenet.client.shared.ReleaseInfoDialog; +import de.applejuicenet.client.shared.ReleaseInfo; import de.applejuicenet.client.shared.SwingWorker; +import javax.swing.*; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.DecimalFormat; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareController.java,v 1.24 2009/02/12 09:11:24 maj0r Exp $ * @@ -51,7 +48,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class ShareController extends GuiController @@ -253,7 +250,7 @@ private void showReleaseInfo() { Share share = ((ShareNode) obj[0]).getShare(); - ReleaseInfoDialog.showReleaseInfo(share.getCheckSum()); + ReleaseInfo.handle(share.getShortfilename(), share.getCheckSum(), (long) share.getSize()); } } @@ -499,7 +496,7 @@ public void run() { try { - int prio = ((Integer) sharePanel.getCmbPrioritaet().getSelectedItem()).intValue(); + int prio = (Integer) sharePanel.getCmbPrioritaet().getSelectedItem(); Object[] values = sharePanel.getShareTable().getSelectedItems(); if(values != null) @@ -673,13 +670,7 @@ public void run() sharePanel.getBtnPrioritaetSetzen().setEnabled(true); sharePanel.getBtnNeuLaden().setEnabled(true); sharePanel.getBtnRefresh().setEnabled(true); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - initShareSelectionTree(); - } - }); + SwingUtilities.invokeLater(() -> initShareSelectionTree()); } }.start(); } diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/SharePanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/SharePanel.java new file mode 100644 index 00000000..00e8593e --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/SharePanel.java @@ -0,0 +1,280 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.share; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.TklPanel; +import de.applejuicenet.client.gui.components.table.NormalHeaderRenderer; +import de.applejuicenet.client.gui.components.tree.WaitNode; +import de.applejuicenet.client.gui.share.table.ShareNode; +import de.applejuicenet.client.gui.share.table.ShareTable; +import de.applejuicenet.client.gui.share.table.ShareTableModel; +import de.applejuicenet.client.gui.share.tree.DirectoryTree; +import de.applejuicenet.client.gui.share.tree.ShareSelectionTreeCellRenderer; +import de.applejuicenet.client.shared.IconManager; +import de.tklsoft.gui.controls.TKLButton; +import de.tklsoft.gui.controls.TKLComboBox; +import de.tklsoft.gui.layout.Synchronizer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import javax.swing.tree.DefaultTreeModel; +import java.awt.*; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/SharePanel.java,v 1.13 2009/02/12 09:11:24 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r [aj@tkl-soft.de] + */ +public class SharePanel extends TklPanel { + private JPanel panelCenter; + private DirectoryTree folderTree = new DirectoryTree(); + private TitledBorder folderTreeBolder; + private TitledBorder mailPanelBolder; + private JLabel dateien = new JLabel(); + private TKLButton neueListe = new TKLButton(); + private TKLButton neuLaden = new TKLButton(); + private TKLButton refresh = new TKLButton(); + private TKLButton prioritaetSetzen = new TKLButton(); + private TKLButton prioritaetAufheben = new TKLButton(); + private TKLComboBox cmbPrio = new TKLComboBox(); + private AJSettings ajSettings; + private ShareTable shareTable; + private ShareTableModel shareModel; + private JPopupMenu popup = new JPopupMenu(); + private JMenuItem sharedwsub; + private JMenuItem sharedwosub; + private JMenuItem notshared; + private JPopupMenu popup2 = new JPopupMenu(); + private JMenuItem itemReleaseInfo = new JMenuItem(); + private JMenuItem itemCopyToClipboard = new JMenuItem(); + private JMenuItem itemCopyToClipboardWithSources = new JMenuItem(); + private JMenuItem itemCopyToClipboardAsUBBCode = new JMenuItem(); + private JMenuItem itemOpenWithProgram = new JMenuItem(); + private JMenuItem itemOpenWithStandardProgramm = new JMenuItem(); + private Logger logger; + + public SharePanel(GuiController guiController) { + super(guiController); + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public JMenuItem getMnuOpenWithStandardProgram() { + return itemOpenWithStandardProgramm; + } + + public TKLButton getBtnPrioritaetAufheben() { + return prioritaetAufheben; + } + + public TKLButton getBtnPrioritaetSetzen() { + return prioritaetSetzen; + } + + public TKLButton getBtnNeuLaden() { + return neuLaden; + } + + public TKLButton getBtnRefresh() { + return refresh; + } + + public TKLButton getBtnNeueListe() { + return neueListe; + } + + public JMenuItem getMnuNotShared() { + return notshared; + } + + public JMenuItem getMnuSharedWithoutSub() { + return sharedwosub; + } + + public JMenuItem getMnuSharedWithSub() { + return sharedwsub; + } + + public JMenuItem getMnuCopyToClipboard() { + return itemCopyToClipboard; + } + + public JMenuItem getMnuReleaseInfo() { + return itemReleaseInfo; + } + + public JMenuItem getMnuCopyToClipboardWithSources() { + return itemCopyToClipboardWithSources; + } + + public JMenuItem getMnuCopyToClipboardAsUBBCode() { + return itemCopyToClipboardAsUBBCode; + } + + public JMenuItem getMnuOpenWithProgram() { + return itemOpenWithProgram; + } + + public ShareTable getShareTable() { + return shareTable; + } + + public ShareTableModel getShareModel() { + return shareModel; + } + + public JLabel getLblDateien() { + return dateien; + } + + public TKLComboBox getCmbPrioritaet() { + return cmbPrio; + } + + public DirectoryTree getDirectoryTree() { + return folderTree; + } + + public JPopupMenu getPopupMenu() { + return popup; + } + + public JPopupMenu getPopupMenu2() { + return popup2; + } + + public TitledBorder getFolderTreeBolder() { + return folderTreeBolder; + } + + public TitledBorder getMainPanelBolder() { + return mailPanelBolder; + } + + private void init() throws Exception { + IconManager im = IconManager.getInstance(); + + itemReleaseInfo.setIcon(im.getIcon("hint")); + itemCopyToClipboard.setIcon(im.getIcon("clipboard")); + itemCopyToClipboardAsUBBCode.setIcon(im.getIcon("clipboard")); + itemCopyToClipboardWithSources.setIcon(im.getIcon("clipboard")); + prioritaetAufheben.setEnabled(false); + prioritaetSetzen.setEnabled(false); + neuLaden.setEnabled(false); + refresh.setEnabled(false); + + popup2.add(itemCopyToClipboard); + popup2.add(itemCopyToClipboardWithSources); + popup2.add(itemCopyToClipboardAsUBBCode); + popup2.add(new JSeparator()); + popup2.add(itemReleaseInfo); + popup2.add(itemOpenWithProgram); + popup2.add(itemOpenWithStandardProgramm); + itemOpenWithProgram.setIcon(im.getIcon("vlc")); + folderTree.setModel(new DefaultTreeModel(new WaitNode())); + folderTree.setCellRenderer(new ShareSelectionTreeCellRenderer()); + + cmbPrio.setEditable(false); + for (int i = 1; i < 251; i++) { + cmbPrio.addItem(new Integer(i)); + } + + sharedwsub = new JMenuItem(); + sharedwsub.setIcon(im.getIcon("sharedwsub")); + sharedwosub = new JMenuItem(); + sharedwosub.setIcon(im.getIcon("sharedwosub")); + notshared = new JMenuItem(); + notshared.setIcon(im.getIcon("notshared")); + popup.add(sharedwsub); + popup.add(sharedwosub); + popup.add(notshared); + + shareModel = new ShareTableModel(new ShareNode(null, null)); + shareTable = new ShareTable(shareModel); + shareTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + TableColumnModel model = shareTable.getColumnModel(); + int n = model.getColumnCount(); + TableCellRenderer renderer = new NormalHeaderRenderer(); + + for (int i = 0; i < n; i++) { + model.getColumn(i).setHeaderRenderer(renderer); + } + + folderTreeBolder = new TitledBorder("Test"); + mailPanelBolder = new TitledBorder("Tester"); + setLayout(new BorderLayout()); + panelCenter = new JPanel(new BorderLayout()); + panelCenter.setBorder(mailPanelBolder); + + neueListe.setIcon(IconManager.getInstance().getIcon("treeRoot")); + neuLaden.setIcon(IconManager.getInstance().getIcon("erneuern")); + + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + Synchronizer synchronizer = new Synchronizer(Synchronizer.METHOD.HEIGHT); + + synchronizer.add(neuLaden); + synchronizer.add(neueListe); + synchronizer.add(cmbPrio); + synchronizer.add(prioritaetSetzen); + synchronizer.add(prioritaetAufheben); + panel1.add(neuLaden); + panel1.add(neueListe); + panel1.add(cmbPrio); + panel1.add(prioritaetSetzen); + panel1.add(prioritaetAufheben); + + panelCenter.add(panel1, BorderLayout.NORTH); + JScrollPane scrollPane = new JScrollPane(shareTable); + + scrollPane.setBackground(shareTable.getBackground()); + scrollPane.getViewport().setOpaque(false); + + panelCenter.add(scrollPane, BorderLayout.CENTER); + panelCenter.add(dateien, BorderLayout.SOUTH); + + JScrollPane aScrollPane = new JScrollPane(folderTree); + + aScrollPane.setBorder(folderTreeBolder); + JPanel panelWest = new JPanel(new BorderLayout()); + + panelWest.add(aScrollPane, BorderLayout.CENTER); + panelWest.add(refresh, BorderLayout.SOUTH); + JSplitPane splitPane = new JSplitPane(); + + splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); + splitPane.setLeftComponent(panelWest); + splitPane.setRightComponent(panelCenter); + splitPane.setBorder(null); + add(splitPane, BorderLayout.CENTER); + + cmbPrio.disableDirtyComponent(true); + } + + public int[] getColumnWidths() { + TableColumnModel tcm = shareTable.getColumnModel(); + int[] widths = new int[tcm.getColumnCount()]; + + for (int i = 0; i < tcm.getColumnCount(); i++) { + widths[i] = tcm.getColumn(i).getWidth(); + } + + return widths; + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java index 033307c5..261c3c99 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java @@ -1,15 +1,13 @@ package de.applejuicenet.client.gui.share; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; - import de.applejuicenet.client.gui.share.table.ShareNode; import de.applejuicenet.client.gui.share.table.ShareTable; +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTableMouseAdapter.java,v 1.3 2004/10/15 13:39:47 maj0r Exp $ * @@ -17,7 +15,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -58,4 +56,4 @@ private void maybeShowPopup(MouseEvent e) { } } } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java similarity index 53% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java index aaf06e8b..44ae08bd 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java @@ -1,19 +1,15 @@ package de.applejuicenet.client.gui.share; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.gui.share.tree.DirectoryNode; import de.applejuicenet.client.gui.share.tree.DirectoryTree; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/ShareTreeMouseAdapter.java,v 1.4 2005/01/18 17:35:29 maj0r Exp $ @@ -22,29 +18,28 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r - * + * @author Maj0r */ public class ShareTreeMouseAdapter extends MouseAdapter { - - private static Logger logger = Logger.getLogger(ShareTreeMouseAdapter.class); - - private DirectoryTree folderTree; - private JPopupMenu popup; - private JMenuItem sharedWithSub; - private JMenuItem sharedWithoutSub; - private JMenuItem notShared; - - public ShareTreeMouseAdapter(DirectoryTree folderTree, JPopupMenu popup, - JMenuItem sharedWithSub, JMenuItem sharedWithoutSub, JMenuItem notShared){ - this.folderTree = folderTree; - this.popup = popup; - this.sharedWithSub = sharedWithSub; - this.sharedWithoutSub = sharedWithoutSub; - this.notShared = notShared; - } - + + private static final Logger logger = LoggerFactory.getLogger(ShareTreeMouseAdapter.class); + + private final DirectoryTree folderTree; + private final JPopupMenu popup; + private final JMenuItem sharedWithSub; + private final JMenuItem sharedWithoutSub; + private final JMenuItem notShared; + + public ShareTreeMouseAdapter(DirectoryTree folderTree, JPopupMenu popup, + JMenuItem sharedWithSub, JMenuItem sharedWithoutSub, JMenuItem notShared) { + this.folderTree = folderTree; + this.popup = popup; + this.sharedWithSub = sharedWithSub; + this.sharedWithoutSub = sharedWithoutSub; + this.notShared = notShared; + } + public void mousePressed(MouseEvent me) { try { if (SwingUtilities.isRightMouseButton(me)) { @@ -53,11 +48,8 @@ public void mousePressed(MouseEvent me) { folderTree.setSelectionRow(iRow); } maybeShowPopup(me); - } - catch (Exception ex) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); } } @@ -65,11 +57,8 @@ public void mouseReleased(MouseEvent e) { try { super.mouseReleased(e); maybeShowPopup(e); - } - catch (Exception ex) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); } } @@ -77,31 +66,27 @@ private void maybeShowPopup(MouseEvent e) { try { if (e.isPopupTrigger()) { DirectoryNode node = (DirectoryNode) folderTree. - getLastSelectedPathComponent(); + getLastSelectedPathComponent(); if (node == null) { return; } popup.removeAll(); int nodeShareMode = node.getShareMode(); if (nodeShareMode == DirectoryNode.NOT_SHARED - || nodeShareMode == DirectoryNode.SHARED_SOMETHING - || nodeShareMode == DirectoryNode.SHARED_SUB) { + || nodeShareMode == DirectoryNode.SHARED_SOMETHING + || nodeShareMode == DirectoryNode.SHARED_SUB) { popup.add(sharedWithSub); popup.add(sharedWithoutSub); popup.show(folderTree, e.getX(), e.getY()); - } - else if (nodeShareMode == DirectoryNode.SHARED_WITH_SUB - || - nodeShareMode == DirectoryNode.SHARED_WITHOUT_SUB) { + } else if (nodeShareMode == DirectoryNode.SHARED_WITH_SUB + || + nodeShareMode == DirectoryNode.SHARED_WITHOUT_SUB) { popup.add(notShared); popup.show(folderTree, e.getX(), e.getY()); } } - } - catch (Exception ex) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); - } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); } } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java index 355baf6b..5681a9d1 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java @@ -3,12 +3,11 @@ */ package de.applejuicenet.client.gui.share.table; -import java.util.HashMap; -import java.util.Map; +import de.applejuicenet.client.fassade.entity.Share; import javax.swing.table.AbstractTableModel; - -import de.applejuicenet.client.fassade.entity.Share; +import java.util.HashMap; +import java.util.Map; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DateiListeTableModel.java,v 1.7 2009/01/18 22:57:48 maj0r Exp $ @@ -17,7 +16,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class DateiListeTableModel extends AbstractTableModel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DragShareNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DragShareNode.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/DragShareNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DragShareNode.java index 4c881952..7bc8a4e9 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DragShareNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/DragShareNode.java @@ -1,9 +1,8 @@ package de.applejuicenet.client.gui.share.table; -import java.io.Serializable; - import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; +import java.io.Serializable; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/table/DragShareNode.java,v 1.2 2004/11/22 16:25:26 maj0r Exp $ @@ -12,7 +11,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareNode.java similarity index 96% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareNode.java index a17c8d3c..9648c63a 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareNode.java @@ -4,15 +4,6 @@ package de.applejuicenet.client.gui.share.table; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.swing.Icon; -import javax.swing.ImageIcon; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Share; @@ -20,6 +11,13 @@ import de.applejuicenet.client.fassade.shared.FileType; import de.applejuicenet.client.gui.components.treetable.Node; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareNode.java,v 1.10 2009/01/18 22:57:48 maj0r Exp $ @@ -28,13 +26,13 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class ShareNode implements Node { - private static ImageIcon treeIcon; - private static Logger logger = Logger.getLogger(ShareNode.class); + private static final ImageIcon treeIcon; + private static final Logger logger = LoggerFactory.getLogger(ShareNode.class); static { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTable.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTable.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTable.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTable.java index c3b0ebba..0cfde8df 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTable.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTable.java @@ -1,16 +1,12 @@ package de.applejuicenet.client.gui.share.table; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDropEvent; - import de.applejuicenet.client.gui.components.dragndrop.DndSourceAdapter; import de.applejuicenet.client.gui.components.treetable.DefaultTreeTableCellRenderer; import de.applejuicenet.client.gui.components.treetable.JTreeTable; import de.applejuicenet.client.gui.components.treetable.TreeTableModelAdapter; +import java.awt.dnd.*; + public class ShareTable extends JTreeTable { private static DragSource dragSource = DragSource.getDefaultDragSource(); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java index 32d83d0e..09427613 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java @@ -1,13 +1,11 @@ package de.applejuicenet.client.gui.share.table; -import java.awt.Component; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.TableCellRenderer; - import de.applejuicenet.client.gui.components.treetable.TreeTableModelAdapter; +import javax.swing.*; +import javax.swing.table.TableCellRenderer; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableCellRenderer.java,v 1.2 2004/10/29 11:58:43 maj0r Exp $ * @@ -15,7 +13,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableModel.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableModel.java index cd36be7f..79124595 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/table/ShareTableModel.java @@ -4,14 +4,13 @@ package de.applejuicenet.client.gui.share.table; -import java.text.SimpleDateFormat; - -import java.util.Date; - import de.applejuicenet.client.gui.components.treetable.AbstractTreeTableModel; import de.applejuicenet.client.gui.components.treetable.TreeTableModel; import de.applejuicenet.client.gui.download.table.DownloadsTableModel; +import java.text.SimpleDateFormat; +import java.util.Date; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/table/ShareTableModel.java,v 1.1 2009/01/27 07:55:55 maj0r Exp $ * @@ -19,7 +18,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class ShareTableModel extends AbstractTreeTableModel @@ -70,7 +69,6 @@ public String getColumnName(int column) return cNames[column]; } - @SuppressWarnings("unchecked") public Class getColumnClass(int column) { return CLASS_TYPES[column]; @@ -113,7 +111,7 @@ public Object getValueAt(Object node, int column) { if(shareNode.isLeaf() && shareNode != getRoot()) { - return new Integer(shareNode.getShare().getPrioritaet()); + return shareNode.getShare().getPrioritaet(); } else { @@ -137,7 +135,7 @@ public Object getValueAt(Object node, int column) { if(shareNode.isLeaf() && shareNode != getRoot()) { - return new Long(shareNode.getShare().getAskCount()); + return shareNode.getShare().getAskCount(); } else { @@ -149,7 +147,7 @@ public Object getValueAt(Object node, int column) { if(shareNode.isLeaf() && shareNode != getRoot()) { - return new Long(shareNode.getShare().getSearchCount()); + return shareNode.getShare().getSearchCount(); } else { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryNode.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryNode.java similarity index 76% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryNode.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryNode.java index 030f3606..3288dd12 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryNode.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryNode.java @@ -1,18 +1,5 @@ package de.applejuicenet.client.gui.share.tree; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.swing.Icon; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; - import de.applejuicenet.client.AppleJuiceClient; import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Directory; @@ -22,6 +9,13 @@ import de.applejuicenet.client.gui.components.tree.ApplejuiceNode; import de.applejuicenet.client.gui.components.treetable.Node; import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import java.util.*; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryNode.java,v 1.7 2005/02/28 14:58:19 maj0r Exp $ @@ -30,20 +24,19 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] - * + * @author Maj0r [aj@tkl-soft.de] */ public class DirectoryNode - extends DefaultMutableTreeNode - implements Node, ApplejuiceNode { - public static final int NOT_SHARED = 0; + extends DefaultMutableTreeNode + implements Node, ApplejuiceNode { + public static final int NOT_SHARED = 0; public static final int SHARED_WITH_SUB = 1; public static final int SHARED_WITHOUT_SUB = 2; public static final int SHARED_SOMETHING = 3; public static final int SHARED_SUB = 4; - - private static Logger logger = Logger.getLogger(DirectoryNode.class); + + private static final Logger logger = LoggerFactory.getLogger(DirectoryNode.class); private static Set shareDirs = new HashSet(); private static Map icons = new HashMap(); @@ -62,14 +55,14 @@ public DirectoryNode() { this.parent = null; this.directory = null; try { - children = new ArrayList(); - List directories = AppleJuiceClient.getAjFassade().getDirectories(null); - for (Directory curDirectory : directories){ - children.add(new DirectoryNode(this, curDirectory)); - } - } catch (IllegalArgumentException e) { - logger.error(e); - } + children = new ArrayList(); + List directories = AppleJuiceClient.getAjFassade().getDirectories(null); + for (Directory curDirectory : directories) { + children.add(new DirectoryNode(this, curDirectory)); + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } } public static void setShareDirs(Set newShareDirs) { @@ -94,32 +87,29 @@ public int getShareMode() { } int shareMode = NOT_SHARED; for (ShareEntry curShareEntry : shareDirs) { - if (directory.getName().indexOf("crypto") != -1){ - int i = 0; - } + if (directory.getName().indexOf("crypto") != -1) { + int i = 0; + } if (curShareEntry.getDir().toLowerCase().startsWith(directory.getPath(). - toLowerCase())) { + toLowerCase())) { if (directory.getPath().length() < curShareEntry.getDir().length() - && - directory.getPath().lastIndexOf(ApplejuiceFassade.separator) == - curShareEntry.getDir().lastIndexOf(ApplejuiceFassade.separator)) { + && + directory.getPath().lastIndexOf(ApplejuiceFassade.separator) == + curShareEntry.getDir().lastIndexOf(ApplejuiceFassade.separator)) { continue; } if (curShareEntry.getShareMode() == SHAREMODE.SUBDIRECTORY) { if (directory.getPath().toLowerCase().startsWith(curShareEntry. - getDir().toLowerCase())) { + getDir().toLowerCase())) { return SHARED_WITH_SUB; - } - else { + } else { return SHARED_SOMETHING; } - } - else { + } else { if (directory.getPath().toLowerCase().startsWith(curShareEntry. - getDir().toLowerCase())) { + getDir().toLowerCase())) { return SHARED_WITHOUT_SUB; - } - else { + } else { return SHARED_SOMETHING; } } @@ -133,7 +123,7 @@ public int getShareMode() { } public Icon getShareModeIcon() { - if (!initialized){ + if (!initialized) { initializeImages(); } switch (getShareMode()) { @@ -154,7 +144,7 @@ public Icon getConvenientIcon() { if (directory == null) { return null; //rootNode } - if (!initialized){ + if (!initialized) { initializeImages(); } switch (directory.getType()) { @@ -202,11 +192,11 @@ private void sortChildren() { for (int i = 0; i < n - 1; i++) { k = i; for (int j = i + 1; j < n; j++) { - if (!((DirectoryNode)children.get(j)).getDirectory().isFileSystem()){ + if (!((DirectoryNode) children.get(j)).getDirectory().isFileSystem()) { continue; } if (children.get(j).toString().compareToIgnoreCase(children.get( - k).toString()) < 0) { + k).toString()) < 0) { k = j; } } @@ -220,20 +210,20 @@ protected Object[] getChildren() { if (children == null) { children = new ArrayList(); try { - List directories = AppleJuiceClient.getAjFassade(). - getDirectories(directory.getPath()); - for (Directory curDirectory : directories){ - children.add(new DirectoryNode(this, curDirectory)); - } - } catch (IllegalArgumentException e) { - logger.error(e); - } + List directories = AppleJuiceClient.getAjFassade(). + getDirectories(directory.getPath()); + for (Directory curDirectory : directories) { + children.add(new DirectoryNode(this, curDirectory)); + } + } catch (IllegalArgumentException e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } sortChildren(); } return children.toArray(new DirectoryNode[children.size()]); } - private static void initializeImages(){ + private static void initializeImages() { initialized = true; IconManager im = IconManager.getInstance(); icons.put("server", im.getIcon("server")); @@ -248,13 +238,13 @@ private static void initializeImages(){ icons.put("warten", im.getIcon("warten")); } - public static int getMaxHeight(){ - if (!initialized){ + public static int getMaxHeight() { + if (!initialized) { initializeImages(); } int maxHeight = 0; - for (Icon curIcon : icons.values()){ - if (curIcon.getIconHeight() > maxHeight){ + for (Icon curIcon : icons.values()) { + if (curIcon.getIconHeight() > maxHeight) { maxHeight = curIcon.getIconHeight(); } } diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryTree.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryTree.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryTree.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryTree.java index eb511029..6cce97bb 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/DirectoryTree.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/DirectoryTree.java @@ -1,7 +1,7 @@ package de.applejuicenet.client.gui.share.tree; -import java.awt.Dimension; -import javax.swing.JTree; +import javax.swing.*; +import java.awt.*; /** @@ -11,7 +11,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java index f67f7ab5..caf2c2cf 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java @@ -1,18 +1,11 @@ package de.applejuicenet.client.gui.share.tree; -import java.awt.Color; -import java.awt.Component; -import java.awt.FlowLayout; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTree; -import javax.swing.UIManager; -import javax.swing.tree.TreeCellRenderer; - import de.applejuicenet.client.gui.components.treetable.Node; +import javax.swing.*; +import javax.swing.tree.TreeCellRenderer; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeCellRenderer.java,v 1.2 2004/11/22 16:25:26 maj0r Exp $ * @@ -20,7 +13,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java index b573d175..2e562f4c 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java @@ -1,14 +1,11 @@ package de.applejuicenet.client.gui.share.tree; -import java.util.Vector; - import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; - - import java.util.List; +import java.util.Vector; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/share/tree/ShareSelectionTreeModel.java,v 1.2 2005/02/28 14:58:19 maj0r Exp $ @@ -17,7 +14,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/HyperlinkAdapter.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/HyperlinkAdapter.java new file mode 100644 index 00000000..ca216b27 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/HyperlinkAdapter.java @@ -0,0 +1,61 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.start; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.shared.DesktopTools; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import java.awt.*; +import java.net.URI; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/HyperlinkAdapter.java,v 1.9 2009/02/12 10:27:34 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class HyperlinkAdapter implements HyperlinkListener { + private static Logger logger; + private Component parent; + + public HyperlinkAdapter(Component parent) { + logger = LoggerFactory.getLogger(getClass()); + this.parent = parent; + } + + public void hyperlinkUpdate(HyperlinkEvent e) { + HyperlinkEvent.EventType type = e.getEventType(); + + if (type == HyperlinkEvent.EventType.ENTERED) { + parent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + + } else if (type == HyperlinkEvent.EventType.EXITED) { + parent.setCursor(Cursor.getDefaultCursor()); + } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (e.getURL() != null) { + String url = e.getURL().toString(); + + if (url.length() != 0) { + executeLink(url); + } + } + } + } + + public static void executeLink(String link) { + try { + DesktopTools.browse(new URI(link)); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NachrichtenWorker.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NachrichtenWorker.java new file mode 100644 index 00000000..71235c59 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NachrichtenWorker.java @@ -0,0 +1,92 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.start; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.exception.NoAccessException; +import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/NachrichtenWorker.java,v 1.5 2009/02/12 13:11:40 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class NachrichtenWorker extends Thread { + private final Logger logger; + private StartController startController; + private JLabel version; + private JTextPane nachrichten; + + public NachrichtenWorker(StartController startController, JLabel version, JTextPane nachrichten) { + logger = LoggerFactory.getLogger(getClass()); + this.startController = startController; + this.version = version; + this.nachrichten = nachrichten; + this.setName("NachrichtenWorker"); + } + + public void run() { + logger.debug("NachrichtenWorkerThread gestartet."); + + try { + final String coreVersion = AppleJuiceClient.getAjFassade().getCoreVersion().getVersion(); + logger.info("verwendeter Core: " + coreVersion); + + String htmlText = null; + String newsURL = OptionsManagerImpl.getInstance().getNewsURL(); + String newsURLFormatted = String.format(newsURL, AppleJuiceClient.getAjFassade().getCoreVersion().getVersion()); + logger.debug(String.format("GET %s", newsURLFormatted)); + + try { + htmlText = WebsiteContentLoader.getWebsiteContent(newsURLFormatted); + } catch (NoAccessException e) { + newsURLFormatted = String.format(newsURL, "index"); // fallback to show regular news + htmlText = WebsiteContentLoader.getWebsiteContent(newsURLFormatted); + } + + int pos = htmlText.toLowerCase().indexOf(""); + + StringBuilder buffer = new StringBuilder(); + + if (pos != -1) { + buffer.append(htmlText.substring(pos)); + } else { + buffer.append(""); + buffer.append(htmlText); + buffer.append(""); + } + + int index; + + while ((index = buffer.indexOf(". ")) != -1) { + buffer.replace(index, index + 1, ".
"); + } + + htmlText = buffer.toString(); + final String htmlContent = htmlText; + + SwingUtilities.invokeLater(() -> { + version.setText("GUI: " + AppleJuiceDialog.getVersion() + "
Core: " + coreVersion + ""); + nachrichten.setContentType("text/html"); + nachrichten.setText(htmlContent); + nachrichten.setFont(version.getFont()); + }); + } catch (Exception e) { + logger.error("Versionsabhängige Nachrichten konnten nicht geladen werden."); + } + + logger.debug("NachrichtenWorkerThread beendet."); + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/start/NorthPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NorthPanel.java similarity index 82% rename from AJClientGUI/src/de/applejuicenet/client/gui/start/NorthPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NorthPanel.java index 15790b42..813e1742 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/start/NorthPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/NorthPanel.java @@ -1,16 +1,10 @@ package de.applejuicenet.client.gui.start; -import java.awt.BorderLayout; -import java.awt.Dimension; - -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; - import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/NorthPanel.java,v 1.2 2004/11/22 16:25:26 maj0r Exp $ * @@ -18,7 +12,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -40,4 +34,4 @@ public NorthPanel(JTextPane serverMessage) { public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, icon.getIconHeight()); } -} \ No newline at end of file +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartController.java new file mode 100644 index 00000000..792a602f --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartController.java @@ -0,0 +1,288 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.start; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Information; +import de.applejuicenet.client.fassade.entity.Server; +import de.applejuicenet.client.fassade.shared.NetworkInfo; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.util.Value; +import de.applejuicenet.client.gui.controller.LanguageSelector; + +import javax.swing.*; +import java.util.Map; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/start/StartController.java,v 1.13 2009/01/28 09:44:09 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class StartController extends GuiController { + private static StartController instance = null; + private final StartPanel startPanel; + private boolean firstChange = true; + private boolean firewalled = false; + private String status2Text; + private String verbindungNachrichtText; + private NetworkInfo netInfo = null; + private Information information = null; + private String firewallWarningText; + private String keinServer = ""; + private String verbindungenText; + + private StartController() { + super(); + startPanel = new StartPanel(this); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static synchronized StartController getInstance() { + if (null == instance) { + instance = new StartController(); + } + + return instance; + } + + private void init() { + HyperlinkAdapter hyperlinkAdapter = new HyperlinkAdapter(startPanel.getServerMessagePane()); + + startPanel.getServerMessagePane().addHyperlinkListener(hyperlinkAdapter); + startPanel.getNachrichtenPane().addHyperlinkListener(hyperlinkAdapter); + + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.NETINFO_CHANGED); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.INFORMATION_CHANGED); + LanguageSelector.getInstance().addLanguageListener(this); + } + + public Value[] getCustomizedValues() { + return null; + } + + public void fireAction(int actionId, Object source) { + + // nix + } + + public JComponent getComponent() { + return startPanel; + } + + public void componentSelected() { + + // nix zu tun + } + + public void componentLostSelection() { + + // nix zu tun + } + + protected void languageChanged() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + keinServer = languageSelector.getFirstAttrbuteByTagName("javagui.mainform.keinserver"); + status2Text = languageSelector.getFirstAttrbuteByTagName("mainform.status.status2"); + StringBuffer temp = new StringBuffer(status2Text); + int pos; + + if (netInfo != null) { + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJUserGesamtAsStringWithPoints()); + } + + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJAnzahlDateienAsStringWithPoints()); + } + + pos = temp.indexOf("%s"); + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJGesamtShareWithPoints(0)); + } + } else { + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, "0"); + } + + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, "0"); + } + + pos = temp.indexOf("%s"); + if (pos != -1) { + temp.replace(pos, pos + 2, "0 MB"); + } + } + + startPanel.getLblStatus().setText(temp.toString()); + firewallWarningText = languageSelector.getFirstAttrbuteByTagName("mainform.firewallwarning.caption"); + if (firewalled) { + startPanel.getLblWarnung().setVisible(true); + startPanel.getLblWarnungIcon().setVisible(true); + startPanel.getLblFirewallWarning().setText(firewallWarningText); + } else { + startPanel.getLblWarnung().setVisible(false); + startPanel.getLblWarnungIcon().setVisible(false); + startPanel.getLblFirewallWarning().setText(""); + } + + verbindungNachrichtText = languageSelector.getFirstAttrbuteByTagName("mainform.html10"); + temp = new StringBuffer(verbindungNachrichtText); + pos = temp.indexOf("%s"); + if (pos != -1) { + temp.replace(pos, pos + 2, keinServer); + } + + pos = temp.indexOf("%d"); + if (pos != -1) { + Map servers = AppleJuiceClient.getAjFassade().getAllServer(); + int count; + + if (servers != null) { + count = servers.size(); + } else { + count = 0; + } + + temp.replace(pos, pos + 2, Integer.toString(count)); + } + + startPanel.getLblVerbindungsnachricht().setText(temp.toString()); + verbindungenText = languageSelector.getFirstAttrbuteByTagName("mainform.status.status0"); + temp = new StringBuffer(verbindungenText); + pos = temp.indexOf("%d"); + if (pos != -1) { + if (information != null) { + temp.replace(pos, pos + 2, Long.toString(information.getOpenConnections())); + } else { + temp.replace(pos, pos + 2, "0"); + } + } + + startPanel.getLblVerbindungen().setText(temp.toString()); + startPanel.getLblNetzwerk() + .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html7") + "

"); + startPanel.getLblNeuigkeiten() + .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html13") + "

"); + startPanel.getLblDeinClient() + .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html1") + "

"); + startPanel.getLblWarnung() + .setText("

" + languageSelector.getFirstAttrbuteByTagName("mainform.html15") + "

"); + } + + protected void contentChanged(DATALISTENER_TYPE type, final Object content) { + if (type == DATALISTENER_TYPE.NETINFO_CHANGED) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + try { + if (firstChange) { + firstChange = false; + new NachrichtenWorker(StartController.this, startPanel.getLblVersion(), startPanel.getNachrichtenPane()).start(); + } + + netInfo = (NetworkInfo) content; + StringBuffer temp = new StringBuffer(status2Text); + int pos = temp.indexOf("%d"); + + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJUserGesamtAsStringWithPoints()); + } + + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJAnzahlDateienAsStringWithPoints()); + } + + pos = temp.indexOf("%s"); + if (pos != -1) { + temp.replace(pos, pos + 2, netInfo.getAJGesamtShareWithPoints(0)); + } + + startPanel.getLblStatus().setText(temp.toString()); + if (netInfo.isFirewalled() != firewalled) { + firewalled = !firewalled; + startPanel.getLblWarnung().setVisible(firewalled); + startPanel.getLblWarnungIcon().setVisible(firewalled); + if (firewalled) { + startPanel.getLblFirewallWarning().setText(firewallWarningText); + } else { + startPanel.getLblFirewallWarning().setText(""); + } + + startPanel.repaint(); + } + + String tmp = netInfo.getWelcomeMessage(); + + if (tmp.compareTo(startPanel.getServerMessagePane().getText()) != 0) { + startPanel.getServerMessagePane().setText(tmp); + startPanel.getServerMessagePane().setCaretPosition(0); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + }); + } else if (type == DATALISTENER_TYPE.INFORMATION_CHANGED) { + SwingUtilities.invokeLater(() -> { + try { + information = (Information) content; + StringBuffer temp = new StringBuffer(verbindungNachrichtText); + int pos = temp.indexOf("%s"); + + if (pos != -1) { + if (information.getVerbindungsStatus() == Information.VERBUNDEN) { + if (information.getServerName() == null || information.getServerName().length() == 0) { + Server server = information.getServer(); + + if (server != null) { + String tmp = server.getHost() + ":" + server.getPort(); + + temp.replace(pos, pos + 2, tmp); + } else { + temp.replace(pos, pos + 2, "?"); + } + } else { + temp.replace(pos, pos + 2, information.getServerName()); + } + } else { + temp.replace(pos, pos + 2, keinServer); + } + + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, Integer.toString(AppleJuiceClient.getAjFassade().getAllServer().size())); + } + } + + startPanel.getLblVerbindungsnachricht().setText(temp.toString()); + temp = new StringBuffer(verbindungenText); + pos = temp.indexOf("%d"); + if (pos != -1) { + temp.replace(pos, pos + 2, Long.toString(information.getOpenConnections())); + } + + startPanel.getLblVerbindungen().setText(temp.toString()); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + }); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartPanel.java new file mode 100644 index 00000000..65971159 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/start/StartPanel.java @@ -0,0 +1,215 @@ +package de.applejuicenet.client.gui.start; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.TklPanel; +import de.applejuicenet.client.shared.IconManager; + +import javax.swing.*; +import java.awt.*; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/StartPanel.java,v + * 1.57 2004/06/15 16:19:19 maj0r Exp $ + * + *

+ * Titel: AppleJuice Client-GUI + *

+ *

+ * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + *

+ *

+ * Copyright: General Public License + *

+ * + * @author Maj0r [aj@tkl-soft.de] + */ + +public class StartPanel extends TklPanel { + + private static final Color APFEL_ROT = new Color(146, 36, 60); + + private JLabel warnungen; + private JLabel deinClient; + private JLabel firewallWarning; + private JTextPane nachrichten; + private JLabel neuigkeiten; + private JLabel netzwerk; + private JLabel status; + private JLabel verbindungsNachricht; + private JLabel verbindungen; + private JLabel version; + private JLabel warnungIcon; + private JTextPane serverMessage; + + public StartPanel(GuiController guiController) { + super(guiController); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public JTextPane getNachrichtenPane() { + return nachrichten; + } + + public JTextPane getServerMessagePane() { + return serverMessage; + } + + public JLabel getLblVersion() { + return version; + } + + public JLabel getLblWarnung() { + return warnungen; + } + + public JLabel getLblWarnungIcon() { + return warnungIcon; + } + + public JLabel getLblStatus() { + return status; + } + + public JLabel getLblFirewallWarning() { + return firewallWarning; + } + + public JLabel getLblVerbindungsnachricht() { + return verbindungsNachricht; + } + + public JLabel getLblVerbindungen() { + return verbindungen; + } + + public JLabel getLblNetzwerk() { + return netzwerk; + } + + public JLabel getLblDeinClient() { + return deinClient; + } + + public JLabel getLblNeuigkeiten() { + return neuigkeiten; + } + + private void init() { + setLayout(new BorderLayout()); + serverMessage = new JTextPane(); + serverMessage.setContentType("text/html"); + serverMessage.setEditable(false); + + JPanel panel3 = new JPanel(new GridBagLayout()); + panel3.setBackground(UIManager.getColor("TextField.background")); + + JPanel panel4 = new JPanel(new BorderLayout()); + panel4.setBackground(UIManager.getColor("TextField.background")); + + IconManager im = IconManager.getInstance(); + JPanel panel1 = new NorthPanel(serverMessage); + panel1.setBackground(UIManager.getColor("TextField.background")); + + GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.left = 5; + + ImageIcon icon2 = im.getIcon("start"); + JLabel label2 = new JLabel(icon2); + panel3.add(label2, constraints); + + constraints.gridx = 1; + constraints.weightx = 1; + deinClient = new JLabel(); + deinClient.setForeground(APFEL_ROT); + panel3.add(deinClient, constraints); + constraints.weightx = 0; + + constraints.gridy++; + constraints.insets.left = 15; + version = new JLabel(); + panel3.add(version, constraints); + + constraints.gridy++; + constraints.insets.left = 5; + constraints.gridx = 0; + ImageIcon icon3 = im.getIcon("warnung"); + warnungIcon = new JLabel(icon3); + panel3.add(warnungIcon, constraints); + + constraints.gridx = 1; + warnungen = new JLabel(); + warnungen.setForeground(APFEL_ROT); + panel3.add(warnungen, constraints); + + constraints.gridy++; + constraints.insets.left = 15; + firewallWarning = new JLabel(); + firewallWarning.setForeground(Color.RED); + + panel3.add(firewallWarning, constraints); + + constraints.gridy++; + constraints.insets.left = 5; + constraints.gridx = 0; + ImageIcon icon4 = im.getIcon("netzwerk"); + JLabel label4 = new JLabel(icon4); + panel3.add(label4, constraints); + + constraints.gridx = 1; + neuigkeiten = new JLabel(); + neuigkeiten.setForeground(APFEL_ROT); + panel3.add(neuigkeiten, constraints); + + constraints.gridy++; + constraints.insets.left = 15; + nachrichten = new JTextPane(); + panel3.add(nachrichten, constraints); + nachrichten.setEditable(false); + nachrichten.setBackground(UIManager.getColor("TextField.background")); + + constraints.gridy++; + constraints.insets.left = 5; + constraints.gridx = 0; + ImageIcon icon5 = im.getIcon("server"); + JLabel label5 = new JLabel(icon5); + panel3.add(label5, constraints); + + constraints.gridx = 1; + netzwerk = new JLabel(); + netzwerk.setForeground(APFEL_ROT); + panel3.add(netzwerk, constraints); + + constraints.gridy++; + constraints.insets.left = 15; + verbindungsNachricht = new JLabel(); + panel3.add(verbindungsNachricht, constraints); + + verbindungen = new JLabel(); + constraints.gridy++; + constraints.insets.top = 5; + panel3.add(verbindungen, constraints); + + constraints.gridy++; + status = new JLabel(); + panel3.add(status, constraints); + + constraints.insets.top = 0; + + add(panel1, BorderLayout.NORTH); + panel4.add(panel3, BorderLayout.NORTH); + JScrollPane scrollPane = new JScrollPane(panel4); + scrollPane.setBorder(null); + add(scrollPane, BorderLayout.CENTER); + } +} diff --git a/ajtray/src/de/applejuicenet/client/gui/tray/DesktopToolJava6.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/DesktopTool.java similarity index 78% rename from ajtray/src/de/applejuicenet/client/gui/tray/DesktopToolJava6.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/DesktopTool.java index 13f77a6f..ded1ca91 100644 --- a/ajtray/src/de/applejuicenet/client/gui/tray/DesktopToolJava6.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/DesktopTool.java @@ -3,16 +3,15 @@ */ package de.applejuicenet.client.gui.tray; -import java.awt.Desktop; + +import java.awt.*; import java.io.File; import java.io.IOException; import java.net.URI; -import de.applejuicenet.client.shared.DesktopToolIF; - -public class DesktopToolJava6 implements DesktopToolIF +public class DesktopTool { - public DesktopToolJava6() + public DesktopTool() { if(!Desktop.isDesktopSupported()) { @@ -20,7 +19,6 @@ public DesktopToolJava6() } } - @Override public void browse(URI uri) { try @@ -33,7 +31,6 @@ public void browse(URI uri) } } - @Override public void open(File toOpen) { try diff --git a/ajtray/src/de/applejuicenet/client/gui/tray/TrayLoader.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/TrayLoader.java similarity index 88% rename from ajtray/src/de/applejuicenet/client/gui/tray/TrayLoader.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/TrayLoader.java index 52d4b445..eeaf8223 100644 --- a/ajtray/src/de/applejuicenet/client/gui/tray/TrayLoader.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/tray/TrayLoader.java @@ -3,31 +3,30 @@ */ package de.applejuicenet.client.gui.tray; -import java.awt.AWTException; -import java.awt.Image; -import java.awt.SystemTray; -import java.awt.TrayIcon; +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.shared.IconManager; + +import javax.swing.*; +import java.awt.*; import java.awt.TrayIcon.MessageType; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.Icon; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - -import de.applejuicenet.client.gui.AppleJuiceDialog; - -public class TrayLoader implements TrayIF +public class TrayLoader { private String zeigen; private String verstecken; private TrayIcon trayIcon = null; - public boolean makeTray(Image image, String title, final AppleJuiceDialog dialog, final JMenuItem popupShowHideMenuItem, + public boolean makeTray( String title, final AppleJuiceDialog dialog, final JMenuItem popupShowHideMenuItem, final Icon zeigenIcon, final Icon versteckenIcon, final JPopupMenu popup) { SystemTray tray = SystemTray.getSystemTray(); + IconManager im = IconManager.getInstance(); + + Image image = im.getIcon("applejuice").getImage(); + trayIcon = new TrayIcon(image, title, null); trayIcon.setImageAutoSize(true); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/HeaderPopupListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/HeaderPopupListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/HeaderPopupListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/HeaderPopupListener.java index 8179c17f..06bd1ff0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/HeaderPopupListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/HeaderPopupListener.java @@ -4,11 +4,11 @@ package de.applejuicenet.client.gui.upload; +import de.applejuicenet.client.gui.components.GuiController; + import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import de.applejuicenet.client.gui.components.GuiController; - public class HeaderPopupListener extends MouseAdapter { private GuiController guiController; diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadController.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadController.java new file mode 100644 index 00000000..a00458d1 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadController.java @@ -0,0 +1,469 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.upload; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Share; +import de.applejuicenet.client.fassade.entity.Upload; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.GuiControllerActionListener; +import de.applejuicenet.client.gui.components.table.HeaderListener; +import de.applejuicenet.client.gui.components.util.Value; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.shared.ReleaseInfo; + +import javax.swing.*; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Map; + +public class UploadController extends GuiController { + private static UploadController instance = null; + private static final int HEADER_DRAGGED = 0; + private static final int HEADER_POPUP = 1; + private static final int TABLE_MOUSE_CLICKED = 2; + private static final int TABLE_POPUP = 3; + private static final int COPY_TO_CLIPBOARD = 4; + private static final int HEADER_WAITING_DRAGGED = 8; + private static final int HEADER_WAITING_POPUP = 9; + private static final int RELEASE_INFO = 18; + private final UploadPanel uploadPanel; + private boolean componentSelected = false; + private boolean initialized = false; + private int anzahlClients = 0; + private String clientText; + private String warteschlangeVoll = ""; + + private UploadController() { + super(); + uploadPanel = new UploadPanel(this); + try { + init(); + LanguageSelector.getInstance().addLanguageListener(this); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.UPLOAD_CHANGED); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static synchronized UploadController getInstance() { + if (null == instance) { + instance = new UploadController(); + } + + return instance; + } + + public Value[] getCustomizedValues() { + return null; + } + + private void init() { + uploadPanel.getUploadActiveTable().getTableHeader().addMouseListener(new HeaderPopupListener(this, HEADER_POPUP)); + uploadPanel.getUploadActiveTable().getTableHeader().addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_DRAGGED)); + uploadPanel.getUploadActiveTable().addMouseListener(new UploadTableMouseListener(this, TABLE_MOUSE_CLICKED)); + uploadPanel.getUploadActiveTable().addMouseListener(new UploadTablePopupListener(this, TABLE_POPUP)); + uploadPanel.getMnuCopyToClipboard().addActionListener(new GuiControllerActionListener(this, COPY_TO_CLIPBOARD)); + uploadPanel.getMnuReleaseInfo().addActionListener(new GuiControllerActionListener(this, RELEASE_INFO)); + + uploadPanel.getUploadWaitingTable().getTableHeader().addMouseListener(new HeaderPopupListener(this, HEADER_WAITING_POPUP)); + uploadPanel.getUploadWaitingTable().getTableHeader() + .addMouseMotionListener(new UploadMouseMotionListener(this, HEADER_WAITING_DRAGGED)); + } + + public void fireAction(int actionId, Object obj) { + switch (actionId) { + + case HEADER_DRAGGED: { + headerDragged(); + break; + } + + case HEADER_POPUP: { + headerPopup((MouseEvent) obj); + break; + } + + case HEADER_WAITING_DRAGGED: { + headerWaitingDragged(); + break; + } + + case HEADER_WAITING_POPUP: { + headerWaitingPopup((MouseEvent) obj); + break; + } + + case TABLE_MOUSE_CLICKED: { + tableMouseClicked((MouseEvent) obj); + break; + } + + case TABLE_POPUP: { + tablePopup((MouseEvent) obj); + break; + } + + case COPY_TO_CLIPBOARD: { + copyLinkToClipboard(); + break; + } + + case RELEASE_INFO: { + showReleaseInfo(); + break; + } + + default: + logger.error("Unregistrierte EventId " + actionId); + } + } + + private void showReleaseInfo() { + int selected = uploadPanel.getUploadActiveTable().getSelectedRow(); + + if (selected == -1) { + return; + } + + Share shareObj = getShareObject4SelectedRow(selected); + + if (shareObj != null) { + ReleaseInfo.handle(shareObj.getShortfilename(), shareObj.getCheckSum(), shareObj.getSize()); + } + } + + private Share getShareObject4SelectedRow(int selected) { + Upload upload = uploadPanel.getUploadActiveTableModel().getRow(selected); + + Integer shareFileId = upload.getShareFileID(); + Map share = AppleJuiceClient.getAjFassade().getShare(false); + + if (share.containsKey(shareFileId)) { + return share.get(shareFileId); + } + + return null; + } + + private void headerDragged() { + PositionManager pm = PositionManagerImpl.getInstance(); + TableColumnModel columnModel = uploadPanel.getUploadActiveTable().getColumnModel(); + TableColumn[] columns = uploadPanel.getTableActiveColumns(); + + for (int i = 0; i < columns.length; i++) { + try { + pm.setUploadColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); + } catch (IllegalArgumentException niaE) { + ; + + //nix zu tun + } + } + } + + private void headerWaitingDragged() { + PositionManager pm = PositionManagerImpl.getInstance(); + TableColumnModel columnModel = uploadPanel.getUploadWaitingTable().getColumnModel(); + TableColumn[] columns = uploadPanel.getTableWaitingColumns(); + + for (int i = 0; i < columns.length; i++) { + try { + pm.setUploadWaitingColumnIndex(i, columnModel.getColumnIndex(columns[i].getIdentifier())); + } catch (IllegalArgumentException niaE) { + ; + + //nix zu tun + } + } + } + + private void tablePopup(MouseEvent e) { + Point p = e.getPoint(); + int selectedRow = uploadPanel.getUploadActiveTable().rowAtPoint(p); + + if (selectedRow != -1) { + uploadPanel.getUploadActiveTable().setRowSelectionInterval(selectedRow, selectedRow); + + // Object selectedItem = ((TreeTableModelAdapter) uploadPanel.getTable().getModel()).nodeForRow(selectedRow); + // + // if(selectedItem instanceof Upload) + // { + // uploadPanel.getPopup().show(uploadPanel.getTable(), e.getX(), e.getY()); + // } + } + } + + private void tableMouseClicked(MouseEvent e) { + Point p = e.getPoint(); + + // if(uploadPanel.getTable().columnAtPoint(p) != 0) + // { + // int selectedRow = uploadPanel.getTable().rowAtPoint(p); + // + // if(e.getClickCount() == 2) + // { + // ((TreeTableModelAdapter) uploadPanel.getTable().getModel()).expandOrCollapseRow(selectedRow); + // } + // } + } + + private void copyLinkToClipboard() { + int selected = uploadPanel.getUploadActiveTable().getSelectedRow(); + + if (selected == -1) { + return; + } + + Share shareObj = getShareObject4SelectedRow(selected); + + if (shareObj != null) { + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuffer toCopy = new StringBuffer(); + + toCopy.append(shareObj.getAjfspLink()); + StringSelection contents = new StringSelection(toCopy.toString()); + cb.setContents(contents, null); + } + } + + private void headerPopup(MouseEvent e) { + TableColumn[] columns = uploadPanel.getTableActiveColumns(); + JCheckBoxMenuItem[] columnPopupItems = uploadPanel.getColumnActivePopupItems(); + TableColumnModel tableColumnModel = uploadPanel.getUploadActiveTable().getColumnModel(); + + for (int i = 1; i < columns.length; i++) { + try { + tableColumnModel.getColumnIndex(columns[i].getIdentifier()); + columnPopupItems[i].setSelected(true); + } catch (IllegalArgumentException niaE) { + columnPopupItems[i].setSelected(false); + } + } + + uploadPanel.getColumnActivePopup().show(uploadPanel.getUploadActiveTable().getTableHeader(), e.getX(), e.getY()); + } + + private void headerWaitingPopup(MouseEvent e) { + TableColumn[] columns = uploadPanel.getTableWaitingColumns(); + JCheckBoxMenuItem[] columnPopupItems = uploadPanel.getColumnWaitingPopupItems(); + TableColumnModel tableColumnModel = uploadPanel.getUploadWaitingTable().getColumnModel(); + + for (int i = 1; i < columns.length; i++) { + try { + tableColumnModel.getColumnIndex(columns[i].getIdentifier()); + columnPopupItems[i].setSelected(true); + } catch (IllegalArgumentException niaE) { + columnPopupItems[i].setSelected(false); + } + } + + uploadPanel.getColumnWaitingPopup().show(uploadPanel.getUploadWaitingTable().getTableHeader(), e.getX(), e.getY()); + } + + public JComponent getComponent() { + return uploadPanel; + } + + public void componentSelected() { + try { + componentSelected = true; + if (!initialized) { + initialized = true; + TableColumnModel headerModelActive = uploadPanel.getUploadActiveTable().getTableHeader().getColumnModel(); + TableColumnModel headerModelWaiting = uploadPanel.getUploadWaitingTable().getTableHeader().getColumnModel(); + + TableColumn[] columnsActive = uploadPanel.getTableActiveColumns(); + int columnCountActive = headerModelActive.getColumnCount(); + int[] uploadActiveSort = null; + TableColumn[] columnsWaiting = uploadPanel.getTableWaitingColumns(); + int columnCountWaiting = headerModelWaiting.getColumnCount(); + PositionManager pm = PositionManagerImpl.getInstance(); + int[] uploadWaitingSort = null; + + if (pm.isLegal()) { + int[] uploadActiveWidths = pm.getUploadWidths(); + boolean[] uploadActiveVisibilies = pm.getUploadColumnVisibilities(); + int[] indizesActive = pm.getUploadColumnIndizes(); + + uploadActiveSort = pm.getUploadSort(); + ArrayList visibleColumnsActive = new ArrayList(); + + for (int i = 0; i < columnsActive.length; i++) { + columnsActive[i].setPreferredWidth(uploadActiveWidths[i]); + uploadPanel.getUploadActiveTable().removeColumn(columnsActive[i]); + if (uploadActiveVisibilies[i]) { + visibleColumnsActive.add(columnsActive[i]); + } + } + + int pos = -1; + + for (int i = 0; i < visibleColumnsActive.size(); i++) { + for (int x = 0; x < columnsActive.length; x++) { + if (visibleColumnsActive.contains(columnsActive[x]) && indizesActive[x] == pos + 1) { + uploadPanel.getUploadActiveTable().addColumn(columnsActive[x]); + pos++; + break; + } + } + } + + int[] uploadWaitingWidths = pm.getUploadWaitingWidths(); + boolean[] uploadWaitingVisibilies = pm.getUploadWaitingColumnVisibilities(); + int[] indizesWaiting = pm.getUploadWaitingColumnIndizes(); + + uploadWaitingSort = pm.getUploadWaitingSort(); + ArrayList visibleColumnsWaiting = new ArrayList(); + + for (int i = 0; i < columnsWaiting.length; i++) { + columnsWaiting[i].setPreferredWidth(uploadWaitingWidths[i]); + uploadPanel.getUploadWaitingTable().removeColumn(columnsWaiting[i]); + if (uploadWaitingVisibilies[i]) { + visibleColumnsWaiting.add(columnsWaiting[i]); + } + } + + pos = -1; + + for (int i = 0; i < visibleColumnsWaiting.size(); i++) { + for (int x = 0; x < columnsWaiting.length; x++) { + if (visibleColumnsWaiting.contains(columnsWaiting[x]) && indizesWaiting[x] == pos + 1) { + uploadPanel.getUploadWaitingTable().addColumn(columnsWaiting[x]); + pos++; + break; + } + } + } + } else { + for (int i = 0; i < columnCountActive; i++) { + headerModelActive.getColumn(i).setPreferredWidth(uploadPanel.getUploadActiveTable().getWidth() / columnCountActive); + } + + for (int i = 0; i < columnCountWaiting; i++) { + headerModelWaiting.getColumn(i) + .setPreferredWidth(uploadPanel.getUploadWaitingTable().getWidth() / columnCountWaiting); + } + } + + uploadPanel.getUploadActiveTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + uploadPanel.getUploadWaitingTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + if (null != uploadActiveSort) { + for (MouseListener curMl : uploadPanel.getUploadActiveTable().getTableHeader().getMouseListeners()) { + if (curMl instanceof HeaderListener) { + ((HeaderListener) curMl).sort(uploadActiveSort[0], uploadActiveSort[1] == 1); + } + } + } + + if (null != uploadWaitingSort) { + for (MouseListener curMl : uploadPanel.getUploadWaitingTable().getTableHeader().getMouseListeners()) { + if (curMl instanceof HeaderListener) { + ((HeaderListener) curMl).sort(uploadWaitingSort[0], uploadWaitingSort[1] == 1); + } + } + } + } + + uploadPanel.getUploadActiveTable().updateUI(); + uploadPanel.getUploadWaitingTable().updateUI(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + public void componentLostSelection() { + componentSelected = false; + } + + protected void languageChanged() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + clientText = languageSelector.getFirstAttrbuteByTagName("mainform.uplcounttext"); + uploadPanel.getUploadListeLabel().setText(clientText.replaceAll("%d", Integer.toString(anzahlClients))); + String[] columnsText = new String[7]; + + columnsText[0] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col0caption"); + columnsText[1] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); + columnsText[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col2caption"); + columnsText[3] = languageSelector.getFirstAttrbuteByTagName("mainform.queue.col6caption"); + columnsText[4] = languageSelector.getFirstAttrbuteByTagName("javagui.uploadform.columnwasserstand"); + columnsText[5] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col4caption"); + columnsText[6] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col5caption"); + TableColumn[] columns = uploadPanel.getTableActiveColumns(); + + for (int i = 0; i < columns.length; i++) { + columns[i].setHeaderValue(columnsText[i]); + } + + columns[0].setPreferredWidth(100); + + columnsText = new String[7]; + + columnsText[0] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col0caption"); + columnsText[1] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col3caption"); + columnsText[2] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col1caption"); + columnsText[3] = languageSelector.getFirstAttrbuteByTagName("javagui.uploadform.columnwasserstand"); + columnsText[4] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col4caption"); + columnsText[5] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.colletzteverbindung"); + columnsText[6] = languageSelector.getFirstAttrbuteByTagName("mainform.uploads.col5caption"); + columns = uploadPanel.getTableWaitingColumns(); + + for (int i = 0; i < columns.length; i++) { + columns[i].setHeaderValue(columnsText[i]); + } + + columns[0].setPreferredWidth(100); + + warteschlangeVoll = languageSelector.getFirstAttrbuteByTagName("javagui.downloadform.warteschlangevoll"); + uploadPanel.getMnuCopyToClipboard().setText(languageSelector.getFirstAttrbuteByTagName("mainform.getlink1.caption")); + uploadPanel.getMnuReleaseInfo().setText(languageSelector.getFirstAttrbuteByTagName("releaseinfo.menu")); + } + + protected void contentChanged(DATALISTENER_TYPE type, final Object content) { + if (type == DATALISTENER_TYPE.UPLOAD_CHANGED) { + SwingUtilities.invokeLater(new Runnable() { + @SuppressWarnings("unchecked") + public void run() { + try { + boolean change = uploadPanel.getUploadActiveTableModel().setUploads((Map) content); + + if (uploadPanel.getUploadWaitingTableModel().setUploads((Map) content)) { + change = true; + } + + anzahlClients = uploadPanel.getUploadActiveTableModel().getRowCount() + + uploadPanel.getUploadWaitingTableModel().getRowCount(); + String tmp = clientText.replaceAll("%d", Integer.toString(anzahlClients)); + long maxUploadPos = AppleJuiceClient.getAjFassade().getInformation().getMaxUploadPositions(); + + if (anzahlClients >= maxUploadPos) { + tmp += " (" + warteschlangeVoll + ")"; + } + + uploadPanel.getUploadListeLabel().setText(tmp); + if (componentSelected && change) { + uploadPanel.getUploadActiveTableModel().forceResort(); + uploadPanel.getUploadActiveTable().updateUI(); + uploadPanel.getUploadWaitingTableModel().forceResort(); + uploadPanel.getUploadWaitingTable().updateUI(); + } + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + }); + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java index d7dce34f..7746d5c2 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadMouseMotionListener.java @@ -4,11 +4,11 @@ package de.applejuicenet.client.gui.upload; +import de.applejuicenet.client.gui.components.GuiController; + import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -import de.applejuicenet.client.gui.components.GuiController; - public class UploadMouseMotionListener extends MouseMotionAdapter { private GuiController guiController; diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadPanel.java new file mode 100644 index 00000000..c57c318a --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadPanel.java @@ -0,0 +1,335 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.upload; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Version; +import de.applejuicenet.client.gui.RegisterI; +import de.applejuicenet.client.gui.components.GuiController; +import de.applejuicenet.client.gui.components.TklPanel; +import de.applejuicenet.client.gui.components.table.HeaderListener; +import de.applejuicenet.client.gui.components.table.SortButtonRenderer; +import de.applejuicenet.client.gui.controller.PositionManager; +import de.applejuicenet.client.gui.controller.PositionManagerImpl; +import de.applejuicenet.client.gui.upload.table.*; +import de.applejuicenet.client.shared.IconManager; +import de.applejuicenet.client.shared.tablecellrenderer.ProgressTableCellRenderer; +import de.applejuicenet.client.shared.tablecellrenderer.SpeedTableCellRenderer; +import de.applejuicenet.client.shared.tablecellrenderer.StringTableCellRenderer; +import de.applejuicenet.client.shared.tablecellrenderer.VersionTableCellRenderer; +import info.clearthought.layout.TableLayout; + +import javax.swing.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Date; + +/** + * $Header: + * /cvsroot/applejuicejava/AJClientGUI/src/de/applejuicenet/client/gui/UploadPanel.java,v + * 1.48 2004/06/23 13:31:24 maj0r Exp $ + * + *

+ * Titel: AppleJuice Client-GUI + *

+ *

+ * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + *

+ *

+ * Copyright: General Public License + *

+ * + * @author Maj0r [aj@tkl-soft.de] + */ +public class UploadPanel extends TklPanel implements RegisterI { + private JLabel uploadListeLabel = new JLabel("0 Clients in Deiner Uploadliste"); + private JPopupMenu popupMenu = new JPopupMenu(); + private JMenuItem itemCopyToClipboard = new JMenuItem(); + private JMenuItem itemReleaseInfo = new JMenuItem(); + private JPopupMenu columnActivePopup = new JPopupMenu(); + private TableColumn[] columnsActiveUploads = new TableColumn[7]; + private JCheckBoxMenuItem[] columnPopupItemsActiveUploads = new JCheckBoxMenuItem[columnsActiveUploads.length]; + private JPopupMenu columnWaitingPopup = new JPopupMenu(); + private TableColumn[] columnsWaitingUploads = new TableColumn[7]; + private JCheckBoxMenuItem[] columnPopupItemsWaitingUploads = new JCheckBoxMenuItem[columnsActiveUploads.length]; + private JTable uploadActiveTable; + private UploadActiveTableModel uploadActiveTableModel; + private JTable uploadWaitingTable; + private UploadWaitingTableModel uploadWaitingTableModel; + + public UploadPanel(GuiController guiController) { + super(guiController); + try { + init(); + } catch (Exception ex) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, ex); + } + } + + private void init() throws Exception { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[][] sizes = + { + {5, f, 5}, + {5, f, f, p} + }; + + TableLayout tableLayout = new TableLayout(sizes); + + setLayout(tableLayout); + uploadActiveTableModel = new UploadActiveTableModel(); + uploadActiveTable = new JTable(uploadActiveTableModel); + + uploadActiveTable.setDefaultRenderer(String.class, new StringTableCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(0).setCellRenderer(new UploadTableFilenameCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(2).setCellRenderer(new SpeedTableCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(3).setCellRenderer(new ProgressTableCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(4).setCellRenderer(new ProgressTableCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(5).setCellRenderer(new UploadTablePrioCellRenderer()); + uploadActiveTable.getColumnModel().getColumn(6).setCellRenderer(new VersionTableCellRenderer()); + + uploadActiveTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isRightMouseButton(e)) { + + int row = uploadActiveTable.rowAtPoint(e.getPoint()); + + if (!uploadActiveTable.getSelectionModel().isSelectedIndex(row)) { + uploadActiveTable.getSelectionModel().setSelectionInterval(row, row); + } + + maybeShowUploadPopup(e); + } + } + }); + + TableColumnModel modelActive = uploadActiveTable.getColumnModel(); + + for (int i = 0; i < columnsActiveUploads.length; i++) { + columnsActiveUploads[i] = modelActive.getColumn(i); + columnPopupItemsActiveUploads[i] = new JCheckBoxMenuItem((String) columnsActiveUploads[i].getHeaderValue()); + final int x = i; + + columnPopupItemsActiveUploads[i].addActionListener(ae -> { + if (columnPopupItemsActiveUploads[x].isSelected()) { + uploadActiveTable.getColumnModel().addColumn(columnsActiveUploads[x]); + PositionManagerImpl.getInstance().setUploadColumnVisible(x, true); + PositionManagerImpl.getInstance() + .setUploadColumnIndex(x, + uploadActiveTable.getColumnModel().getColumnIndex(columnsActiveUploads[x].getIdentifier())); + } else { + uploadActiveTable.getColumnModel().removeColumn(columnsActiveUploads[x]); + PositionManagerImpl.getInstance().setUploadColumnVisible(x, false); + for (int y = 0; y < columnsActiveUploads.length; y++) { + try { + PositionManagerImpl.getInstance() + .setUploadColumnIndex(y, + uploadActiveTable.getColumnModel() + .getColumnIndex(columnsActiveUploads[y].getIdentifier())); + } catch (IllegalArgumentException niaE) { + //nix zu tun + } + } + } + }); + columnActivePopup.add(columnPopupItemsActiveUploads[i]); + } + + columnPopupItemsActiveUploads[0].setEnabled(false); + columnPopupItemsActiveUploads[0].setSelected(true); + + SortButtonRenderer renderer = new SortButtonRenderer(); + JTableHeader header = uploadActiveTable.getTableHeader(); + + header.setDefaultRenderer(renderer); + header.addMouseListener(new HeaderListener(header, renderer) { + private PositionManager pm = PositionManagerImpl.getInstance(); + + @Override + public void internalSort(int column, boolean ascent) { + pm.setUploadSort(column, ascent); + + super.internalSort(column, ascent); + } + }); + + uploadWaitingTableModel = new UploadWaitingTableModel(); + uploadWaitingTable = new JTable(uploadWaitingTableModel); + + uploadWaitingTable.getColumnModel().getColumn(1).setCellRenderer(new UploadTableWaitingStatusCellRenderer()); + uploadWaitingTable.getColumnModel().getColumn(3).setCellRenderer(new ProgressTableCellRenderer()); + uploadWaitingTable.getColumnModel().getColumn(4).setCellRenderer(new UploadTablePrioCellRenderer()); + + uploadWaitingTable.setDefaultRenderer(Version.class, new VersionTableCellRenderer()); + uploadWaitingTable.setDefaultRenderer(Date.class, new UploadTableDateCellRenderer()); + + renderer = new SortButtonRenderer(); + + header = uploadWaitingTable.getTableHeader(); + header.setDefaultRenderer(renderer); + header.addMouseListener(new HeaderListener(header, renderer) { + private PositionManager pm = PositionManagerImpl.getInstance(); + + @Override + public void internalSort(int column, boolean ascent) { + pm.setUploadWaitingSort(column, ascent); + + super.internalSort(column, ascent); + } + }); + + TableColumnModel modelWaiting = uploadWaitingTable.getColumnModel(); + + for (int i = 0; i < columnsWaitingUploads.length; i++) { + columnsWaitingUploads[i] = modelWaiting.getColumn(i); + columnPopupItemsWaitingUploads[i] = new JCheckBoxMenuItem((String) columnsWaitingUploads[i].getHeaderValue()); + final int x = i; + + columnPopupItemsWaitingUploads[i].addActionListener(ae -> { + if (columnPopupItemsWaitingUploads[x].isSelected()) { + uploadWaitingTable.getColumnModel().addColumn(columnsWaitingUploads[x]); + PositionManagerImpl.getInstance().setUploadWaitingColumnVisible(x, true); + PositionManagerImpl.getInstance() + .setUploadWaitingColumnIndex(x, + uploadWaitingTable.getColumnModel() + .getColumnIndex(columnsWaitingUploads[x].getIdentifier())); + } else { + uploadWaitingTable.getColumnModel().removeColumn(columnsWaitingUploads[x]); + PositionManagerImpl.getInstance().setUploadWaitingColumnVisible(x, false); + for (int y = 0; y < columnsWaitingUploads.length; y++) { + try { + PositionManagerImpl.getInstance() + .setUploadWaitingColumnIndex(y, + uploadWaitingTable.getColumnModel() + .getColumnIndex(columnsWaitingUploads[y].getIdentifier())); + } catch (IllegalArgumentException niaE) { + ; + + //nix zu tun + } + } + } + }); + columnWaitingPopup.add(columnPopupItemsWaitingUploads[i]); + } + + columnPopupItemsWaitingUploads[0].setEnabled(false); + columnPopupItemsWaitingUploads[0].setSelected(true); + + JScrollPane aScrollPaneActive = new JScrollPane(uploadActiveTable); + + aScrollPaneActive.setBackground(uploadActiveTable.getBackground()); + aScrollPaneActive.getViewport().setOpaque(false); + add(aScrollPaneActive, "1, 1"); + + JScrollPane aScrollPaneWaiting = new JScrollPane(uploadWaitingTable); + + IconManager im = IconManager.getInstance(); + + aScrollPaneWaiting.setBackground(uploadWaitingTable.getBackground()); + aScrollPaneWaiting.getViewport().setOpaque(false); + add(aScrollPaneWaiting, "1, 2"); + + add(uploadListeLabel, "1, 3, L, T"); + itemCopyToClipboard.setIcon(im.getIcon("clipboard")); + popupMenu.add(itemCopyToClipboard); + + itemReleaseInfo.setIcon(im.getIcon("hint")); + + popupMenu.add(itemReleaseInfo); + } + + private void maybeShowUploadPopup(MouseEvent e) { + int[] selected = uploadActiveTable.getSelectedRows(); + + if (null == selected || selected.length == 0) { + return; + } + + getPopup().show(uploadActiveTable, e.getX(), e.getY()); + } + + public int[] getColumnActiveWidths() { + int[] widths = new int[columnsActiveUploads.length]; + + for (int i = 0; i < columnsActiveUploads.length; i++) { + widths[i] = columnsActiveUploads[i].getWidth(); + } + + return widths; + } + + public int[] getColumnWaitingWidths() { + int[] widths = new int[columnsWaitingUploads.length]; + + for (int i = 0; i < columnsWaitingUploads.length; i++) { + widths[i] = columnsWaitingUploads[i].getWidth(); + } + + return widths; + } + + public JTable getUploadWaitingTable() { + return uploadWaitingTable; + } + + public UploadWaitingTableModel getUploadWaitingTableModel() { + return uploadWaitingTableModel; + } + + public JTable getUploadActiveTable() { + return uploadActiveTable; + } + + public UploadActiveTableModel getUploadActiveTableModel() { + return uploadActiveTableModel; + } + + public TableColumn[] getTableActiveColumns() { + return columnsActiveUploads; + } + + public TableColumn[] getTableWaitingColumns() { + return columnsWaitingUploads; + } + + public JCheckBoxMenuItem[] getColumnActivePopupItems() { + return columnPopupItemsActiveUploads; + } + + public JCheckBoxMenuItem[] getColumnWaitingPopupItems() { + return columnPopupItemsWaitingUploads; + } + + public JPopupMenu getColumnActivePopup() { + return columnActivePopup; + } + + public JPopupMenu getColumnWaitingPopup() { + return columnWaitingPopup; + } + + public JPopupMenu getPopup() { + return popupMenu; + } + + public JLabel getUploadListeLabel() { + return uploadListeLabel; + } + + public JMenuItem getMnuCopyToClipboard() { + return itemCopyToClipboard; + } + + public JMenuItem getMnuReleaseInfo() { + return itemReleaseInfo; + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java index 4b05e200..82c03be5 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTableMouseListener.java @@ -1,10 +1,10 @@ package de.applejuicenet.client.gui.upload; +import de.applejuicenet.client.gui.components.GuiController; + import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import de.applejuicenet.client.gui.components.GuiController; - public class UploadTableMouseListener extends MouseAdapter{ private GuiController guiController; private int actionId; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java index ffab6153..fd0418c9 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/UploadTablePopupListener.java @@ -1,10 +1,10 @@ package de.applejuicenet.client.gui.upload; +import de.applejuicenet.client.gui.components.GuiController; + import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import de.applejuicenet.client.gui.components.GuiController; - public class UploadTablePopupListener extends MouseAdapter{ private GuiController guiController; private int actionId; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java index b4b0eb5e..c1ed1cb0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadActiveTableModel.java @@ -4,14 +4,6 @@ package de.applejuicenet.client.gui.upload.table; -import java.text.SimpleDateFormat; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.table.AbstractTableModel; - import de.applejuicenet.client.fassade.entity.Upload; import de.applejuicenet.client.fassade.entity.Version; import de.applejuicenet.client.gui.components.table.SortableTableModel; @@ -19,6 +11,12 @@ import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; +import javax.swing.table.AbstractTableModel; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class UploadActiveTableModel extends AbstractTableModel implements LanguageListener, SortableTableModel { final static String[] COL_NAMES = diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java index 8c1dd157..c555f4ff 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableDateCellRenderer.java @@ -4,13 +4,12 @@ package de.applejuicenet.client.gui.upload.table; -import java.awt.Component; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; import java.text.SimpleDateFormat; import java.util.Date; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - public class UploadTableDateCellRenderer extends DefaultTableCellRenderer { private static final SimpleDateFormat FORMATER_LONG = new SimpleDateFormat("dd.MM. HH:mm:ss"); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java similarity index 90% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java index 80d345a0..ab205279 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableFilenameCellRenderer.java @@ -4,15 +4,13 @@ package de.applejuicenet.client.gui.upload.table; -import java.awt.Component; - -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.Upload; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + public class UploadTableFilenameCellRenderer extends DefaultTableCellRenderer { @Override diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java index 0c202807..109e8284 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTablePrioCellRenderer.java @@ -4,11 +4,9 @@ package de.applejuicenet.client.gui.upload.table; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; public class UploadTablePrioCellRenderer extends DefaultTableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java index 05eeec73..e719dd07 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadTableWaitingStatusCellRenderer.java @@ -4,18 +4,14 @@ package de.applejuicenet.client.gui.upload.table; -import java.awt.Component; - -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.Upload; import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + public class UploadTableWaitingStatusCellRenderer extends DefaultTableCellRenderer { private static Icon verbindungUnbekanntIcon = IconManager.getInstance().getIcon("verbindungUnbekannt"); diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java index 99d66b4b..d65848ce 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/upload/table/UploadWaitingTableModel.java @@ -4,15 +4,6 @@ package de.applejuicenet.client.gui.upload.table; -import java.text.SimpleDateFormat; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.swing.table.AbstractTableModel; - import de.applejuicenet.client.fassade.entity.Upload; import de.applejuicenet.client.fassade.entity.Version; import de.applejuicenet.client.gui.components.table.SortableTableModel; @@ -20,6 +11,13 @@ import de.applejuicenet.client.gui.controller.LanguageSelector; import de.applejuicenet.client.gui.listener.LanguageListener; +import javax.swing.table.AbstractTableModel; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + public class UploadWaitingTableModel extends AbstractTableModel implements LanguageListener, SortableTableModel { final static String[] COL_NAMES = {"Dateiname", "Status", "Nickname", "Wasserstand", "Prioritaet", "letzte Verbindung", "Client"}; diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionKind.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionKind.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionKind.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionKind.java index 7343c531..294fd858 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionKind.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionKind.java @@ -7,7 +7,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionXML.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionXML.java similarity index 75% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionXML.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionXML.java index 3fb8c08c..7d36fe9f 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionXML.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/ConnectionXML.java @@ -1,16 +1,15 @@ package de.applejuicenet.client.gui.wizard; -import java.io.File; -import java.util.ArrayList; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.XMLDecoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.shared.XMLDecoder; +import java.io.File; +import java.util.ArrayList; /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/ConnectionXML.java,v 1.9 2005/02/28 14:58:19 maj0r Exp $ @@ -19,23 +18,22 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r - * + * @author Maj0r */ public class ConnectionXML - extends XMLDecoder { + extends XMLDecoder { private static Logger logger; private ConnectionXML(String path) { super(path); - logger = Logger.getLogger(getClass()); + logger = LoggerFactory.getLogger(getClass()); } public static ConnectionKind[] getConnections() { try { String path = System.getProperty("user.dir") + File.separator + - "wizard.xml"; + "wizard.xml"; ConnectionXML connectionXML = new ConnectionXML(path); Element e = null; @@ -45,7 +43,7 @@ public static ConnectionKind[] getConnections() { int maxDownload; int maxNewConnectionsPro10Sek; NodeList nodes = connectionXML.document.getElementsByTagName( - "wizard"); + "wizard"); nodes = nodes.item(0).getChildNodes(); int nodesSize = nodes.getLength(); for (int y = 0; y < nodesSize; y++) { @@ -55,19 +53,16 @@ public static ConnectionKind[] getConnections() { maxUpload = Integer.parseInt(e.getAttribute("maxupload")); maxDownload = Integer.parseInt(e.getAttribute("maxdownload")); maxNewConnectionsPro10Sek = Integer.parseInt(e.getAttribute( - "maxnewconnections10")); + "maxnewconnections10")); connectionKinds.add(new ConnectionKind(bezeichnung, - maxUpload, maxDownload, maxNewConnectionsPro10Sek)); + maxUpload, maxDownload, maxNewConnectionsPro10Sek)); } } - return (ConnectionKind[]) connectionKinds.toArray(new - ConnectionKind[connectionKinds.size()]); - } - catch (Exception e) { - if (logger.isEnabledFor(Level.ERROR)) { - logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); - } + return connectionKinds.toArray(new + ConnectionKind[connectionKinds.size()]); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); return null; } } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt1Panel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt1Panel.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt1Panel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt1Panel.java index 4e0880e7..a3c78002 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt1Panel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt1Panel.java @@ -4,21 +4,16 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import java.io.File; - -import javax.swing.JLabel; - import de.applejuicenet.client.gui.controller.LanguageSelector; - import de.tklsoft.gui.controls.TKLComboBox; import de.tklsoft.gui.controls.TKLTextArea; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt1Panel.java,v 1.16 2009/01/14 13:20:55 maj0r Exp $ * @@ -26,7 +21,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class Schritt1Panel extends WizardPanel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt2Panel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt2Panel.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt2Panel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt2Panel.java index 97f2868e..622d86b5 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt2Panel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt2Panel.java @@ -4,15 +4,12 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; - -import javax.swing.JLabel; - import de.tklsoft.gui.controls.TKLLabel; import de.tklsoft.gui.controls.TKLTextArea; +import javax.swing.*; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt2Panel.java,v 1.14 2009/01/12 09:19:20 maj0r Exp $ * @@ -20,7 +17,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class Schritt2Panel extends WizardPanel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt3Panel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt3Panel.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt3Panel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt3Panel.java index 30c904bc..38648ab6 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt3Panel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt3Panel.java @@ -4,20 +4,17 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -import javax.swing.JLabel; - import de.applejuicenet.client.fassade.shared.AJSettings; import de.tklsoft.gui.controls.InvalidRule; import de.tklsoft.gui.controls.ModifyableComponent; import de.tklsoft.gui.controls.TKLTextArea; import de.tklsoft.gui.controls.TKLTextField; +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt3Panel.java,v 1.18 2009/01/12 09:19:20 maj0r Exp $ * @@ -25,7 +22,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class Schritt3Panel extends WizardPanel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt4Panel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt4Panel.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt4Panel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt4Panel.java index 1ed3c4b5..f7bb42c4 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt4Panel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt4Panel.java @@ -4,15 +4,12 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; - -import javax.swing.JLabel; - import de.tklsoft.gui.controls.TKLComboBox; import de.tklsoft.gui.controls.TKLTextArea; +import javax.swing.*; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt4Panel.java,v 1.14 2009/01/12 09:19:20 maj0r Exp $ * @@ -20,7 +17,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class Schritt4Panel extends WizardPanel diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt5Panel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt5Panel.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt5Panel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt5Panel.java index a292761d..5083cc10 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt5Panel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/Schritt5Panel.java @@ -4,14 +4,11 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; - -import javax.swing.JLabel; - import de.tklsoft.gui.controls.TKLTextArea; +import javax.swing.*; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/Schritt5Panel.java,v 1.13 2009/01/12 09:19:20 maj0r Exp $ * @@ -19,7 +16,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class Schritt5Panel extends WizardPanel diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardDialog.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardDialog.java new file mode 100644 index 00000000..3b4f681b --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardDialog.java @@ -0,0 +1,226 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.wizard; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import de.applejuicenet.client.gui.listener.LanguageListener; +import de.applejuicenet.client.shared.IconManager; +import de.tklsoft.gui.controls.TKLButton; +import de.tklsoft.gui.controls.TKLPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardDialog.java,v 1.10 2009/01/12 09:19:20 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class WizardDialog extends JDialog implements LanguageListener { + private Logger logger; + private WizardPanel aktuellesPanel; + private WizardPanel schritt1 = new Schritt1Panel(); + private WizardPanel schritt2 = new Schritt2Panel(); + private WizardPanel schritt3; + private WizardPanel schritt4 = new Schritt4Panel(); + private WizardPanel schritt5 = new Schritt5Panel(); + private TKLPanel buttons = new TKLPanel(new FlowLayout(FlowLayout.RIGHT)); + private TKLButton zurueck = new TKLButton(); + private TKLButton weiter = new TKLButton(); + private TKLButton ende = new TKLButton(); + private AJSettings ajSettings; + private boolean regularClosed = false; + + public WizardDialog(Frame parent, boolean modal) { + super(parent, modal); + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + LanguageSelector ls = LanguageSelector.getInstance(); + + ls.addLanguageListener(this); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public WizardDialog(JDialog parent, boolean modal, AJSettings ajSettings) { + super(parent, modal); + logger = LoggerFactory.getLogger(getClass()); + try { + this.ajSettings = ajSettings; + init(); + LanguageSelector ls = LanguageSelector.getInstance(); + + ls.addLanguageListener(this); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + if (ajSettings == null) { + ajSettings = AppleJuiceClient.getAjFassade().getAJSettings(); + } + + schritt3 = new Schritt3Panel(this, ajSettings); + getContentPane().setLayout(new BorderLayout()); + ImageIcon icon1 = IconManager.getInstance().getIcon("wizardbanner"); + JLabel label1 = new JLabel(icon1); + + schritt1.setVorherigesPanel(null); + schritt1.setNaechstesPanel(schritt2); + schritt2.setVorherigesPanel(schritt1); + schritt2.setNaechstesPanel(schritt3); + schritt3.setVorherigesPanel(schritt2); + schritt3.setNaechstesPanel(schritt4); + schritt4.setVorherigesPanel(schritt3); + schritt4.setNaechstesPanel(schritt5); + schritt5.setVorherigesPanel(schritt4); + schritt5.setNaechstesPanel(null); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent evt) { + LanguageSelector.getInstance().removeLanguageListener(WizardDialog.this); + OptionsManagerImpl.getInstance().setErsterStart(false); + dispose(); + } + }); + zurueck.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + if (aktuellesPanel.getVorherigesPanel() != null) { + getContentPane().remove(aktuellesPanel); + aktuellesPanel = aktuellesPanel.getVorherigesPanel(); + getContentPane().add(aktuellesPanel, BorderLayout.CENTER); + weiter.setEnabled(true); + if (aktuellesPanel.getVorherigesPanel() == null) { + zurueck.setEnabled(false); + } else { + zurueck.setEnabled(true); + } + + if (aktuellesPanel == schritt3) { + if (((Schritt3Panel) schritt3).isValidNickname()) { + setWeiterEnabled(true); + } else { + setWeiterEnabled(false); + } + } else { + setWeiterEnabled(true); + } + + WizardDialog.this.validate(); + WizardDialog.this.repaint(); + } + } + }); + weiter.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + if (aktuellesPanel.getNaechstesPanel() != null) { + getContentPane().remove(aktuellesPanel); + aktuellesPanel = aktuellesPanel.getNaechstesPanel(); + getContentPane().add(aktuellesPanel, BorderLayout.CENTER); + zurueck.setEnabled(true); + if (aktuellesPanel.getNaechstesPanel() == null) { + weiter.setEnabled(false); + } else { + if (aktuellesPanel == schritt3) { + if (((Schritt3Panel) schritt3).isValidNickname()) { + setWeiterEnabled(true); + } else { + setWeiterEnabled(false); + } + } else { + setWeiterEnabled(true); + } + } + + WizardDialog.this.validate(); + WizardDialog.this.repaint(); + } + } + }); + ende.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + regularClosed = true; + close(); + } + }); + buttons.add(zurueck); + buttons.add(weiter); + buttons.add(ende); + buttons.setBackground(Color.WHITE); + zurueck.setEnabled(false); + + getContentPane().add(label1, BorderLayout.NORTH); + getContentPane().add(schritt1, BorderLayout.CENTER); + aktuellesPanel = schritt1; + getContentPane().add(buttons, BorderLayout.SOUTH); + setSize(icon1.getIconWidth(), icon1.getIconHeight() + 180 + buttons.getPreferredSize().height); + setResizable(false); + fireLanguageChanged(); + } + + public boolean isRegularClosed() { + return regularClosed; + } + + private void close() { + LanguageSelector.getInstance().removeLanguageListener(this); + int result = JOptionPane.showConfirmDialog(this, + LanguageSelector.getInstance().getFirstAttrbuteByTagName("connect.remember.caption") + + " ?", "appleJuice Client", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if (result == JOptionPane.YES_OPTION) { + if (((Schritt3Panel) schritt3).isValidNickname()) { + ConnectionKind connection = ((Schritt4Panel) schritt4).getVerbindungsart(); + + ajSettings.setNick(((Schritt3Panel) schritt3).getNickname()); + ajSettings.setMaxUpload(connection.getMaxUpload() * 1024); + ajSettings.setMaxDownload(connection.getMaxDownload() * 1024); + ajSettings.setMaxNewConnectionsPerTurn(connection.getMaxNewConnectionsPro10Sek()); + AppleJuiceClient.getAjFassade().saveAJSettings(ajSettings); + } + } else { + regularClosed = false; + } + + OptionsManagerImpl.getInstance().setErsterStart(false); + dispose(); + } + + public void setWeiterEnabled(boolean enabled) { + weiter.setEnabled(enabled); + } + + public void fireLanguageChanged() { + LanguageSelector languageSelector = LanguageSelector.getInstance(); + + setTitle(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.titel")); + zurueck.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.zurueck")); + weiter.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.weiter")); + ende.setText(languageSelector.getFirstAttrbuteByTagName("javagui.wizard.ende")); + schritt1.fireLanguageChanged(); + schritt2.fireLanguageChanged(); + schritt3.fireLanguageChanged(); + schritt4.fireLanguageChanged(); + schritt5.fireLanguageChanged(); + repaint(); + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardPanel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardPanel.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardPanel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardPanel.java index 5ecd7bdc..02ab16fb 100644 --- a/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardPanel.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/gui/wizard/WizardPanel.java @@ -1,10 +1,10 @@ package de.applejuicenet.client.gui.wizard; -import java.awt.Color; - import de.applejuicenet.client.gui.controller.LanguageSelector; import de.tklsoft.gui.controls.TKLPanel; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/gui/wizard/WizardPanel.java,v 1.7 2005/02/22 09:21:07 maj0r Exp $ * @@ -12,7 +12,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/ConnectionSettings.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ConnectionSettings.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/shared/ConnectionSettings.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ConnectionSettings.java index 08303af1..d35e2ab1 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/ConnectionSettings.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ConnectionSettings.java @@ -10,7 +10,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -102,4 +102,4 @@ public void setXmlPort(int xmlPort) { public String toString() { return this.getHost() + ":" + this.getXmlPort(); } -} \ No newline at end of file +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/DesktopTools.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/DesktopTools.java new file mode 100644 index 00000000..f8ffbded --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/DesktopTools.java @@ -0,0 +1,47 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.gui.AppleJuiceDialog; +import de.applejuicenet.client.gui.controller.LanguageSelector; +import de.applejuicenet.client.gui.tray.DesktopTool; + +import javax.swing.*; +import java.io.File; +import java.net.URI; + +public class DesktopTools { + private static final DesktopTool desktopToolIF; + + static { + desktopToolIF = new DesktopTool(); + } + + public static boolean isAdvancedSupported() { + return null != desktopToolIF; + } + + public static void browse(URI uri) { + if (null != desktopToolIF && !System.getProperty("os.name").toLowerCase().contains("linux")) { + desktopToolIF.browse(uri); + } else { + try { + Runtime.getRuntime().exec(new String[]{"xdg-open", uri.toURL().toString()}); + } catch (Exception ex) { + LanguageSelector ls = LanguageSelector.getInstance(); + String nachricht = ls.getFirstAttrbuteByTagName("javagui.startup.updatefehlernachricht"); + String titel = ls.getFirstAttrbuteByTagName("mainform.caption"); + + JOptionPane.showMessageDialog(AppleJuiceDialog.getApp(), nachricht, titel, JOptionPane.INFORMATION_MESSAGE); + } + } + } + + public static void open(File toOpen) { + if (null != desktopToolIF) { + desktopToolIF.open(toOpen); + } + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/IconManager.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/IconManager.java new file mode 100644 index 00000000..71aec442 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/IconManager.java @@ -0,0 +1,93 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r [aj@tkl-soft.de] + */ +public class IconManager { + private static IconManager instance = null; + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final Map icons; + + private IconManager() { + icons = new HashMap<>(); + } + + public static IconManager getInstance() { + if (instance == null) { + instance = new IconManager(); + } + + return instance; + } + + public ImageIcon getIcon(String key) { + ImageIcon result = null; + + try { + + if (icons.containsKey(key)) { + result = icons.get(key); + } else { + String iconSet = OptionsManagerImpl.getInstance().getIconSetName(); + + String path = System.getProperty("user.dir") + File.separator + "icons" + File.separator + iconSet + File.separator + key + ".png"; + + File file = new File(path); + + if (!file.exists()) { + throw new FileNotFoundException("No Icon for " + key + " found"); + } + + Image img = Toolkit.getDefaultToolkit().getImage(path); + + result = new ImageIcon(img); + icons.put(key, result); + } + } catch (Exception e) { + logger.info("Icon " + key + ".png nicht gefunden", e); + } + + return result; + } + + public Properties getIconProperties(String identifier) { + String iconSet = OptionsManagerImpl.getInstance().getIconSetName(); + String path = System.getProperty("user.dir") + File.separator + "icons" + File.separator + iconSet + File.separator + identifier + ".properties"; + File aFile = new File(path); + + if (aFile.isFile()) { + Properties props = new Properties(); + + try { + props.load(new FileInputStream(aFile)); + } catch (Exception e) { + return null; + } + + return props; + } else { + return null; + } + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/LookAFeel.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/LookAFeel.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/shared/LookAFeel.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/LookAFeel.java diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/MultiLineToolTip.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/MultiLineToolTip.java similarity index 92% rename from AJClientGUI/src/de/applejuicenet/client/shared/MultiLineToolTip.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/MultiLineToolTip.java index 3a642aa7..c6ed49bd 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/MultiLineToolTip.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/MultiLineToolTip.java @@ -4,19 +4,13 @@ package de.applejuicenet.client.shared; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; - +import javax.swing.*; +import javax.swing.plaf.metal.MetalToolTipUI; +import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import javax.swing.JComponent; -import javax.swing.JToolTip; -import javax.swing.SwingUtilities; -import javax.swing.plaf.metal.MetalToolTipUI; - /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/MultiLineToolTip.java,v 1.14 2009/01/19 15:45:29 maj0r Exp $ * @@ -24,7 +18,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class MultiLineToolTip extends JToolTip diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/NumberAndSpecialCharsInputVerifier.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/NumberAndSpecialCharsInputVerifier.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/shared/NumberAndSpecialCharsInputVerifier.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/NumberAndSpecialCharsInputVerifier.java diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/NumberInputVerifier.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/NumberInputVerifier.java similarity index 97% rename from AJClientGUI/src/de/applejuicenet/client/shared/NumberInputVerifier.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/NumberInputVerifier.java index 48e2be1e..63fac2de 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/NumberInputVerifier.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/NumberInputVerifier.java @@ -11,7 +11,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -55,4 +55,4 @@ public void insertString(int offset, String str, AttributeSet attSet) throws super.insertString(offset, str, attSet); old = getText(0, getLength()); } -} \ No newline at end of file +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PluginJarClassLoader.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PluginJarClassLoader.java new file mode 100644 index 00000000..d0346e1b --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PluginJarClassLoader.java @@ -0,0 +1,237 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.gui.plugins.PluginConnector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.io.*; +import java.lang.reflect.Constructor; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.SecureClassLoader; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/PluginJarClassLoader.java,v 1.31 2009/01/12 10:33:12 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r aj@tkl-soft.de> + */ +public class PluginJarClassLoader extends SecureClassLoader { + private static final Logger logger = LoggerFactory.getLogger(PluginJarClassLoader.class); + private Properties pluginProperties = null; + private ImageIcon pluginIcon = null; + private Map languageFiles = new HashMap<>(); + private Map availableIcons = new HashMap(); + private Map availableIcons2File = new HashMap(); + + public PluginJarClassLoader() { + super(); + } + + @SuppressWarnings("unchecked") + public PluginConnector getPlugin(File pluginJar) throws Exception { + pluginProperties = null; + pluginIcon = null; + languageFiles.clear(); + + try { + loadClassBytesFromJar(pluginJar); + String theClassName = pluginProperties.getProperty("general.classname"); + Class cl = loadClass(theClassName); + Class[] constructorHelper = {Properties.class, Map.class, ImageIcon.class, Map.class}; + Constructor con = cl.getConstructor(constructorHelper); + PluginConnector aPlugin = (PluginConnector) con.newInstance(new Object[] + { + pluginProperties, languageFiles, pluginIcon, + availableIcons + }); + + return aPlugin; + } catch (Throwable e) { + logger.info("Plugin " + pluginJar.getName() + " entspricht nicht dem Standard und wurde nicht geladen.", e); + + return null; + } + } + + @SuppressWarnings("unchecked") + private void loadClassBytesFromJar(File jar) throws Exception { + if (!jar.isFile()) { + return; + } + + JarFile jf = new JarFile(jar); + String entryName; + HashMap lazyLoad = new HashMap<>(); + + for (Enumeration e = jf.entries(); e.hasMoreElements(); ) { + ZipEntry entry = (ZipEntry) e.nextElement(); + + entryName = entry.getName(); + if (entryName.indexOf("$") == -1) { + continue; + } + + String name = entryName.replace('/', '.'); + + name = name.replaceAll(".class", ""); + byte[] buf = readEntry(jf, entry); + + lazyLoad.put(name, buf); + } + + for (Enumeration e = jf.entries(); e.hasMoreElements(); ) { + ZipEntry entry = (ZipEntry) e.nextElement(); + + entryName = entry.getName(); + if (entryName.indexOf(".class") == -1 && !entryName.equals("plugin.properties") && !entryName.endsWith(".gif") && + !entryName.endsWith(".png") && !entryName.startsWith("language_") && !entryName.endsWith(".jar") && + entryName.indexOf("$") == -1) { + continue; + } + + byte[] buf = readEntry(jf, entry); + + if (entryName.equals("plugin.properties")) { + InputStream iS = jf.getInputStream(entry); + + pluginProperties = new Properties(); + pluginProperties.load(new InputStreamReader(iS, StandardCharsets.UTF_8)); + } else if (entryName.indexOf("icon.gif") != -1) { + pluginIcon = new ImageIcon(buf); + availableIcons.put(entryName.substring(0, entryName.length() - 4), pluginIcon); + availableIcons2File.put(entryName, jar); + } else if (entryName.endsWith(".gif") || entryName.endsWith(".png")) { + ImageIcon icon = new ImageIcon(buf); + + availableIcons.put(entryName.substring(0, entryName.length() - 4), icon); + availableIcons2File.put(entryName, jar); + } else if (entryName.startsWith("language_") && entryName.endsWith(".properties")) { + InputStream iS = jf.getInputStream(entry); + + Properties curLanguageProperties = new Properties(); + + curLanguageProperties.load(new InputStreamReader(iS, StandardCharsets.UTF_8)); + + String sprache = curLanguageProperties.getProperty("language"); + + languageFiles.put(sprache, curLanguageProperties); + } else if (entryName.endsWith(".jar")) { + File aFile = File.createTempFile("ajg", null); + FileOutputStream os = new FileOutputStream(aFile); + + os.write(buf); + os.close(); + loadClassBytesFromJar(aFile); + aFile.delete(); + } else { + String name = entryName.replace('/', '.'); + + name = name.replaceAll(".class", ""); + defineMyClass(buf, name, jf); + String key = name + "$"; + + if (lazyLoad.containsKey(key + "1")) { + int i = 1; + + while (true) { + byte[] tmp = lazyLoad.get(key + i); + + if (null == tmp) { + break; + } + + defineMyClass(tmp, key + i, jf); + i++; + } + } + } + } + + lazyLoad.clear(); + } + + private byte[] readEntry(JarFile jf, ZipEntry entry) + throws IOException { + InputStream is = jf.getInputStream(entry); + int l = (int) entry.getSize(); + byte[] buf = new byte[l]; + int read = 0; + + while (read < l) { + int incr = is.read(buf, read, l - read); + + read += incr; + } + + return buf; + } + + @SuppressWarnings("unchecked") + private void defineMyClass(byte[] buf, String name, JarFile jarFile) + throws IOException { + try { + Class clazz = findLoadedClass(name); + + if (null != clazz) { + return; + } + + while (true) { + try { + clazz = defineClass(name, buf, 0, buf.length); + break; + } catch (NoClassDefFoundError clfE) { + + // rekursiv probieren + String className = clfE.getMessage(); + ZipEntry entry = jarFile.getEntry(className + ".class"); + byte[] innerBuf = readEntry(jarFile, entry); + + className = className.replace('/', '.'); + defineMyClass(innerBuf, className, jarFile); + } + } + + resolveClass(clazz); + } catch (LinkageError lE) { + logger.debug("Mist im Plugin", lE); + + //Klasse wurde aus irgendeinem Grund bereits geladen + } + } + + @Override + public URL getResource(String name) { + File entry = availableIcons2File.get(name); + + if (null == entry) { + return null; + } + + URL url = null; + + try { + url = new URL("jar:file:" + entry.getAbsolutePath() + "!/" + name); + } catch (MalformedURLException e) { + // bloed, aber nicht soooo schlimm + } + + return url; + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PolicyJarClassLoader.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PolicyJarClassLoader.java new file mode 100644 index 00000000..8e4f26ad --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/PolicyJarClassLoader.java @@ -0,0 +1,121 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.powerdownload.AutomaticPowerdownloadPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/PolicyJarClassLoader.java,v 1.7 2009/01/12 09:02:56 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class PolicyJarClassLoader extends URLClassLoader { + private Logger logger; + + public PolicyJarClassLoader(URL url) { + super(new URL[]{url}); + logger = LoggerFactory.getLogger(getClass()); + } + + @SuppressWarnings("unchecked") + public AutomaticPowerdownloadPolicy getPolicy(String jar) + throws Exception { + try { + File aJar = new File(jar); + List classes = loadClassBytesFromJar(aJar); + + if (classes == null) { + return null; + } + + String className; + Class cl; + Constructor con; + AutomaticPowerdownloadPolicy policy; + + for (String curClassName : classes) { + cl = loadClass(curClassName); + if (AutomaticPowerdownloadPolicy.class.isAssignableFrom(cl)) { + con = cl.getConstructor(new Class[]{ApplejuiceFassade.class}); + policy = (AutomaticPowerdownloadPolicy) con.newInstance(new Object[]{AppleJuiceClient.getAjFassade()}); + + return policy; + } + } + + return null; + } catch (Exception e) { + logger.info("Plugin " + jar + " entspricht nicht dem Standard und wurde nicht geladen.", e); + + return null; + } + } + + @SuppressWarnings("unchecked") + private List loadClassBytesFromJar(File jar) + throws Exception { + if (!jar.isFile()) { + return null; + } + + JarFile jf = new JarFile(jar); + String entryName; + List classes = new ArrayList(); + ZipEntry entry; + InputStream is; + int l; + byte[] buf; + int read; + int incr; + String name; + + for (Enumeration e = jf.entries(); e.hasMoreElements(); ) { + entry = (ZipEntry) e.nextElement(); + + entryName = entry.getName(); + if (entryName.indexOf(".class") == -1) { + continue; + } + + is = jf.getInputStream(entry); + l = (int) entry.getSize(); + buf = new byte[l]; + read = 0; + + while (read < l) { + incr = is.read(buf, read, l - read); + + read += incr; + } + + name = entryName.replace('/', '.'); + + name = name.replaceAll(".class", ""); + defineClass(name, buf, 0, buf.length); + classes.add(name); + } + + return classes; + } +} diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ReleaseInfo.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ReleaseInfo.java new file mode 100644 index 00000000..55c2b2c1 --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/ReleaseInfo.java @@ -0,0 +1,62 @@ +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.gui.start.HyperlinkAdapter; + +import java.io.*; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.Properties; + +public class ReleaseInfo { + + private static final String defaultHost = new String(Base64.getDecoder().decode("aHR0cHM6Ly93d3cuYXBwbGUtZGVsdXhlLmNvL2luZGV4LnBocD9jdD00MDMmdmE9JXM=")); + + private static String releaseInfoHost = null; + + private static void init() { + if (null == releaseInfoHost) { + Properties props = new Properties(); + String path = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui" + File.separator + "rel.properties"; + + File aFile = new File(path); + if (aFile.exists()) { + try { + FileInputStream fiS = new FileInputStream(aFile); + props.load(fiS); + fiS.close(); + + releaseInfoHost = props.getProperty("host", defaultHost); + } catch (Exception e) { + // nix zu tun + } + } else { + props.setProperty("host", defaultHost); + try (OutputStream outputStream = new FileOutputStream(aFile)) { + props.store(outputStream, null); + } catch (IOException e) { + // nix zu tun + } + } + + releaseInfoHost = (releaseInfoHost == null) ? defaultHost : releaseInfoHost; + } + } + + public static void handle(String filename, String hash, Long size) { + init(); + + String ajfsp = String.format("ajfsp://file%%7C%s%%7C%s%%7C%s/", encodeValue(filename), hash, size); + + HyperlinkAdapter.executeLink(String.format(releaseInfoHost, ajfsp)); + } + + private static String encodeValue(String value) { + try { + return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex.getCause()); + } + } + +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/Settings.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Settings.java similarity index 98% rename from AJClientGUI/src/de/applejuicenet/client/shared/Settings.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Settings.java index b0afa867..2cbd4c61 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/Settings.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Settings.java @@ -3,10 +3,10 @@ */ package de.applejuicenet.client.shared; -import java.awt.Color; - import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import java.awt.*; + /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/src/de/applejuicenet/client/shared/Settings.java,v 1.13 2009/02/01 14:45:03 maj0r Exp $ * @@ -14,7 +14,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class Settings diff --git a/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SoundPlayer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SoundPlayer.java new file mode 100644 index 00000000..4fe8968b --- /dev/null +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SoundPlayer.java @@ -0,0 +1,176 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.shared; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.controller.OptionsManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.sound.sampled.*; +import java.io.File; +import java.io.IOException; + +/** + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class SoundPlayer { + public static final int ABGEBROCHEN = 0; + public static final int SUCHEN = 1; + public static final int VERBINDEN = 2; + public static final int GESPEICHERT = 3; + public static final int KOMPLETT = 4; + public static final int LADEN = 5; + public static final int POWER = 6; + public static final int VERWEIGERT = 7; + public static final int KONKRETISIEREN = 8; + public static final int ZUGANG_GEWAEHRT = 9; + public static final int GESTARTET = 10; + private static SoundPlayer instance = null; + private static Logger logger; + private final String soundPath; + + private SoundPlayer() { + String soundPack = OptionsManagerImpl.getInstance().getSoundSetName(); + soundPath = System.getProperty("user.dir") + File.separator + "sounds" + File.separator + soundPack + File.separator; + } + + public static SoundPlayer getInstance() { + if (instance == null) { + instance = new SoundPlayer(); + logger = LoggerFactory.getLogger(instance.getClass()); + } + + return instance; + } + + public void playSound(int sound) { + try { + if (!OptionsManagerImpl.getInstance().isSoundEnabled()) { + return; + } + + File soundFile = null; + + switch (sound) { + + case ABGEBROCHEN: { + soundFile = new File(soundPath + "abgebrochen.wav"); + break; + } + + case SUCHEN: { + soundFile = new File(soundPath + "suchen.wav"); + break; + } + + case VERBINDEN: { + soundFile = new File(soundPath + "verbinden.wav"); + break; + } + + case GESPEICHERT: { + soundFile = new File(soundPath + "gespeichert.wav"); + break; + } + + case KOMPLETT: { + soundFile = new File(soundPath + "komplett.wav"); + break; + } + + case LADEN: { + soundFile = new File(soundPath + "laden.wav"); + break; + } + + case POWER: { + soundFile = new File(soundPath + "pwdl.wav"); + break; + } + + case VERWEIGERT: { + soundFile = new File(soundPath + "verweigert.wav"); + break; + } + + case KONKRETISIEREN: { + soundFile = new File(soundPath + "konkretisieren.wav"); + break; + } + + case ZUGANG_GEWAEHRT: { + soundFile = new File(soundPath + "zuganggestattet.wav"); + break; + } + + case GESTARTET: { + soundFile = new File(soundPath + "gestartet.wav"); + break; + } + + default: + logger.error("SoundPlayer::playSound() ungueltiger Parameter: " + sound); + } + + final Clip soundToPlay = loadSound(soundFile); + + if (null != soundToPlay) { + new Thread("SoundPlayer") { + public void run() { + soundToPlay.start(); + soundToPlay.addLineListener(e -> { + if (e.getType() == LineEvent.Type.STOP) { + interrupt(); + } + }); + } + }.start(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private Clip loadSound(File file) { + Clip clip = null; + + try { + AudioInputStream sound; + + sound = AudioSystem.getAudioInputStream(file); + AudioFormat format = sound.getFormat(); + + if ((format.getEncoding() == AudioFormat.Encoding.ULAW) || (format.getEncoding() == AudioFormat.Encoding.ALAW)) { + AudioFormat tmp = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), + format.getSampleSizeInBits() * 2, format.getChannels(), format.getFrameSize() * 2, + format.getFrameRate(), true); + + sound = AudioSystem.getAudioInputStream(tmp, sound); + format = tmp; + } + + DataLine.Info info = new DataLine.Info(Clip.class, sound.getFormat(), + ((int) sound.getFrameLength() * format.getFrameSize())); + + clip = (Clip) AudioSystem.getLine(info); + clip.open(sound); + } catch (LineUnavailableException luE) { + logger.info("Kein Audioausgabegeraet gefunden. Bitte Soundausgabe deaktivieren.", luE); + } catch (IOException ioE) { + logger.error("Die Datei " + file.getAbsolutePath() + " konnte nicht gefunden werden."); + } catch (UnsupportedAudioFileException uafE) { + logger.error("Die Datei " + file.getAbsolutePath() + " hat ein ungueltiges Format und kann nicht ausgegeben werden."); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + return clip; + } +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/Splash.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Splash.java similarity index 69% rename from AJClientGUI/src/de/applejuicenet/client/shared/Splash.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Splash.java index f4950676..76a730d4 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/Splash.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/Splash.java @@ -7,25 +7,15 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ -import java.awt.AWTException; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Robot; -import java.awt.Toolkit; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; import java.util.Properties; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; -import javax.swing.JProgressBar; - public class Splash extends JDialog { private Image image; @@ -45,25 +35,28 @@ public void setProgress(int position, String text){ && position <= progress.getMaximum() ){ progress.setValue(position); progress.setString(text); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + e.printStackTrace(); + } } } private void init(){ setUndecorated(true); + setBackground(new Color(0, 0, 0, 0)); int w = image.getWidth(this); int h = image.getHeight(this); - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - Image back = null; - setBounds( (d.width - w) / 2, (d.height - h) / 3, w, h); - try { - back = new Robot().createScreenCapture(getBounds()); - } - catch (AWTException e) { - ; - } + Rectangle r = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); + Dimension d = new Dimension(r.width, r.height); + setBounds((d.width - w) / 2, (d.height - h) / 3, w, h); + Image back = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics g = back.getGraphics(); g.drawImage(image, 0, 0, this); + g.dispose(); JLabel label = new JLabel(new ImageIcon(back)); + label.setOpaque(false); label.setBounds(0, 0, w, h); try{ Properties props = IconManager.getInstance().getIconProperties("splashscreen"); @@ -76,18 +69,23 @@ private void init(){ throw new Exception(); } progress.setBounds(x, y, width, height); + progress.setOpaque(false); } catch(Exception e){ progress.setBounds(160, 61, 180, 15); + progress.setOpaque(false); } - JLayeredPane panel = new JLayeredPane(); - panel.add(progress, JLayeredPane.DEFAULT_LAYER); + panel = new JLayeredPane(); + panel.setBounds(0, 0, w, h); + panel.setOpaque(false); panel.add(label, JLayeredPane.DEFAULT_LAYER); - getContentPane().add(panel); + panel.add(progress, JLayeredPane.PALETTE_LAYER); + setContentPane(panel); + getRootPane().setOpaque(false); } public void dispose() { super.dispose(); image = null; } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/SwingWorker.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SwingWorker.java similarity index 99% rename from AJClientGUI/src/de/applejuicenet/client/shared/SwingWorker.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SwingWorker.java index 0b1d910a..6c705dfd 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/SwingWorker.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/SwingWorker.java @@ -1,6 +1,6 @@ package de.applejuicenet.client.shared; -import javax.swing.SwingUtilities; +import javax.swing.*; /** * This is the 3rd version of SwingWorker (also known as diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/exception/InvalidPasswordException.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/InvalidPasswordException.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/shared/exception/InvalidPasswordException.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/InvalidPasswordException.java index 535ac91a..59af248e 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/exception/InvalidPasswordException.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/InvalidPasswordException.java @@ -7,7 +7,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -17,4 +17,4 @@ public class InvalidPasswordException public InvalidPasswordException() { super("Ungueltiges Kennwort"); } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java index 0986d1d6..7c2106a0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/LanguageSelectorNotInstanciatedException.java @@ -7,7 +7,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -17,4 +17,4 @@ public class LanguageSelectorNotInstanciatedException public LanguageSelectorNotInstanciatedException() { super("Der LanguageSelector muss erst initialisiert werden."); } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/exception/NoIconAvailableException.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/NoIconAvailableException.java similarity index 94% rename from AJClientGUI/src/de/applejuicenet/client/shared/exception/NoIconAvailableException.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/NoIconAvailableException.java index c2006df9..e9d874de 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/exception/NoIconAvailableException.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/NoIconAvailableException.java @@ -7,7 +7,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -17,4 +17,4 @@ public class NoIconAvailableException public NoIconAvailableException() { super("An der angebenen Stelle wurde kein Icon gefunden."); } -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/exception/NodeAlreadyExistsException.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/NodeAlreadyExistsException.java similarity index 100% rename from AJClientGUI/src/de/applejuicenet/client/shared/exception/NodeAlreadyExistsException.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/NodeAlreadyExistsException.java diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/exception/PartlistException.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/PartlistException.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/shared/exception/PartlistException.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/PartlistException.java index f49a4f98..93ce9c94 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/exception/PartlistException.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/exception/PartlistException.java @@ -7,7 +7,7 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/icons/DummyClass.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/icons/DummyClass.java similarity index 92% rename from AJClientGUI/src/de/applejuicenet/client/shared/icons/DummyClass.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/icons/DummyClass.java index 9408ee62..b10b2fd6 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/icons/DummyClass.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/icons/DummyClass.java @@ -7,9 +7,9 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public final class DummyClass { -} \ No newline at end of file +} diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java index 3452a1ee..97c68da7 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/ProgressTableCellRenderer.java @@ -3,13 +3,10 @@ */ package de.applejuicenet.client.shared.tablecellrenderer; -import java.awt.Component; - -import java.text.DecimalFormat; - -import javax.swing.JProgressBar; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.text.DecimalFormat; public class ProgressTableCellRenderer extends JProgressBar implements TableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java similarity index 95% rename from AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java index 3c629731..24e80da0 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SizeTableCellRenderer.java @@ -4,11 +4,9 @@ package de.applejuicenet.client.shared.tablecellrenderer; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; public class SizeTableCellRenderer extends DefaultTableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java index 18be7dff..623cddf1 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/SpeedTableCellRenderer.java @@ -4,11 +4,9 @@ package de.applejuicenet.client.shared.tablecellrenderer; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; public class SpeedTableCellRenderer extends DefaultTableCellRenderer { diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java similarity index 91% rename from AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java index 61306e6a..a26c2a73 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/StringTableCellRenderer.java @@ -4,7 +4,7 @@ package de.applejuicenet.client.shared.tablecellrenderer; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; public class StringTableCellRenderer extends DefaultTableCellRenderer diff --git a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java similarity index 93% rename from AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java rename to modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java index 36f8fd5f..59346455 100644 --- a/AJClientGUI/src/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java +++ b/modules/AJCoreGUI/src/main/java/de/applejuicenet/client/shared/tablecellrenderer/VersionTableCellRenderer.java @@ -4,17 +4,13 @@ package de.applejuicenet.client.shared.tablecellrenderer; -import java.awt.Component; - -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.DefaultTableCellRenderer; - import de.applejuicenet.client.fassade.entity.Version; import de.applejuicenet.client.shared.IconManager; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + public class VersionTableCellRenderer extends DefaultTableCellRenderer { public VersionTableCellRenderer() diff --git a/modules/AJCoreGUI/src/main/resources/logback.xml b/modules/AJCoreGUI/src/main/resources/logback.xml new file mode 100644 index 00000000..130f1439 --- /dev/null +++ b/modules/AJCoreGUI/src/main/resources/logback.xml @@ -0,0 +1,24 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} %M\(%line\) - %msg%n + + + + + ${user.home}/appleJuice/gui/logs/${timestamp}.html + + + + %relative%thread%level%logger%line%msg + + + + + + + + + diff --git a/modules/ajcorefassade/pom.xml b/modules/ajcorefassade/pom.xml new file mode 100644 index 00000000..8fcc713a --- /dev/null +++ b/modules/ajcorefassade/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + de.applejuicenet.client.gui + ajcorefassade + jar + 1.0.0 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + xerces + xercesImpl + 2.12.2 + + + + + + + maven-dependency-plugin + + + prepare-package + + copy-dependencies + + + ../../resources/lib/ + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + false + + + + + + diff --git a/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/ApplejuiceFassade.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/ApplejuiceFassade.java new file mode 100644 index 00000000..53a810fa --- /dev/null +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/ApplejuiceFassade.java @@ -0,0 +1,934 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.fassade; + +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.controller.DataPropertyChangeInformer; +import de.applejuicenet.client.fassade.controller.DataUpdateInformer; +import de.applejuicenet.client.fassade.controller.xml.*; +import de.applejuicenet.client.fassade.entity.*; +import de.applejuicenet.client.fassade.entity.ShareEntry.SHAREMODE; +import de.applejuicenet.client.fassade.exception.CoreLostException; +import de.applejuicenet.client.fassade.exception.IllegalArgumentException; +import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; +import de.applejuicenet.client.fassade.exception.WrongPasswordException; +import de.applejuicenet.client.fassade.listener.CoreConnectionSettingsListener; +import de.applejuicenet.client.fassade.listener.CoreStatusListener; +import de.applejuicenet.client.fassade.listener.CoreStatusListener.STATUS; +import de.applejuicenet.client.fassade.listener.DataUpdateListener; +import de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE; +import de.applejuicenet.client.fassade.shared.AJSettings; +import de.applejuicenet.client.fassade.shared.HtmlLoader; +import de.applejuicenet.client.fassade.shared.NetworkInfo; +import de.applejuicenet.client.fassade.shared.StringConstants; +import de.applejuicenet.client.fassade.tools.MD5Encoder; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.*; + +public class ApplejuiceFassade implements CoreConnectionSettingsListener { + public static final String MIN_NEEDED_CORE_VERSION = "0.31.149.112"; + public static final String ERROR_MESSAGE = "Unbehandelte Exception"; + public static String separator; + private static HashSet coreListener = new HashSet(); + private final CoreConnectionSettingsHolder coreHolder; + private Map informer = new HashMap(); + private ModifiedXMLHolder modifiedXML; + private InformationXMLHolder informationXML = null; + private ShareXMLHolder shareXML = null; + private SettingsXMLHolder settingsXML = null; + private DirectoryXMLHolder directoryXML = null; + private Version coreVersion; + private Map share = null; + private PartListXMLHolder partlistXML = null; + private long sleepTime = 2000; + + // Thread + private Thread workerThread; + + public ApplejuiceFassade(CoreConnectionSettingsHolder coreConnectionSettingsHolder) + throws IllegalArgumentException { + coreHolder = coreConnectionSettingsHolder; + coreHolder.addListener(this); + modifiedXML = new ModifiedXMLHolder(coreHolder, this); + DataUpdateInformer downloadInformer = new DataUpdateInformer(DATALISTENER_TYPE.DOWNLOAD_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getDownloads(); + } + }; + + informer.put(downloadInformer.getDataUpdateListenerType(), downloadInformer); + DataUpdateInformer searchInformer = new DataUpdateInformer(DATALISTENER_TYPE.SEARCH_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getSearchs(); + } + }; + + informer.put(searchInformer.getDataUpdateListenerType(), searchInformer); + DataUpdateInformer serverInformer = new DataUpdateInformer(DATALISTENER_TYPE.SERVER_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getServer(); + } + }; + + informer.put(serverInformer.getDataUpdateListenerType(), serverInformer); + DataUpdateInformer uploadInformer = new DataUpdateInformer(DATALISTENER_TYPE.UPLOAD_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getUploads(); + } + }; + + informer.put(uploadInformer.getDataUpdateListenerType(), uploadInformer); + DataUpdateInformer shareInformer = new DataUpdateInformer(DATALISTENER_TYPE.SHARE_CHANGED) { + protected Object getContentObject() { + return shareXML.getShare(); + } + }; + + informer.put(shareInformer.getDataUpdateListenerType(), shareInformer); + DataUpdateInformer networkInformer = new DataUpdateInformer(DATALISTENER_TYPE.NETINFO_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getNetworkInfo(); + } + }; + + informer.put(networkInformer.getDataUpdateListenerType(), networkInformer); + DataUpdateInformer speedInformer = new DataUpdateInformer(DATALISTENER_TYPE.SPEED_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getSpeeds(); + } + }; + + informer.put(speedInformer.getDataUpdateListenerType(), speedInformer); + DataUpdateInformer informationInformer = new DataUpdateInformer(DATALISTENER_TYPE.INFORMATION_CHANGED) { + protected Object getContentObject() { + return modifiedXML.getInformation(); + } + }; + + informer.put(informationInformer.getDataUpdateListenerType(), informationInformer); + } + + public DataPropertyChangeInformer getDownloadPropertyChangeInformer() { + return modifiedXML.getDownloadPropertyChangeInformer(); + } + + public Long getLastCoreTimestamp() { + if (modifiedXML != null) { + return modifiedXML.getTimestamp(); + } else { + return null; + } + } + + public void addDataUpdateListener(DataUpdateListener listener, DATALISTENER_TYPE type) { + if (informer.containsKey(type)) { + DataUpdateInformer anInformer = informer.get(type); + + anInformer.addDataUpdateListener(listener); + } + } + + public void removeDataUpdateListener(DataUpdateListener listener, DATALISTENER_TYPE type) { + if (informer.containsKey(type)) { + DataUpdateInformer anInformer = informer.get(type); + + anInformer.removeDataUpdateListener(listener); + } + } + + public static boolean addCoreStatusListener(CoreStatusListener listener) { + return coreListener.add(listener); + } + + public static boolean removeCoreStatusListener(CoreStatusListener listener) { + return coreListener.remove(listener); + } + + private void informCoreStatusListener(STATUS newStatus) { + for (CoreStatusListener curListener : coreListener) { + curListener.fireStatusChanged(newStatus); + } + } + + public boolean isLocalhost() { + return coreHolder.isLocalhost(); + } + + private void checkForValidCoreversion() { + if (getCoreVersion() == null) { + return; + } + + if (getCoreVersion().checkForValidCoreVersion() < 0) { + throw new RuntimeException("invalid coreversion"); + } + } + + private int tryUpdate(int versuch) { + int anzahl = versuch; + + if (updateModifiedXML()) { + anzahl = 0; + } else { + anzahl++; + if (anzahl == 3) { + throw new CoreLostException(); + } + } + + return anzahl; + } + + public void startXMLCheck() { + workerThread = new Thread("ApplejuiceFassadeXMLCheckThread") { + public void run() { + setPriority(Thread.NORM_PRIORITY); + int versuch = 0; + + // load XMLs + informationXML = new InformationXMLHolder(coreHolder); + directoryXML = new DirectoryXMLHolder(coreHolder); + shareXML = new ShareXMLHolder(coreHolder); + if (coreVersion == null) { + coreVersion = informationXML.getCoreVersion(); + checkForValidCoreversion(); + } + + informCoreStatusListener(STATUS.STARTED); + while (!isInterrupted()) { + try { + versuch = tryUpdate(versuch); + sleep(sleepTime); + } catch (InterruptedException e) { + + // nicht zu tun + ; + } + } + } + }; + workerThread.start(); + } + + public void setUpdateInterval(long millis) { + if (millis > 0) { + sleepTime = millis; + } + } + + public void stopXMLCheck() { + if (workerThread != null) { + workerThread.interrupt(); + workerThread = null; + informCoreStatusListener(STATUS.CLOSED); + } + } + + public String[] getCurrentIncomingDirs() { + Map download = getDownloadsSnapshot(); + ArrayList incomingDirs = new ArrayList(); + boolean found; + + synchronized (download) { + for (Download curDownload : download.values()) { + if (curDownload.getTargetDirectory().length() == 0) { + continue; + } + + found = false; + for (int i = 0; i < incomingDirs.size(); i++) { + if (incomingDirs.get(i).compareToIgnoreCase(curDownload.getTargetDirectory()) == 0) { + found = true; + break; + } + } + + if (!found) { + incomingDirs.add(curDownload.getTargetDirectory()); + } + } + } + + incomingDirs.add(""); + return incomingDirs.toArray(new String[incomingDirs.size()]); + } + + public Information getInformation() { + return modifiedXML.getInformation(); + } + + public PartList getPartList(DownloadSource downloadSource) + throws WebSiteNotFoundException { + if (partlistXML == null) { + partlistXML = new PartListXMLHolder(coreHolder); + } + + return partlistXML.getPartList(downloadSource); + } + + public PartList getPartList(Download download) throws WebSiteNotFoundException { + if (partlistXML == null) { + partlistXML = new PartListXMLHolder(coreHolder); + } + + return partlistXML.getPartList(download); + } + + public String[] getNetworkKnownServers(String ServerListURL) { + NetworkServerXMLHolder getServerXMLHolder = NetworkServerXMLHolder.getInstance(); + + return getServerXMLHolder.getNetworkKnownServers(ServerListURL); + } + + public AJSettings getAJSettings() { + if (settingsXML == null) { + settingsXML = new SettingsXMLHolder(coreHolder); + } + + return settingsXML.getAJSettings(); + } + + public AJSettings getCurrentAJSettings() { + if (settingsXML == null) { + return getAJSettings(); + } else { + return settingsXML.getCurrentAJSettings(); + } + } + + public void setMaxUpAndDown(final Long maxUp, final Long maxDown) + throws IllegalArgumentException { + if (maxUp == null || maxUp.longValue() <= 0) { + throw new IllegalArgumentException("invalid maxUp"); + } + + if (maxDown == null || maxDown.longValue() <= 0) { + throw new IllegalArgumentException("invalid maxDown"); + } + + new Thread() { + public void run() { + StringBuilder parameters = new StringBuilder("MaxUpload="); + + parameters.append(maxUp.toString()); + parameters.append("&MaxDownload="); + parameters.append(maxDown.toString()); + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + + parameters.toString(), false); + } + }.start(); + } + + public void saveAJSettings(AJSettings ajSettings) { + StringBuilder parameters = new StringBuilder(); + + try { + parameters.append("Nickname=" + URLEncoder.encode(ajSettings.getNick(), "UTF-8")); + parameters.append("&XMLPort=" + Long.toString(ajSettings.getXMLPort())); + parameters.append("&Port=" + Long.toString(ajSettings.getPort())); + parameters.append("&MaxUpload=" + Long.toString(ajSettings.getMaxUpload())); + parameters.append("&MaxDownload=" + Long.toString(ajSettings.getMaxDownload())); + parameters.append("&Speedperslot=" + Integer.toString(ajSettings.getSpeedPerSlot())); + parameters.append("&Incomingdirectory=" + URLEncoder.encode(ajSettings.getIncomingDir(), "UTF-8")); + parameters.append("&Temporarydirectory=" + URLEncoder.encode(ajSettings.getTempDir(), "UTF-8")); + parameters.append("&maxconnections=" + URLEncoder.encode(Long.toString(ajSettings.getMaxConnections()), "UTF-8")); + parameters.append("&maxsourcesperfile=" + URLEncoder.encode(Long.toString(ajSettings.getMaxSourcesPerFile()), "UTF-8")); + parameters.append("&autoconnect=" + URLEncoder.encode(Boolean.toString(ajSettings.isAutoConnect()), "UTF-8")); + parameters.append("&maxnewconnectionsperturn=" + + URLEncoder.encode(Long.toString(ajSettings.getMaxNewConnectionsPerTurn()), "UTF-8")); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + parameters.toString(), + false); + } + + public Map getAllServer() { + if (modifiedXML != null) { + return modifiedXML.getServer(); + } + + return null; + } + + public boolean updateModifiedXML() { + try { + if (modifiedXML.update()) { + if (modifiedXML.isServerChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.SERVER_CHANGED); + } + + if (modifiedXML.isDownloadChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.DOWNLOAD_CHANGED); + } + + if (modifiedXML.isUploadChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.UPLOAD_CHANGED); + } + + if (modifiedXML.isNetworkInfoChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.NETINFO_CHANGED); + } + + if (modifiedXML.isSpeedChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.SPEED_CHANGED); + } + + if (modifiedXML.isSearchChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.SEARCH_CHANGED); + } + + if (modifiedXML.isInformationChanged()) { + informDataUpdateListener(DATALISTENER_TYPE.INFORMATION_CHANGED); + } + } + + return true; + } catch (WrongPasswordException wpE) { + stopXMLCheck(); + throw wpE; + } catch (Exception re) { + + // connection to core lost, next try + return false; + } + } + + public void resumeDownload(List downloads) + throws IllegalArgumentException { + if (downloads == null) { + throw new IllegalArgumentException("invalid download-list"); + } + + if (downloads.size() == 0) { + return; + } + + for (Download curDownload : downloads) { + if (curDownload == null) { + throw new IllegalArgumentException("invalid download-list"); + } + } + + StringBuffer parameters = new StringBuffer(); + int index = 0; + + for (Download curDownload : downloads) { + parameters.append("&id"); + if (index != 0) { + parameters.append(Integer.toString(index)); + } + + parameters.append("=" + curDownload.getId()); + index++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/resumedownload?password=" + coreHolder.getCorePassword() + parameters, false); + } + + public void startSearch(String searchString) throws IllegalArgumentException { + if (searchString == null) { + throw new IllegalArgumentException("invalid search-phrase"); + } + + String toSearch = searchString.trim(); + + if (toSearch.length() == 0) { + throw new IllegalArgumentException("invalid search-phrase"); + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/search?password=" + coreHolder.getCorePassword() + "&search=" + toSearch, false); + } + + public synchronized void cancelSearch(Search search) + throws IllegalArgumentException { + if (search == null) { + throw new IllegalArgumentException("invalid search"); + } + + new CancelThread(search).start(); + } + + public void renameDownload(Download download, String newFilename) + throws IllegalArgumentException { + if (download == null) { + throw new IllegalArgumentException("invalid download"); + } + + if (newFilename == null || newFilename.length() == 0 || newFilename.trim().length() == 0) { + throw new IllegalArgumentException("invalid filename"); + } + + String encodedName = newFilename; + + try { + StringBuffer tempLink = new StringBuffer(encodedName); + + for (int i = 0; i < tempLink.length(); i++) { + if (tempLink.charAt(i) == ' ') { + tempLink.setCharAt(i, '.'); + } + } + + encodedName = URLEncoder.encode(tempLink.toString(), "ISO-8859-1"); + } catch (UnsupportedEncodingException ex) { + ; + + // gibbet, also nix zu behandeln... + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/renamedownload?password=" + coreHolder.getCorePassword() + "&id=" + download.getId() + + "&name=" + encodedName, false); + } + + public void setTargetDir(List downloads, String newDirectoryName) + throws IllegalArgumentException { + if (downloads == null) { + throw new IllegalArgumentException("invalid download-list"); + } + + if (downloads.size() == 0) { + return; + } + + newDirectoryName = processSubdir(newDirectoryName); + for (Download curDownload : downloads) { + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/settargetdir?password=" + coreHolder.getCorePassword() + "&id=" + + curDownload.getId() + "&dir=" + newDirectoryName, false); + } + } + + public void shutdownCore() { + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/exitcore?password=" + coreHolder.getCorePassword(), false); + } + + public void setPassword(String password, boolean passwordIsPlaintext) + throws IllegalArgumentException { + if (password == null || (!passwordIsPlaintext && (password.length() == 0 || password.trim().length() == 0))) { + throw new IllegalArgumentException("invalid password"); + } + + String newPassword = passwordIsPlaintext ? MD5Encoder.getMD5(password) : password; + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/setpassword?password=" + coreHolder.getCorePassword() + "&newpassword=" + + newPassword, false); + coreHolder.setCorePassword(password, false); + } + + public void cancelDownload(List downloads) + throws IllegalArgumentException { + if (downloads == null) { + throw new IllegalArgumentException("invalid download-list"); + } + + if (downloads.size() == 0) { + return; + } + + for (Download curDownload : downloads) { + if (curDownload == null) { + throw new IllegalArgumentException("invalid download-list"); + } + } + + StringBuffer parameters = new StringBuffer(); + int index = 0; + + for (Download curDownload : downloads) { + parameters.append("&id"); + if (index != 0) { + parameters.append(Integer.toString(index)); + } + + parameters.append("=" + curDownload.getId()); + index++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/canceldownload?password=" + coreHolder.getCorePassword() + parameters, false); + } + + public void cleanDownloadList() { + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/cleandownloadlist?password=" + coreHolder.getCorePassword(), false); + } + + public void pauseDownload(List downloads) + throws IllegalArgumentException { + if (downloads == null) { + throw new IllegalArgumentException("invalid download-list"); + } + + if (downloads.size() == 0) { + return; + } + + for (Download curDownload : downloads) { + if (curDownload == null) { + throw new IllegalArgumentException("invalid download-list"); + } + } + + StringBuffer parameters = new StringBuffer(); + int index = 0; + + for (Download curDownload : downloads) { + parameters.append("&id"); + if (index != 0) { + parameters.append(Integer.toString(index)); + } + + parameters.append("=" + curDownload.getId()); + index++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/pausedownload?password=" + coreHolder.getCorePassword() + parameters, false); + } + + public void connectToServer(Server server) throws IllegalArgumentException { + if (server == null) { + throw new IllegalArgumentException("invalid server"); + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/serverlogin?password=" + coreHolder.getCorePassword() + "&id=" + server.getId(), false); + } + + public Object getObjectById(Integer id) throws IllegalArgumentException { + if (id == null) { + throw new IllegalArgumentException("invalid id"); + } + + GetObjectXMLHolder getObjectXMLHolder = new GetObjectXMLHolder(coreHolder); + + return getObjectXMLHolder.getObjectByID(id.intValue()); + } + + public void entferneServer(List server) throws IllegalArgumentException { + if (server == null) { + throw new IllegalArgumentException("invalid server"); + } + + if (server.size() == 0) { + return; + } + + for (Server curServer : server) { + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/removeserver?password=" + coreHolder.getCorePassword() + "&id=" + + curServer.getId(), false); + } + } + + public void setPrioritaet(Share share, Integer priority) + throws IllegalArgumentException { + if (share == null) { + throw new IllegalArgumentException("invalid share"); + } + + setPrioritaet(share.getId(), priority); + } + + public void setPrioritaet(Download download, Integer priority) + throws IllegalArgumentException { + if (download == null) { + throw new IllegalArgumentException("invalid download"); + } + + setPrioritaet(download.getId(), priority); + } + + private void setPrioritaet(int id, Integer priority) + throws IllegalArgumentException { + if (priority == null) { + throw new IllegalArgumentException("invalid priority"); + } + + if (priority.intValue() < 1 || priority.intValue() > 250) { + throw new IllegalArgumentException("invalid priority: has to be 1<= x <=250"); + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/setpriority?password=" + coreHolder.getCorePassword() + "&id=" + id + "&priority=" + + priority.intValue(), false); + } + + private String processSubdir(String subdir) { + if (subdir == null) { + subdir = ""; + } else { + subdir = subdir.trim(); + if (subdir.indexOf(File.separator) == 0 || subdir.indexOf(ApplejuiceFassade.separator) == 0) { + subdir = subdir.substring(1); + } + + subdir = subdir.replace(".", "_"); + subdir = subdir.replace(":", "_"); + } + + return subdir; + } + + public synchronized String processLink(final String link, String subdir) + throws IllegalArgumentException { + if (link == null || link.length() == 0) { + throw new IllegalArgumentException("invalid link"); + } + + subdir = processSubdir(subdir); + String encodedLink = link; + + try { + StringBuffer tempLink = new StringBuffer(link); + + for (int i = 0; i < tempLink.length(); i++) { + if (tempLink.charAt(i) == ' ') { + tempLink.setCharAt(i, '.'); + } + } + + encodedLink = URLEncoder.encode(tempLink.toString(), "ISO-8859-1"); + } catch (UnsupportedEncodingException ex) { + ; + + //gibbet nicht, also nix zu behandeln... + } + + return HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/processlink?password=" + coreHolder.getCorePassword() + "&link=" + + encodedLink + "&subdir=" + subdir, true); + } + + public void setPowerDownload(List downloads, Integer powerDownload) + throws IllegalArgumentException { + if (downloads == null || downloads.size() == 0) { + throw new IllegalArgumentException("invalid downloadlist"); + } + + if (downloads.size() == 0) { + return; + } + + for (Download curDownload : downloads) { + if (curDownload == null) { + throw new IllegalArgumentException("invalid download-array"); + } + } + + if (powerDownload.intValue() < 0 || powerDownload.intValue() > 490) { + throw new IllegalArgumentException("invalid priority: has to be 1<= x <=490"); + } + + StringBuffer parameters = new StringBuffer(StringConstants.AND_PWDL + powerDownload); + int index = 0; + + for (Download curDownload : downloads) { + parameters.append("&id"); + if (index != 0) { + parameters.append(Integer.toString(index)); + } + + parameters.append("=" + curDownload.getId()); + index++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + StringConstants.SET_PWDL_URL + coreHolder.getCorePassword() + parameters, false); + } + + /** + * 0 = connection 1 = wrong password 2 = no connection + */ + public synchronized int isCoreAvailable() { + try { + String result = HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + StringConstants.GET_INFORMATION_URL + coreHolder.getCorePassword()); + + if (result.indexOf("") == -1) { + return 2; + } + } catch (WebSiteNotFoundException ex) { + return 2; + } catch (WrongPasswordException wpE) { + return 1; + } + + return 0; + } + + public Version getCoreVersion() { + return coreVersion; + } + + public Map getDownloadsSnapshot() { + return modifiedXML.getDownloads(); + } + + public void informDataUpdateListener(DATALISTENER_TYPE type) { + if (informer.containsKey(type)) { + DataUpdateInformer anInformer = informer.get(type); + + anInformer.informDataUpdateListener(); + } + } + + public Map getShare(boolean reinit) { + if (share == null || reinit) { + share = shareXML.getShare(); + } + + return share; + } + + public void addShareEntry(List paths, SHAREMODE shareMode) { + Set shareDirs = getAJSettings().getShareDirs(); + StringBuilder parameters = new StringBuilder(); + + parameters.append("countshares=" + shareDirs.size() + paths.size()); + int i = 1; + + for (ShareEntry curShareEntry : shareDirs) { + try { + parameters.append(StringConstants.AND_SHAREDDIRECTORY); + parameters.append(i); + parameters.append(StringConstants.GLEICH); + parameters.append(URLEncoder.encode(curShareEntry.getDir(), StringConstants.UTF_8)); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + + parameters.append(StringConstants.AND_SHARESUB); + parameters.append(i); + parameters.append(StringConstants.GLEICH); + parameters.append(curShareEntry.getShareMode() == SHAREMODE.SUBDIRECTORY ? StringConstants.TRUE : StringConstants.FALSE); + i++; + } + + for (String curPath : paths) { + try { + parameters.append(StringConstants.AND_SHAREDDIRECTORY); + parameters.append(i); + parameters.append(StringConstants.GLEICH); + parameters.append(URLEncoder.encode(curPath, StringConstants.UTF_8)); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + + parameters.append(StringConstants.AND_SHARESUB); + parameters.append(i); + parameters.append(StringConstants.GLEICH); + parameters.append(shareMode == SHAREMODE.SUBDIRECTORY ? StringConstants.TRUE : StringConstants.FALSE); + + i++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + StringConstants.SET_SETTINGS_URL + coreHolder.getCorePassword() + StringConstants.AND + + parameters, false); + } + + public void removeShareEntry(List paths) { + Set shareDirs = getAJSettings().getShareDirs(); + ArrayList toRemove = new ArrayList(); + + for (String curPath : paths) { + for (ShareEntry curShareEntry : shareDirs) { + if (curShareEntry.getDir().compareToIgnoreCase(curPath) == 0) { + toRemove.add(curShareEntry); + break; + } + } + } + + for (ShareEntry curShareEntry : toRemove) { + shareDirs.remove(curShareEntry); + } + + setShare(shareDirs); + } + + public void setShare(Set newShare) { + if (newShare == null) { + return; + } + + String parameters = "countshares=" + newShare.size(); + int i = 1; + + for (ShareEntry curShareEntry : newShare) { + try { + parameters += "&sharedirectory" + i + "=" + URLEncoder.encode(curShareEntry.getDir(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + + parameters += "&sharesub" + i + "=" + (curShareEntry.getShareMode() == SHAREMODE.SUBDIRECTORY ? "true" : "false"); + i++; + } + + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.GET, + "/function/setsettings?password=" + coreHolder.getCorePassword() + "&" + parameters, false); + } + + public List getDirectories(String directory) + throws IllegalArgumentException { + return directoryXML.getDirectories(directory); + } + + public NetworkInfo getNetworkInfo() { + return modifiedXML.getNetworkInfo(); + } + + public void fireSettingsChanged(ITEM item, String oldValue, String newValue) { + } + + private class CancelThread extends Thread { + private final Search search; + private boolean cancel = false; + private Thread innerThread; + + public CancelThread(Search search) { + this.search = search; + } + + public void run() { + try { + if (search.getCreationTime() > System.currentTimeMillis() - 10000) { + sleep(10000); + } + while (!cancel) { + innerThread = new Thread() { + public void run() { + HtmlLoader.getHtmlXMLContent(coreHolder.getCoreHost(), coreHolder.getCorePort(), HtmlLoader.POST, + "/function/cancelsearch?password=" + coreHolder.getCorePassword() + "&id=" + + search.getId(), true); + cancel = true; + + } + }; + innerThread.start(); + sleep(4000); + innerThread.interrupt(); + } + } catch (InterruptedException iE) { + innerThread.interrupt(); + interrupt(); + } + } + } +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java index 9d2a77a5..14d61ae9 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/CoreConnectionSettingsHolder.java @@ -4,13 +4,13 @@ package de.applejuicenet.client.fassade.controller; -import java.util.HashSet; - import de.applejuicenet.client.fassade.exception.IllegalArgumentException; import de.applejuicenet.client.fassade.listener.CoreConnectionSettingsListener; import de.applejuicenet.client.fassade.listener.CoreConnectionSettingsListener.ITEM; import de.applejuicenet.client.fassade.tools.MD5Encoder; +import java.util.HashSet; + public final class CoreConnectionSettingsHolder { private String coreHost; @@ -88,7 +88,7 @@ public void setCoreHost(String coreHost) throws IllegalArgumentException public void setCorePort(Integer corePort) throws IllegalArgumentException { - if(corePort == null || corePort.intValue() < 0) + if(corePort == null || corePort < 0) { throw new IllegalArgumentException("illegal port"); } diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java index c20a62f9..7fa79395 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataPropertyChangeInformer.java @@ -1,11 +1,11 @@ package de.applejuicenet.client.fassade.controller; -import java.util.HashSet; -import java.util.Set; - import de.applejuicenet.client.fassade.event.DataPropertyChangeEvent; import de.applejuicenet.client.fassade.listener.DataPropertyChangeListener; +import java.util.HashSet; +import java.util.Set; + public final class DataPropertyChangeInformer { private Set listener = new HashSet(); @@ -25,4 +25,4 @@ public void propertyChanged(DataPropertyChangeEvent dataPropertyChangeEvent) { curListener.propertyChanged(dataPropertyChangeEvent); } } -} \ No newline at end of file +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java index 628f6c3d..d09bf21a 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/DataUpdateInformer.java @@ -4,12 +4,12 @@ package de.applejuicenet.client.fassade.controller; -import java.util.HashSet; -import java.util.Set; - import de.applejuicenet.client.fassade.listener.DataUpdateListener; import de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE; +import java.util.HashSet; +import java.util.Set; + public abstract class DataUpdateInformer { private final DATALISTENER_TYPE listenerType; diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java index d65ed654..f88d5b18 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryDO.java @@ -1,10 +1,10 @@ package de.applejuicenet.client.fassade.controller.xml; +import de.applejuicenet.client.fassade.entity.Directory; + import java.util.ArrayList; import java.util.List; -import de.applejuicenet.client.fassade.entity.Directory; - /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/controller/dac/DirectoryDO.java,v @@ -21,7 +21,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java index 53f83b4c..5cb312e7 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DirectoryXMLHolder.java @@ -1,14 +1,13 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.net.URLEncoder; -import java.util.List; -import java.util.Vector; - +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.entity.Directory; import org.w3c.dom.Element; import org.w3c.dom.NodeList; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.entity.Directory; +import java.net.URLEncoder; +import java.util.List; +import java.util.Vector; /** * $Header: @@ -26,7 +25,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java index 75f7fb93..6e351285 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadDO.java @@ -4,13 +4,13 @@ package de.applejuicenet.client.fassade.controller.xml; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.DownloadSource; + import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; - /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/controller/dac/DownloadDO.java,v @@ -27,7 +27,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ class DownloadDO implements Download diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java index a752e2bf..5bc40fe4 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/DownloadSourceDO.java @@ -22,7 +22,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ class DownloadSourceDO extends DownloadSource diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java index 8e1e589a..b4c7f890 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/GetObjectXMLHolder.java @@ -12,13 +12,13 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; public class GetObjectXMLHolder extends WebXMLParser { diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationDO.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationDO.java index ac7c98b9..a8e17f34 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationDO.java @@ -23,7 +23,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ class InformationDO extends Information diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java similarity index 96% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java index 9ebe4269..7f070b7f 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/InformationXMLHolder.java @@ -4,11 +4,11 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.CharArrayWriter; -import java.io.StringReader; - +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.shared.HtmlLoader; +import de.applejuicenet.client.fassade.shared.StringConstants; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -16,10 +16,8 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.ApplejuiceFassade; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.shared.HtmlLoader; -import de.applejuicenet.client.fassade.shared.StringConstants; +import java.io.CharArrayWriter; +import java.io.StringReader; /** * $Header: @@ -37,7 +35,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class InformationXMLHolder extends DefaultHandler @@ -45,7 +43,7 @@ public class InformationXMLHolder extends DefaultHandler private static InformationXMLHolder instance = null; private VersionDO version = null; private XMLReader xr = null; - private String xmlCommand = StringConstants.XML_INFORMATION_XML_PASSWORD; + private String xmlCommand; private CharArrayWriter contents = new CharArrayWriter(); private String coreVersion; private CoreConnectionSettingsHolder coreHolder; diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java index 065462b7..2fca111d 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ModifiedXMLHolder.java @@ -4,36 +4,12 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.CharArrayWriter; -import java.io.StringReader; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import org.apache.xerces.parsers.SAXParser; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; import de.applejuicenet.client.fassade.controller.DataPropertyChangeInformer; import de.applejuicenet.client.fassade.controller.xml.SearchDO.SearchEntryDO; import de.applejuicenet.client.fassade.controller.xml.SearchDO.SearchEntryDO.FileNameDO; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.Information; -import de.applejuicenet.client.fassade.entity.Search; -import de.applejuicenet.client.fassade.entity.Server; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.fassade.entity.Upload; +import de.applejuicenet.client.fassade.entity.*; import de.applejuicenet.client.fassade.event.DataPropertyChangeEvent; import de.applejuicenet.client.fassade.event.DownloadDataPropertyChangeEvent; import de.applejuicenet.client.fassade.exception.CoreLostException; @@ -41,6 +17,17 @@ import de.applejuicenet.client.fassade.shared.HtmlLoader; import de.applejuicenet.client.fassade.shared.NetworkInfo; import de.applejuicenet.client.fassade.shared.StringConstants; +import org.apache.xerces.parsers.SAXParser; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.helpers.XMLReaderFactory; + +import java.io.CharArrayWriter; +import java.io.StringReader; +import java.util.*; /** * $Header: @@ -58,7 +45,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public class ModifiedXMLHolder extends DefaultHandler diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java similarity index 90% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java index 4dfbfc16..4fa79893 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/NetworkServerXMLHolder.java @@ -12,16 +12,13 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ -import java.io.StringReader; - -import java.util.ArrayList; -import java.util.List; +import de.applejuicenet.client.fassade.shared.ProxySettings; +import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -29,7 +26,9 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.shared.WebsiteContentLoader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; public class NetworkServerXMLHolder extends DefaultHandler { @@ -83,14 +82,13 @@ private void checkServerAttributes(Attributes attr) } } - public String[] getNetworkKnownServers() + public String[] getNetworkKnownServers(String ServerListURL) { String xmlData = null; - try { - xmlData = WebsiteContentLoader.getWebsiteContent("http://www.applejuicenet.org", 80, "/serverlist/xmllist.php"); - if(xmlData == null || xmlData.length() == 0) + xmlData = WebsiteContentLoader.getWebsiteContent(ServerListURL); + if(xmlData.length() == 0) { return null; } diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListDO.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListDO.java index 28a7a023..45c58ce4 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListDO.java @@ -12,17 +12,18 @@ *

Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ -import java.util.ArrayList; -import java.util.List; import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.fassade.entity.Part; import de.applejuicenet.client.fassade.entity.PartList; +import java.util.ArrayList; +import java.util.List; + class PartListDO extends PartList { private Object valueHolder; diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java index 0d7543ab..742f134b 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/PartListXMLHolder.java @@ -4,11 +4,14 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.CharArrayWriter; -import java.io.StringReader; - +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.DownloadSource; +import de.applejuicenet.client.fassade.entity.PartList; +import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; +import de.applejuicenet.client.fassade.shared.HtmlLoader; +import de.applejuicenet.client.fassade.shared.StringConstants; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -16,13 +19,8 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.entity.Download; -import de.applejuicenet.client.fassade.entity.DownloadSource; -import de.applejuicenet.client.fassade.entity.PartList; -import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; -import de.applejuicenet.client.fassade.shared.HtmlLoader; -import de.applejuicenet.client.fassade.shared.StringConstants; +import java.io.CharArrayWriter; +import java.io.StringReader; /** * $Header: @@ -40,7 +38,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class PartListXMLHolder extends DefaultHandler diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SearchDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SearchDO.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SearchDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SearchDO.java index 26953003..e1c7a417 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SearchDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SearchDO.java @@ -4,19 +4,14 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import de.applejuicenet.client.fassade.controller.xml.SearchDO.SearchEntryDO.FileNameDO; import de.applejuicenet.client.fassade.entity.FileName; import de.applejuicenet.client.fassade.entity.Search; import de.applejuicenet.client.fassade.entity.SearchEntry; import de.applejuicenet.client.fassade.shared.FileType; +import java.util.*; + /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/SearchDO.java,v @@ -33,7 +28,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ class SearchDO extends Search diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java similarity index 97% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java index 1259574f..2586ce04 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SecurerXMLHolder.java @@ -4,10 +4,10 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.StringReader; - +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; +import de.applejuicenet.client.fassade.shared.HtmlLoader; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -15,9 +15,7 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; -import de.applejuicenet.client.fassade.shared.HtmlLoader; +import java.io.StringReader; /** * $Header: @@ -28,14 +26,14 @@ * Titel: AppleJuice Client-GUI *

*

- * Beschreibung: Offizielles GUI f�r den von muhviehstarr entwickelten + * Beschreibung: Offizielles GUI für den von muhviehstarr entwickelten * appleJuice-Core *

*

* Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class SecurerXMLHolder extends DefaultHandler diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ServerDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ServerDO.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ServerDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ServerDO.java index fdf7fefa..e1c1a315 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ServerDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ServerDO.java @@ -22,7 +22,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ class ServerDO extends Server diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java index fb698cfc..769f05e5 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SessionXMLHolder.java @@ -4,10 +4,11 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.StringReader; - +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.exception.CoreLostException; +import de.applejuicenet.client.fassade.shared.HtmlLoader; +import de.applejuicenet.client.fassade.shared.StringConstants; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -15,10 +16,7 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.exception.CoreLostException; -import de.applejuicenet.client.fassade.shared.HtmlLoader; -import de.applejuicenet.client.fassade.shared.StringConstants; +import java.io.StringReader; /** * $Header: @@ -36,7 +34,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class SessionXMLHolder extends DefaultHandler diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java index 5647fc22..45f52b7c 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/SettingsXMLHolder.java @@ -4,16 +4,15 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.util.HashSet; -import java.util.Set; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; import de.applejuicenet.client.fassade.entity.ShareEntry; import de.applejuicenet.client.fassade.shared.AJSettings; import de.applejuicenet.client.fassade.shared.StringConstants; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import java.util.HashSet; +import java.util.Set; /** * $Header: @@ -31,7 +30,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class SettingsXMLHolder extends WebXMLParser diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareDO.java similarity index 94% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareDO.java index a2cc1889..7e397431 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareDO.java @@ -22,7 +22,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ class ShareDO implements Share @@ -140,4 +140,8 @@ public void setSearchCount(long searchCount) { this.searchCount = searchCount; } + + public String getAjfspLink() { + return String.format("ajfsp://file|%s|%s|%s/", getShortfilename(), getCheckSum(), getSize()); + } } diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java similarity index 98% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java index dabfe5ca..bf4a43fc 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareEntryDO.java @@ -22,7 +22,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ class ShareEntryDO implements ShareEntry diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java index 213cc591..5621504b 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/ShareXMLHolder.java @@ -4,13 +4,11 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.StringReader; - -import java.util.HashMap; -import java.util.Map; - +import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; +import de.applejuicenet.client.fassade.entity.Share; +import de.applejuicenet.client.fassade.shared.HtmlLoader; +import de.applejuicenet.client.fassade.shared.StringConstants; import org.apache.xerces.parsers.SAXParser; - import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -18,10 +16,9 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; -import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; -import de.applejuicenet.client.fassade.entity.Share; -import de.applejuicenet.client.fassade.shared.HtmlLoader; -import de.applejuicenet.client.fassade.shared.StringConstants; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; /** * $Header: @@ -39,7 +36,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class ShareXMLHolder extends DefaultHandler diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/UploadDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/UploadDO.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/UploadDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/UploadDO.java index a8604020..ea22ae1e 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/UploadDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/UploadDO.java @@ -21,7 +21,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ class UploadDO extends Upload diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/VersionDO.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/VersionDO.java similarity index 97% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/VersionDO.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/VersionDO.java index cef946be..b5920dad 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/VersionDO.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/VersionDO.java @@ -22,7 +22,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ class VersionDO extends Version diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java index 8c83826c..9bb7e4be 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/WebXMLParser.java @@ -1,21 +1,19 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - import de.applejuicenet.client.fassade.controller.CoreConnectionSettingsHolder; import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; import de.applejuicenet.client.fassade.shared.HtmlLoader; import de.applejuicenet.client.fassade.shared.XMLDecoder; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.StringReader; /** * $Header: @@ -33,7 +31,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java similarity index 96% rename from ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java index 1958ff42..f3042cdd 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/controller/xml/XMLValueHolder.java @@ -4,12 +4,6 @@ package de.applejuicenet.client.fassade.controller.xml; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.StringReader; -import java.util.Properties; - import org.apache.xerces.parsers.SAXParser; import org.xml.sax.Attributes; import org.xml.sax.InputSource; @@ -18,6 +12,10 @@ import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.Properties; + public class XMLValueHolder extends DefaultHandler { private XMLReader xr = null; @@ -35,7 +33,8 @@ public void parseProperties(File propertiesFile) throws IllegalArgumentException FileInputStream fiS = new FileInputStream(propertiesFile); values.clear(); - values.load(fiS); + + values.load(new InputStreamReader(fiS, StandardCharsets.UTF_8)); fiS.close(); } catch(Exception e) diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Directory.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Directory.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Directory.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Directory.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Download.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Download.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Download.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Download.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/DownloadSource.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/DownloadSource.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/DownloadSource.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/DownloadSource.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/FileName.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/FileName.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/FileName.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/FileName.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/IdOwner.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/IdOwner.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/IdOwner.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/IdOwner.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Information.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Information.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Information.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Information.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Part.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Part.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Part.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Part.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/PartList.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/PartList.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/PartList.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/PartList.java index d08ecdad..b0ef227e 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/PartList.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/PartList.java @@ -4,7 +4,7 @@ package de.applejuicenet.client.fassade.entity; -import java.awt.Color; +import java.awt.*; public abstract class PartList { diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Search.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Search.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Search.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Search.java index 7bd22c47..5ad094df 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Search.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Search.java @@ -1,9 +1,9 @@ package de.applejuicenet.client.fassade.entity; -import java.util.List; - import de.applejuicenet.client.fassade.shared.FileType; +import java.util.List; + public abstract class Search implements IdOwner { public static int currentSearchCount = 0; diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/SearchEntry.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/SearchEntry.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/SearchEntry.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/SearchEntry.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Server.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Server.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Server.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Server.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Share.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Share.java similarity index 91% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Share.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Share.java index 89c7ff7e..1bd0829b 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Share.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Share.java @@ -15,8 +15,10 @@ public interface Share extends IdOwner{ int getPrioritaet(); long getAskCount(); - + long getLastAsked(); - + long getSearchCount(); + + String getAjfspLink(); } diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/ShareEntry.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/ShareEntry.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/ShareEntry.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/ShareEntry.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/entity/Upload.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Upload.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/entity/Upload.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Upload.java diff --git a/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Version.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Version.java new file mode 100644 index 00000000..f5e0ae10 --- /dev/null +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/entity/Version.java @@ -0,0 +1,78 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.fassade.entity; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.shared.StringConstants; + +import java.util.StringTokenizer; + +public abstract class Version { + public static final int UNKNOWN = 0; + public static final int WIN32 = 1; + public static final int LINUX = 2; + public static final int MACINTOSH = 3; + public static final int SOLARIS = 4; + public static final int OS2 = 5; + public static final int FREEBSD = 6; + public static final int NETWARE = 7; + + public abstract String getVersion(); + + public abstract int getBetriebsSystem(); + + public static int getOSTypByOSName(String OSName) { + int result = -1; + + if (OSName.compareToIgnoreCase(StringConstants.WINDOWS_NT) == 0) { + result = WIN32; + } else if (OSName.compareToIgnoreCase(StringConstants.LINUX) == 0) { + result = LINUX; + } + + return result; + } + + public final int compareTo(String versionNr) { + if (getVersion().compareToIgnoreCase(versionNr) == 0) { + return 0; + } + + StringTokenizer token1 = new StringTokenizer(getVersion(), StringConstants.POINT); + StringTokenizer token2 = new StringTokenizer(versionNr, StringConstants.POINT); + + if (token1.countTokens() != 4 || token2.countTokens() != 4) { + // alles Mist + return 0; + } + + String[] foundCore = new String[4]; + String[] neededCore = new String[4]; + + for (int i = 0; i < 4; i++) { + foundCore[i] = token1.nextToken(); + neededCore[i] = token2.nextToken(); + } + + for (int i = 0; i < 4; i++) { + if (Integer.parseInt(foundCore[i]) > Integer.parseInt(neededCore[i])) { + break; + } else if (Integer.parseInt(foundCore[i]) < Integer.parseInt(neededCore[i])) { + return -1; + } + } + + return 1; + } + + @Override + public String toString() { + return getVersion(); + } + + public final int checkForValidCoreVersion() { + return compareTo(ApplejuiceFassade.MIN_NEEDED_CORE_VERSION); + } +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/event/DataPropertyChangeEvent.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/event/DataPropertyChangeEvent.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/event/DataPropertyChangeEvent.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/event/DataPropertyChangeEvent.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/event/DownloadDataPropertyChangeEvent.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/event/DownloadDataPropertyChangeEvent.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/event/DownloadDataPropertyChangeEvent.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/event/DownloadDataPropertyChangeEvent.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/exception/CoreLostException.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/CoreLostException.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/exception/CoreLostException.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/CoreLostException.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/exception/IllegalArgumentException.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/IllegalArgumentException.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/exception/IllegalArgumentException.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/IllegalArgumentException.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/exception/NoAccessException.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/NoAccessException.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/exception/NoAccessException.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/NoAccessException.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/exception/WebSiteNotFoundException.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/WebSiteNotFoundException.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/exception/WebSiteNotFoundException.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/WebSiteNotFoundException.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/exception/WrongPasswordException.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/WrongPasswordException.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/exception/WrongPasswordException.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/exception/WrongPasswordException.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/listener/CoreConnectionSettingsListener.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/CoreConnectionSettingsListener.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/listener/CoreConnectionSettingsListener.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/CoreConnectionSettingsListener.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/listener/CoreStatusListener.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/CoreStatusListener.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/listener/CoreStatusListener.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/CoreStatusListener.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/listener/DataPropertyChangeListener.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/DataPropertyChangeListener.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/listener/DataPropertyChangeListener.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/DataPropertyChangeListener.java diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/listener/DataUpdateListener.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/DataUpdateListener.java similarity index 95% rename from ajcorefassade/src/de/applejuicenet/client/fassade/listener/DataUpdateListener.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/DataUpdateListener.java index 83f8ec54..18c6174c 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/listener/DataUpdateListener.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/listener/DataUpdateListener.java @@ -16,7 +16,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ @@ -29,4 +29,4 @@ enum DATALISTENER_TYPE { } public void fireContentChanged(DATALISTENER_TYPE type, Object content); -} \ No newline at end of file +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/AJSettings.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/AJSettings.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/AJSettings.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/AJSettings.java index f0db3ff1..4fde6eb3 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/AJSettings.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/AJSettings.java @@ -4,10 +4,10 @@ package de.applejuicenet.client.fassade.shared; -import java.util.Set; - import de.applejuicenet.client.fassade.entity.ShareEntry; +import java.util.Set; + /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/AJSettings.java,v @@ -24,7 +24,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class AJSettings diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/FileType.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/FileType.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/FileType.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/FileType.java index d7bbd5cb..24cf5fb9 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/FileType.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/FileType.java @@ -23,7 +23,7 @@ * Copyright: General Public License *

* - * @author: Maj0r [aj@tkl-soft.de] + * @author Maj0r [aj@tkl-soft.de] * */ public enum FileType diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/HtmlLoader.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/HtmlLoader.java similarity index 96% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/HtmlLoader.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/HtmlLoader.java index 9b810218..1f382028 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/HtmlLoader.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/HtmlLoader.java @@ -4,20 +4,14 @@ package de.applejuicenet.client.fassade.shared; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; +import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; +import de.applejuicenet.client.fassade.exception.WrongPasswordException; +import java.io.*; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; -import de.applejuicenet.client.fassade.exception.WebSiteNotFoundException; -import de.applejuicenet.client.fassade.exception.WrongPasswordException; - public abstract class HtmlLoader { public static final int POST = 0; diff --git a/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/NetworkInfo.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/NetworkInfo.java new file mode 100644 index 00000000..1682230e --- /dev/null +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/NetworkInfo.java @@ -0,0 +1,242 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.fassade.shared; + +/** + * $Header: + * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/NetworkInfo.java,v + * 1.1 2004/12/03 07:57:12 maj0r Exp $ + * + *

+ * Titel: AppleJuice Client-GUI + *

+ *

+ * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + *

+ *

+ * Copyright: General Public License + *

+ * + * @author Maj0r [aj@tkl-soft.de] + */ +public class NetworkInfo { + private long ajUserGesamt; + private long ajAnzahlDateien; + private String ajGesamtShare; + private boolean firewalled; + private String externeIP; + private int tryConnectToServer; + private int connectedWithServerId; + private String welcomeMessage; + private long connectionTime; + + public NetworkInfo() { + } + + public NetworkInfo(long ajUserGesamt, long ajAnzahlDateien, String ajGesamtShare, boolean firewalled, String externeIP, + int tryConnectToServer, int connectedWithServerId, String welcomeMessage, long connectionTime) { + this.ajUserGesamt = ajUserGesamt; + this.ajAnzahlDateien = ajAnzahlDateien; + this.ajGesamtShare = ajGesamtShare; + this.firewalled = firewalled; + this.externeIP = externeIP; + this.tryConnectToServer = tryConnectToServer; + this.connectedWithServerId = connectedWithServerId; + this.connectionTime = connectionTime; + setWelcomeMessage(welcomeMessage); + } + + public NetworkInfo(String ajUserGesamt, String ajAnzahlDateien, String ajGesamtShare, boolean firewalled, String externeIP, + int tryConnectToServer, int connectedWithServerId) { + if (ajUserGesamt == null || ajUserGesamt.length() == 0) { + this.ajUserGesamt = 0; + } else { + this.ajUserGesamt = Long.parseLong(ajUserGesamt); + } + + if (ajAnzahlDateien == null || ajAnzahlDateien.length() == 0) { + this.ajAnzahlDateien = 0; + } else { + this.ajAnzahlDateien = Long.parseLong(ajAnzahlDateien); + } + + this.ajGesamtShare = ajGesamtShare; + this.firewalled = firewalled; + this.externeIP = externeIP; + this.tryConnectToServer = tryConnectToServer; + this.connectedWithServerId = connectedWithServerId; + } + + public void setAjUserGesamt(long ajUserGesamt) { + this.ajUserGesamt = ajUserGesamt; + } + + public void setAjAnzahlDateien(long ajAnzahlDateien) { + this.ajAnzahlDateien = ajAnzahlDateien; + } + + public void setAjGesamtShare(String ajGesamtShare) { + this.ajGesamtShare = ajGesamtShare; + } + + public void setFirewalled(boolean firewalled) { + this.firewalled = firewalled; + } + + public void setExterneIP(String externeIP) { + this.externeIP = externeIP; + } + + public void setTryConnectToServer(int tryConnectToServer) { + this.tryConnectToServer = tryConnectToServer; + } + + public void setConnectedWithServerId(int connectedWithServerId) { + this.connectedWithServerId = connectedWithServerId; + } + + public void setWelcomeMessage(String welcomeMessage) { + if (!welcomeMessage.toLowerCase().contains(StringConstants.HTML_START)) { + welcomeMessage = StringConstants.HTML_START + welcomeMessage + StringConstants.HTML_END; + } + + this.welcomeMessage = welcomeMessage; + } + + public void setConnectionTime(long connectionTime) { + this.connectionTime = connectionTime; + } + + public String getAJGesamtShare(long faktor) { + ajGesamtShare = ajGesamtShare.replace(',', '.'); + double share = Double.parseDouble(ajGesamtShare); + + if (share == 0) { + return StringConstants._0_00_MB; + } + + if (faktor == 0) { // selbst entscheiden + if (share / 1024 < 1024) { + faktor = 1024; + } else if (share / 1048576 < 1024) { + faktor = 1048576; + } else if (share / 1073741824 < 1048576) { + faktor = 1073741824; + } else { + faktor = 1; + } + } + + share = share / faktor; + String result = Double.toString(share); + + if (result.indexOf(StringConstants.POINT) + 3 < result.length()) { + result = result.substring(0, result.indexOf(StringConstants.POINT) + 3); + } + + result = result.replace('.', ','); + if (faktor == 1) { + result += StringConstants.MB; + } else if (faktor == 1024) { + result += StringConstants.GB; + } else if (faktor == 1048576) { + result += StringConstants.TB; + } else if (faktor == 1073741824) { + result += StringConstants.PB; + } else { + result += StringConstants.TWO_QUESTIONMARKS; + } + + return result; + } + + public String getAJGesamtShareWithPoints(long faktor) { + String result = getAJGesamtShare(faktor); + + return insertPoints(result); + } + + public boolean isFirewalled() { + return firewalled; + } + + public String getExterneIP() { + return externeIP; + } + + public long getAJUserGesamt() { + return ajUserGesamt; + } + + public String getAJUserGesamtAsString() { + return Long.toString(ajUserGesamt); + } + + public String getAJUserGesamtAsStringWithPoints() { + String result = getAJUserGesamtAsString(); + + return insertPoints(result); + } + + public long getAJAnzahlDateien() { + return ajAnzahlDateien; + } + + public String getAJAnzahlDateienAsString() { + return Long.toString(ajAnzahlDateien); + } + + public String getAJAnzahlDateienAsStringWithPoints() { + return insertPoints(Long.toString(ajAnzahlDateien)); + } + + private String insertPoints(String tochange) { + StringBuffer result = new StringBuffer(tochange); + int laenge; + + if (result.indexOf(StringConstants.COMMA) == -1) { + if (result.indexOf(StringConstants.SPACE) == -1) { + laenge = result.length(); + } else { + laenge = result.indexOf(StringConstants.SPACE); + } + } else { + laenge = result.indexOf(StringConstants.COMMA); + } + + int zaehler = 0; + + for (int i = laenge - 1; i > 0; i--) { + zaehler++; + if (zaehler == 3) { + zaehler = 0; + result.insert(i, '.'); + } + } + + return result.toString(); + } + + public int getTryConnectToServer() { + return tryConnectToServer; + } + + public int getConnectedWithServerId() { + return connectedWithServerId; + } + + public String getWelcomeMessage() { + if (welcomeMessage == null) { + return StringConstants.EMPTY; + } + + return welcomeMessage; + } + + public long getConnectionTime() { + return connectionTime; + } +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ProxySettings.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ProxySettings.java similarity index 80% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/ProxySettings.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ProxySettings.java index bb9397c5..fb2d0c10 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ProxySettings.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ProxySettings.java @@ -5,6 +5,8 @@ package de.applejuicenet.client.fassade.shared; +import java.util.Base64; + /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ProxySettings.java,v @@ -21,7 +23,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public class ProxySettings @@ -31,14 +33,6 @@ public class ProxySettings private String userpass; private boolean use; - public ProxySettings(boolean use, String host, int port, String user, String pass) - { - this.host = host; - this.port = port; - this.use = use; - setUserpass(user, pass); - } - public ProxySettings(boolean use, String host, int port, String userpass) { this.host = host; @@ -64,7 +58,8 @@ public String getUserpass() public void setUserpass(String user, String passwort) { - this.userpass = new sun.misc.BASE64Encoder().encode((user + ":" + passwort).getBytes()); + Base64.Encoder base64Encoder = Base64.getEncoder().withoutPadding(); + this.userpass = base64Encoder.encodeToString((user + ":" + passwort).getBytes()); } public boolean isUse() diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/StringConstants.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/StringConstants.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/StringConstants.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/StringConstants.java index c58c0827..f85eee62 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/StringConstants.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/StringConstants.java @@ -94,6 +94,7 @@ public interface StringConstants String COMMA = ","; String SPACE = " "; String TWO_QUESTIONMARKS = " ??"; + String PB = " PB"; String TB = " TB"; String GB = " GB"; String MB = " MB"; diff --git a/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java new file mode 100644 index 00000000..591d080c --- /dev/null +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java @@ -0,0 +1,60 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.fassade.shared; + +import de.applejuicenet.client.fassade.exception.NoAccessException; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; + +/** + * $Header: + * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/WebsiteContentLoader.java,v + * 1.1 2004/12/03 07:57:12 maj0r Exp $ + * + *

+ * Titel: AppleJuice Client-GUI + *

+ *

+ * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + *

+ *

+ * Copyright: General Public License + *

+ * + * @author Maj0r + */ + +public abstract class WebsiteContentLoader { + public static String getWebsiteContent(String website) throws NoAccessException { + StringBuilder htmlContent = new StringBuilder(); + + try { + URL url = new URL(website); + URLConnection uc = url.openConnection(); + + uc.setRequestProperty("User-Agent", + String.format("ajcorefassade; Java/%s; (%s/%s)", System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.version"))); + + InputStream content = uc.getInputStream(); + BufferedReader in = new BufferedReader(new InputStreamReader(content)); + String line; + + while ((line = in.readLine()) != null) { + htmlContent.append(line); + } + + } catch (IOException e) { + throw new NoAccessException("wrong proxysettings?", e); + } + + return htmlContent.toString(); + } +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/XMLDecoder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/XMLDecoder.java similarity index 97% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/XMLDecoder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/XMLDecoder.java index 78eb613c..7e4f8b00 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/XMLDecoder.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/XMLDecoder.java @@ -4,26 +4,19 @@ package de.applejuicenet.client.fassade.shared; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.*; + /** * $Header: * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/XMLDecoder.java,v @@ -40,7 +33,7 @@ * Copyright: General Public License *

* - * @author: Maj0r + * @author Maj0r * */ public abstract class XMLDecoder diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZLibUtils.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZLibUtils.java similarity index 99% rename from ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZLibUtils.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZLibUtils.java index ba0dc92d..fb218591 100644 --- a/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZLibUtils.java +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZLibUtils.java @@ -6,7 +6,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; - import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; diff --git a/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java new file mode 100644 index 00000000..9528d360 --- /dev/null +++ b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java @@ -0,0 +1,75 @@ +package de.applejuicenet.client.fassade.shared; + +/** + * $Header: + * /cvsroot/applejuicejava/ajcorefassade/src/de/applejuicenet/client/fassade/shared/ZeichenErsetzer.java,v + * 1.1 2004/12/03 07:57:12 maj0r Exp $ + * + *

+ * Titel: AppleJuice Client-GUI + *

+ *

+ * Beschreibung: Offizielles GUI fuer den von muhviehstarr entwickelten + * appleJuice-Core + *

+ *

+ * Copyright: General Public License + *

+ * + * @author Maj0r + */ + +public abstract class ZeichenErsetzer { + + public static String korrigiereUmlaute(String text) { + if (text == null) { + return ""; + } + StringBuffer temp = new StringBuffer(text); + int index; + while ((index = temp.indexOf("\\\"")) != -1) { + temp.replace(index, index + 2, "\""); + } + while ((index = temp.indexOf("ü")) != -1) { + temp.replace(index, index + 6, "ü"); + } + while ((index = temp.indexOf("Ü")) != -1) { + temp.replace(index, index + 6, "Ü"); + } + while ((index = temp.indexOf("ä")) != -1) { + temp.replace(index, index + 6, "ä"); + } + while ((index = temp.indexOf("Ä")) != -1) { + temp.replace(index, index + 6, "Ä"); + } + while ((index = temp.indexOf("ö")) != -1) { + temp.replace(index, index + 6, "ö"); + } + while ((index = temp.indexOf("Ö")) != -1) { + temp.replace(index, index + 6, "Ö"); + } + while ((index = temp.indexOf("ß")) != -1) { + temp.replace(index, index + 7, "ß"); + } + while ((index = temp.indexOf("&")) != -1) { + temp.replace(index, index + 5, ""); + } + while ((index = temp.indexOf("<")) != -1) { + temp.replace(index, index + 4, "<"); + } + while ((index = temp.indexOf(">")) != -1) { + temp.replace(index, index + 4, ">"); + } + while ((index = temp.indexOf("#&")) != -1) { + try { + int decimal = Integer.parseInt(temp.substring(index + 2, + index + 6)); + String test = String.valueOf((char) decimal); + temp.replace(index, index + 7, test); + } catch (Exception e) { + temp.replace(index, index + 7, "!Fehler!"); + } + } + return temp.toString(); + } +} diff --git a/ajcorefassade/src/de/applejuicenet/client/fassade/tools/MD5Encoder.java b/modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/tools/MD5Encoder.java similarity index 100% rename from ajcorefassade/src/de/applejuicenet/client/fassade/tools/MD5Encoder.java rename to modules/ajcorefassade/src/main/java/de/applejuicenet/client/fassade/tools/MD5Encoder.java diff --git a/modules/logviewer/pom.xml b/modules/logviewer/pom.xml new file mode 100644 index 00000000..4a5a49f8 --- /dev/null +++ b/modules/logviewer/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + de.applejuicenet.client.gui.plugins + logviewer + jar + 1.3.1 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + de.applejuicenet.client.gui + AJCoreGUI + 0.85.3 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + ${project.artifactId} + + false + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0 + + + copy.plugins + package + + copy + + + + + ${basedir}/target/${project.artifactId}.jar + ${project.parent.basedir}/resources/plugins/${project.artifactId}.jar + + + + + + + + + diff --git a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/FileModificationDateComparator.java b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/FileModificationDateComparator.java similarity index 100% rename from AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/FileModificationDateComparator.java rename to modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/FileModificationDateComparator.java diff --git a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java similarity index 90% rename from AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java rename to modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java index 88f42d7c..69477698 100644 --- a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java +++ b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/FileNameListCellRenderer.java @@ -4,15 +4,12 @@ package de.applejuicenet.client.gui.plugins.logviewer; -import java.awt.Component; +import de.tklsoft.gui.controls.TKLLabel; +import javax.swing.*; +import java.awt.*; import java.io.File; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -import de.tklsoft.gui.controls.TKLLabel; - public class FileNameListCellRenderer extends TKLLabel implements ListCellRenderer { public FileNameListCellRenderer() diff --git a/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java new file mode 100644 index 00000000..1969b9a1 --- /dev/null +++ b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java @@ -0,0 +1,89 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugins.logviewer; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.gui.plugins.PluginConnector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.util.Map; +import java.util.Properties; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPlugin.java,v 1.4 2009/01/23 09:58:24 maj0r Exp $ + * + *

Titel: AppleJuice Core-GUI

+ *

Beschreibung: GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: GPL

+ * + * @author loevenwong + */ +public class LogViewerPlugin extends PluginConnector { + private static Logger logger; + private static final String path = AppleJuiceClient.getPath() + File.separator + "logs"; + private final JTextPane logPane = new JTextPane(); + private final SortedStringListModel listModel = new SortedStringListModel(); + private final JList list = new JList(listModel); + + public LogViewerPlugin(Properties pluginsProperties, Map languageFiles, ImageIcon icon, + Map availableIcons) { + super(pluginsProperties, languageFiles, icon, availableIcons); + logger = LoggerFactory.getLogger(getClass()); + try { + setLayout(new BorderLayout()); + logPane.setBackground(getBackground()); + logPane.setContentType("text/html"); + logPane.setEditable(false); + logPane.setBorder(null); + list.setCellRenderer(new FileNameListCellRenderer()); + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(list), new JScrollPane(logPane)); + add(splitPane, BorderLayout.CENTER); + readLogDir(); + list.addListSelectionListener(e -> { + if (!e.getValueIsAdjusting()) { + doDisplayLogfile(); + } + }); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void doDisplayLogfile() { + try { + File selectedLog = (File) list.getSelectedValue(); + + logPane.setPage("file://localhost/" + selectedLog.getAbsolutePath()); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void readLogDir() { + File logPath = new File(path); + + if (!logPath.isDirectory()) { + return; + } + + File[] htmlFiles = logPath.listFiles((dir, name) -> name.endsWith(".html")); + + listModel.setData(htmlFiles); + } + + public void fireLanguageChanged() { + } + + public void registerSelected() { + } + + public void fireContentChanged(de.applejuicenet.client.fassade.listener.DataUpdateListener.DATALISTENER_TYPE arg0, Object arg1) { + } +} diff --git a/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPluginTestLoader.java b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPluginTestLoader.java new file mode 100644 index 00000000..5bddd5f2 --- /dev/null +++ b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/LogViewerPluginTestLoader.java @@ -0,0 +1,25 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugins.logviewer; + +import de.applejuicenet.client.gui.plugincontrol.TestLoader; +import de.applejuicenet.client.gui.plugins.PluginConnector; + +import javax.swing.*; +import java.util.Map; +import java.util.Properties; + +public class LogViewerPluginTestLoader extends TestLoader { + @Override + protected String getPath() { + return "logviewer"; + } + + @Override + protected PluginConnector getPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, + Map availableIcons) { + return new LogViewerPlugin(pluginProperties, languageFiles, icon, availableIcons); + } +} diff --git a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java similarity index 96% rename from AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java rename to modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java index 1600dd0a..cba67c69 100644 --- a/AJClientGUI/plugin_src/logviewer/src/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java +++ b/modules/logviewer/src/main/java/de/applejuicenet/client/gui/plugins/logviewer/SortedStringListModel.java @@ -4,14 +4,12 @@ package de.applejuicenet.client.gui.plugins.logviewer; +import javax.swing.*; +import javax.swing.event.ListDataListener; import java.io.File; - import java.util.HashSet; import java.util.TreeSet; -import javax.swing.ListModel; -import javax.swing.event.ListDataListener; - public class SortedStringListModel implements ListModel { private TreeSet data = new TreeSet(new FileModificationDateComparator()); diff --git a/modules/logviewer/src/main/resources/icon.gif b/modules/logviewer/src/main/resources/icon.gif new file mode 100644 index 00000000..b4570367 Binary files /dev/null and b/modules/logviewer/src/main/resources/icon.gif differ diff --git a/AJClientGUI/plugin_src/logviewer/plugin.properties b/modules/logviewer/src/main/resources/plugin.properties similarity index 66% rename from AJClientGUI/plugin_src/logviewer/plugin.properties rename to modules/logviewer/src/main/resources/plugin.properties index 4aa631f1..c6f734ed 100644 --- a/AJClientGUI/plugin_src/logviewer/plugin.properties +++ b/modules/logviewer/src/main/resources/plugin.properties @@ -1,7 +1,7 @@ general.title=LogViewer -general.version=1.3 +general.version=1.3.1 general.author=loevenwong general.contact=tloevenich@tkl-soft.de -general.description=Mit dem Logviewer können die Logs angezeigt werden. +general.description=Mit dem Logviewer können die Logs angezeigt werden. general.istab=true general.classname=de.applejuicenet.client.gui.plugins.logviewer.LogViewerPlugin diff --git a/modules/speedgraph/pom.xml b/modules/speedgraph/pom.xml new file mode 100644 index 00000000..6dc13781 --- /dev/null +++ b/modules/speedgraph/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + de.applejuicenet.client.gui.plugins + speedgraph + jar + 0.9.2 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + de.applejuicenet.client.gui + AJCoreGUI + 0.85.3 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + ${project.artifactId} + + false + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0 + + + copy.plugins + package + + copy + + + + + ${basedir}/target/${project.artifactId}.jar + ${project.parent.basedir}/resources/plugins/${project.artifactId}.jar + + + + + + + + + diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/GraphPanel.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/GraphPanel.java new file mode 100644 index 00000000..26b9e3c4 --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/GraphPanel.java @@ -0,0 +1,77 @@ +package de.applejuicenet.client.gui.plugins; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/ajzab0815/Repository/AJStatsPlugin/de/applejuicenet/client/gui/plugins/ajstats/GraphPanel.java,v 1.1 2004/05/21 18:52:21 zab0815 Exp $ + * + *

Titel: AppleJuice Core-GUI

+ *

Beschreibung: Erstes GUI für den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: open-source

+ * + * @author: Maj0r + *

+ * $Log: GraphPanel.java,v $ + * Revision 1.1 2004/05/21 18:52:21 zab0815 + * First commit since upgrading to new Plugin interface. Only few changes with settings are needed. + *

+ * Revision 1.1 2004/01/06 20:49:07 andy + * Initial checkin + *

+ * Revision 1.4 2003/12/29 11:00:02 zab0815 + * Automatisches scaling der Anzeige und scrolling bei vollem Display, komplett überarbeitet. + *

+ * * $Log: GraphPanel.java,v $ + * * Revision 1.1 2004/05/21 18:52:21 zab0815 + * * First commit since upgrading to new Plugin interface. Only few changes with settings are needed. + * * + * * Revision 1.1 2004/01/06 20:49:07 andy + * * Initial checkin + * * + * Revision 1.3 2003/12/22 16:25:02 maj0r + * Bug behoben, der auftratt, wenn das Plugin aktualisiert wurde, obwohl es noch nicht angezeigt wird (Danke an Luke). + *

+ * Revision 1.2 2003/09/15 07:28:45 maj0r + * Plugin zeigt nun ein Raster und die Zeit auf der x-Achse. + *

+ * Revision 1.1 2003/09/13 11:33:17 maj0r + * Neues Plugin SpeedGraph. + */ + +public class GraphPanel extends JPanel { + + public GraphPanel() { + //private UpDownChart ud = new UpDownChart(); + Logger logger = LoggerFactory.getLogger(getClass()); + try { + setLayout(new BorderLayout()); + this.setBackground(Color.BLACK); + //add(new JScrollPane(ud), BorderLayout.NORTH); + setBackground(Color.BLACK); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + + } + + public void paintComponent(Graphics g) { + g.setColor(Color.BLACK); + g.fillRect(0, 0, getWidth(), getHeight()); + //System.out.println("GpahPanel ("+getHeight()+","+getWidth()+") paintComponent"); + //ud.paintComponent(g); + //super.paintComponent(g); + } + + public void update(HashMap speeds) { + //ud.update (speeds); + } + + ; + +} diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPlugin.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPlugin.java new file mode 100644 index 00000000..93c7d0fb --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPlugin.java @@ -0,0 +1,332 @@ +package de.applejuicenet.client.gui.plugins; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/ajzab0815/Repository/AJStatsPlugin/de/applejuicenet/client/gui/plugins/AJStatsPlugin.java,v 1.3 2004/06/17 10:14:03 zab0815 Exp $ + * + *

Titel: AppleJuice Core-GUI

+ *

Beschreibung: Erstes GUI für den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: open-source

+ * + * @author: zab0815 + *

+ * $Log: AJStatsPlugin.java,v $ + * Revision 1.3 2004/06/17 10:14:03 zab0815 + * Fix BUG with timertask, read settings for max up/download speed, read initial settings + *

+ * Revision 1.2 2004/05/28 21:47:41 zab0815 + * Next try... + * need to delete data when graph is full and make things multithreaded. + * Also the timer has to define the scroll-speed. + *

+ * Revision 1.1 2004/05/21 18:52:21 zab0815 + * First commit since upgrading to new Plugin interface. Only few changes with settings are needed. + *

+ * Revision 1.1 2004/01/06 20:49:07 andy + * Initial checkin + *

+ * Revision 0.9 2003/12/22 16:25:35 zab0815 + * Neues Plugin auf basis von SpeedGraph vom Maj0r. + */ +public class SpeedGraphPlugin extends PluginConnector implements FocusListener, ActionListener, ComponentListener, KeyListener, MouseListener { + + private GraphPanel graphPanel = null; + private UpDownChart ud = null; + private static Logger logger; + + private String savePath; + private Properties properties; + + private void init() { + logger = LoggerFactory.getLogger(getClass()); + savePath = System.getProperty("user.home") + File.separator + "appleJuice" + File.separator + "gui"; + savePath = savePath + File.separator + "speedgraph.properties"; + properties = new Properties(); + + File tmpFile = new File(savePath); + if (tmpFile.isFile()) { + try { + properties.load(new FileInputStream(tmpFile)); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + setLayout(new BorderLayout()); + + graphPanel = new GraphPanel(); + graphPanel.setBackground(Color.BLACK); + + ud = new UpDownChart(); + ud.setParent(this); + addPropertyChangeListener(ud); + addMouseListener(ud); + addMouseMotionListener(ud); + + String propGradient = properties.getProperty("UseGradient"); + + if (propGradient != null) { + int propGradientDir; + + try { + propGradientDir = Integer.decode(properties.getProperty("GradientDirection")); + } catch (Exception e) { + propGradientDir = UpDownChart.BG_UP_TO_DOWN; + properties.put("GradientDirection", Integer.toString(UpDownChart.BG_NO_GRADIENT)); + } + + ud.setGradientDirection(propGradientDir); + ud.setBGStart(getPropertyColor("GradientStart", Color.white)); + ud.setBGEnd(getPropertyColor("GradientEnd", Color.green)); + ud.setUpdatePeriod(Long.parseLong(properties.getProperty("UpdateTime", "2000"))); + } else { + ud.setGradientDirection(UpDownChart.BG_NO_GRADIENT); + } + + JSplitPane jsPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, graphPanel, ud); + jsPane.setDividerLocation(getHeight() / 2); + add(jsPane, BorderLayout.CENTER); + setBackground(Color.BLACK); + } + + public void saveProperties() { + try { + properties.store(new FileOutputStream(savePath), "ajStatsPlugin-PropertyFile"); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + public Properties getProperties() { + return properties; + } + + public void setPropertyColor(String propertyKey, Color ColorKey) { + + String valString; + valString = "0x" + Integer.toHexString(ColorKey.getRGB()); + + properties.put(propertyKey, valString); + } + + public Color getPropertyColor(String propertyKey, Color defaultCol) { + + try { + String keyStr = properties.get(propertyKey).toString(); + long keyLong = Long.decode(keyStr); +// System.out.println( propertyKey + ":" + Long.toHexString(keyLong.longValue()) + +// " Red:" + ((int)((keyLong.longValue() >> 16) & 0xff)) + +// " Green:" + ((int)(keyLong.longValue() >> 8) & 0xff) + +// " Blue:" + ((int)keyLong.longValue() & 0xff) + +// " Alpha:" + ((int)(keyLong.longValue() >> 24) & 0xff)); + + return new Color((int) (keyLong >> 16) & 0xff, + (int) (keyLong >> 8) & 0xff, + (int) (keyLong) & 0xff, + (int) (keyLong >> 24) & 0xff); + } catch (Exception e) { +// System.out.println(e.toString() + " bei Key:" + propertyKey); + return defaultCol; + } + } + + public SpeedGraphPlugin(Properties pluginsProperties, Map languageFiles, ImageIcon icon, Map availableIcons) { + super(pluginsProperties, languageFiles, icon, availableIcons); + + try { + init(); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.SPEED_CHANGED); + fireContentChanged(DATALISTENER_TYPE.SPEED_CHANGED, new HashMap()); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public static void main(String[] args) { + JFrame jp = new JFrame("SpeedGraph"); + JButton jb = new JButton("Settings"); + final UpDownChart plugin = new UpDownChart(); + + JFrame.setDefaultLookAndFeelDecorated(true); + jp.setSize(800, 600); + jb.setSize(100, 50); + plugin.setSize(600, 700); + + jb.addActionListener(e -> { + JFrame js = new JFrame("Plugin Settings"); + SpeedGraphSettings pluginSettings = new SpeedGraphSettings(); + js.getContentPane().add(pluginSettings); + + js.setSize(800, 600); + js.setVisible(true); + }); + + jp.getContentPane().add(plugin); + jp.getContentPane().add(jb); + jp.setVisible(true); + } + + + public void fireLanguageChanged() { + } + + /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. + Über den DataManger können diese abgerufen werden.*/ + public void fireContentChanged(DATALISTENER_TYPE type, Object content) { + if (type == DATALISTENER_TYPE.SPEED_CHANGED) { + + try { + HashMap map = (HashMap) content; //geänderte Uploads + + graphPanel.update(map); + ud.update(map); + } catch (Exception e) { + logger.error("Fehler: " + e); + } + } + } + + public JPanel getOptionPanel() { + SpeedGraphSettings settings = new SpeedGraphSettings(); + settings.parent = this; + return settings.getPanel(); + } + + public void registerSelected() { + } + + /* (non-Javadoc) + * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) + */ + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) + */ + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent) + */ + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent) + */ + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) + */ + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent) + */ + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) + */ + public void keyPressed(KeyEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) + */ + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) + */ + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) + */ + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) + */ + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) + */ + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) + */ + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } +} diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPluginTestLoader.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPluginTestLoader.java new file mode 100644 index 00000000..3ff57ffe --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphPluginTestLoader.java @@ -0,0 +1,24 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugins; + +import de.applejuicenet.client.gui.plugincontrol.TestLoader; + +import javax.swing.*; +import java.util.Map; +import java.util.Properties; + +public class SpeedGraphPluginTestLoader extends TestLoader { + @Override + protected String getPath() { + return "speedgraph"; + } + + @Override + protected PluginConnector getPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, + Map availableIcons) { + return new SpeedGraphPlugin(pluginProperties, languageFiles, icon, availableIcons); + } +} diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphSettings.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphSettings.java new file mode 100644 index 00000000..ed7f6358 --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/SpeedGraphSettings.java @@ -0,0 +1,507 @@ +/* + * Created on 02.01.2004 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package de.applejuicenet.client.gui.plugins; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Zab + *

+ * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class SpeedGraphSettings extends JPanel { + + private javax.swing.JButton btnUpColor = null; + private javax.swing.JButton btnDownColor = null; + private javax.swing.JLabel lblUpColor = null; + private javax.swing.JLabel lblDownColor = null; + + private final javax.swing.JSlider jSlider = null; + private javax.swing.JSlider JSUpdateTime = null; // + private javax.swing.JLabel jLabel = null; + private javax.swing.JCheckBox jCheckBox = null; + private javax.swing.JButton btnBGColorBegin = null; + private javax.swing.JButton btnBGColorEnd = null; + private javax.swing.JLabel lblBGColorBegin = null; + private javax.swing.JLabel lblBGColorEnd = null; + + private javax.swing.JLabel LblValue = null; + private javax.swing.JComboBox CmbBGDirection = null; + + public SpeedGraphPlugin parent = null; + + public SpeedGraphSettings() { + } + + private void initialize() { + java.awt.GridBagConstraints consGridBagConstraints19 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints18 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints17 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints16 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints15 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints14 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints13 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints12 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints11 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints10 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints9 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints8 = new java.awt.GridBagConstraints(); + + java.awt.GridBagConstraints consGridBagConstraints7 = new java.awt.GridBagConstraints(); + + this.setLayout(new java.awt.GridBagLayout()); // Generated + setSize(455, 300); + consGridBagConstraints7.gridx = 0; // Generated + consGridBagConstraints7.gridy = 0; // Generated + consGridBagConstraints7.ipadx = 10; // Generated + consGridBagConstraints7.ipady = 0; // Generated + consGridBagConstraints7.insets = new java.awt.Insets(10, 25, 10, 25); // Generated + consGridBagConstraints7.fill = java.awt.GridBagConstraints.BOTH; // Generated + consGridBagConstraints8.gridx = 2; // Generated + consGridBagConstraints8.gridy = 0; // Generated + consGridBagConstraints8.ipadx = 20; // Generated + consGridBagConstraints8.ipady = 0; // Generated + consGridBagConstraints8.insets = new java.awt.Insets(5, 0, 12, 40); // Generated + consGridBagConstraints8.fill = java.awt.GridBagConstraints.NONE; // Generated + consGridBagConstraints9.gridx = 0; // Generated + consGridBagConstraints9.gridy = 1; // Generated + consGridBagConstraints9.ipadx = 10; // Generated + consGridBagConstraints9.ipady = 0; // Generated + consGridBagConstraints9.insets = new java.awt.Insets(0, 25, 10, 25); // Generated + consGridBagConstraints9.fill = java.awt.GridBagConstraints.BOTH; // Generated + consGridBagConstraints10.gridx = 2; // Generated + consGridBagConstraints10.gridy = 1; // Generated + consGridBagConstraints10.ipadx = 20; // Generated + consGridBagConstraints10.ipady = 0; // Generated + consGridBagConstraints10.insets = new java.awt.Insets(0, 0, 10, 40); // Generated + consGridBagConstraints11.gridx = 0; // Generated + consGridBagConstraints11.gridy = 7; // Generated + consGridBagConstraints11.gridwidth = 3; // Generated + consGridBagConstraints11.weightx = 1.0; // Generated + consGridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated + consGridBagConstraints11.ipadx = 0; // Generated + consGridBagConstraints11.ipady = 0; // Generated + consGridBagConstraints11.insets = new java.awt.Insets(2, 25, 50, 25); // Generated + consGridBagConstraints12.gridx = 0; // Generated + consGridBagConstraints12.gridy = 6; // Generated + consGridBagConstraints12.gridwidth = 2; // Generated + consGridBagConstraints12.ipadx = 0; // Generated + consGridBagConstraints12.ipady = 0; // Generated + consGridBagConstraints12.insets = new java.awt.Insets(5, 25, 2, 25); // Generated + consGridBagConstraints12.fill = java.awt.GridBagConstraints.NONE; // Generated + consGridBagConstraints12.anchor = java.awt.GridBagConstraints.WEST; // Generated + consGridBagConstraints13.gridx = 0; // Generated + consGridBagConstraints13.gridy = 2; // Generated + consGridBagConstraints13.ipadx = 70; // Generated + consGridBagConstraints13.ipady = -1; // Generated + consGridBagConstraints13.insets = new java.awt.Insets(10, 25, 0, 10); // Generated + consGridBagConstraints13.anchor = java.awt.GridBagConstraints.CENTER; // Generated + consGridBagConstraints14.gridx = 2; // Generated + consGridBagConstraints14.gridy = 3; // Generated + consGridBagConstraints14.insets = new java.awt.Insets(5, 0, 10, 40); // Generated + consGridBagConstraints14.ipadx = 20; // Generated + consGridBagConstraints15.gridx = 2; // Generated + consGridBagConstraints15.gridy = 4; // Generated + consGridBagConstraints15.insets = new java.awt.Insets(0, 0, 10, 40); // Generated + consGridBagConstraints15.ipadx = 20; // Generated + consGridBagConstraints16.gridx = 0; // Generated + consGridBagConstraints16.gridy = 3; // Generated + consGridBagConstraints16.insets = new java.awt.Insets(5, 25, 10, 25); // Generated + consGridBagConstraints16.fill = java.awt.GridBagConstraints.BOTH; // Generated + consGridBagConstraints17.gridx = 0; // Generated + consGridBagConstraints17.gridy = 4; // Generated + consGridBagConstraints17.insets = new java.awt.Insets(0, 25, 10, 25); // Generated + consGridBagConstraints17.fill = java.awt.GridBagConstraints.BOTH; // Generated + consGridBagConstraints18.gridx = 2; // Generated + consGridBagConstraints18.gridy = 6; // Generated + consGridBagConstraints18.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated + consGridBagConstraints18.insets = new java.awt.Insets(5, 0, 2, 25); // Generated + consGridBagConstraints19.gridx = 2; // Generated + consGridBagConstraints19.gridy = 2; // Generated + consGridBagConstraints19.weightx = 1.0; // Generated + consGridBagConstraints19.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated + consGridBagConstraints19.insets = new java.awt.Insets(10, 0, 0, 25); // Generated + this.add(getLblUpColor(), consGridBagConstraints7); // Generated + this.add(getBtnUpColor(), consGridBagConstraints8); // Generated + this.add(getLblDownColor(), consGridBagConstraints9); // Generated + this.add(getBtnDownColor(), consGridBagConstraints10); // Generated + this.add(getJSUpdateTime(), consGridBagConstraints11); // Generated + this.add(getJLabel(), consGridBagConstraints12); // Generated + this.add(getJCheckBox(), consGridBagConstraints13); // Generated + this.add(getBtnBGColorBegin(), consGridBagConstraints14); // Generated + this.add(getBtnBGColorEnd(), consGridBagConstraints15); // Generated + this.add(getLblBGColorBegin(), consGridBagConstraints16); // Generated + this.add(getLblBGColorEnd(), consGridBagConstraints17); // Generated + this.add(getLblValue(), consGridBagConstraints18); // Generated + this.add(getCmbBGDirection(), consGridBagConstraints19); // Generated + + } + + private JLabel getLblUpColor() { + if (lblUpColor == null) { + lblUpColor = new JLabel(); + lblUpColor.setText("Upload Color"); + lblUpColor.setOpaque(true); + + lblUpColor.setBackground(parent.getPropertyColor("UploadColor", Color.red)); + } + return lblUpColor; + } + + private javax.swing.JButton getBtnUpColor() { + if (btnUpColor == null) { + btnUpColor = new javax.swing.JButton(); + btnUpColor.setText("Wählen"); + btnUpColor.setMnemonic(java.awt.event.KeyEvent.VK_W); + + btnUpColor.addActionListener(e -> { + Color col = JColorChooser.showDialog(getPanel(), "Upload Farbe wählen", + parent.getPropertyColor("UploadColor", Color.red)); + if (col != null) { + parent.setPropertyColor("UploadColor", col); + getLblUpColor().setBackground(col); + } + }); + } + return btnUpColor; + } + + private JLabel getLblDownColor() { + if (lblDownColor == null) { + lblDownColor = new JLabel(); + lblDownColor.setText("Download Color"); + lblDownColor.setOpaque(true); + + lblDownColor.setBackground(parent.getPropertyColor("DownloadColor", Color.blue)); + } + return lblDownColor; + } + + private javax.swing.JButton getBtnDownColor() { + if (btnDownColor == null) { + btnDownColor = new javax.swing.JButton(); + btnDownColor.setText("Wählen"); + btnDownColor.setMnemonic(java.awt.event.KeyEvent.VK_H); + + btnDownColor.addActionListener(e -> { + Color col = JColorChooser.showDialog(getPanel(), "Download Farbe wählen", + parent.getPropertyColor("DownloadColor", Color.blue)); + if (col != null) { + parent.setPropertyColor("DownloadColor", col); + getLblDownColor().setBackground(col); + } + }); + } + return btnDownColor; + } + + public JPanel getPanel() { + initialize(); + return this; + } + + /** + * @return Icon with 18x18 from given color + */ + private Icon getColorIcon(Color color) { + Image ico = createVolatileImage(18, 18); + + try { + ico.getGraphics().setColor(color); + ico.getGraphics().fillRect(0, 0, 17, 17); + //System.out.println("Icon drawn"); + } catch (NullPointerException e) { + //System.out.println("Error in getColorIcon() "); e.printStackTrace(); + //System.out.println("Icon not drawn"); + return null; + } + + return new ImageIcon(ico); + } + + private Color chooseColor(Color color) { + try { + getBtnUpColor().setIcon(getColorIcon(parent.getPropertyColor("UploadColor", Color.red))); + getBtnDownColor().setIcon(getColorIcon(parent.getPropertyColor("DownloadColor", Color.blue))); + } catch (NullPointerException e) { + parent.setPropertyColor("UploadColor", Color.red); + parent.setPropertyColor("DownloadColor", Color.blue); + } + return Color.BLACK; + } + + /** + * This method initializes jSlider1 + * + * @return javax.swing.JSlider + */ + private javax.swing.JSlider getJSUpdateTime() { + if (JSUpdateTime == null) { + try { + JSUpdateTime = new javax.swing.JSlider(); + JSUpdateTime.setMaximum(5000); // Generated + JSUpdateTime.setMinimum(500); // Generated + JSUpdateTime.setMinorTickSpacing(100); // Generated + JSUpdateTime.setName("JSUpdateTime"); // Generated + JSUpdateTime.setPaintLabels(true); // Generated + JSUpdateTime.setPaintTicks(true); // Generated + JSUpdateTime.setValue(Integer.parseInt(parent.getProperties().getProperty("UpdateTime", "2000"))); // Generated + getLblValue().setText(Integer.toString((JSUpdateTime.getValue()))); + JSUpdateTime.addChangeListener(e -> { + getLblValue().setText(Integer.toString((JSUpdateTime.getValue()))); + parent.getProperties().put("UpdateTime", Integer.toString(JSUpdateTime.getValue())); + parent.saveProperties(); + firePropertyChange("UpdateTime", 0, JSUpdateTime.getValue()); + }); + + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return JSUpdateTime; + } + + /** + * This method initializes jLabel + * + * @return javax.swing.JLabel + */ + private javax.swing.JLabel getJLabel() { + if (jLabel == null) { + try { + jLabel = new javax.swing.JLabel(); + jLabel.setText("Update time [ms]"); // Generated + jLabel.setDisplayedMnemonic(java.awt.event.KeyEvent.VK_U); // Generated + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return jLabel; + } + + /** + * This method initializes jCheckBox + * + * @return javax.swing.JCheckBox + */ + private javax.swing.JCheckBox getJCheckBox() { + if (jCheckBox == null) { + try { + jCheckBox = new javax.swing.JCheckBox(); + jCheckBox.setText("Farbverlauf benutzen"); // Generated + + // prüfen,ob Gradient verwendet wird. + try { + jCheckBox.setSelected(Boolean.getBoolean(parent.getProperties().getProperty("UseGradient", "false"))); + } catch (NullPointerException e) { + jCheckBox.setSelected(false); + parent.getProperties().put("UseGradient", Boolean.toString(false)); + } + + jCheckBox.addChangeListener(e -> { + boolean state = jCheckBox.isSelected(); + getBtnBGColorEnd().setEnabled(state); + getLblBGColorEnd().setEnabled(state); + getCmbBGDirection().setEnabled(state); + parent.getProperties().put("UseGradient", Boolean.toString(state)); + }); + + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return jCheckBox; + } + + /** + * This method initializes jButton + * + * @return javax.swing.JButton + */ + private javax.swing.JButton getBtnBGColorBegin() { + if (btnBGColorBegin == null) { + try { + btnBGColorBegin = new javax.swing.JButton(); + btnBGColorBegin.setText("Wählen"); // Generated + btnBGColorBegin.setMnemonic(java.awt.event.KeyEvent.VK_L); + btnBGColorBegin.addActionListener(e -> { + Color col = null; + try { + col = JColorChooser.showDialog(getPanel(), "Hintergrund Beginn Farbe wählen", + parent.getPropertyColor("GradientStart", Color.white)); + } catch (NullPointerException er) { + col = JColorChooser.showDialog(getPanel(), "Hintergrund Beginn Farbe wählen", + Color.white); + } + + if (col != null) { + parent.setPropertyColor("GradientStart", col); + getLblBGColorBegin().setBackground(col); + } + }); + + } catch (java.lang.Throwable e) { + + } + } + return btnBGColorBegin; + } + + /** + * This method initializes jButton + * + * @return javax.swing.JButton + */ + private javax.swing.JButton getBtnBGColorEnd() { + if (btnBGColorEnd == null) { + try { + btnBGColorEnd = new javax.swing.JButton(); + btnBGColorEnd.setText("Wählen"); // Generated + btnBGColorEnd.setMnemonic(java.awt.event.KeyEvent.VK_N); // Generated + btnBGColorEnd.addActionListener(e -> { + Color col = null; + try { + col = JColorChooser.showDialog(getPanel(), "Hintergrund Ende Farbe wählen", + parent.getPropertyColor("GradientEnd", Color.blue)); + } catch (NullPointerException er) { + col = JColorChooser.showDialog(getPanel(), "Hintergrund Ende Farbe wählen", + Color.blue); + } + if (col != null) { + parent.setPropertyColor("GradientEnd", col); + getLblBGColorEnd().setBackground(col); + } + }); + + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return btnBGColorEnd; + } + + /** + * This method initializes jLabel1 + * + * @return javax.swing.JLabel + */ + private javax.swing.JLabel getLblBGColorBegin() { + if (lblBGColorBegin == null) { + try { + lblBGColorBegin = new javax.swing.JLabel(); + lblBGColorBegin.setText("Hintergrund Start"); // Generated + lblBGColorBegin.setOpaque(true); + try { + lblBGColorBegin.setBackground(parent.getPropertyColor("GradientStart", Color.white)); + } catch (NullPointerException e) { + lblBGColorBegin.setBackground(Color.white); + } + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return lblBGColorBegin; + } + + /** + * This method initializes jLabel2 + * + * @return javax.swing.JLabel + */ + private javax.swing.JLabel getLblBGColorEnd() { + if (lblBGColorEnd == null) { + try { + lblBGColorEnd = new javax.swing.JLabel(); + lblBGColorEnd.setText("Hintergrund Ende"); // Generated + lblBGColorEnd.setOpaque(true); + try { + lblBGColorEnd.setBackground(parent.getPropertyColor("GradientEnd", Color.blue)); + } catch (NullPointerException e) { + lblBGColorEnd.setBackground(Color.blue); + } + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return lblBGColorEnd; + } + + /** + * This method initializes jLabel1 + * + * @return javax.swing.JLabel + */ + private javax.swing.JLabel getLblValue() { + if (LblValue == null) { + try { + LblValue = new javax.swing.JLabel(); + LblValue.setText(""); // Generated + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return LblValue; + } + + /** + * This method initializes jComboBox + * + * @return javax.swing.JComboBox + */ + private javax.swing.JComboBox getCmbBGDirection() { + if (CmbBGDirection == null) { + try { + CmbBGDirection = new javax.swing.JComboBox(); + CmbBGDirection.addItem(makeObj("Links - Rechts", 0)); + CmbBGDirection.addItem(makeObj("Rechts - Links", 1)); + CmbBGDirection.addItem(makeObj("Oben - Unten", 2)); + CmbBGDirection.addItem(makeObj("Unten - Oben", 3)); + CmbBGDirection.addItem(makeObj("ObenLinks - UntenRechts", 4)); + CmbBGDirection.addItem(makeObj("UntenRechts - ObenLinks", 5)); + CmbBGDirection.addItem(makeObj("ObenRechts - UntenLinks", 6)); + CmbBGDirection.addItem(makeObj("UntenLinks - ObenRechts", 7)); + + try { + CmbBGDirection.setSelectedIndex(Integer.parseInt(parent.getProperties().getProperty("GradientDirection"), UpDownChart.BG_UP_TO_DOWN)); + } catch (NullPointerException e) { + CmbBGDirection.setSelectedIndex(UpDownChart.BG_UP_TO_DOWN); + } + + CmbBGDirection.addActionListener(e -> parent.getProperties().put("GradientDirection", Integer.toString(CmbBGDirection.getSelectedIndex()))); + + } catch (java.lang.Throwable e) { + // TODO: Something + } + } + return CmbBGDirection; + } + + private Object makeObj(final String item, final int index) { + return new Object() { + public String toString() { + return item; + } + + public int getIndex() { + return index; + } + }; + } +} diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownChart.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownChart.java new file mode 100644 index 00000000..ffc23c1c --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownChart.java @@ -0,0 +1,921 @@ +/* + * Created on 29.12.2003 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package de.applejuicenet.client.gui.plugins; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Timer; +import java.util.TimerTask; + +/*TODO UL/DL marken für ISDN, DSL,... + +/** + * @author Zab0815 + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class UpDownChart extends JPanel implements MouseListener, MouseMotionListener, PropertyChangeListener { + /*** BG_NO_GRADIENT draws simple background with BGStart as color */ + public final static int BG_NO_GRADIENT = -1; + /*** BG_LEFT_TO_RIGHT draws the gradient from left with BGStart to right with BGEnd */ + public final static int BG_LEFT_TO_RIGHT = 0; + /*** BG_RIGHT_TO_LEFT draws the gradient from right with BGStart to left with BGEnd */ + public final static int BG_RIGHT_TO_LEFT = 1; + /*** BG_DOWN_TO_UP draws the gradient from up with BGStart to down with BGEnd */ + public final static int BG_UP_TO_DOWN = 2; + /*** BG_DOWN_TO_UP draws the gradient from down with BGStart to up with BGEnd */ + public final static int BG_DOWN_TO_UP = 3; + /*** BG_UPLEFT_TO_DOWNRIGHT draws the gradient from up-left with BGStart to down-right with BGEnd */ + public final static int BG_UPLEFT_TO_DOWNRIGHT = 4; + /*** BG_DOWNRIGHT_TO_UPLEFT draws the gradient from down-right with BGStart to up-left with BGEnd */ + public final static int BG_DOWNRIGHT_TO_UPLEFT = 5; + /*** BG_UPRIGHT_TO_DOWNLEFT draws the gradient from up-right with BGStart to down-left with BGEnd */ + public final static int BG_UPRIGHT_TO_DOWNLEFT = 6; + /*** BG_DOWNLEFT_TO_UPRIGHT draws the gradient from down-left with BGStart to up-right with BGEnd */ + public final static int BG_DOWNLEFT_TO_UPRIGHT = 7; + + private final int minChartHeight = 100; + + private static Logger logger; + private static TimerThread timerThread; + private TimerTask chartTimer = null; + + private long initTime = 0; + + private static int gradientDirection = BG_DOWN_TO_UP; + private static Color BGEnd = new Color(20, 200, 20); + private static Color BGStart = new Color(0, 0, 0); + private Color downCol = new Color(20, 20, 200); + private Color upCol = new Color(200, 20, 20); + private Color lineCol = new Color(255, 255, 255); + + private UpDownData ud = null; + private SpeedGraphPlugin parent = null; + + private int maxWidth = 0; + private int legendX = 250; + private int legendY = 10; + private int legendWidth = 200; + private int legendHeight = 20; + private int legendAlpha = 128; + private int mouseX = 0; + private int mouseY = 0; + + private int topY = 0; + private int bottomY = 0; + private int bottomHeight = 30; + private int maxSpeed = 10; + private int aktX = 0; + private int oldHeight = 0; + private int oldWidth = 0; + + private Image image = null; + private BufferedImage backImage = null; + private BufferedImage legendImage = null; + + private boolean dragging = false; + private String uploadSpeedKey = "uploadspeed"; + private String downloadSpeedKey = "downloadspeed"; + private long updatePeriod; + + /** + * @return Returns the updatePeriod. + */ + public long getUpdatePeriod() { + return updatePeriod; + } + + /** + * @param updatePeriod The updatePeriod to set. + */ + public void setUpdatePeriod(long updatePeriod) { + this.updatePeriod = updatePeriod; + } + + /** + * @param parent The properties to set. + */ + public void setParent(SpeedGraphPlugin parent) { + this.parent = parent; + readProperies(); + } + + private class chartTimerTask extends TimerTask { + + public void run() { + aktX++; + repaint(); + //System.out.println("Timer:" + (System.currentTimeMillis() - initTime)); + } + } + + public UpDownChart() { + logger = LoggerFactory.getLogger(getClass()); + addMouseListener(this); + initTime = System.currentTimeMillis(); + try { + try { + timerThread = new TimerThread(); + chartTimer = new chartTimerTask(); + } catch (Exception e1) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e1); + } + + ud = new UpDownData(); + } catch (NullPointerException e) { + logger.error("Nullpointer-exception: data-storage not initialized!", e); + } + } + + + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && dragging) { + if (legendX + e.getX() - mouseX > 0) + legendX += e.getX() - mouseX; + else legendX = 0; + + if (legendY + e.getY() - mouseY > topY) + legendY += e.getY() - mouseY; + else legendY = topY; + + dragging = false; + legendAlpha = 80; + repaint(); + } + } + + ; + + public void mousePressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && !dragging) { + if (e.getX() > legendX && e.getX() < legendX + 200) { + if (e.getY() > legendY && e.getY() < legendY + 20) { + dragging = true; + mouseX = e.getX(); + mouseY = e.getY(); + legendAlpha = 200; + repaint(); + } + } + } + } + + ; + + /* (non-Javadoc) + * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) + */ + public void mouseDragged(MouseEvent e) { + if (legendX + e.getX() - mouseX > 0) + legendX += e.getX() - mouseX; + else legendX = 0; + + if (legendY + e.getY() - mouseY > topY) + legendY += e.getY() - mouseY; + else legendY = topY; + legendAlpha = 80; + } + + /* (non-Javadoc) + * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) + */ + public void mouseMoved(MouseEvent e) { + } + + ; + + public void mouseExited(MouseEvent e) { + dragging = false; + } + + ; + + public void mouseEntered(MouseEvent e) { + } + + ; + + public void mouseClicked(MouseEvent e) { + } + + ; + + static class TimerThread extends Timer { + + private boolean hasStarted = false; + + public void run(TimerTask task, long delay, long period) { + this.schedule(task, delay, period); + this.hasStarted = true; + } + + public boolean hasRunStarted() { + return this.hasStarted; + } + } + + public void update(HashMap info) { + + if (ud == null) { + ud = new UpDownData(); + } + + //add data to the array + try { + //Prüfen, ob mehr Daten gespeichert wurden, als angezeigt werden können. + if (ud.size() > maxWidth) + //erstes element aus dem Array löschen. + ud.remove(0); + + ud.add((Long) info.get(uploadSpeedKey), (Long) info.get(downloadSpeedKey), System.currentTimeMillis()); + if (ud.size() == 1 && timerThread.hasRunStarted()) { + timerThread.schedule(chartTimer, 1000, updatePeriod); + } + + } catch (NullPointerException e) { + //No Data, or no Time then exit + } + +// if (getWidth()==0 || getHeight()==0){ +// /* +// Da kamen schneller Daten rein, als das Plugin angezeigt werden konnte. +// Wir nehmen folglich erst den naechsten Durchgang. +// */ +// return; +// } + + //drawGraph(); + //repaint(); + } + + + public void paintComponent(Graphics g) { +// initializeImages(); + if (image != null) { + boolean UpdateFlag = false; + + if (getHeight() != oldHeight || getWidth() != oldWidth) { + UpdateFlag = true; + } + + if (Boolean.parseBoolean(parent.getProperties().getProperty("changed"))) { + readProperies(); + + UpdateFlag = true; + } + + if (UpdateFlag == true) { + oldHeight = getHeight(); + bottomY = getHeight() - bottomHeight; + oldWidth = getWidth(); + maxWidth = getWidth(); + + image = null; + //System.out.println("discard image"); + backImage = null; + //System.out.println("discard backImage"); + initializeImages(); + } + + try { + Graphics2D g2 = (Graphics2D) image.getGraphics(); + + //check if we're running out of visible area + if (ud.size() >= maxWidth) { + ///remove the first element of data + ud.remove(0); + } + + g2.clearRect(0, 0, image.getWidth(null), image.getHeight(null)); + + //copy backImage to components Image + g2.drawImage(backImage, 0, 0, image.getWidth(null), image.getHeight(null) + , 0, 0, backImage.getWidth(), backImage.getHeight(), Color.BLACK, null); + + //g.drawImage(backImage, 0, 0, image.getWidth(null), image.getHeight(null), new Color(0,0,0), null); + + //copy legendImage to components Image + + drawLabel(); + drawLines(); + drawGraph(); + + g.drawImage(image, 0, 0, null); + g.drawImage(legendImage, legendX, legendY, new Color(0, 0, 0, legendAlpha), null); + } catch (Exception e) { + logger.error("Error drawing graphics :" + e.getMessage() + "\r\n" + e.getCause()); + } + } else { + initializeImages(); + super.paintComponent(g); + } + } + + /** + * + */ + private void drawGraph() { + Graphics2D g = (Graphics2D) image.getGraphics(); + //get first time-stamp + int lastDown = 0; + int lastUp = 0; + long lastTimeLabel = ud.get(0).getTime(); + double lAverageUp = 0.0; + double lAverageDown = 0.0; + + maxSpeed = 0; + + do { + maxSpeed += 10; + } while (ud.getMaxUp() > maxSpeed * 1024); + + do { + maxSpeed += 10; + } while (ud.getMaxDown() > maxSpeed * 1024); + + //draw upload rate-graph + for (int i = 0; i < ud.size(); i++) { + int up = (int) (ud.get(i).getUp() * bottomY / maxSpeed / 1024.0); + int down = (int) (ud.get(i).getDown() * bottomY / maxSpeed / 1024.0); + int xPos = i; + + lAverageUp += ud.get(i).getUp(); + lAverageDown += ud.get(i).getDown(); + + //System.out.print("upspeed = " + upSpeed.doubleValue() + " up = " + up + "\r\n"); +// if ((ud.get(i).getUp() > maxSpeed*1024) || (ud.get(i).getDown() > maxSpeed*1024)) { +// maxSpeed += 10; +// //forceResize =true; +// repaint(); +// return; +// } + g.setColor(upCol); + g.drawLine(31 + xPos, bottomY - lastUp, xPos + 32, bottomY - up); + g.setColor(downCol); + g.drawLine(31 + xPos, bottomY - lastDown, xPos + 32, bottomY - down); + + if (i % 50 == 0) { + lastTimeLabel = ud.get(i).getTime(); + drawTime(xPos + 31, ud.get(i).getTime()); + } + + lastUp = up; + lastDown = down; + } + + Stroke s = new BasicStroke(1, BasicStroke.CAP_ROUND, + BasicStroke.JOIN_ROUND, 0, new float[]{6, 6, 6, 6, 6, 6, 0, 0}, 0); + + NumberFormat nf = DecimalFormat.getInstance(); + nf.setMaximumFractionDigits(2); + nf.setMinimumFractionDigits(2); + + drawMark(g, lAverageUp / ud.size(), nf, upCol, s); + drawMark(g, lAverageDown / ud.size(), nf, downCol, s); + + s = new BasicStroke(1, BasicStroke.CAP_ROUND, + BasicStroke.JOIN_ROUND, 0, new float[]{6, 6, 0, 0, 6, 6, 0, 0}, 0); + + + //draw line for maximum Up/Download regarding the settings + drawMark(g, AppleJuiceClient.getAjFassade().getCurrentAJSettings().getMaxUploadInKB() * 1024, nf, Color.GRAY, s); + drawMark(g, AppleJuiceClient.getAjFassade().getCurrentAJSettings().getMaxDownloadInKB() * 1024, nf, Color.GRAY, s); + + double Average = lAverageUp / ud.size(); + drawMark(g, Average, nf, upCol.brighter(), s); + + Average = lAverageDown / ud.size(); + drawMark(g, Average, nf, downCol.brighter(), s); + + + g.dispose(); + } + + /** + * Draw horizontal Line as mark + * + * @param g graphics to draw in + * @param speedVal speed in Byte/s + * @param nf NumberFormat for text + * @param col Color to draw text and Line + * @param stroke Stroke to draw line with + */ + private void drawMark(Graphics2D g, double speedVal, NumberFormat nf, Color col, Stroke stroke) { + Double value = speedVal / 1024.0; + + g.setStroke(stroke); + g.setColor(col.brighter()); + + speedVal = bottomY - (speedVal * bottomY / maxSpeed / 1024.0); + g.drawLine(31, (int) speedVal, image.getWidth(null), (int) speedVal); + g.setColor(col.brighter()); + String outText = nf.format(value); + + g.drawString(outText, image.getWidth(null) - g.getFontMetrics().stringWidth(outText) - 10, (int) speedVal - 10); + } + + /** + * + */ + private void drawLabel() { + +// try { +// Graphics2D g = (Graphics2D)image.getGraphics(); +// FontMetrics fm = g.getFontMetrics(); +// +// //setup format of outtext +// NumberFormat nf = NumberFormat.getInstance(); +// nf.setMinimumIntegerDigits(3); +// +// //first clear old text - fill with gradient +// //g.setPaint(getGradient(gradientDirection,image.getHeight(null),30)); +// //g.fillRect(0, 0, 30, image.getHeight(null)); +// +// //setup font +// g.setColor(Color.WHITE); +// int strWidth = fm.stringWidth ( "XXX -" ); +// int strHeight = fm.getAscent(); +// g.setFont(new Font(g.getFont().getName(), Font.PLAIN, g.getFont().getSize())); +// g.drawString("kb/s", 30-g.getFontMetrics().stringWidth("kb/s "), image.getHeight(null)-strHeight); +// +// +// //draw text for speed +// for (int i=0;i<(maxSpeed/10)+1;i++){ +// //calculate y-position +// int yPos = (int)(bottomY-((bottomY - topY - strHeight*1.0)/( maxSpeed/10)) * i); +// +// //set color and draw text for speed +// g.drawString(nf.format(i*10), 30-strWidth, yPos+strHeight/2); +// } +// g.setColor(lineCol); +// g.drawLine(30,topY,30,bottomY); +// g.dispose(); +// } +// catch (Exception e) { +// if (logger.isEnabled(Level.ERROR)) +// logger.error("Error drawing labels :" + e.getMessage() + "\r\n" + e.getCause()); +// } + } + + /** + * + */ + public void drawLegend(int alpha) { + try { + Graphics2D g = (Graphics2D) legendImage.getGraphics(); + + g.setFont(new Font(g.getFont().getName(), Font.BOLD, g.getFont().getSize())); + int strHeight = g.getFontMetrics().getAscent(); + + //fill transparent area + g.setColor(new Color(0, 0, 0, 255)); + g.fillRect(0, 0, legendWidth, legendHeight); + + //draw rounded frame around Legend + g.setColor(new Color(0, 0, 0, alpha)); + g.fillRoundRect(1, 1, legendWidth - 2, legendHeight - 2, 7, 7); + g.setColor(lineCol); + g.drawRoundRect(1, 1, legendWidth - 2, legendHeight - 2, 7, 7); + + //now draw text + g.setColor(Color.WHITE); + g.drawString("Download", 32, strHeight + 3); + g.drawString("Upload", 132, strHeight + 3); + + //and the lines before the text + g.setStroke(new BasicStroke((float) 2.0)); + g.setColor(downCol); + g.drawLine(10, (int) (strHeight * 1), 25, (int) (strHeight * 1)); + + g.setColor(upCol); + g.drawLine(110, (int) (strHeight * 1), 125, (int) (strHeight * 1)); + g.dispose(); + } catch (Exception e) { + logger.error("Error painting legend :" + e.getMessage() + "\r\n" + e.getCause()); + } + } + + /** + * + */ + public void drawBackground() { + try { + Graphics2D g = (Graphics2D) backImage.getGraphics(); + if (gradientDirection != BG_NO_GRADIENT) { + g.setPaint(getGradient(gradientDirection, backImage.getHeight(), backImage.getWidth())); + } else + g.setColor(getBGStart()); + + g.fillRect(0, 0, backImage.getWidth(), backImage.getHeight()); + g.dispose(); + } catch (Exception e) { + logger.error("Error painting background :" + e.getMessage() + "\r\n" + e.getCause()); + } + } + + /** + * + */ + private void drawLines() { + try { + int divider = 5; + //setup Scaling for horizontal speedmarks (10 / 5 kBit/s) + //everything above 50 kBit is 10kBit/s or 5kBit/s if below 50kBit. + if ((ud.getMaxDown() / 1024 > 50) || (ud.getMaxUp() / 1024 > 50)) { + divider = 10; + } + int yStep = maxSpeed / divider; + + Graphics2D g = (Graphics2D) image.getGraphics(); + + FontMetrics fm = g.getFontMetrics(); + + //setup format of outtext + NumberFormat nf = NumberFormat.getInstance(); + nf.setMinimumIntegerDigits(3); + + //setup font + int strWidth = fm.stringWidth("XXX -"); + int strHeight = fm.getAscent(); + g.setFont(new Font(g.getFont().getName(), Font.PLAIN, g.getFont().getSize())); + g.drawString("kb/s", 30 - g.getFontMetrics().stringWidth("kb/s "), image.getHeight(null) - strHeight); + + for (int i = 0; i < (yStep) + 1; i++) { + //calculate y-position + int yPos = bottomY - ((bottomY - topY) / (yStep)) * i; + + g.setColor(lineCol); + //set Linestyle to dashed if line is between numbers of 10th + if ((i * divider % 10) != 0) { + float[] dash = {(float) 5.0, (float) 2.0}; + g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, + BasicStroke.JOIN_ROUND, 0, new float[]{0, 0, 0, 6, 0, 0, 0, 6}, 0)); + } else + g.setStroke(new BasicStroke()); + + + //draw horizontal line + g.drawLine(29, yPos, getWidth() - 1, yPos); + + //set color and draw text for speed + g.drawString(nf.format(i * divider), 30 - strWidth, yPos + strHeight / 2); + } + //draw vertical Line + g.setColor(lineCol); + g.setStroke(new BasicStroke()); + g.drawLine(30, topY, 30, bottomY); + + g.dispose(); + } catch (Exception e) { + logger.error("Error drawing lines :" + e.getMessage() + "\r\n" + e.getCause()); + } + + } + + /** + * + */ + private void drawTime(int aktXPos, long time) { + try { + Graphics2D g = (Graphics2D) image.getGraphics(); + + g.setFont(new Font(g.getFont().getName(), g.getFont().getStyle(), 10)); + int strHeight = g.getFontMetrics().getAscent(); + + String actualTime = new SimpleDateFormat("HH:mm").format(new Date(time)); + int strWidth = g.getFontMetrics().stringWidth(actualTime); + g.drawString(actualTime, aktXPos, bottomY + strHeight + 3); + + g.setColor(Color.RED); + float[] dash = {(float) 5.0, (float) 2.0}; + g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, + BasicStroke.JOIN_ROUND, 0, new float[]{0, 0, 0, 6, 0, 0, 0, 6}, 0)); + g.drawLine(aktXPos, topY - 2, aktXPos, bottomY - 2); + g.dispose(); + } catch (Exception e) { + logger.error("Error drawing time :" + e.getMessage() + "\r\n" + e.getCause()); + } + + } + + private void readProperies() { + try { + upCol = parent.getPropertyColor("UploadColor", Color.red); + downCol = parent.getPropertyColor("DownloadColor", Color.blue); + + BGStart = parent.getPropertyColor("GradientStart", Color.white); + BGEnd = parent.getPropertyColor("GradientEnd", Color.darkGray); + + if (!Boolean.parseBoolean(parent.getProperties().getProperty("UseGradient"))) + gradientDirection = BG_NO_GRADIENT; + else + gradientDirection = Integer.parseInt(parent.getProperties().getProperty("GradientDirection")); + + updatePeriod = Integer.parseInt(parent.getProperties().getProperty("UpdateTime", "2000")); + try { + timerThread.schedule(chartTimer, 500, updatePeriod); + } catch (IllegalStateException | IllegalMonitorStateException e) { + System.err.println("Not owner - no wait();"); + } finally { + //timerThread.schedule(chartTimer, 500, updatePeriod); + } + + parent.getProperties().put("changed", "false"); + parent.saveProperties(); + } catch (Exception e) { + logger.error("Error reading Properties :" + e.getMessage() + "\r\n" + e.getCause()); + } + } + + /** + * + */ + private void initializeImages() { + try { + if (image == null) { + try { + if (getWidth() == 0) { + return; + } + if (getHeight() < minChartHeight) { + return; + } + + bottomY = getHeight() - bottomHeight; + maxWidth = getWidth() - 31; + + image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); + //System.out.print("new image("+ image.getWidth(null)+ "," + image.getHeight(null) +")\r\n"); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + if (legendImage == null) { + try { + legendImage = new BufferedImage(legendWidth, legendHeight, BufferedImage.TYPE_INT_ARGB); + drawLegend(legendAlpha); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + if (backImage == null) { + try { + switch (gradientDirection) { + case UpDownChart.BG_DOWN_TO_UP: + case UpDownChart.BG_UP_TO_DOWN: + backImage = new BufferedImage(10, getHeight() - topY, BufferedImage.TYPE_INT_ARGB); + break; + case UpDownChart.BG_LEFT_TO_RIGHT: + case UpDownChart.BG_RIGHT_TO_LEFT: + backImage = new BufferedImage(getWidth() - 31, 10, BufferedImage.TYPE_INT_ARGB); + break; + default: + backImage = new BufferedImage(10, getHeight() - topY, BufferedImage.TYPE_INT_ARGB); + break; + } + //System.out.print("new backImage("+ backImage.getWidth(null)+ "," + backImage.getHeight(null) +")\r\n"); + drawBackground(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + logger.error("Error creating Image :" + e.getMessage() + "\r\n" + e.getCause()); + } + } + + /** + * Generates a gradient in the selected direction of the given BGStart and BGEnd colors. + * The direction may either be one of the following:
+ * BG_LEFT_TO_RIGHT
+ * BG_RIGHT_TO_LEFT
+ * BG_UP_TO_DOWN
+ * BG_DOWN_TO_UP
+ * BG_UPLEFT_TO_DOWNRIGHT
+ * BG_DOWNRIGHT_TO_UPLEFT
+ * BG_UPRIGHT_TO_DOWNLEFT
+ * BG_DOWNLEFT_TO_UPRIGHT
+ * + * @param direction: see above + * @param height: height of the gradient + * @param width: width of the gradient + * @return the GradientPaint of the selected direction and size + */ + private static GradientPaint getGradient(int direction, int height, int width) { + int x1 = 0; + int x2 = 0; + int y1 = 0; + int y2 = 0; + switch (direction) { + case BG_UP_TO_DOWN: + x1 = 1; + x2 = 1; + y1 = height; + y2 = 0; + break; + case BG_DOWN_TO_UP: + x1 = 1; + x2 = 1; + y1 = 0; + y2 = height; + break; + case BG_LEFT_TO_RIGHT: + x1 = 0; + x2 = width; + y1 = 1; + y2 = 1; + break; + case BG_RIGHT_TO_LEFT: + x1 = width; + x2 = 0; + y1 = 1; + y2 = 1; + break; + case BG_UPLEFT_TO_DOWNRIGHT: + x1 = 0; + x2 = width; + y1 = height; + y2 = 0; + break; + case BG_UPRIGHT_TO_DOWNLEFT: + x1 = width; + x2 = 0; + y1 = height; + y2 = 0; + break; + case BG_DOWNLEFT_TO_UPRIGHT: + x1 = 0; + x2 = width; + y1 = 0; + y2 = height; + break; + case BG_DOWNRIGHT_TO_UPLEFT: + x1 = width; + x2 = 0; + y1 = 0; + y2 = height; + break; + case BG_NO_GRADIENT: + x1 = 0; + x2 = 0; + y1 = 0; + y2 = 0; + return null; + } + return new GradientPaint(x1, y1, BGStart, x2, y2, BGEnd); + } + + + /** + * @return Returns the bGEnd. + */ + public Color getBGEnd() { + return BGEnd; + } + + /** + * @param end The bGEnd to set. + */ + public void setBGEnd(Color end) { + BGEnd = end; + } + + /** + * @return Returns the bGStart. + */ + public Color getBGStart() { + return BGStart; + } + + /** + * @param start The bGStart to set. + */ + public void setBGStart(Color start) { + BGStart = start; + } + + /** + * @return Returns the downCol. + */ + public Color getDownCol() { + return downCol; + } + + /** + * @param downCol The downCol to set. + */ + public void setDownCol(Color downCol) { + this.downCol = downCol; + } + + /** + * @return Returns the lineCol. + */ + public Color getLineCol() { + return lineCol; + } + + /** + * @param lineCol The lineCol to set. + */ + public void setLineCol(Color lineCol) { + this.lineCol = lineCol; + } + + /** + * @return Returns the maxSpeed. + */ + public int getMaxSpeed() { + return maxSpeed; + } + + /** + * @param maxSpeed The maxSpeed to set. + */ + public void setMaxSpeed(int maxSpeed) { + this.maxSpeed = maxSpeed; + } + + /** + * @return Returns the image. + */ + public Image getImage() { + return image; + } + + /** + * @return Returns the maxWidth. + */ + public int getMaxWidth() { + return maxWidth; + } + + /** + * @param maxWidth The maxWidth to set. + */ + public void setMaxWidth(int maxWidth) { + this.maxWidth = maxWidth; + } + + /** + * @return Returns the upCol. + */ + public Color getUpCol() { + return upCol; + } + + /** + * @param upCol The upCol to set. + */ + public void setUpCol(Color upCol) { + this.upCol = upCol; + } + + /** + * @return Returns the gradientDirection. + */ + public int getGradientDirection() { + return gradientDirection; + } + + /** + * @param gradientDirection The gradientDirection to set. + */ + public void setGradientDirection(int gradientDirection) { + UpDownChart.gradientDirection = gradientDirection; + } + + /* (non-Javadoc) + * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent evt) { + System.out.println(evt.getPropertyName() + ":" + evt.getOldValue() + "->" + evt.getNewValue()); + } + + +} diff --git a/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownData.java b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownData.java new file mode 100644 index 00000000..df7281fb --- /dev/null +++ b/modules/speedgraph/src/main/java/de/applejuicenet/client/gui/plugins/UpDownData.java @@ -0,0 +1,95 @@ +/* + * Created on 03.01.2004 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package de.applejuicenet.client.gui.plugins; + +import java.util.ArrayList; + + +/** + * @author Zab + *

+ * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class UpDownData { + public class ArrayData { + private long i_up; + private long i_down; + private long i_time; + + public ArrayData(long up, long down, long time) { + i_up = up; + i_down = down; + i_time = time; + } + + public long getUp() { + return i_up; + } + + public long getDown() { + return i_down; + } + + public long getTime() { + return i_time; + } + } + + private ArrayList Data = new ArrayList(); + private long maxDownVal; + private long maxUpVal; + + public UpDownData() { + } + + public UpDownData(int size) { + Data = new ArrayList(size); + } + + public void add(int upRate, int downRate, long time) { + add(upRate, downRate, time); + } + + public void add(long upRate, long downRate, long time) { + Data.add(new ArrayData(upRate, downRate, time)); + if (maxDownVal < downRate) maxDownVal = downRate; + if (maxUpVal < upRate) maxUpVal = upRate; + } + + public void add(Long upRate, Long downRate, long time) { + add(upRate.longValue(), downRate.longValue(), time); + } + + public void clear() { + Data.clear(); + } + + public ArrayData get(int index) { + return (ArrayData) Data.get(index); + } + + public long getMaxUp() { + return maxUpVal; + } + + public long getMaxDown() { + return maxDownVal; + } + + public void remove(int index) { + Data.remove(index); + } + + public Object[] toArray() { + return Data.toArray(); + } + + public int size() { + return Data.size(); + } +} diff --git a/modules/speedgraph/src/main/resources/icon.gif b/modules/speedgraph/src/main/resources/icon.gif new file mode 100644 index 00000000..827d2263 Binary files /dev/null and b/modules/speedgraph/src/main/resources/icon.gif differ diff --git a/modules/speedgraph/src/main/resources/icon2.jpg b/modules/speedgraph/src/main/resources/icon2.jpg new file mode 100644 index 00000000..d303c3ea Binary files /dev/null and b/modules/speedgraph/src/main/resources/icon2.jpg differ diff --git a/modules/speedgraph/src/main/resources/plugin.properties b/modules/speedgraph/src/main/resources/plugin.properties new file mode 100644 index 00000000..a78b6070 --- /dev/null +++ b/modules/speedgraph/src/main/resources/plugin.properties @@ -0,0 +1,7 @@ +general.title=SpeedGraph +general.version=0.9.2 +general.author=Zab0815 +general.contact=zab0815@zab0815.homelinux.org +general.description=SpeedGraph zeigt den Verlauf der Up- und Downloadraten. +general.istab=true +general.classname=de.applejuicenet.client.gui.plugins.SpeedGraphPlugin diff --git a/modules/standardpwdlpolicy/pom.xml b/modules/standardpwdlpolicy/pom.xml new file mode 100644 index 00000000..26886514 --- /dev/null +++ b/modules/standardpwdlpolicy/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + de.applejuicenet.client.gui.plugins + StandardPwdlPolicy + jar + 1.3.1 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + de.applejuicenet.client.gui + AJCoreGUI + 0.85.3 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + ${project.artifactId} + + false + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0 + + + copy.plugins + package + + copy + + + + + ${basedir}/target/${project.artifactId}.jar + ${project.parent.basedir}/resources/pwdlpolicies/${project.artifactId}.jar + + + + + + + + + diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java b/modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java similarity index 95% rename from AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java rename to modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java index 2c3e8067..e3b23786 100644 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java +++ b/modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/EinstellungenDialog.java @@ -1,29 +1,17 @@ package de.applejuicenet.client.gui.powerdownload; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; - import de.applejuicenet.client.gui.powerdownload.StandardAutomaticPwdlPolicy.Reihenfolge; import de.applejuicenet.client.shared.IconManager; import de.applejuicenet.client.shared.NumberAndSpecialCharsInputVerifier; import de.applejuicenet.client.shared.NumberInputVerifier; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + public class EinstellungenDialog extends JDialog implements ActionListener { private static String PROZENT_GELADEN = "prozentGeladen"; @@ -237,4 +225,4 @@ public Reihenfolge[] getReihenfolge() { reihenfolge[3] = Reihenfolge.ID; return reihenfolge; } -} \ No newline at end of file +} diff --git a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java b/modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java similarity index 94% rename from AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java rename to modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java index e6b97cb2..1f42e1bf 100644 --- a/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java +++ b/modules/standardpwdlpolicy/src/main/java/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java @@ -1,24 +1,20 @@ package de.applejuicenet.client.gui.powerdownload; -import java.awt.Frame; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - import de.applejuicenet.client.fassade.ApplejuiceFassade; import de.applejuicenet.client.fassade.entity.Download; import de.applejuicenet.client.fassade.entity.DownloadSource; import de.applejuicenet.client.fassade.exception.IllegalArgumentException; import de.applejuicenet.client.gui.AppleJuiceDialog; +import java.awt.*; +import java.util.List; +import java.util.*; + /** * $Header: * /cvsroot/applejuicejava/AJClientGUI/pwdl_policy_src/standardpwdlpolicy/src/de/applejuicenet/client/gui/powerdownload/StandardAutomaticPwdlPolicy.java,v * 1.17 2005/02/17 22:22:21 loevenwong Exp $ - * + * *

* Titel: AppleJuice Client-GUI *

@@ -29,9 +25,9 @@ *

* Copyright: General Public License *

- * - * @author: Maj0r [aj@tkl-soft.de] - * + * + * @author Maj0r [aj@tkl-soft.de] + * */ public class StandardAutomaticPwdlPolicy extends AutomaticPowerdownloadPolicy { @@ -169,7 +165,7 @@ public void informPaused() { } public String getVersion() { - return "1.3"; + return "1.3.1"; } public String getDescription() { @@ -223,11 +219,11 @@ public Sortierkriterium(Double prozentGeladen, Long groesse, } public Sortierkriterium(Download current) { - this.prozentGeladen = new Double(current.getProzentGeladen()); - this.groesse = new Long(current.getGroesse()); - this.id = new Integer(current.getId()); + this.prozentGeladen = current.getProzentGeladen(); + this.groesse = (long) current.getGroesse(); + this.id = current.getId(); if (current.getSources() != null) { - this.quellenAnzahl = new Integer(current.getSources().length); + this.quellenAnzahl = current.getSources().length; } } diff --git a/modules/tklcontrols/LICENSE.md b/modules/tklcontrols/LICENSE.md new file mode 100644 index 00000000..210895e2 --- /dev/null +++ b/modules/tklcontrols/LICENSE.md @@ -0,0 +1,130 @@ +Mozilla Public License Version 1.1 +1. Definitions. + +1.0.1. "Commercial Use" + means distribution or otherwise making the Covered Code available to a third party. +1.1. "Contributor" + means each entity that creates or contributes to the creation of Modifications. +1.2. "Contributor Version" + means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. +1.3. "Covered Code" + means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. +1.4. "Electronic Distribution Mechanism" + means a mechanism generally accepted in the software development community for the electronic transfer of data. +1.5. "Executable" + means Covered Code in any form other than Source Code. +1.6. "Initial Developer" + means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. +1.7. "Larger Work" + means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. +1.8. "License" + means this document. +1.8.1. "Licensable" + means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. +1.9. "Modifications" + + means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: + + 1. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. + 2. Any new file that contains any part of the Original Code or previous Modifications. + +1.10. "Original Code" + means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. +1.10.1. "Patent Claims" + means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. +1.11. "Source Code" + means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. +1.12. "You" (or "Your") + means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. + +2. Source Code License. +2.1. The Initial Developer Grant. + +The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: + + 1. under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and + 2. under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). + 3. the licenses granted in this Section 2.1 (a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. + 4. Notwithstanding Section 2.1 (b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. + +2.2. Contributor Grant. + +Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license + + 1. under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and + 2. under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). + 3. the licenses granted in Sections 2.2 (a) and 2.2 (b) are effective on the date Contributor first makes Commercial Use of the Covered Code. + 4. Notwithstanding Section 2.2 (b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. + +3. Distribution Obligations. +3.1. Application of License. + +The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. +3.2. Availability of Source Code. + +Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. +3.3. Description of Modifications. + +You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. +3.4. Intellectual Property Matters +(a) Third Party Claims + +If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. +(b) Contributor APIs + +If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the legal file. +(c) Representations. + +Contributor represents that, except as disclosed pursuant to Section 3.4 (a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. +3.5. Required Notices. + +You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. +3.6. Distribution of Executable Versions. + +You may distribute Covered Code in Executable form only if the requirements of Sections 3.1, 3.2, 3.3, 3.4 and 3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. +3.7. Larger Works. + +You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. +4. Inability to Comply Due to Statute or Regulation. + +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the legal file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. +5. Application of this License. + +This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. +6. Versions of the License. +6.1. New Versions + +Netscape Communications Corporation ("Netscape") may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. +6.2. Effect of New Versions + +Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License. +6.3. Derivative Works + +If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) +7. Disclaimer of warranty + +Covered code is provided under this license on an "as is" basis, without warranty of any kind, either expressed or implied, including, without limitation, warranties that the covered code is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the covered code is with you. Should any covered code prove defective in any respect, you (not the initial developer or any other contributor) assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty constitutes an essential part of this license. No use of any covered code is authorized hereunder except under this disclaimer. +8. Termination + +8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. + +8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: + + 1. such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. + 2. any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. + +8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. + +8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. +9. Limitation of liability + +Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall you, the initial developer, any other contributor, or any distributor of covered code, or any supplier of any of such parties, be liable to any person for any indirect, special, incidental, or consequential damages of any character including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to you. +10. U.S. government end users + +The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. +11. Miscellaneous + +This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. +12. Responsibility for claims + +As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. diff --git a/modules/tklcontrols/README.md b/modules/tklcontrols/README.md new file mode 100755 index 00000000..8369c833 --- /dev/null +++ b/modules/tklcontrols/README.md @@ -0,0 +1,3 @@ +TKLControls +version: 1.0 +written by Torsten Krall and Timo Lövenich diff --git a/modules/tklcontrols/pom.xml b/modules/tklcontrols/pom.xml new file mode 100644 index 00000000..8d5f253c --- /dev/null +++ b/modules/tklcontrols/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + de.tklsoft + tklcontrols + jar + 1.0.0 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + + maven-dependency-plugin + + + prepare-package + + copy-dependencies + + + ../../resources/lib/ + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + false + + + + + + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/DelegationObject.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/DelegationObject.java new file mode 100755 index 00000000..a84ca43e --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/DelegationObject.java @@ -0,0 +1,19 @@ +package de.tklsoft.gui.controls; + +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public abstract class DelegationObject { + + public static void notifyPapas(Component ersterPapa, KeyEvent keyEvent) { + for(Object moeglicherFrame = ersterPapa; moeglicherFrame != null; moeglicherFrame = ((Component)moeglicherFrame).getParent()) { + KeyListener[] listeners = ((Component)moeglicherFrame).getKeyListeners(); + + for(int i = 0; i < listeners.length; ++i) { + listeners[i].keyReleased(keyEvent); + } + } + + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/InvalidRule.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/InvalidRule.java new file mode 100755 index 00000000..7e40456d --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/InvalidRule.java @@ -0,0 +1,48 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; + +public interface InvalidRule { + + boolean isInvalid(ModifyableComponent var1); + + public static class NotEmptyInvalidRule implements InvalidRule { + + private static NotEmptyInvalidRule instance = null; + + + public static InvalidRule getInstance() { + if(instance == null) { + instance = new NotEmptyInvalidRule(); + } + + return instance; + } + + public boolean isInvalid(ModifyableComponent aComponent) { + JComponent component = aComponent.getComponent(); + return component instanceof JTextField?((JTextField)component).getText().length() > 0:(component instanceof JComboBox?((JComboBox)component).getSelectedItem() != null:true); + } + + } + + public static class EmptyInvalidRule implements InvalidRule { + + private static EmptyInvalidRule instance = null; + + + public static InvalidRule getInstance() { + if(instance == null) { + instance = new EmptyInvalidRule(); + } + + return instance; + } + + public boolean isInvalid(ModifyableComponent aComponent) { + JComponent component = aComponent.getComponent(); + return component instanceof JTextField?((JTextField)component).getText().length() == 0:(component instanceof JComboBox?((JComboBox)component).getSelectedItem() == null:true); + } + + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/ModifyableComponent.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/ModifyableComponent.java new file mode 100755 index 00000000..45f3859a --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/ModifyableComponent.java @@ -0,0 +1,37 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.beans.PropertyChangeListener; + +public interface ModifyableComponent { + + void addStatusPropertyChangeListener(PropertyChangeListener var1); + + void removeStatusPropertyChangeListener(PropertyChangeListener var1); + + void addInvalidRule(InvalidRule var1); + + void removeInvalidRule(InvalidRule var1); + + void ignoreInvalidRules(boolean var1); + + void resetValidStatus(); + + void fireCheckRules(); + + boolean isInvalid(); + + void ignoreStatus(StatusHolder.STATUSFLAG var1, boolean var2); + + Object getOldValue(); + + void confirmNewValue(); + + JComponent getComponent(); + + boolean isDirty(); + + void resetToOldValue(); + + void disableDirtyComponent(boolean var1); +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/StatusHolder.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/StatusHolder.java new file mode 100755 index 00000000..b1e77728 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/StatusHolder.java @@ -0,0 +1,143 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.controls.border.ModifyableComponentBorder; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class StatusHolder { + + private final ModifyableComponent parentComponent; + private HashSet ignoreStati = new HashSet(); + private STATUSFLAG status; + private ModifyableComponentBorder dirtyBorder; + private Set listeners; + private Set rules; + private boolean ignoreRules; + + + StatusHolder(ModifyableComponent component, int borderWidth) { + this.status = STATUSFLAG.NORMAL; + this.listeners = new HashSet(); + this.rules = new HashSet(); + this.ignoreRules = true; + this.parentComponent = component; + this.dirtyBorder = new ModifyableComponentBorder(component.getComponent(), borderWidth); + component.getComponent().setBorder(this.dirtyBorder); + this.addStatusPropertyChangeListener(this.dirtyBorder); + } + + public void setStatus(STATUSFLAG newStatus) { + PropertyChangeEvent ev = new PropertyChangeEvent(this.parentComponent, "border", this.status, newStatus); + this.status = newStatus; + this.informStatusPropertyChangeListeners(ev); + } + + public STATUSFLAG getStatus() { + return this.status; + } + + public void addStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.listeners.add(propertyChangeListener); + } + + public void removeStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.listeners.remove(propertyChangeListener); + } + + private void informStatusPropertyChangeListeners(PropertyChangeEvent ev) { + Iterator i$ = this.listeners.iterator(); + + while(i$.hasNext()) { + PropertyChangeListener curListener = (PropertyChangeListener)i$.next(); + curListener.propertyChange(ev); + } + + } + + public void addInvalidRule(InvalidRule rule) { + this.rules.add(rule); + } + + public void removeInvalidRule(InvalidRule rule) { + this.rules.remove(rule); + } + + public void ignoreInvalidRules(boolean ignore) { + this.ignoreRules = ignore; + } + + public boolean shouldIgnoreInvalidRules() { + return this.ignoreRules; + } + + public void resetValidStatus() { + this.setStatus(STATUSFLAG.NORMAL); + } + + public void ignoreStatus(STATUSFLAG status, boolean ignore) { + if(ignore) { + this.ignoreStati.add(status); + } else { + this.ignoreStati.remove(status); + } + + } + + public void fireCheckRules() { + if(this.ignoreRules) { + if(!this.ignoreStati.contains(STATUSFLAG.MODIFIED) && this.parentComponent.isDirty()) { + this.setStatus(STATUSFLAG.MODIFIED); + } else { + this.setStatus(STATUSFLAG.NORMAL); + } + + } else if(this.ignoreStati.contains(STATUSFLAG.INVALID)) { + this.setStatus(STATUSFLAG.NORMAL); + } else { + if(this.isInvalid()) { + this.setStatus(STATUSFLAG.INVALID); + } else if(!this.ignoreStati.contains(STATUSFLAG.MODIFIED) && this.parentComponent.isDirty()) { + this.setStatus(STATUSFLAG.MODIFIED); + } else { + this.setStatus(STATUSFLAG.NORMAL); + } + + } + } + + public boolean isInvalid() { + if(this.ignoreRules) { + return false; + } else { + Iterator i$ = this.rules.iterator(); + + InvalidRule curRule; + do { + if(!i$.hasNext()) { + return false; + } + + curRule = (InvalidRule)i$.next(); + } while(!curRule.isInvalid(this.parentComponent)); + + return true; + } + } + + public static enum STATUSFLAG { + + NORMAL("NORMAL", 0), + MODIFIED("MODIFIED", 1), + INVALID("INVALID", 2); + // $FF: synthetic field + private static final STATUSFLAG[] $VALUES = new STATUSFLAG[]{NORMAL, MODIFIED, INVALID}; + + + private STATUSFLAG(String var1, int var2) {} + + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLButton.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLButton.java new file mode 100755 index 00000000..4fd1a94b --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLButton.java @@ -0,0 +1,54 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.layout.Synchronizable; +import de.tklsoft.gui.layout.Synchronizer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLButton extends JButton implements Synchronizable { + + private Synchronizer synchronizer; + + + public TKLButton(String text, Icon icon) { + super(text, icon); + this.synchronizer = null; + this.init(); + } + + public TKLButton(String text) { + this(text, (Icon)null); + } + + public TKLButton(Icon icon) { + this("", icon); + } + + public TKLButton() { + this("", (Icon)null); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLButton.this.getParent(), keyEvent); + } + }); + } + + public void setSynchronizer(Synchronizer synchronizer) { + this.synchronizer = synchronizer; + } + + public Dimension getPreferredSize() { + return this.synchronizer == null?super.getPreferredSize():this.synchronizer.getSize(this); + } + + public Dimension getNormalSize() { + return super.getPreferredSize(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCalendarComboBox.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCalendarComboBox.java new file mode 100755 index 00000000..c324a6b0 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCalendarComboBox.java @@ -0,0 +1,305 @@ +/* + * Decompiled with CFR 0.150. + */ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.controls.calendar.JCalendarPanel; + +import javax.swing.*; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicArrowButton; +import java.awt.*; +import java.awt.event.*; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +public class TKLCalendarComboBox + extends JPanel + implements ActionListener, + AncestorListener, + ChangeListener, + SwingConstants { + private int _popupLocation = 2; + private boolean _calendarWindowFocusLost = false; + private Calendar _selected; + private BasicArrowButton _button; + private JSpinner _spinner = new JSpinner(); + private JWindow _calendarWindow; + private JCalendarPanel _calendarPanel; + private List _changeListener = new ArrayList(); + private boolean _fireingChangeEvent = false; + private boolean _changed = false; + + public TKLCalendarComboBox() { + this._calendarPanel = new JCalendarPanel(); + this.createGUI(); + } + + public TKLCalendarComboBox(Calendar cal) { + this._calendarPanel = new JCalendarPanel(cal); + this.createGUI(); + } + + private void createGUI() { + this._calendarPanel.setListenerModus(2); + this._selected = (Calendar)this._calendarPanel.getCalendar().clone(); + this._calendarPanel.addChangeListener(this); + this._calendarPanel.setBorder(BorderFactory.createLineBorder(Color.black)); + this.setLayout(new BorderLayout()); + this._spinner.setModel(new SpinnerDateModel()); + this._spinner.setEditor(new JSpinner.DateEditor(this._spinner, ((SimpleDateFormat)this._calendarPanel.getDateFormat()).toPattern())); + this._spinner.getModel().setValue(this._selected.getTime()); + this._spinner.setBorder(null); + ((JSpinner.DefaultEditor)this._spinner.getEditor()).getTextField().addFocusListener(new FocusAdapter(){ + + public void focusLost(FocusEvent e) { + if (!TKLCalendarComboBox.this._calendarPanel.getCalendar().getTime().equals(TKLCalendarComboBox.this._spinner.getModel().getValue())) { + Date date = (Date)TKLCalendarComboBox.this._spinner.getModel().getValue(); + TKLCalendarComboBox.this._selected.setTime(date); + TKLCalendarComboBox.this._calendarPanel.setCalendar(TKLCalendarComboBox.this._selected); + TKLCalendarComboBox.this.fireChangeEvent(); + } + } + }); + this._button = new BasicArrowButton(5); + Insets insets = new Insets(this._button.getMargin().top, 0, this._button.getMargin().bottom, 0); + this._button.setMargin(insets); + this._button.addActionListener(this); + this._button.setEnabled(true); + this._button.addFocusListener(new FocusAdapter(){ + + public void focusGained(FocusEvent e) { + JComponent opposite; + if (e.getOppositeComponent() != null && e.getOppositeComponent() instanceof JComponent && (opposite = (JComponent)e.getOppositeComponent()).getTopLevelAncestor() != TKLCalendarComboBox.this._calendarWindow && !TKLCalendarComboBox.this._calendarWindowFocusLost) { + TKLCalendarComboBox.this._calendarWindowFocusLost = false; + } + } + }); + this.add((Component)this._spinner, "Center"); + this.add((Component)this._button, "East"); + this.setBorder(new JTextField().getBorder()); + } + + public Dimension getPreferredSize() { + return new Dimension(120, super.getPreferredSize().height); + } + + private void createCalendarWindow() { + Window ancestor = (Window)this.getTopLevelAncestor(); + this._calendarWindow = new JWindow(ancestor); + JPanel contentPanel = (JPanel)this._calendarWindow.getContentPane(); + contentPanel.setLayout(new BorderLayout()); + contentPanel.add(this._calendarPanel); + ((JComponent)((RootPaneContainer)((Object)ancestor)).getContentPane()).addAncestorListener(this); + ((JComponent)((RootPaneContainer)((Object)ancestor)).getContentPane()).addMouseListener(new MouseAdapter(){ + + public void mouseClicked(MouseEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + }); + this._calendarWindow.addWindowListener(new WindowAdapter(){ + + public void windowDeactivated(WindowEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + }); + this._calendarWindow.addWindowFocusListener(new WindowAdapter(){ + + public void windowLostFocus(WindowEvent e) { + if (TKLCalendarComboBox.this._button.isSelected()) { + TKLCalendarComboBox.this._calendarWindowFocusLost = true; + } + TKLCalendarComboBox.this.hideCalendar(); + } + }); + ancestor.addComponentListener(new ComponentAdapter(){ + + public void componentResized(ComponentEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + + public void componentMoved(ComponentEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + + public void componentShown(ComponentEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + + public void componentHidden(ComponentEvent e) { + TKLCalendarComboBox.this.hideCalendar(); + } + }); + this._calendarWindow.pack(); + } + + public Calendar getCalendar() { + return this._calendarPanel.getCalendar(); + } + + public void setTime(long time) { + Calendar calendar = this._calendarPanel.getCalendar(); + calendar.setTimeInMillis(time); + this.setCalendar(calendar); + } + + public void setCalendar(Calendar cal) { + this._calendarPanel.setCalendar(cal); + this._spinner.getModel().setValue(this._calendarPanel.getCalendar().getTime()); + } + + public JCalendarPanel getCalendarPanel() { + return this._calendarPanel; + } + + public void setPopUpLocation(int location) { + this._popupLocation = location; + } + + public int getPopUpLocation() { + return this._popupLocation; + } + + public void setVerticalAlignment(int value) { + } + + public void setHorizontalAlignment(int value) { + ((JSpinner.DefaultEditor)this._spinner.getEditor()).getTextField().setHorizontalAlignment(value); + } + + public void actionPerformed(ActionEvent e) { + if (this._calendarWindow != null && this._calendarWindow.isVisible()) { + this.hideCalendar(); + } else { + this.showCalender(); + } + } + + public void hideCalendar() { + if (this._calendarWindow.isVisible()) { + this._calendarWindow.setVisible(false); + if (!this._calendarPanel.getCalendar().getTime().equals(this._spinner.getModel().getValue())) { + this._changed = true; + } + if (this._changed) { + this._spinner.getModel().setValue(this._calendarPanel.getCalendar().getTime()); + this._selected = (Calendar)this._calendarPanel.getCalendar().clone(); + this._changed = false; + this.fireChangeEvent(); + } + } + } + + public void showCalender() { + Window ancestor = (Window)this.getTopLevelAncestor(); + if (this._calendarWindow == null || ancestor != this._calendarWindow.getOwner()) { + this.createCalendarWindow(); + } + Date date = (Date)this._spinner.getModel().getValue(); + this._selected.setTime(date); + this._calendarPanel.setCalendar(this._selected); + Point location = this.getLocationOnScreen(); + int x = this._popupLocation == 4 ? (int)location.getX() + this._button.getSize().width - this._calendarWindow.getSize().width : (this._popupLocation == 0 ? (int)location.getX() + (this._button.getSize().width - this._calendarWindow.getSize().width) / 2 : (int)location.getX()); + int y = (int)location.getY() + this._button.getHeight(); + Rectangle screenSize = this.getDesktopBounds(); + if (x < 0) { + x = 0; + } + if (y < 0) { + y = 0; + } + if (x + this._calendarWindow.getWidth() > screenSize.width) { + x = screenSize.width - this._calendarWindow.getWidth(); + } + if (y + 30 + this._calendarWindow.getHeight() > screenSize.height) { + y = (int)location.getY() - this._calendarWindow.getHeight(); + } + this._calendarWindow.setBounds(x, y, this._calendarWindow.getWidth(), this._calendarWindow.getHeight()); + this._calendarWindow.setVisible(true); + } + + private Rectangle getDesktopBounds() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice[] gd = ge.getScreenDevices(); + Rectangle[] screenDeviceBounds = new Rectangle[gd.length]; + Rectangle desktopBounds = new Rectangle(); + for (int i = 0; i < gd.length; ++i) { + GraphicsConfiguration gc = gd[i].getDefaultConfiguration(); + screenDeviceBounds[i] = gc.getBounds(); + desktopBounds = desktopBounds.union(screenDeviceBounds[i]); + } + return desktopBounds; + } + + public void ancestorAdded(AncestorEvent event) { + this.hideCalendar(); + } + + public void ancestorMoved(AncestorEvent event) { + this.hideCalendar(); + } + + public void ancestorRemoved(AncestorEvent event) { + this.hideCalendar(); + } + + public void stateChanged(ChangeEvent e) { + this._changed = true; + this.hideCalendar(); + } + + public void addChangeListener(ChangeListener listener) { + this._changeListener.add(listener); + } + + public void removeChangeListener(ChangeListener listener) { + this._changeListener.remove(listener); + } + + public ChangeListener[] getChangeListener() { + return (ChangeListener[])this._changeListener.toArray(); + } + + protected void fireChangeEvent() { + if (!this._fireingChangeEvent) { + this._fireingChangeEvent = true; + ChangeEvent event = new ChangeEvent(this); + for (ChangeListener cl : this._changeListener) { + cl.stateChanged(event); + } + this._fireingChangeEvent = false; + } + } + + public void setEnabled(boolean enabled) { + this._spinner.setEnabled(enabled); + this._button.setEnabled(enabled); + } + + public boolean isEnabled() { + return this._button.isEnabled(); + } + + public int getPopupLocation() { + return this._popupLocation; + } + + public void setPopupLocation(int location) { + this._popupLocation = location; + } + + public SpinnerDateModel getModel() { + return (SpinnerDateModel)this._spinner.getModel(); + } + + public void setSpinnerDateModel(SpinnerDateModel model) { + this._spinner.setModel(model); + } +} + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCheckBox.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCheckBox.java new file mode 100755 index 00000000..435abf5e --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLCheckBox.java @@ -0,0 +1,122 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.layout.Synchronizable; +import de.tklsoft.gui.layout.Synchronizer; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeListener; + +public class TKLCheckBox extends JCheckBox implements ModifyableComponent, Synchronizable { + + private Synchronizer synchronizer; + private StatusHolder statusHolder; + private boolean oldValue; + + + public TKLCheckBox(String text, boolean selected) { + super(text, selected); + this.synchronizer = null; + this.oldValue = selected; + this.init(); + } + + public TKLCheckBox() { + this("", false); + } + + public TKLCheckBox(String text) { + this(text, false); + } + + private void init() { + this.statusHolder = new StatusHolder(this, 13); + this.setBorderPainted(true); + this.addChangeListener(ce -> TKLCheckBox.this.fireCheckRules()); + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLCheckBox.this.getParent(), keyEvent); + TKLCheckBox.this.fireCheckRules(); + } + }); + } + + public void setSynchronizer(Synchronizer synchronizer) { + this.synchronizer = synchronizer; + } + + public Dimension getPreferredSize() { + return this.synchronizer == null?super.getPreferredSize():this.synchronizer.getSize(this); + } + + public Dimension getNormalSize() { + return super.getPreferredSize(); + } + + public void addStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.addStatusPropertyChangeListener(propertyChangeListener); + } + + public void removeStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.removeStatusPropertyChangeListener(propertyChangeListener); + } + + public void addInvalidRule(InvalidRule rule) { + this.statusHolder.addInvalidRule(rule); + } + + public void removeInvalidRule(InvalidRule rule) { + this.statusHolder.removeInvalidRule(rule); + } + + public void ignoreInvalidRules(boolean ignore) { + this.statusHolder.ignoreInvalidRules(ignore); + } + + public void ignoreStatus(StatusHolder.STATUSFLAG statusFlag, boolean ignore) { + this.statusHolder.ignoreStatus(statusFlag, ignore); + } + + public void resetValidStatus() { + this.statusHolder.resetValidStatus(); + } + + public void fireCheckRules() { + this.statusHolder.fireCheckRules(); + } + + public boolean isInvalid() { + return this.statusHolder.isInvalid(); + } + + public Object getOldValue() { + return this.oldValue; + } + + public void confirmNewValue() { + this.oldValue = this.isSelected(); + this.statusHolder.fireCheckRules(); + } + + public JComponent getComponent() { + return this; + } + + public boolean isDirty() { + return this.oldValue != this.isSelected(); + } + + public void resetToOldValue() { + this.setSelected(this.oldValue); + } + + public void disableDirtyComponent(boolean disable) { + this.statusHolder.ignoreStatus(StatusHolder.STATUSFLAG.MODIFIED, disable); + this.statusHolder.fireCheckRules(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLComboBox.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLComboBox.java new file mode 100755 index 00000000..64e358a2 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLComboBox.java @@ -0,0 +1,149 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.layout.Synchronizable; +import de.tklsoft.gui.layout.Synchronizer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeListener; + +public class TKLComboBox extends JComboBox implements ModifyableComponent, Synchronizable { + + private Synchronizer synchronizer; + private StatusHolder statusHolder; + private Object oldValue; + + + public TKLComboBox(Object[] data) { + super(data); + this.synchronizer = null; + this.oldValue = null; + this.init(); + } + + public TKLComboBox() { + this(new Object[0]); + } + + private void init() { + this.statusHolder = new StatusHolder(this, -1); + this.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange() == 1) { + TKLComboBox.this.fireCheckRules(); + } + + } + }); + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLComboBox.this.getParent(), keyEvent); + } + }); + } + + public void setSelectedItem(Object anObject, boolean ignoreInvalidRules) { + if(ignoreInvalidRules && !this.statusHolder.shouldIgnoreInvalidRules()) { + this.ignoreInvalidRules(true); + super.setSelectedItem(anObject); + this.ignoreInvalidRules(false); + } else { + super.setSelectedItem(anObject); + } + + } + + public void setSelectedItem(Object anObject) { + this.setSelectedItem(anObject, false); + } + + public void addItem(Object anObject) { + if(this.statusHolder.shouldIgnoreInvalidRules()) { + super.addItem(anObject); + } else { + this.ignoreInvalidRules(true); + super.addItem(anObject); + this.ignoreInvalidRules(false); + } + + } + + public void addStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.addStatusPropertyChangeListener(propertyChangeListener); + } + + public void removeStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.removeStatusPropertyChangeListener(propertyChangeListener); + } + + public void addInvalidRule(InvalidRule rule) { + this.statusHolder.addInvalidRule(rule); + } + + public void removeInvalidRule(InvalidRule rule) { + this.statusHolder.removeInvalidRule(rule); + } + + public void ignoreInvalidRules(boolean ignore) { + this.statusHolder.ignoreInvalidRules(ignore); + } + + public void ignoreStatus(StatusHolder.STATUSFLAG statusFlag, boolean ignore) { + this.statusHolder.ignoreStatus(statusFlag, ignore); + } + + public void resetValidStatus() { + this.statusHolder.resetValidStatus(); + } + + public void fireCheckRules() { + this.statusHolder.fireCheckRules(); + } + + public boolean isInvalid() { + return this.statusHolder.isInvalid(); + } + + public void setSynchronizer(Synchronizer synchronizer) { + this.synchronizer = synchronizer; + } + + public Dimension getPreferredSize() { + return this.synchronizer == null?super.getPreferredSize():this.synchronizer.getSize(this); + } + + public Dimension getNormalSize() { + return super.getPreferredSize(); + } + + public Object getOldValue() { + return this.oldValue; + } + + public void confirmNewValue() { + this.oldValue = this.getSelectedItem(); + this.statusHolder.fireCheckRules(); + } + + public JComponent getComponent() { + return this; + } + + public boolean isDirty() { + return this.oldValue != this.getSelectedItem(); + } + + public void resetToOldValue() { + this.setSelectedItem(this.oldValue); + } + + public void disableDirtyComponent(boolean disable) { + this.statusHolder.ignoreStatus(StatusHolder.STATUSFLAG.MODIFIED, disable); + this.statusHolder.fireCheckRules(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLDesktopPane.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLDesktopPane.java new file mode 100755 index 00000000..54fa8aa9 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLDesktopPane.java @@ -0,0 +1,35 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.*; + +public class TKLDesktopPane extends JDesktopPane { + + private int x = 20; + private int xModifier = 0; + private int y = 20; + private Dimension dim = null; + private int width; + private int height; + + + public Rectangle getPreferredPanelRectangle() { + if(this.dim == null) { + this.dim = this.getSize(); + this.width = this.dim.width; + this.height = this.dim.height; + } else { + this.dim = this.getSize(); + } + + if(this.x > this.width / 2 || this.y > this.height / 2) { + this.xModifier += 20; + this.x = 20 + this.xModifier; + this.y = 20; + } + + this.x += 30; + this.y += 30; + return new Rectangle(this.x, this.y, this.width / 3 * 2, this.height / 3 * 2); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorMainMenu.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorMainMenu.java new file mode 100755 index 00000000..281e1020 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorMainMenu.java @@ -0,0 +1,213 @@ +/* + * Decompiled with CFR 0.150. + */ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; + +public class TKLFloorMainMenu { + private final JButton northButton; + private final JButton southButton; + private final MenuPanel menuPanel; + private final String name; + private final TKLFloorTab parent; + + public TKLFloorMainMenu(TKLFloorTab parent, String name) { + this.name = name.toLowerCase(); + this.parent = parent; + this.northButton = new JButton(name); + this.northButton.setBorderPainted(false); + this.northButton.setBackground(Color.LIGHT_GRAY); + this.southButton = new JButton(name); + this.southButton.setBorderPainted(false); + this.southButton.setBackground(Color.LIGHT_GRAY); + MenuButtonListener actionListener = new MenuButtonListener(name, this); + this.northButton.addActionListener(actionListener); + this.southButton.addActionListener(actionListener); + this.menuPanel = new MenuPanel(); + } + + public String getName() { + return this.name; + } + + public void setName(String newName) { + this.northButton.setText(newName); + this.southButton.setText(newName); + } + + JButton getNorthButton() { + return this.northButton; + } + + JButton getSouthButton() { + return this.southButton; + } + + MenuPanel getMenuPanel() { + return this.menuPanel; + } + + public TklFloorButton addIcon(String name, Icon icon, ActionListener actionListener) { + if (this.menuPanel != null) { + return this.menuPanel.addButton(name, icon, actionListener); + } + return null; + } + + private class MenuPanel + extends JPanel { + private final GridBagConstraints gridconst = new GridBagConstraints(); + private int currentMaxY = -1; + private final HashMap buttons = new HashMap(); + + public MenuPanel() { + this.setLayout(new GridBagLayout()); + this.gridconst.anchor = 11; + this.gridconst.fill = 2; + this.gridconst.insets = new Insets(0, 0, 0, 0); + this.gridconst.weightx = 1.0; + this.gridconst.gridx = 0; + this.gridconst.weighty = 1.0; + this.gridconst.gridy = 251; + this.add(new JLabel(), this.gridconst); + this.gridconst.weighty = 0.0; + } + + void renameButton(String oldValue, String newValue) { + Object obj = this.buttons.get(oldValue); + if (obj != null) { + this.buttons.remove(oldValue); + this.buttons.put(newValue, obj); + } + } + + public TklFloorButton addButton(String name, Icon icon, ActionListener actionListener) { + if (name == null || name.length() == 0) { + throw new RuntimeException("Ung\u00fcltiger Name!"); + } + if (icon == null) { + throw new RuntimeException("Ung\u00fcltiges Icon!"); + } + if (actionListener == null) { + throw new RuntimeException("Ung\u00fcltiger ActionListener!"); + } + if (this.buttons.containsKey(name.toLowerCase())) { + throw new RuntimeException("Buttonname '" + name + "' bereits definiert!"); + } + ButtonPanel buttonPanel = new ButtonPanel(name, icon, actionListener); + this.buttons.put(name, buttonPanel); + if (this.currentMaxY >= 249) { + throw new RuntimeException("Maximal 250 Men\u00fceintr\u00e4ge m\u00f6glich!"); + } + ++this.currentMaxY; + this.gridconst.gridy = this.currentMaxY; + this.add(buttonPanel, this.gridconst); + return new TklFloorButton(this, buttonPanel); + } + } + + private class MenuButtonListener implements ActionListener { + private final TKLFloorMainMenu tKLFloorMainMenu; + + public MenuButtonListener(String name, TKLFloorMainMenu tKLFloorMainMenu2) { + String name1 = name.toLowerCase(); + this.tKLFloorMainMenu = tKLFloorMainMenu2; + } + + public void actionPerformed(ActionEvent e) { + TKLFloorMainMenu.this.parent.showMenu(this.tKLFloorMainMenu); + } + } + + private class ButtonPanel extends JPanel { + private final JLabel buttonLabel; + + ButtonPanel(String name, Icon icon, ActionListener actionListener) { + super(new GridBagLayout()); + JLabel button = new JLabel(icon); + button.setPreferredSize(new Dimension(48, 48)); + button.setMinimumSize(new Dimension(48, 48)); + button.addMouseListener(new MouseOverAdapter(actionListener, name)); + button.setBorder(BorderFactory.createLineBorder(button.getBackground())); + GridBagConstraints gridconstint = new GridBagConstraints(); + gridconstint.anchor = 11; + gridconstint.fill = 2; + gridconstint.insets = new Insets(10, 5, 0, 5); + gridconstint.weightx = 1.0; + gridconstint.weighty = 0.0; + gridconstint.gridx = 0; + this.add(new JLabel(), gridconstint); + gridconstint.weightx = 0.0; + gridconstint.gridx = 1; + this.add(button, gridconstint); + gridconstint.gridx = 2; + gridconstint.weightx = 1.0; + this.add(new JLabel(), gridconstint); + gridconstint.weightx = 0.0; + gridconstint.gridx = 0; + gridconstint.gridy = 1; + gridconstint.gridwidth = 3; + gridconstint.insets.top = 0; + this.buttonLabel = new JLabel(name, SwingConstants.CENTER); + this.add(this.buttonLabel, gridconstint); + } + + String getButtonText() { + return this.buttonLabel.getText(); + } + + void setButtonText(String newText) { + this.buttonLabel.setText(newText); + } + } + + private class MouseOverAdapter extends MouseAdapter { + private final ActionListener actionListener; + private final String name; + + public MouseOverAdapter(ActionListener actionListener, String name) { + this.actionListener = actionListener; + this.name = name; + } + + public void mouseEntered(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + source.setBorder(BorderFactory.createLineBorder(Color.black)); + } + + public void mouseClicked(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + if (this.actionListener != null) { + this.actionListener.actionPerformed(new ActionEvent(source, 0, this.name)); + } + } + + public void mouseExited(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + source.setBorder(BorderFactory.createLineBorder(source.getBackground())); + } + } + + public class TklFloorButton { + private final ButtonPanel buttonPanel; + private final MenuPanel parent; + + TklFloorButton(MenuPanel parent, ButtonPanel buttonPanel) { + this.buttonPanel = buttonPanel; + this.parent = parent; + } + + public void setText(String newText) { + this.parent.renameButton(this.buttonPanel.getButtonText(), newText); + this.buttonPanel.setButtonText(newText); + } + } +} + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorTab.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorTab.java new file mode 100755 index 00000000..a74325c2 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFloorTab.java @@ -0,0 +1,98 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +public class TKLFloorTab extends JPanel { + + private final JPanel northPanel = new JPanel(new GridBagLayout()); + private final JPanel southPanel = new JPanel(new GridBagLayout()); + private final CardLayout cardLayout = new CardLayout(); + private final JPanel centerPanel; + private final ArrayList mainMenuButtons; + private final HashMap yIndizes; + private final GridBagConstraints constraints; + private int maxY; + + + public TKLFloorTab() { + this.centerPanel = new JPanel(this.cardLayout); + this.mainMenuButtons = new ArrayList<>(); + this.yIndizes = new HashMap<>(); + this.constraints = new GridBagConstraints(); + this.maxY = -1; + this.setLayout(new BorderLayout()); + this.add(this.northPanel, "North"); + this.add(this.southPanel, "South"); + this.add(this.centerPanel, "Center"); + this.constraints.anchor = 11; + this.constraints.fill = 1; + this.constraints.insets = new Insets(0, 0, 0, 0); + this.constraints.weightx = 1.0D; + this.constraints.weighty = 0.0D; + this.constraints.gridx = 0; + } + + public void showMenu(TKLFloorMainMenu tKLFloorMainMenu) { + String name = tKLFloorMainMenu.getName(); + if(name != null && name.length() != 0) { + Integer indexTmp = this.yIndizes.get(name.toLowerCase()); + if(indexTmp != null) { + int index = indexTmp; + + for(int i = 0; i < this.yIndizes.size(); ++i) { + JButton northButton = (this.mainMenuButtons.get(i)).getNorthButton(); + northButton.setSelected(false); + JButton southButton = (this.mainMenuButtons.get(i)).getSouthButton(); + southButton.setSelected(false); + if(i <= index) { + northButton.setVisible(true); + if(i != index) { + northButton.setBackground(Color.LIGHT_GRAY); + } else { + northButton.setBackground(Color.WHITE); + } + + southButton.setVisible(false); + } else { + northButton.setVisible(false); + southButton.setVisible(true); + } + } + + this.cardLayout.show(this.centerPanel, name.toLowerCase()); + } + + } + } + + public void addMenu(TKLFloorMainMenu tKLFloorMainMenu) { + String name = tKLFloorMainMenu.getName(); + Iterator northButton = this.mainMenuButtons.iterator(); + + TKLFloorMainMenu southButton; + do { + if(!northButton.hasNext()) { + JButton northButton1 = tKLFloorMainMenu.getNorthButton(); + JButton southButton1 = tKLFloorMainMenu.getSouthButton(); + ++this.maxY; + this.constraints.gridy = this.maxY; + northButton1.setVisible(false); + this.northPanel.add(northButton1, this.constraints); + this.southPanel.add(southButton1, this.constraints); + northButton1.setVisible(false); + this.mainMenuButtons.add(tKLFloorMainMenu); + this.yIndizes.put(name.toLowerCase(), this.maxY); + this.centerPanel.add(name.toLowerCase(), tKLFloorMainMenu.getMenuPanel()); + return; + } + + southButton = northButton.next(); + } while(!southButton.getName().equalsIgnoreCase(name)); + + throw new RuntimeException("Menüname '" + name + "' bereits definiert!"); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFrame.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFrame.java new file mode 100755 index 00000000..e6c3de2d --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLFrame.java @@ -0,0 +1,39 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +public class TKLFrame extends JFrame { + + private WindowListener closeWindowListener; + + + public TKLFrame() { + this(""); + } + + public TKLFrame(String title) { + super(title); + this.closeWindowListener = new WindowAdapter() { + public void windowClosing(WindowEvent e) { + TKLFrame.this.closeFrame(0); + } + }; + this.addWindowListener(this.closeWindowListener); + } + + protected void closeFrame(int i) { + System.exit(i); + } + + public void enableCloseWindowListener(boolean enable) { + if(enable) { + this.addWindowListener(this.closeWindowListener); + } else { + this.removeWindowListener(this.closeWindowListener); + } + + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLLabel.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLLabel.java new file mode 100755 index 00000000..ac89ae82 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLLabel.java @@ -0,0 +1,38 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLLabel extends JLabel { + + public TKLLabel(String text, Icon image) { + super(text, image, 0); + this.init(); + } + + public TKLLabel(String text) { + this(text, (Icon)null); + } + + public TKLLabel(Icon image) { + this("", image); + } + + public TKLLabel() { + this("", (Icon)null); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLLabel.this.getParent(), keyEvent); + } + }); + } + + public void enableBorder() { + this.setBorder(BorderFactory.createEtchedBorder()); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPanel.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPanel.java new file mode 100755 index 00000000..a22e70a0 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPanel.java @@ -0,0 +1,13 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.*; + +public class TKLPanel extends JPanel { + + public TKLPanel() {} + + public TKLPanel(LayoutManager layoutManager) { + super(layoutManager); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPasswordField.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPasswordField.java new file mode 100755 index 00000000..a81c8c2c --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLPasswordField.java @@ -0,0 +1,50 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.layout.Synchronizable; +import de.tklsoft.gui.layout.Synchronizer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLPasswordField extends JPasswordField implements Synchronizable { + + private Synchronizer synchronizer = null; + private boolean dirty = false; + + + public TKLPasswordField() { + this.init(); + } + + public boolean isDirty() { + return this.dirty; + } + + public void resetDirtyFlag() { + this.dirty = false; + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + TKLPasswordField.this.dirty = true; + DelegationObject.notifyPapas(TKLPasswordField.this.getParent(), keyEvent); + } + }); + } + + public void setSynchronizer(Synchronizer synchronizer) { + this.synchronizer = synchronizer; + } + + public Dimension getPreferredSize() { + return this.synchronizer == null?super.getPreferredSize():this.synchronizer.getSize(this); + } + + public Dimension getNormalSize() { + return super.getPreferredSize(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLRadioButton.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLRadioButton.java new file mode 100755 index 00000000..d0d8bff4 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLRadioButton.java @@ -0,0 +1,22 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLRadioButton extends JRadioButton { + + public TKLRadioButton(String schluesselname) { + super(schluesselname); + this.init(); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLRadioButton.this.getParent(), keyEvent); + } + }); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLSlider.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLSlider.java new file mode 100755 index 00000000..694fd296 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLSlider.java @@ -0,0 +1,22 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLSlider extends JSlider { + + public TKLSlider(int min, int max, int value) { + super(min, max, value); + this.init(); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLSlider.this.getParent(), keyEvent); + } + }); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTable.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTable.java new file mode 100755 index 00000000..412a798c --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTable.java @@ -0,0 +1,27 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import javax.swing.table.TableModel; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLTable extends JTable { + + public TKLTable() { + this.init(); + } + + public TKLTable(TableModel tableModel) { + super(tableModel); + this.init(); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLTable.this.getParent(), keyEvent); + } + }); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextArea.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextArea.java new file mode 100755 index 00000000..cd87dfb5 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextArea.java @@ -0,0 +1,30 @@ +package de.tklsoft.gui.controls; + +import javax.swing.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class TKLTextArea extends JTextArea { + + public TKLTextArea(String text) { + super(text); + this.init(); + } + + public TKLTextArea() { + this(""); + } + + private void init() { + this.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLTextArea.this.getParent(), keyEvent); + } + }); + } + + public void enableBorder() { + this.setBorder(BorderFactory.createEtchedBorder()); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextField.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextField.java new file mode 100755 index 00000000..bf15bd47 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/TKLTextField.java @@ -0,0 +1,123 @@ +package de.tklsoft.gui.controls; + +import de.tklsoft.gui.layout.Synchronizable; +import de.tklsoft.gui.layout.Synchronizer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeListener; + +public class TKLTextField extends JTextField implements ModifyableComponent, Synchronizable { + + private Synchronizer synchronizer = null; + private StatusHolder statusHolder; + private String oldValue = ""; + + + public TKLTextField() { + this.init(); + } + + public TKLTextField(int columncount) { + super(columncount); + this.init(); + } + + public TKLTextField(String text) { + super(text); + this.oldValue = text; + this.init(); + } + + private void init() { + this.statusHolder = new StatusHolder(this, -1); + this.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if((e.isMetaDown() || e.isControlDown()) && e.getKeyCode() == KeyEvent.VK_Z) { + TKLTextField.this.setText(TKLTextField.this.oldValue); + } + } + public void keyReleased(KeyEvent keyEvent) { + super.keyReleased(keyEvent); + DelegationObject.notifyPapas(TKLTextField.this.getParent(), keyEvent); + TKLTextField.this.fireCheckRules(); + } + }); + } + + public void addStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.addStatusPropertyChangeListener(propertyChangeListener); + } + + public void removeStatusPropertyChangeListener(PropertyChangeListener propertyChangeListener) { + this.statusHolder.removeStatusPropertyChangeListener(propertyChangeListener); + } + + public void addInvalidRule(InvalidRule rule) { + this.statusHolder.addInvalidRule(rule); + } + + public void removeInvalidRule(InvalidRule rule) { + this.statusHolder.removeInvalidRule(rule); + } + + public void ignoreInvalidRules(boolean ignore) { + this.statusHolder.ignoreInvalidRules(ignore); + } + + public void ignoreStatus(StatusHolder.STATUSFLAG statusFlag, boolean ignore) { + this.statusHolder.ignoreStatus(statusFlag, ignore); + } + + public void resetValidStatus() { + this.statusHolder.resetValidStatus(); + } + + public void fireCheckRules() { + this.statusHolder.fireCheckRules(); + } + + public boolean isInvalid() { + return this.statusHolder.isInvalid(); + } + + public void setSynchronizer(Synchronizer synchronizer) { + this.synchronizer = synchronizer; + } + + public Dimension getPreferredSize() { + return this.synchronizer == null?super.getPreferredSize():this.synchronizer.getSize(this); + } + + public Dimension getNormalSize() { + return super.getPreferredSize(); + } + + public Object getOldValue() { + return this.oldValue; + } + + public void confirmNewValue() { + this.oldValue = this.getText(); + this.statusHolder.fireCheckRules(); + } + + public void resetToOldValue() { + this.setText(this.oldValue); + } + + public JComponent getComponent() { + return this; + } + + public boolean isDirty() { + return !this.oldValue.equals(this.getText()); + } + + public void disableDirtyComponent(boolean disable) { + this.statusHolder.ignoreStatus(StatusHolder.STATUSFLAG.MODIFIED, disable); + this.statusHolder.fireCheckRules(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/border/ModifyableComponentBorder.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/border/ModifyableComponentBorder.java new file mode 100755 index 00000000..51560191 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/border/ModifyableComponentBorder.java @@ -0,0 +1,110 @@ +/* + * Decompiled with CFR 0.150. + */ +package de.tklsoft.gui.controls.border; + +import de.tklsoft.gui.controls.StatusHolder; +import de.tklsoft.icon.IconManager; + +import javax.swing.*; +import javax.swing.border.AbstractBorder; +import javax.swing.border.Border; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +public class ModifyableComponentBorder + extends AbstractBorder + implements PropertyChangeListener { + public static final String BORDER_STATUS_CHANGED = "border"; + private static Icon invalidIcon = IconManager.getInstance().getIcon("border_invalid"); + private final JComponent parentComponent; + private final Insets insets; + private int[] colors = new int[]{255, 0, 0}; + private Color currentColor = new Color(this.colors[0], this.colors[1], this.colors[2]); + private Border notDirtyBorder; + private int increment = 20; + private Timer timer; + private StatusHolder.STATUSFLAG status = StatusHolder.STATUSFLAG.NORMAL; + private Color modifiedColor = Color.BLUE; + private final int borderWidth; + private boolean hasToEnableBorder = false; + + public ModifyableComponentBorder(JComponent parentComponent, int borderWidth) { + this.parentComponent = parentComponent; + this.borderWidth = borderWidth; + this.notDirtyBorder = parentComponent.getBorder(); + if (this.notDirtyBorder != null) { + this.insets = this.notDirtyBorder.getBorderInsets(parentComponent); + this.hasToEnableBorder = true; + } else { + this.notDirtyBorder = BorderFactory.createLineBorder(parentComponent.getBackground(), 2); + this.insets = new Insets(1, 1, 1, 1); + } + this.init(); + } + + public ModifyableComponentBorder(JComponent parentComponent) { + this(parentComponent, -1); + } + + private void init() { + this.timer = new Timer(100, e -> { + if (ModifyableComponentBorder.this.parentComponent.isShowing()) { + ModifyableComponentBorder.this.currentColor = new Color(ModifyableComponentBorder.this.colors[0], ModifyableComponentBorder.this.colors[1], ModifyableComponentBorder.this.colors[2]); + int[] arrn = ModifyableComponentBorder.this.colors; + arrn[1] = arrn[1] + ModifyableComponentBorder.this.increment; + int[] arrn2 = ModifyableComponentBorder.this.colors; + arrn2[2] = arrn2[2] + ModifyableComponentBorder.this.increment; + if (ModifyableComponentBorder.this.colors[1] >= 240 || ModifyableComponentBorder.this.colors[1] == 0) { + ModifyableComponentBorder.this.increment = -ModifyableComponentBorder.this.increment; + } + ModifyableComponentBorder.this.parentComponent.repaint(); + } + }); + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (this.status == StatusHolder.STATUSFLAG.NORMAL) { + this.notDirtyBorder.paintBorder(c, g, x, y, width, height); + } else if (this.status == StatusHolder.STATUSFLAG.MODIFIED) { + this.drawBorder(this.modifiedColor, g, x, y, this.borderWidth == -1 ? width : this.borderWidth, height); + } else { + this.drawBorder(this.currentColor, g, x, y, this.borderWidth == -1 ? width : this.borderWidth, height); + invalidIcon.paintIcon(c, g, width - invalidIcon.getIconWidth() - this.insets.right - 2, this.insets.top + 2); + } + } + + private void drawBorder(Color color, Graphics g, int x, int y, int width, int height) { + Color tmpcolor = g.getColor(); + g.setColor(color); + g.drawRect(x, y, width - 1, height - 1); + g.drawRect(x + 1, y + 1, width - 3, height - 3); + g.setColor(tmpcolor); + } + + public Insets getBorderInsets(Component c) { + if (this.status == StatusHolder.STATUSFLAG.NORMAL) { + return this.notDirtyBorder.getBorderInsets(c); + } + if (this.status == StatusHolder.STATUSFLAG.MODIFIED) { + return this.insets; + } + return this.insets; + } + + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getSource() == this.parentComponent && evt.getPropertyName().equals(BORDER_STATUS_CHANGED)) { + this.status = (StatusHolder.STATUSFLAG)((Object)evt.getNewValue()); + if (this.status == StatusHolder.STATUSFLAG.INVALID && !this.timer.isRunning()) { + this.timer.start(); + } else if (this.status != StatusHolder.STATUSFLAG.INVALID && this.timer.isRunning()) { + this.timer.stop(); + } + this.parentComponent.repaint(); + } + } +} + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/DayLabel.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/DayLabel.java new file mode 100755 index 00000000..6460aaac --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/DayLabel.java @@ -0,0 +1,61 @@ +package de.tklsoft.gui.controls.calendar; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class DayLabel extends FlatButton implements ActionListener { + + private boolean _today; + private JMonthPanel _monthPanel; + private int _day; + private boolean _selected = false; + + + public DayLabel(int day, boolean today, JMonthPanel monthPanel) { + super(Integer.toString(day)); + this._today = today; + if(this._today) { + super.setBorder(BorderFactory.createEtchedBorder()); + } + + this.setBackground(JMonthPanel.BACKGROUND_COLOR); + this.addActionListener(this); + this._day = day; + this._monthPanel = monthPanel; + this.setHorizontalAlignment(4); + } + + public void setBorder(Border border) { + if(this._today) { + super.setBorder(BorderFactory.createEtchedBorder()); + } else { + super.setBorder(border); + } + + } + + public void setSelected(boolean selected) { + this._selected = selected; + if(this._selected) { + this.setOpaque(true); + this.setBackground(JMonthPanel.SELECTED_BACKGROUND_COLOR); + this.setForeground(JMonthPanel.SELECTED_FONT_COLOR); + } else { + this.setOpaque(false); + this.setBackground(JMonthPanel.BACKGROUND_COLOR); + this.setForeground(JMonthPanel.FONT_COLOR); + } + + } + + public boolean isSelected() { + return this._selected; + } + + public void actionPerformed(ActionEvent e) { + this._monthPanel.setSelectedDayOfMonth(this._day); + this.requestFocus(); + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/FlatButton.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/FlatButton.java new file mode 100755 index 00000000..823e6de0 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/FlatButton.java @@ -0,0 +1,50 @@ +package de.tklsoft.gui.controls.calendar; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +public class FlatButton extends JButton implements FocusListener, MouseListener { + + private final Border _focus = BorderFactory.createEtchedBorder(); + private final Border _withoutfocus = BorderFactory.createEmptyBorder(2, 2, 2, 2); + + + public FlatButton(String text) { + super(text); + this.setBorder(this._withoutfocus); + if(UIManager.getLookAndFeel().getClass().toString().startsWith("class com.jgoodies")) { + this.setOpaque(false); + } else { + this.setContentAreaFilled(false); + } + + this.addFocusListener(this); + this.addMouseListener(this); + } + + public void focusGained(FocusEvent e) { + this.setBorder(this._focus); + } + + public void focusLost(FocusEvent e) { + this.setBorder(this._withoutfocus); + } + + public void mouseClicked(MouseEvent e) {} + + public void mouseEntered(MouseEvent e) { + this.setBorder(this._focus); + } + + public void mouseExited(MouseEvent e) { + this.setBorder(this._withoutfocus); + } + + public void mousePressed(MouseEvent e) {} + + public void mouseReleased(MouseEvent e) {} +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarDialog.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarDialog.java new file mode 100755 index 00000000..b0f85c8d --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarDialog.java @@ -0,0 +1,76 @@ +package de.tklsoft.gui.controls.calendar; + +import de.tklsoft.gui.controls.TKLCalendarComboBox; + +import javax.swing.*; +import java.awt.*; +import java.util.Calendar; + +public class JCalendarDialog { + + private Component _parentComponent; + private String _title; + private String _message; + private TKLCalendarComboBox _calendarBox; + private int _optionType; + private int _messageType; + + + public JCalendarDialog(Component parentComponent, String title, String message) { + this._parentComponent = parentComponent; + this._title = title; + this._message = message; + this._calendarBox = new TKLCalendarComboBox(); + this._optionType = 2; + this._messageType = 3; + } + + public JCalendarDialog(Component parentComponent, String title, String message, TKLCalendarComboBox calendarBox) { + this._parentComponent = parentComponent; + this._title = title; + this._message = message; + this._calendarBox = calendarBox; + this._optionType = 2; + this._messageType = 3; + } + + public JCalendarDialog(Component parentComponent, String title, String message, TKLCalendarComboBox calendarBox, int optionType, int messageType) { + this._parentComponent = parentComponent; + this._title = title; + this._message = message; + this._calendarBox = calendarBox; + this._optionType = optionType; + this._messageType = messageType; + } + + public JCalendarDialog(Component parentComponent, String title, String message, int optionType, int messageType) { + this._parentComponent = parentComponent; + this._title = title; + this._message = message; + this._optionType = optionType; + this._messageType = messageType; + this._calendarBox = new TKLCalendarComboBox(); + } + + public Calendar getCalendar() { + return this.getCalendar(0); + } + + public Calendar getCalendar(int messageOption) { + return this.showConfirmDialog() == messageOption?this._calendarBox.getCalendar():null; + } + + private int showConfirmDialog() { + new JTextField(); + JPanel calPanel = new JPanel(); + FlowLayout layout = new FlowLayout(); + layout.setAlignment(0); + layout.setHgap(0); + layout.setVgap(0); + calPanel.setLayout(layout); + calPanel.add(this._calendarBox); + Object[] msg = new Object[]{this._message, calPanel}; + int result = JOptionPane.showConfirmDialog(this._parentComponent, msg, this._title, this._optionType, this._messageType); + return result; + } +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarPanel.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarPanel.java new file mode 100755 index 00000000..f33aa08a --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JCalendarPanel.java @@ -0,0 +1,308 @@ +/* + * Decompiled with CFR 0.150. + */ +package de.tklsoft.gui.controls.calendar; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Locale; + +public class JCalendarPanel + extends JPanel + implements ItemListener, + ChangeListener { + public static final int FIRE_EVERYTIME = 1; + public static final int FIRE_DAYCHANGES = 2; + private int _listenermode = 1; + private boolean _updating = false; + private Calendar _cal; + private DateFormat _format; + private Locale _locale; + private JComboBox _month; + private JComboBox _year; + private JMonthPanel _monthPanel; + private ArrayList _changeListener = new ArrayList(); + private boolean _fireingChangeEvent = false; + + public JCalendarPanel() { + this.createGUI(Calendar.getInstance(), Locale.getDefault(), DateFormat.getDateInstance(2, Locale.getDefault()), true); + } + + public JCalendarPanel(Calendar cal) { + this.createGUI(cal, Locale.getDefault(), DateFormat.getDateInstance(2, Locale.getDefault()), true); + } + + public JCalendarPanel(Locale locale) { + this.createGUI(Calendar.getInstance(locale), locale, DateFormat.getDateInstance(2, locale), true); + } + + public JCalendarPanel(Calendar cal, Locale locale) { + this.createGUI(cal, locale, DateFormat.getDateInstance(2, locale), true); + } + + public JCalendarPanel(Calendar cal, Locale locale, DateFormat dateFormat) { + this.createGUI(cal, locale, dateFormat, true); + } + + public JCalendarPanel(Calendar cal, Locale locale, DateFormat dateFormat, boolean flat) { + this.createGUI(cal, locale, dateFormat, flat); + } + + private void createGUI(Calendar cal, Locale locale, DateFormat dateFormat, boolean flat) { + this._locale = locale; + this._cal = Calendar.getInstance(locale); + this._cal.set(5, cal.get(5)); + this._cal.set(2, cal.get(2)); + this._cal.set(1, cal.get(1)); + this._format = dateFormat; + this.setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + this._month = this.createMonth(); + this._month.addItemListener(this); + this.add((Component)this._month, c); + this._year = this.createYear(); + this._year.addItemListener(this); + c.gridwidth = 0; + this.add((Component)this._year, c); + c.anchor = 10; + c.fill = 1; + c.insets = new Insets(1, 1, 1, 1); + this._monthPanel = new JMonthPanel(this._cal, this._locale); + this._monthPanel.addChangeListener(this); + this.add((Component)this._monthPanel, c); + c.insets = new Insets(0, 0, 1, 0); + this.add((Component)this.createButtonPanel(flat), c); + this._monthPanel.grabFocus(); + } + + private JPanel createButtonPanel(boolean flat) { + JButton yearRight; + JButton dayRight; + JButton today; + JButton dayLeft; + JButton yearLeft; + JPanel buttonpanel = new JPanel(); + if (flat) { + yearLeft = new FlatButton("<<"); + dayLeft = new FlatButton("<"); + today = new FlatButton("Heute"); + dayRight = new FlatButton(">"); + yearRight = new FlatButton(">>"); + } else { + yearLeft = new JButton("<<"); + yearLeft.setMargin(new Insets(1, 1, 1, 1)); + dayLeft = new JButton("<"); + dayLeft.setMargin(new Insets(1, 1, 1, 1)); + today = new JButton("Heute"); + today.setMargin(new Insets(2, 2, 2, 2)); + dayRight = new JButton(">"); + dayRight.setMargin(new Insets(1, 1, 1, 1)); + yearRight = new JButton(">>"); + yearRight.setMargin(new Insets(1, 1, 1, 1)); + } + buttonpanel.setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + c.fill = 0; + c.insets = new Insets(0, 0, 0, 5); + yearLeft.setMargin(new Insets(1, 1, 1, 1)); + yearLeft.setToolTipText("Letztes Jahr"); + yearLeft.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + if (JCalendarPanel.this._year.getSelectedIndex() > 0) { + int month = JCalendarPanel.this._cal.get(2); + JCalendarPanel.this._cal.set(1, JCalendarPanel.this._cal.get(1) - 1); + if (JCalendarPanel.this._cal.get(2) != month) { + JCalendarPanel.this._cal.set(2, month); + } + JCalendarPanel.this.setCalendar(JCalendarPanel.this._cal); + } + } + }); + buttonpanel.add((Component)yearLeft, c); + dayLeft.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + int monthIndex = JCalendarPanel.this._cal.get(2); + JCalendarPanel.this._cal.set(2, monthIndex - 1); + if (JCalendarPanel.this._cal.get(2) == monthIndex) { + JCalendarPanel.this._cal.set(5, 0); + } + JCalendarPanel.this.setCalendar(JCalendarPanel.this._cal); + } + }); + dayLeft.setMargin(new Insets(1, 1, 1, 1)); + dayLeft.setToolTipText("N\u00e4chstes Jahr"); + buttonpanel.add((Component)dayLeft, c); + GridBagConstraints c2 = new GridBagConstraints(); + c2.fill = 2; + c2.weightx = 1.0; + today.setMargin(new Insets(2, 2, 2, 2)); + today.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + JCalendarPanel.this.setCalendar(Calendar.getInstance()); + } + }); + buttonpanel.add((Component)today, c2); + c.insets = new Insets(0, 5, 0, 0); + dayRight.setMargin(new Insets(1, 1, 1, 1)); + dayRight.setToolTipText("N\u00e4chster Monate"); + dayRight.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + int monthIndex = JCalendarPanel.this._cal.get(2); + JCalendarPanel.this._cal.set(2, monthIndex + 1); + if (JCalendarPanel.this._cal.get(2) != (monthIndex + 1) % 12) { + JCalendarPanel.this._cal.set(5, 0); + } + JCalendarPanel.this.setCalendar(JCalendarPanel.this._cal); + } + }); + buttonpanel.add((Component)dayRight, c); + yearRight.setMargin(new Insets(1, 1, 1, 1)); + yearRight.setToolTipText("N\u00e4chstes Jahr"); + yearRight.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + if (JCalendarPanel.this._year.getSelectedIndex() < JCalendarPanel.this._year.getItemCount() - 1) { + int month = JCalendarPanel.this._cal.get(2); + JCalendarPanel.this._cal.set(1, JCalendarPanel.this._cal.get(1) + 1); + if (JCalendarPanel.this._cal.get(2) != month) { + JCalendarPanel.this._cal.set(2, month); + } + JCalendarPanel.this.setCalendar(JCalendarPanel.this._cal); + } + } + }); + buttonpanel.add((Component)yearRight, c); + return buttonpanel; + } + + private JComboBox createYear() { + JComboBox year = new JComboBox(); + for (int i = 1900; i <= 2100; ++i) { + year.addItem("" + i); + } + year.setSelectedIndex(this._cal.get(1) - 1900); + return year; + } + + private JComboBox createMonth() { + JComboBox month = new JComboBox(); + SimpleDateFormat format = new SimpleDateFormat("MMMMM", this._locale); + Calendar currentCal = Calendar.getInstance(this._locale); + currentCal.set(5, 1); + for (int i = 0; i < 12; ++i) { + currentCal.set(2, i); + currentCal.set(1, this._cal.get(1)); + String myString = format.format(currentCal.getTime()); + month.addItem(myString); + } + month.setSelectedIndex(this._cal.get(2)); + return month; + } + + private void updateCalendar() { + if (!this._updating) { + this._updating = true; + this._cal.set(2, this._month.getSelectedIndex()); + this._cal.set(1, this._year.getSelectedIndex() + 1900); + this._cal.set(5, this._monthPanel.getSelectedDayOfMonth()); + this._monthPanel.setCalendar(this._cal); + this._monthPanel.grabFocus(); + this._updating = false; + } + } + + public Calendar getCalendar() { + this.updateCalendar(); + return this._cal; + } + + public void setCalendar(Calendar cal) { + this._updating = true; + this._cal.set(5, cal.get(5)); + this._cal.set(2, cal.get(2)); + this._cal.set(1, cal.get(1)); + this._monthPanel.setCalendar(this._cal); + this._year.setSelectedIndex(this._cal.get(1) - 1900); + this._month.setSelectedIndex(this._cal.get(2)); + this._monthPanel.grabFocus(); + this._updating = false; + } + + public String toString() { + this.updateCalendar(); + return this._format.format(this._cal.getTime()); + } + + public String toString(DateFormat format) { + this.updateCalendar(); + return format.format(this._cal.getTime()); + } + + public void itemStateChanged(ItemEvent e) { + this.updateCalendar(); + if (this._listenermode == 1) { + this.fireChangeEvent(); + } + } + + public void stateChanged(ChangeEvent e) { + this.updateCalendar(); + this.fireChangeEvent(); + } + + public void addChangeListener(ChangeListener listener) { + this._changeListener.add(listener); + } + + public void removeChangeListener(ChangeListener listener) { + this._changeListener.remove(listener); + } + + public ChangeListener[] getChangeListener() { + return (ChangeListener[])this._changeListener.toArray(); + } + + protected void fireChangeEvent() { + if (!this._fireingChangeEvent) { + this._fireingChangeEvent = true; + ChangeEvent event = new ChangeEvent(this); + for (ChangeListener cl : this._changeListener) { + cl.stateChanged(event); + } + this._fireingChangeEvent = false; + } + } + + public void setListenerModus(int mode) { + this._listenermode = mode; + } + + public void setEnabled(boolean enabled) { + this._month.setEnabled(enabled); + this._year.setEnabled(enabled); + this._monthPanel.setEnabled(enabled); + } + + public boolean isEnabled() { + return this._month.isEnabled(); + } + + public DateFormat getDateFormat() { + return this._format; + } +} + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JMonthPanel.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JMonthPanel.java new file mode 100755 index 00000000..cd9742a3 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/controls/calendar/JMonthPanel.java @@ -0,0 +1,220 @@ +package de.tklsoft.gui.controls.calendar; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Iterator; +import java.util.Locale; + +public class JMonthPanel extends JPanel { + + private boolean _enabled = true; + private Calendar _cal; + private Locale _locale; + private ArrayList _days; + private ArrayList _changeListener = new ArrayList<>(); + private boolean _fireingChangeEvent = false; + public static final Color BACKGROUND_COLOR = UIManager.getColor("TextField.background"); + public static final Color FONT_COLOR = UIManager.getColor("TextField.foreground"); + public static final Color SELECTED_BACKGROUND_COLOR = UIManager.getColor("TextField.selectionBackground"); + public static final Color SELECTED_FONT_COLOR = UIManager.getColor("TextField.selectionForeground"); + public static final Color HEADER_BACKGROUND_COLOR = UIManager.getColor("TextField.inactiveForeground"); + public static final Color HEADER_FONT_COLOR = UIManager.getColor("TextField.inactiveBackground"); + + + public JMonthPanel() { + this.init(Calendar.getInstance(), Locale.getDefault()); + } + + public JMonthPanel(Calendar cal) { + this.init(cal, Locale.getDefault()); + } + + public JMonthPanel(Locale locale) { + this.init(Calendar.getInstance(locale), locale); + } + + public JMonthPanel(Calendar cal, Locale locale) { + this.init(cal, locale); + } + + private void init(Calendar cal, Locale loc) { + this._cal = Calendar.getInstance(loc); + this._cal.set(5, cal.get(5)); + this._cal.set(2, cal.get(2)); + this._cal.set(1, cal.get(1)); + this._locale = loc; + this.createGUI(); + } + + private void createGUI() { + this.setLayout(new BorderLayout()); + this.add(this.createHeader(), "North"); + this.add(this.createTable(), "Center"); + } + + private JPanel createHeader() { + JPanel header = new JPanel(); + header.setLayout(new GridLayout(1, 7, 1, 1)); + header.setBackground(HEADER_BACKGROUND_COLOR); + SimpleDateFormat format = new SimpleDateFormat("E", this._locale); + Calendar cal = (Calendar)this._cal.clone(); + char[] letters = new char[7]; + + int pos; + for(pos = 0; pos < 7; ++pos) { + letters[cal.get(7) - 1] = format.format(cal.getTime()).charAt(0); + cal.set(5, cal.get(5) + 1); + } + + pos = cal.getFirstDayOfWeek() - 1; + + for(int i = 0; i < 7; ++i) { + JLabel empty = new JLabel(String.valueOf(letters[pos])); + ++pos; + if(pos > 6) { + pos = 0; + } + + empty.setHorizontalAlignment(4); + empty.setForeground(HEADER_FONT_COLOR); + header.add(empty); + } + + return header; + } + + private JPanel createTable() { + this._days = new ArrayList<>(); + JPanel table = new JPanel(); + table.setBackground(BACKGROUND_COLOR); + table.setLayout(new GridLayout(6, 7, 1, 1)); + int position = 0; + Calendar today = Calendar.getInstance(); + Calendar cal = (Calendar)this._cal.clone(); + cal.set(5, 1); + int month = cal.get(2); + int firstDay = cal.get(7); + if(firstDay == 0) { + --firstDay; + } else { + firstDay -= cal.getFirstDayOfWeek(); + } + + if(firstDay < 0) { + firstDay += 7; + } + + while(position < firstDay) { + JLabel curDay = new JLabel(); + table.add(curDay); + ++position; + } + + int var10 = this._cal.get(5); + + while(position < 42 && cal.get(2) == month) { + boolean empty = false; + if(cal.get(1) == today.get(1) && cal.get(2) == today.get(2) && cal.get(5) == today.get(5)) { + empty = true; + } + + DayLabel day = new DayLabel(cal.get(5), empty, this); + table.add(day); + this._days.add(day); + if(var10 == cal.get(5)) { + day.setSelected(true); + } + + ++position; + cal.set(5, cal.get(5) + 1); + } + + while(position < 42) { + JLabel var11 = new JLabel(); + table.add(var11); + ++position; + } + + return table; + } + + public void setCalendar(Calendar cal) { + this._cal.set(5, cal.get(5)); + this._cal.set(2, cal.get(2)); + this._cal.set(1, cal.get(1)); + this.removeAll(); + this.createGUI(); + this.updateUI(); + DayLabel dayLabel = this._days.get(cal.get(5) - 1); + dayLabel.grabFocus(); + this.setBackground(BACKGROUND_COLOR); + } + + public void grabFocus() { + super.grabFocus(); + DayLabel dayLabel = this._days.get(this._cal.get(5) - 1); + dayLabel.grabFocus(); + } + + public Calendar getCalendar() { + return this._cal; + } + + public void setSelectedDayOfMonth(int day) { + if(this._enabled && day > 0 && day <= this._days.size()) { + int oldday = this._cal.get(5); + DayLabel dayLabel = this._days.get(oldday - 1); + dayLabel.setSelected(false); + this._cal.set(5, day); + dayLabel = this._days.get(day - 1); + dayLabel.setSelected(true); + this.updateUI(); + this.fireChangeEvent(); + } + + } + + public int getSelectedDayOfMonth() { + return this._cal.get(5); + } + + public void addChangeListener(ChangeListener listener) { + this._changeListener.add(listener); + } + + public void removeChangeListener(ChangeListener listener) { + this._changeListener.remove(listener); + } + + public ChangeListener[] getChangeListener() { + return (ChangeListener[]) this._changeListener.toArray(); + } + + protected void fireChangeEvent() { + if(!this._fireingChangeEvent) { + this._fireingChangeEvent = true; + ChangeEvent event = new ChangeEvent(this); + + for (ChangeListener cl : this._changeListener) { + cl.stateChanged(event); + } + + this._fireingChangeEvent = false; + } + + } + + public void setEnabled(boolean enabled) { + this._enabled = enabled; + } + + public boolean isEnabled() { + return this._enabled; + } + +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizable.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizable.java new file mode 100755 index 00000000..d774b3b1 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizable.java @@ -0,0 +1,10 @@ +package de.tklsoft.gui.layout; + +import java.awt.*; + +public interface Synchronizable { + + void setSynchronizer(Synchronizer var1); + + Dimension getNormalSize(); +} diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizer.java b/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizer.java new file mode 100755 index 00000000..70b3b5a6 --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/gui/layout/Synchronizer.java @@ -0,0 +1,75 @@ +/* + * Decompiled with CFR 0.150. + */ +package de.tklsoft.gui.layout; + +import java.awt.*; +import java.util.HashSet; + +public class Synchronizer { + private final HashSet items = new HashSet<>(); + private final METHOD method; + + public Synchronizer(METHOD method) { + this.method = method; + } + + public void add(Synchronizable synchronizable) { + this.items.add(synchronizable); + synchronizable.setSynchronizer(this); + } + + public Dimension getSize(Synchronizable synchronizable) { + if (this.method == METHOD.WIDTH) { + return this.getSizeByWidth(synchronizable); + } + if (this.method == METHOD.HEIGHT) { + return this.getSizeByHeight(synchronizable); + } + if (this.method == METHOD.WIGHT_AND_HEIGHT) { + return this.getSizeByWidthAndHeight(); + } + return null; + } + + private Dimension getSizeByWidthAndHeight() { + int height = 0; + int width = 0; + for (Synchronizable curSynchronizable : this.items) { + Dimension dim = curSynchronizable.getNormalSize(); + if (dim.height > height) { + height = dim.height; + } + if (dim.width <= width) continue; + width = dim.width; + } + return new Dimension(width, height); + } + + private Dimension getSizeByHeight(Synchronizable synchronizable) { + int height = 0; + for (Synchronizable curSynchronizable : this.items) { + Dimension dim = curSynchronizable.getNormalSize(); + if (dim.height <= height) continue; + height = dim.height; + } + return new Dimension(synchronizable.getNormalSize().width, height); + } + + private Dimension getSizeByWidth(Synchronizable synchronizable) { + int width = 0; + for (Synchronizable curSynchronizable : this.items) { + Dimension dim = curSynchronizable.getNormalSize(); + if (dim.width <= width) continue; + width = dim.width; + } + return new Dimension(width, synchronizable.getNormalSize().height); + } + + public enum METHOD { + WIDTH, + HEIGHT, + WIGHT_AND_HEIGHT + } +} + diff --git a/modules/tklcontrols/src/main/java/de.tklsoft/icon/IconManager.java b/modules/tklcontrols/src/main/java/de.tklsoft/icon/IconManager.java new file mode 100755 index 00000000..b9162d7f --- /dev/null +++ b/modules/tklcontrols/src/main/java/de.tklsoft/icon/IconManager.java @@ -0,0 +1,44 @@ +package de.tklsoft.icon; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +public class IconManager { + + private static IconManager instance = null; + private final Map icons = new HashMap<>(); + + public static IconManager getInstance() { + if (instance == null) { + instance = new IconManager(); + } + + return instance; + } + + public ImageIcon getIcon(String key) { + ImageIcon result; + + String iconSet = "classic"; + + try { + if (icons.containsKey(key)) { + result = (ImageIcon) icons.get(key); + } else { + String url = System.getProperty("user.dir") + File.separator + "icons" + File.separator + iconSet + File.separator + key + ".png"; + Image img = (new ImageIcon(url)).getImage(); + result = new ImageIcon(img); + icons.put(key, result); + } + + return result; + } catch (Exception var6) { + var6.printStackTrace(); + return null; + } + } + +} diff --git a/modules/versionchecker/pom.xml b/modules/versionchecker/pom.xml new file mode 100644 index 00000000..04cd57df --- /dev/null +++ b/modules/versionchecker/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + de.applejuicenet.client.gui.plugins + versionchecker + jar + 1.6.1 + + + de.applejuicenet.client + AJClientGUI + 0.85.3 + ./../../pom.xml + + + + UTF-8 + 11 + 11 + + + + + de.applejuicenet.client.gui + AJCoreGUI + 0.85.3 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + ${project.artifactId} + + false + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0 + + + copy.plugins + package + + copy + + + + + ${basedir}/target/${project.artifactId}.jar + ${project.parent.basedir}/resources/plugins/${project.artifactId}.jar + + + + + + + + + diff --git a/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersionCheckerPlugin.java b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersionCheckerPlugin.java new file mode 100644 index 00000000..939a7b81 --- /dev/null +++ b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersionCheckerPlugin.java @@ -0,0 +1,74 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugins.versionchecker; + +import de.applejuicenet.client.AppleJuiceClient; +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.Upload; +import de.applejuicenet.client.gui.plugins.PluginConnector; +import de.applejuicenet.client.gui.plugins.versionchecker.panels.MainPanel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/VersionChecker.java,v 1.5 2009/01/12 10:18:00 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: GPL

+ * + * @author Maj0r + */ +public class VersionCheckerPlugin extends PluginConnector { + private MainPanel mainPanel; + private final Logger logger; + + public VersionCheckerPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, + Map availableIcons) { + super(pluginProperties, languageFiles, icon, availableIcons); + logger = LoggerFactory.getLogger(getClass()); + try { + setLayout(new BorderLayout()); + mainPanel = new MainPanel(); + add(mainPanel, BorderLayout.CENTER); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.DOWNLOAD_CHANGED); + AppleJuiceClient.getAjFassade().addDataUpdateListener(this, DATALISTENER_TYPE.UPLOAD_CHANGED); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void fireLanguageChanged() { + } + + /*Wird automatisch aufgerufen, wenn neue Informationen vom Server eingegangen sind. + ueber den DataManger koennen diese abgerufen werden.*/ + @SuppressWarnings("unchecked") + public void fireContentChanged(DATALISTENER_TYPE type, Object content) { + try { + if (type == DATALISTENER_TYPE.DOWNLOAD_CHANGED) { + HashMap downloads = (HashMap) content; + + mainPanel.updateByDownload(downloads); + } else if (type == DATALISTENER_TYPE.UPLOAD_CHANGED) { + HashMap uploads = (HashMap) content; + + mainPanel.updateByUploads(uploads); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + public void registerSelected() { + } +} diff --git a/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerPluginTestLoader.java b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerPluginTestLoader.java new file mode 100644 index 00000000..1de52bdf --- /dev/null +++ b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/VersioncheckerPluginTestLoader.java @@ -0,0 +1,25 @@ +/* + * Copyright 2006 TKLSoft.de All rights reserved. + */ + +package de.applejuicenet.client.gui.plugins.versionchecker; + +import de.applejuicenet.client.gui.plugincontrol.TestLoader; +import de.applejuicenet.client.gui.plugins.PluginConnector; + +import javax.swing.*; +import java.util.Map; +import java.util.Properties; + +public class VersioncheckerPluginTestLoader extends TestLoader { + @Override + protected String getPath() { + return "versionchecker"; + } + + @Override + protected PluginConnector getPlugin(Properties pluginProperties, Map languageFiles, ImageIcon icon, + Map availableIcons) { + return new VersionCheckerPlugin(pluginProperties, languageFiles, icon, availableIcons); + } +} diff --git a/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java new file mode 100644 index 00000000..d1712622 --- /dev/null +++ b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java @@ -0,0 +1,295 @@ +package de.applejuicenet.client.gui.plugins.versionchecker.panels; + +import de.applejuicenet.client.fassade.ApplejuiceFassade; +import de.applejuicenet.client.fassade.entity.Download; +import de.applejuicenet.client.fassade.entity.DownloadSource; +import de.applejuicenet.client.fassade.entity.Upload; +import de.applejuicenet.client.fassade.entity.Version; +import de.applejuicenet.client.shared.IconManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.HashSet; + +/** + * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/MainPanel.java,v 1.1 2006/05/04 14:15:17 maj0r Exp $ + * + *

Titel: AppleJuice Client-GUI

+ *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

+ *

Copyright: General Public License

+ * + * @author Maj0r + */ +public class MainPanel extends JPanel { + private final Logger logger; + private final HashMap versions = new HashMap(); + private final HashSet ids = new HashSet(); + private VersionTableModel versionTableModel = new VersionTableModel(); + private JTable versionTable; + private final DecimalFormat formatter = new DecimalFormat("###,##0.00"); + + public MainPanel() { + logger = LoggerFactory.getLogger(getClass()); + try { + init(); + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void init() { + setLayout(new BorderLayout()); + versionTableModel = new VersionTableModel(); + versionTable = new JTable(); + versionTable.setModel(versionTableModel); + for (int i = 0; i < versionTable.getColumnCount(); i++) { + versionTable.getTableHeader().getColumnModel().getColumn(i).setHeaderRenderer(new TableHeaderCellRenderer()); + if (i > 0) { + versionTable.getColumnModel().getColumn(i).setCellRenderer(new TableValueCellRenderer()); + } + } + + add(new JScrollPane(versionTable), BorderLayout.CENTER); + } + + public void updateByDownload(HashMap downloads) { + String versionsNr; + String key; + String key2; + VersionHolder versionHolder; + boolean updateView = false; + + try { + synchronized (downloads) { + for (Download curDownload : downloads.values()) { + if (curDownload == null) { + continue; + } + + for (DownloadSource curSource : curDownload.getSources()) { + if (curSource == null || curSource.getVersion() == null) { + continue; + } + + key = Integer.toString(curSource.getId()); + if (!ids.contains(key)) { + updateView = true; + ids.add(key); + versionsNr = curSource.getVersion().getVersion(); + key2 = versionsNr; + if (versions.containsKey(key2)) { + versionHolder = versions.get(key2); + } else { + versionHolder = new VersionHolder(versionsNr); + versions.put(key2, versionHolder); + } + + versionHolder.addUser(curSource.getVersion().getBetriebsSystem()); + } + } + } + } + + if (updateView) { + versionTableModel.setTable(versions); + updateTableHeader(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + private void updateTableHeader() { + SwingUtilities.invokeLater(() -> versionTable.getTableHeader().updateUI()); + } + + public void updateByUploads(HashMap uploads) { + String versionsNr; + String key; + String key2; + VersionHolder versionHolder; + boolean updateView = false; + + try { + synchronized (uploads) { + for (Upload curUpload : uploads.values()) { + if (curUpload == null || curUpload.getVersion() == null) { + continue; + } + + key = Integer.toString(curUpload.getId()); + if (!ids.contains(key)) { + updateView = true; + ids.add(key); + versionsNr = curUpload.getVersion().getVersion(); + key2 = versionsNr; + if (versions.containsKey(key2)) { + versionHolder = versions.get(key2); + } else { + versionHolder = new VersionHolder(versionsNr); + versions.put(key2, versionHolder); + } + + versionHolder.addUser(curUpload.getVersion().getBetriebsSystem()); + } + } + } + + if (updateView) { + versionTableModel.setTable(versions); + updateTableHeader(); + } + } catch (Exception e) { + logger.error(ApplejuiceFassade.ERROR_MESSAGE, e); + } + } + + class TableHeaderCellRenderer extends JLabel implements TableCellRenderer { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, + int column) { + switch (column) { + + case 1: { + setIcon(getVersionIcon(Version.WIN32)); + setText(value.toString() + getPercent(Version.WIN32)); + break; + } + + case 2: { + setIcon(getVersionIcon(Version.LINUX)); + setText(value.toString() + getPercent(Version.LINUX)); + break; + } + + case 3: { + setIcon(getVersionIcon(Version.MACINTOSH)); + setText(value.toString() + getPercent(Version.MACINTOSH)); + break; + } + + case 4: { + setIcon(getVersionIcon(Version.SOLARIS)); + setText(value.toString() + getPercent(Version.SOLARIS)); + break; + } + + case 5: { + setIcon(getVersionIcon(Version.OS2)); + setText(value.toString() + getPercent(Version.OS2)); + break; + } + + case 6: { + setIcon(getVersionIcon(Version.FREEBSD)); + setText(value.toString() + getPercent(Version.FREEBSD)); + break; + } + + case 7: { + setIcon(getVersionIcon(Version.NETWARE)); + setText(value.toString() + getPercent(Version.NETWARE)); + break; + } + + case 8: { + setIcon(getVersionIcon(-11 /*unbekannt*/)); + setText(value.toString() + getPercent(-11)); + break; + } + + default: + + //setText(value.toString()); + break; + } + + setBackground(table.getBackground()); + setForeground(table.getForeground()); + setEnabled(table.isEnabled()); + setFont(table.getFont()); + setOpaque(true); + return this; + } + } + + private String getPercent(int os) { + if (VersionHolder.countAll == 0) { + return ""; + } + + int gesamt = 0; + + for (VersionHolder curHolder : versions.values()) { + gesamt += curHolder.getUser(os); + } + + if (gesamt == 0) { + return ""; + } + + double percent = (double) gesamt / VersionHolder.countAll * 100; + + return " ( " + formatter.format(percent) + "% )"; + } + + private Icon getVersionIcon(int version) { + switch (version) { + + case Version.WIN32: + return IconManager.getInstance().getIcon("winsymbol"); + + case Version.LINUX: + return IconManager.getInstance().getIcon("linuxsymbol"); + + case Version.FREEBSD: + return IconManager.getInstance().getIcon("freebsdsymbol"); + + case Version.MACINTOSH: + return IconManager.getInstance().getIcon("macsymbol"); + + case Version.SOLARIS: + return IconManager.getInstance().getIcon("sunossymbol"); + + case Version.NETWARE: + return IconManager.getInstance().getIcon("netwaresymbol"); + + case Version.OS2: + return IconManager.getInstance().getIcon("os2symbol"); + + default: + return IconManager.getInstance().getIcon("unbekanntsymbol"); + } + } + + class TableValueCellRenderer extends JLabel implements TableCellRenderer { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, + int column) { + setText(value.toString()); + if (isSelected) { + setForeground(table.getSelectionForeground()); + setBackground(table.getSelectionBackground()); + } else { + setBackground(table.getBackground()); + try { + if (Integer.parseInt(value.toString()) > 0) { + setForeground(Color.BLUE); + } else { + setForeground(table.getForeground()); + } + } catch (Exception e) { + setForeground(table.getForeground()); + } + } + + setEnabled(table.isEnabled()); + setFont(table.getFont()); + setOpaque(true); + return this; + } + } +} diff --git a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java similarity index 98% rename from AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java rename to modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java index ecb209ce..58aadbe7 100644 --- a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java +++ b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionHolder.java @@ -9,7 +9,7 @@ *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ @@ -98,4 +98,4 @@ public int getUser(int os){ } } } -} \ No newline at end of file +} diff --git a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java similarity index 99% rename from AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java rename to modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java index f9c7fba3..04b1d170 100644 --- a/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java +++ b/modules/versionchecker/src/main/java/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java @@ -4,13 +4,11 @@ package de.applejuicenet.client.gui.plugins.versionchecker.panels; +import javax.swing.table.AbstractTableModel; import java.text.DecimalFormat; - import java.util.HashMap; import java.util.StringTokenizer; -import javax.swing.table.AbstractTableModel; - /** * $Header: /home/xubuntu/berlios_backup/github/tmp-cvs/applejuicejava/Repository/AJClientGUI/plugin_src/versionchecker/src/de/applejuicenet/client/gui/plugins/versionchecker/panels/VersionTableModel.java,v 1.2 2009/01/07 15:29:22 maj0r Exp $ * @@ -18,7 +16,7 @@ *

Beschreibung: Erstes GUI fuer den von muhviehstarr entwickelten appleJuice-Core

*

Copyright: General Public License

* - * @author: Maj0r + * @author Maj0r * */ public class VersionTableModel extends AbstractTableModel diff --git a/modules/versionchecker/src/main/resources/icon.gif b/modules/versionchecker/src/main/resources/icon.gif new file mode 100644 index 00000000..e4545f39 Binary files /dev/null and b/modules/versionchecker/src/main/resources/icon.gif differ diff --git a/AJClientGUI/plugin_src/versionchecker/language_deutsch.properties b/modules/versionchecker/src/main/resources/language_deutsch.properties similarity index 67% rename from AJClientGUI/plugin_src/versionchecker/language_deutsch.properties rename to modules/versionchecker/src/main/resources/language_deutsch.properties index ff23b467..f4d2e7bd 100644 --- a/AJClientGUI/plugin_src/versionchecker/language_deutsch.properties +++ b/modules/versionchecker/src/main/resources/language_deutsch.properties @@ -1,3 +1,3 @@ language=deutsch -language.description=Welche Core-Versionen sind zurzeit im Einsatz? Welche Betriebssysteme werden eingesetzt? Dieses Plugin beantwortet Deine Fragen. GUI ab 0.70.4 wird benöigt. -language.istab=true \ No newline at end of file +language.description=Welche Core-Versionen sind zurzeit im Einsatz? Welche Betriebssysteme werden eingesetzt? Dieses Plugin beantwortet Deine Fragen. +language.istab=true diff --git a/AJClientGUI/plugin_src/versionchecker/language_english.properties b/modules/versionchecker/src/main/resources/language_english.properties similarity index 81% rename from AJClientGUI/plugin_src/versionchecker/language_english.properties rename to modules/versionchecker/src/main/resources/language_english.properties index 7dced079..a3d615d4 100644 --- a/AJClientGUI/plugin_src/versionchecker/language_english.properties +++ b/modules/versionchecker/src/main/resources/language_english.properties @@ -1,2 +1,2 @@ language=english -language.description=Which core-version are currently used? Which operating-systems are used? This plugins answers your questions. GUI 0.70.4 or higher is needed. \ No newline at end of file +language.description=Which core-version are currently used? Which operating-systems are used? This plugins answers your questions. diff --git a/AJClientGUI/plugin_src/versionchecker/plugin.properties b/modules/versionchecker/src/main/resources/plugin.properties similarity index 76% rename from AJClientGUI/plugin_src/versionchecker/plugin.properties rename to modules/versionchecker/src/main/resources/plugin.properties index ae35dd7e..5edbb0de 100644 --- a/AJClientGUI/plugin_src/versionchecker/plugin.properties +++ b/modules/versionchecker/src/main/resources/plugin.properties @@ -1,7 +1,7 @@ general.title=VersionChecker -general.version=1.6 +general.version=1.6.1 general.author=Maj0r general.contact=tkrall@tkl-soft.de -general.description=Welche Core-Versionen sind zurzeit im Einsatz? Welche Betriebssysteme werden eingesetzt? Dieses Plugin beantwortet Deine Fragen. GUI ab 0.70.4 wird benötigt." +general.description=Welche Core-Versionen sind zurzeit im Einsatz? Welche Betriebssysteme werden eingesetzt? Dieses Plugin beantwortet Deine Fragen. general.istab=true -general.classname=de.applejuicenet.client.gui.plugins.versionchecker.VersionChecker \ No newline at end of file +general.classname=de.applejuicenet.client.gui.plugins.versionchecker.VersionCheckerPlugin diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..2a53c1f1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + de.applejuicenet.client + AJClientGUI + 0.85.3 + + 11 + 11 + + pom + + + modules/ajcorefassade + modules/tklcontrols + modules/AJCoreGUI + modules/logviewer + modules/versionchecker + modules/standardpwdlpolicy + modules/speedgraph + + + + + + false + maven-clean-plugin + 2.5 + + + + ${basedir}/resources/lib/ + + *.jar + + + + ${basedir}/resources/plugins/ + + *.jar + + + + ${basedir}/resources/pwdlpolicies/ + + *.jar + + + + + + + false + io.github.fvarrui + javapackager + 1.6.2 + + + javapackager.mac + install + + package + + + AJCoreGUI + AJCoreGUI + de.applejuicenet.client.AppleJuiceClient + ${basedir}/modules/AJCoreGUI/target/AJCoreGUI.jar + false + mac + 11 + appleJuiceNETZ + https://applejuicenet.cc + + -Dapple.awt.application.appearance=system + + + de.applejuicenet.client.AppleJuiceClient + true + false + false + false + + + resources/icons + resources/language + resources/lib + resources/plugins + resources/pwdlpolicies + resources/sounds + resources/themes + resources/wizard.xml + + + + + + + false + maven-antrun-plugin + 3.0.0 + + + antrun.package.archive + install + + run + + + + + + + + + + + + + + + + diff --git a/resources/icons/classic/abbrechen.png b/resources/icons/classic/abbrechen.png new file mode 100644 index 00000000..ce7f4964 Binary files /dev/null and b/resources/icons/classic/abbrechen.png differ diff --git a/resources/icons/classic/about.png b/resources/icons/classic/about.png new file mode 100644 index 00000000..7304a40c Binary files /dev/null and b/resources/icons/classic/about.png differ diff --git a/resources/icons/classic/aelter24h.png b/resources/icons/classic/aelter24h.png new file mode 100644 index 00000000..0e71b183 Binary files /dev/null and b/resources/icons/classic/aelter24h.png differ diff --git a/resources/icons/classic/amigaossymbol.png b/resources/icons/classic/amigaossymbol.png new file mode 100644 index 00000000..1638b762 Binary files /dev/null and b/resources/icons/classic/amigaossymbol.png differ diff --git a/resources/icons/classic/applejuice.png b/resources/icons/classic/applejuice.png new file mode 100644 index 00000000..2255f08a Binary files /dev/null and b/resources/icons/classic/applejuice.png differ diff --git a/resources/icons/classic/applejuicebanner.png b/resources/icons/classic/applejuicebanner.png new file mode 100644 index 00000000..f93e2b2c Binary files /dev/null and b/resources/icons/classic/applejuicebanner.png differ diff --git a/resources/icons/classic/applejuiceinfobanner.png b/resources/icons/classic/applejuiceinfobanner.png new file mode 100644 index 00000000..503f53db Binary files /dev/null and b/resources/icons/classic/applejuiceinfobanner.png differ diff --git a/resources/icons/classic/archive.png b/resources/icons/classic/archive.png new file mode 100644 index 00000000..54a85b3c Binary files /dev/null and b/resources/icons/classic/archive.png differ diff --git a/resources/icons/classic/bereinigen.png b/resources/icons/classic/bereinigen.png new file mode 100644 index 00000000..b8d1764a Binary files /dev/null and b/resources/icons/classic/bereinigen.png differ diff --git a/resources/icons/classic/border_invalid.png b/resources/icons/classic/border_invalid.png new file mode 100644 index 00000000..b8ce3315 Binary files /dev/null and b/resources/icons/classic/border_invalid.png differ diff --git a/resources/icons/classic/browsen.png b/resources/icons/classic/browsen.png new file mode 100644 index 00000000..d7d4320a Binary files /dev/null and b/resources/icons/classic/browsen.png differ diff --git a/resources/icons/classic/chat.png b/resources/icons/classic/chat.png new file mode 100644 index 00000000..51d0b6bf Binary files /dev/null and b/resources/icons/classic/chat.png differ diff --git a/resources/icons/classic/clipboard.png b/resources/icons/classic/clipboard.png new file mode 100644 index 00000000..74fa761a Binary files /dev/null and b/resources/icons/classic/clipboard.png differ diff --git a/resources/icons/classic/cool.png b/resources/icons/classic/cool.png new file mode 100644 index 00000000..92cd53b0 Binary files /dev/null and b/resources/icons/classic/cool.png differ diff --git a/resources/icons/classic/debug.png b/resources/icons/classic/debug.png new file mode 100644 index 00000000..feb15e5e Binary files /dev/null and b/resources/icons/classic/debug.png differ diff --git a/resources/icons/classic/decrease.png b/resources/icons/classic/decrease.png new file mode 100644 index 00000000..931e4b9f Binary files /dev/null and b/resources/icons/classic/decrease.png differ diff --git a/resources/icons/classic/deutsch.png b/resources/icons/classic/deutsch.png new file mode 100644 index 00000000..e20bf5b3 Binary files /dev/null and b/resources/icons/classic/deutsch.png differ diff --git a/resources/icons/classic/diskette.png b/resources/icons/classic/diskette.png new file mode 100644 index 00000000..4d8b45b7 Binary files /dev/null and b/resources/icons/classic/diskette.png differ diff --git a/resources/icons/classic/download.png b/resources/icons/classic/download.png new file mode 100644 index 00000000..fa3b0728 Binary files /dev/null and b/resources/icons/classic/download.png differ diff --git a/resources/icons/classic/eek.png b/resources/icons/classic/eek.png new file mode 100644 index 00000000..2555cfbf Binary files /dev/null and b/resources/icons/classic/eek.png differ diff --git a/resources/icons/classic/erneuern.png b/resources/icons/classic/erneuern.png new file mode 100644 index 00000000..0958bace Binary files /dev/null and b/resources/icons/classic/erneuern.png differ diff --git a/resources/icons/classic/firewall.png b/resources/icons/classic/firewall.png new file mode 100644 index 00000000..f8332e3f Binary files /dev/null and b/resources/icons/classic/firewall.png differ diff --git a/resources/icons/classic/folderopen.png b/resources/icons/classic/folderopen.png new file mode 100644 index 00000000..2f2a8331 Binary files /dev/null and b/resources/icons/classic/folderopen.png differ diff --git a/resources/icons/classic/freebsdsymbol.png b/resources/icons/classic/freebsdsymbol.png new file mode 100644 index 00000000..83a7019b Binary files /dev/null and b/resources/icons/classic/freebsdsymbol.png differ diff --git a/resources/icons/classic/hide.png b/resources/icons/classic/hide.png new file mode 100644 index 00000000..bd6882f9 Binary files /dev/null and b/resources/icons/classic/hide.png differ diff --git a/resources/icons/classic/hint.png b/resources/icons/classic/hint.png new file mode 100644 index 00000000..0dc1b204 Binary files /dev/null and b/resources/icons/classic/hint.png differ diff --git a/resources/icons/classic/image.png b/resources/icons/classic/image.png new file mode 100644 index 00000000..6d52e8c4 Binary files /dev/null and b/resources/icons/classic/image.png differ diff --git a/resources/icons/classic/increase.png b/resources/icons/classic/increase.png new file mode 100644 index 00000000..414da963 Binary files /dev/null and b/resources/icons/classic/increase.png differ diff --git a/resources/icons/classic/info.png b/resources/icons/classic/info.png new file mode 100644 index 00000000..5eb6951a Binary files /dev/null and b/resources/icons/classic/info.png differ diff --git a/resources/icons/classic/irixsymbol.png b/resources/icons/classic/irixsymbol.png new file mode 100644 index 00000000..fe38e7a4 Binary files /dev/null and b/resources/icons/classic/irixsymbol.png differ diff --git a/resources/icons/classic/iso.png b/resources/icons/classic/iso.png new file mode 100644 index 00000000..34a03eee Binary files /dev/null and b/resources/icons/classic/iso.png differ diff --git a/resources/icons/classic/juenger24h.png b/resources/icons/classic/juenger24h.png new file mode 100644 index 00000000..8495adbc Binary files /dev/null and b/resources/icons/classic/juenger24h.png differ diff --git a/resources/icons/classic/laufwerk.png b/resources/icons/classic/laufwerk.png new file mode 100644 index 00000000..b422213e Binary files /dev/null and b/resources/icons/classic/laufwerk.png differ diff --git a/resources/icons/classic/led_gray.png b/resources/icons/classic/led_gray.png new file mode 100644 index 00000000..a3338fd3 Binary files /dev/null and b/resources/icons/classic/led_gray.png differ diff --git a/resources/icons/classic/led_green.png b/resources/icons/classic/led_green.png new file mode 100644 index 00000000..5dd361b7 Binary files /dev/null and b/resources/icons/classic/led_green.png differ diff --git a/resources/icons/classic/led_red.png b/resources/icons/classic/led_red.png new file mode 100644 index 00000000..ebe34b24 Binary files /dev/null and b/resources/icons/classic/led_red.png differ diff --git a/resources/icons/classic/linuxsymbol.png b/resources/icons/classic/linuxsymbol.png new file mode 100644 index 00000000..428e6590 Binary files /dev/null and b/resources/icons/classic/linuxsymbol.png differ diff --git a/resources/icons/classic/macsymbol.png b/resources/icons/classic/macsymbol.png new file mode 100644 index 00000000..9845e25f Binary files /dev/null and b/resources/icons/classic/macsymbol.png differ diff --git a/resources/icons/classic/meinshare.png b/resources/icons/classic/meinshare.png new file mode 100644 index 00000000..f31f6d59 Binary files /dev/null and b/resources/icons/classic/meinshare.png differ diff --git a/resources/icons/classic/mmonitor.png b/resources/icons/classic/mmonitor.png new file mode 100644 index 00000000..a3ad6870 Binary files /dev/null and b/resources/icons/classic/mmonitor.png differ diff --git a/resources/icons/classic/movie.png b/resources/icons/classic/movie.png new file mode 100644 index 00000000..84aa6ce5 Binary files /dev/null and b/resources/icons/classic/movie.png differ diff --git a/resources/icons/classic/netwaresymbol.png b/resources/icons/classic/netwaresymbol.png new file mode 100644 index 00000000..203234bf Binary files /dev/null and b/resources/icons/classic/netwaresymbol.png differ diff --git a/resources/icons/classic/netzwerk.png b/resources/icons/classic/netzwerk.png new file mode 100644 index 00000000..d671e5f7 Binary files /dev/null and b/resources/icons/classic/netzwerk.png differ diff --git a/resources/icons/classic/neuedateiliste.png b/resources/icons/classic/neuedateiliste.png new file mode 100644 index 00000000..06e6427f Binary files /dev/null and b/resources/icons/classic/neuedateiliste.png differ diff --git a/resources/icons/classic/notshared.png b/resources/icons/classic/notshared.png new file mode 100644 index 00000000..1aff85b0 Binary files /dev/null and b/resources/icons/classic/notshared.png differ diff --git a/resources/icons/classic/openbsdsymbol.png b/resources/icons/classic/openbsdsymbol.png new file mode 100644 index 00000000..5a6e67d6 Binary files /dev/null and b/resources/icons/classic/openbsdsymbol.png differ diff --git a/resources/icons/classic/opt_ansicht.png b/resources/icons/classic/opt_ansicht.png new file mode 100644 index 00000000..cd6330e9 Binary files /dev/null and b/resources/icons/classic/opt_ansicht.png differ diff --git a/resources/icons/classic/opt_passwort.png b/resources/icons/classic/opt_passwort.png new file mode 100644 index 00000000..f87da349 Binary files /dev/null and b/resources/icons/classic/opt_passwort.png differ diff --git a/resources/icons/classic/opt_plugins.png b/resources/icons/classic/opt_plugins.png new file mode 100644 index 00000000..bdf9d016 Binary files /dev/null and b/resources/icons/classic/opt_plugins.png differ diff --git a/resources/icons/classic/opt_proxy.png b/resources/icons/classic/opt_proxy.png new file mode 100644 index 00000000..d674ecc1 Binary files /dev/null and b/resources/icons/classic/opt_proxy.png differ diff --git a/resources/icons/classic/opt_standard.png b/resources/icons/classic/opt_standard.png new file mode 100644 index 00000000..5939974a Binary files /dev/null and b/resources/icons/classic/opt_standard.png differ diff --git a/resources/icons/classic/opt_verbindung.png b/resources/icons/classic/opt_verbindung.png new file mode 100644 index 00000000..6e846cfe Binary files /dev/null and b/resources/icons/classic/opt_verbindung.png differ diff --git a/resources/icons/classic/optionen.png b/resources/icons/classic/optionen.png new file mode 100644 index 00000000..29822272 Binary files /dev/null and b/resources/icons/classic/optionen.png differ diff --git a/resources/icons/classic/os2symbol.png b/resources/icons/classic/os2symbol.png new file mode 100644 index 00000000..6a192f3b Binary files /dev/null and b/resources/icons/classic/os2symbol.png differ diff --git a/resources/icons/classic/partliste.png b/resources/icons/classic/partliste.png new file mode 100644 index 00000000..f82c0842 Binary files /dev/null and b/resources/icons/classic/partliste.png differ diff --git a/resources/icons/classic/pause.png b/resources/icons/classic/pause.png new file mode 100644 index 00000000..0e99eaf1 Binary files /dev/null and b/resources/icons/classic/pause.png differ diff --git a/resources/icons/classic/pdf.png b/resources/icons/classic/pdf.png new file mode 100644 index 00000000..6be40206 Binary files /dev/null and b/resources/icons/classic/pdf.png differ diff --git a/resources/icons/classic/server.png b/resources/icons/classic/server.png new file mode 100644 index 00000000..ec49ac0e Binary files /dev/null and b/resources/icons/classic/server.png differ diff --git a/resources/icons/classic/serverloeschen.png b/resources/icons/classic/serverloeschen.png new file mode 100644 index 00000000..74db907a Binary files /dev/null and b/resources/icons/classic/serverloeschen.png differ diff --git a/resources/icons/classic/serverneu.png b/resources/icons/classic/serverneu.png new file mode 100644 index 00000000..37e83dbb Binary files /dev/null and b/resources/icons/classic/serverneu.png differ diff --git a/resources/icons/classic/serververbinden.png b/resources/icons/classic/serververbinden.png new file mode 100644 index 00000000..7459ebdf Binary files /dev/null and b/resources/icons/classic/serververbinden.png differ diff --git a/resources/icons/classic/serververbunden.png b/resources/icons/classic/serververbunden.png new file mode 100644 index 00000000..3ccad745 Binary files /dev/null and b/resources/icons/classic/serververbunden.png differ diff --git a/resources/icons/classic/serverversuche.png b/resources/icons/classic/serverversuche.png new file mode 100644 index 00000000..39d0fe1c Binary files /dev/null and b/resources/icons/classic/serverversuche.png differ diff --git a/resources/icons/classic/sharedwosub.png b/resources/icons/classic/sharedwosub.png new file mode 100644 index 00000000..ca25fa5e Binary files /dev/null and b/resources/icons/classic/sharedwosub.png differ diff --git a/resources/icons/classic/sharedwsub.png b/resources/icons/classic/sharedwsub.png new file mode 100644 index 00000000..713ae288 Binary files /dev/null and b/resources/icons/classic/sharedwsub.png differ diff --git a/resources/icons/classic/skull.png b/resources/icons/classic/skull.png new file mode 100644 index 00000000..2b82dd10 Binary files /dev/null and b/resources/icons/classic/skull.png differ diff --git a/resources/icons/classic/somethingshared.png b/resources/icons/classic/somethingshared.png new file mode 100644 index 00000000..a306b21d Binary files /dev/null and b/resources/icons/classic/somethingshared.png differ diff --git a/resources/icons/classic/sound.png b/resources/icons/classic/sound.png new file mode 100644 index 00000000..0ca7e7a8 Binary files /dev/null and b/resources/icons/classic/sound.png differ diff --git a/resources/icons/classic/soundoff.png b/resources/icons/classic/soundoff.png new file mode 100644 index 00000000..00b4b0f6 Binary files /dev/null and b/resources/icons/classic/soundoff.png differ diff --git a/resources/icons/classic/soundon.png b/resources/icons/classic/soundon.png new file mode 100644 index 00000000..e990149f Binary files /dev/null and b/resources/icons/classic/soundon.png differ diff --git a/resources/icons/classic/speichern.png b/resources/icons/classic/speichern.png new file mode 100644 index 00000000..568e243c Binary files /dev/null and b/resources/icons/classic/speichern.png differ diff --git a/resources/icons/classic/splashscreen.png b/resources/icons/classic/splashscreen.png new file mode 100644 index 00000000..1a6f0f88 Binary files /dev/null and b/resources/icons/classic/splashscreen.png differ diff --git a/AJClientGUI/icons/splashscreen.properties b/resources/icons/classic/splashscreen.properties similarity index 100% rename from AJClientGUI/icons/splashscreen.properties rename to resources/icons/classic/splashscreen.properties diff --git a/resources/icons/classic/start.png b/resources/icons/classic/start.png new file mode 100644 index 00000000..0c9c2065 Binary files /dev/null and b/resources/icons/classic/start.png differ diff --git a/resources/icons/classic/suchen.png b/resources/icons/classic/suchen.png new file mode 100644 index 00000000..e78e2cfd Binary files /dev/null and b/resources/icons/classic/suchen.png differ diff --git a/resources/icons/classic/sunossymbol.png b/resources/icons/classic/sunossymbol.png new file mode 100644 index 00000000..e52ef9d0 Binary files /dev/null and b/resources/icons/classic/sunossymbol.png differ diff --git a/resources/icons/classic/text.png b/resources/icons/classic/text.png new file mode 100644 index 00000000..73e66ff1 Binary files /dev/null and b/resources/icons/classic/text.png differ diff --git a/resources/icons/classic/tree.png b/resources/icons/classic/tree.png new file mode 100644 index 00000000..1285bd5d Binary files /dev/null and b/resources/icons/classic/tree.png differ diff --git a/resources/icons/classic/treeIndirekt.png b/resources/icons/classic/treeIndirekt.png new file mode 100644 index 00000000..0731685f Binary files /dev/null and b/resources/icons/classic/treeIndirekt.png differ diff --git a/resources/icons/classic/treeRoot.png b/resources/icons/classic/treeRoot.png new file mode 100644 index 00000000..64e2cf56 Binary files /dev/null and b/resources/icons/classic/treeRoot.png differ diff --git a/resources/icons/classic/treeUebertrage.png b/resources/icons/classic/treeUebertrage.png new file mode 100644 index 00000000..555cb801 Binary files /dev/null and b/resources/icons/classic/treeUebertrage.png differ diff --git a/resources/icons/classic/treeWarteschlange.png b/resources/icons/classic/treeWarteschlange.png new file mode 100644 index 00000000..6bcb7a75 Binary files /dev/null and b/resources/icons/classic/treeWarteschlange.png differ diff --git a/resources/icons/classic/umbenennen.png b/resources/icons/classic/umbenennen.png new file mode 100644 index 00000000..66027289 Binary files /dev/null and b/resources/icons/classic/umbenennen.png differ diff --git a/resources/icons/classic/unbekanntsymbol.png b/resources/icons/classic/unbekanntsymbol.png new file mode 100644 index 00000000..4f978c88 Binary files /dev/null and b/resources/icons/classic/unbekanntsymbol.png differ diff --git a/resources/icons/classic/update.png b/resources/icons/classic/update.png new file mode 100644 index 00000000..94eaf15f Binary files /dev/null and b/resources/icons/classic/update.png differ diff --git a/resources/icons/classic/upload.png b/resources/icons/classic/upload.png new file mode 100644 index 00000000..66d8f835 Binary files /dev/null and b/resources/icons/classic/upload.png differ diff --git a/resources/icons/classic/verbinden.png b/resources/icons/classic/verbinden.png new file mode 100644 index 00000000..01f1a665 Binary files /dev/null and b/resources/icons/classic/verbinden.png differ diff --git a/resources/icons/classic/verbindungUnbekannt.png b/resources/icons/classic/verbindungUnbekannt.png new file mode 100644 index 00000000..96cd86be Binary files /dev/null and b/resources/icons/classic/verbindungUnbekannt.png differ diff --git a/resources/icons/classic/verzeichnislink.png b/resources/icons/classic/verzeichnislink.png new file mode 100644 index 00000000..455c3c5b Binary files /dev/null and b/resources/icons/classic/verzeichnislink.png differ diff --git a/resources/icons/classic/vlc.png b/resources/icons/classic/vlc.png new file mode 100644 index 00000000..5d7fd0d3 Binary files /dev/null and b/resources/icons/classic/vlc.png differ diff --git a/resources/icons/classic/warnung.png b/resources/icons/classic/warnung.png new file mode 100644 index 00000000..6b0c9a13 Binary files /dev/null and b/resources/icons/classic/warnung.png differ diff --git a/resources/icons/classic/warten.png b/resources/icons/classic/warten.png new file mode 100644 index 00000000..e91b4fa9 Binary files /dev/null and b/resources/icons/classic/warten.png differ diff --git a/resources/icons/classic/web.png b/resources/icons/classic/web.png new file mode 100644 index 00000000..ec9c8350 Binary files /dev/null and b/resources/icons/classic/web.png differ diff --git a/resources/icons/classic/winsymbol.png b/resources/icons/classic/winsymbol.png new file mode 100644 index 00000000..942710ff Binary files /dev/null and b/resources/icons/classic/winsymbol.png differ diff --git a/resources/icons/classic/wizardbanner.png b/resources/icons/classic/wizardbanner.png new file mode 100644 index 00000000..90c50fad Binary files /dev/null and b/resources/icons/classic/wizardbanner.png differ diff --git a/resources/icons/classic/zielordner.png b/resources/icons/classic/zielordner.png new file mode 100644 index 00000000..64606c28 Binary files /dev/null and b/resources/icons/classic/zielordner.png differ diff --git a/resources/icons/modern/abbrechen.png b/resources/icons/modern/abbrechen.png new file mode 100644 index 00000000..cf640c10 Binary files /dev/null and b/resources/icons/modern/abbrechen.png differ diff --git a/resources/icons/modern/about.png b/resources/icons/modern/about.png new file mode 100644 index 00000000..567ece7e Binary files /dev/null and b/resources/icons/modern/about.png differ diff --git a/resources/icons/modern/aelter24h.png b/resources/icons/modern/aelter24h.png new file mode 100644 index 00000000..0954aa40 Binary files /dev/null and b/resources/icons/modern/aelter24h.png differ diff --git a/resources/icons/modern/amigaossymbol.png b/resources/icons/modern/amigaossymbol.png new file mode 100644 index 00000000..1638b762 Binary files /dev/null and b/resources/icons/modern/amigaossymbol.png differ diff --git a/resources/icons/modern/applejuice.png b/resources/icons/modern/applejuice.png new file mode 100644 index 00000000..2255f08a Binary files /dev/null and b/resources/icons/modern/applejuice.png differ diff --git a/resources/icons/modern/applejuicebanner.png b/resources/icons/modern/applejuicebanner.png new file mode 100644 index 00000000..7508e216 Binary files /dev/null and b/resources/icons/modern/applejuicebanner.png differ diff --git a/resources/icons/modern/applejuiceinfobanner.png b/resources/icons/modern/applejuiceinfobanner.png new file mode 100644 index 00000000..d0c9ac47 Binary files /dev/null and b/resources/icons/modern/applejuiceinfobanner.png differ diff --git a/resources/icons/modern/archive.png b/resources/icons/modern/archive.png new file mode 100644 index 00000000..584bfc31 Binary files /dev/null and b/resources/icons/modern/archive.png differ diff --git a/resources/icons/modern/bereinigen.png b/resources/icons/modern/bereinigen.png new file mode 100644 index 00000000..af7ff592 Binary files /dev/null and b/resources/icons/modern/bereinigen.png differ diff --git a/resources/icons/modern/border_invalid.png b/resources/icons/modern/border_invalid.png new file mode 100644 index 00000000..b8ce3315 Binary files /dev/null and b/resources/icons/modern/border_invalid.png differ diff --git a/resources/icons/modern/browsen.png b/resources/icons/modern/browsen.png new file mode 100644 index 00000000..68f21d30 Binary files /dev/null and b/resources/icons/modern/browsen.png differ diff --git a/resources/icons/modern/chat.png b/resources/icons/modern/chat.png new file mode 100644 index 00000000..e54ebeba Binary files /dev/null and b/resources/icons/modern/chat.png differ diff --git a/resources/icons/modern/clipboard.png b/resources/icons/modern/clipboard.png new file mode 100644 index 00000000..73cb3dd1 Binary files /dev/null and b/resources/icons/modern/clipboard.png differ diff --git a/resources/icons/modern/cool.png b/resources/icons/modern/cool.png new file mode 100644 index 00000000..92cd53b0 Binary files /dev/null and b/resources/icons/modern/cool.png differ diff --git a/resources/icons/modern/debug.png b/resources/icons/modern/debug.png new file mode 100644 index 00000000..feb15e5e Binary files /dev/null and b/resources/icons/modern/debug.png differ diff --git a/resources/icons/modern/decrease.png b/resources/icons/modern/decrease.png new file mode 100644 index 00000000..931e4b9f Binary files /dev/null and b/resources/icons/modern/decrease.png differ diff --git a/resources/icons/modern/deutsch.png b/resources/icons/modern/deutsch.png new file mode 100644 index 00000000..e20bf5b3 Binary files /dev/null and b/resources/icons/modern/deutsch.png differ diff --git a/resources/icons/modern/diskette.png b/resources/icons/modern/diskette.png new file mode 100644 index 00000000..b57a3cae Binary files /dev/null and b/resources/icons/modern/diskette.png differ diff --git a/resources/icons/modern/download.png b/resources/icons/modern/download.png new file mode 100644 index 00000000..45fb0d5d Binary files /dev/null and b/resources/icons/modern/download.png differ diff --git a/resources/icons/modern/eek.png b/resources/icons/modern/eek.png new file mode 100644 index 00000000..2555cfbf Binary files /dev/null and b/resources/icons/modern/eek.png differ diff --git a/resources/icons/modern/erneuern.png b/resources/icons/modern/erneuern.png new file mode 100644 index 00000000..303cca01 Binary files /dev/null and b/resources/icons/modern/erneuern.png differ diff --git a/resources/icons/modern/firewall.png b/resources/icons/modern/firewall.png new file mode 100644 index 00000000..93cc8b39 Binary files /dev/null and b/resources/icons/modern/firewall.png differ diff --git a/resources/icons/modern/folderopen.png b/resources/icons/modern/folderopen.png new file mode 100644 index 00000000..4590e780 Binary files /dev/null and b/resources/icons/modern/folderopen.png differ diff --git a/resources/icons/modern/freebsdsymbol.png b/resources/icons/modern/freebsdsymbol.png new file mode 100644 index 00000000..d049b70d Binary files /dev/null and b/resources/icons/modern/freebsdsymbol.png differ diff --git a/resources/icons/modern/hide.png b/resources/icons/modern/hide.png new file mode 100644 index 00000000..bd6882f9 Binary files /dev/null and b/resources/icons/modern/hide.png differ diff --git a/resources/icons/modern/hint.png b/resources/icons/modern/hint.png new file mode 100644 index 00000000..092a180e Binary files /dev/null and b/resources/icons/modern/hint.png differ diff --git a/resources/icons/modern/image.png b/resources/icons/modern/image.png new file mode 100644 index 00000000..6d52e8c4 Binary files /dev/null and b/resources/icons/modern/image.png differ diff --git a/resources/icons/modern/increase.png b/resources/icons/modern/increase.png new file mode 100644 index 00000000..414da963 Binary files /dev/null and b/resources/icons/modern/increase.png differ diff --git a/resources/icons/modern/info.png b/resources/icons/modern/info.png new file mode 100644 index 00000000..ba531912 Binary files /dev/null and b/resources/icons/modern/info.png differ diff --git a/resources/icons/modern/irixsymbol.png b/resources/icons/modern/irixsymbol.png new file mode 100644 index 00000000..fe38e7a4 Binary files /dev/null and b/resources/icons/modern/irixsymbol.png differ diff --git a/resources/icons/modern/iso.png b/resources/icons/modern/iso.png new file mode 100644 index 00000000..34a03eee Binary files /dev/null and b/resources/icons/modern/iso.png differ diff --git a/resources/icons/modern/juenger24h.png b/resources/icons/modern/juenger24h.png new file mode 100644 index 00000000..6ab8c62e Binary files /dev/null and b/resources/icons/modern/juenger24h.png differ diff --git a/resources/icons/modern/laufwerk.png b/resources/icons/modern/laufwerk.png new file mode 100644 index 00000000..a74336a1 Binary files /dev/null and b/resources/icons/modern/laufwerk.png differ diff --git a/resources/icons/modern/led_gray.png b/resources/icons/modern/led_gray.png new file mode 100644 index 00000000..d27f7d26 Binary files /dev/null and b/resources/icons/modern/led_gray.png differ diff --git a/resources/icons/modern/led_green.png b/resources/icons/modern/led_green.png new file mode 100644 index 00000000..08f8b8c2 Binary files /dev/null and b/resources/icons/modern/led_green.png differ diff --git a/resources/icons/modern/led_red.png b/resources/icons/modern/led_red.png new file mode 100644 index 00000000..1c500ba3 Binary files /dev/null and b/resources/icons/modern/led_red.png differ diff --git a/resources/icons/modern/linuxsymbol.png b/resources/icons/modern/linuxsymbol.png new file mode 100644 index 00000000..bbefe2ec Binary files /dev/null and b/resources/icons/modern/linuxsymbol.png differ diff --git a/resources/icons/modern/macsymbol.png b/resources/icons/modern/macsymbol.png new file mode 100644 index 00000000..aad55180 Binary files /dev/null and b/resources/icons/modern/macsymbol.png differ diff --git a/resources/icons/modern/meinshare.png b/resources/icons/modern/meinshare.png new file mode 100644 index 00000000..e7142c9e Binary files /dev/null and b/resources/icons/modern/meinshare.png differ diff --git a/resources/icons/modern/mmonitor.png b/resources/icons/modern/mmonitor.png new file mode 100644 index 00000000..a3ad6870 Binary files /dev/null and b/resources/icons/modern/mmonitor.png differ diff --git a/resources/icons/modern/movie.png b/resources/icons/modern/movie.png new file mode 100644 index 00000000..aa8370ae Binary files /dev/null and b/resources/icons/modern/movie.png differ diff --git a/resources/icons/modern/netwaresymbol.png b/resources/icons/modern/netwaresymbol.png new file mode 100644 index 00000000..203234bf Binary files /dev/null and b/resources/icons/modern/netwaresymbol.png differ diff --git a/resources/icons/modern/netzwerk.png b/resources/icons/modern/netzwerk.png new file mode 100644 index 00000000..ae8cae80 Binary files /dev/null and b/resources/icons/modern/netzwerk.png differ diff --git a/resources/icons/modern/neuedateiliste.png b/resources/icons/modern/neuedateiliste.png new file mode 100644 index 00000000..4fb49843 Binary files /dev/null and b/resources/icons/modern/neuedateiliste.png differ diff --git a/resources/icons/modern/notshared.png b/resources/icons/modern/notshared.png new file mode 100644 index 00000000..60745978 Binary files /dev/null and b/resources/icons/modern/notshared.png differ diff --git a/resources/icons/modern/openbsdsymbol.png b/resources/icons/modern/openbsdsymbol.png new file mode 100644 index 00000000..57a88111 Binary files /dev/null and b/resources/icons/modern/openbsdsymbol.png differ diff --git a/resources/icons/modern/opt_ansicht.png b/resources/icons/modern/opt_ansicht.png new file mode 100644 index 00000000..36fa1aa1 Binary files /dev/null and b/resources/icons/modern/opt_ansicht.png differ diff --git a/resources/icons/modern/opt_passwort.png b/resources/icons/modern/opt_passwort.png new file mode 100644 index 00000000..ab875381 Binary files /dev/null and b/resources/icons/modern/opt_passwort.png differ diff --git a/resources/icons/modern/opt_plugins.png b/resources/icons/modern/opt_plugins.png new file mode 100644 index 00000000..6cde0caf Binary files /dev/null and b/resources/icons/modern/opt_plugins.png differ diff --git a/resources/icons/modern/opt_proxy.png b/resources/icons/modern/opt_proxy.png new file mode 100644 index 00000000..0f9bac6f Binary files /dev/null and b/resources/icons/modern/opt_proxy.png differ diff --git a/resources/icons/modern/opt_standard.png b/resources/icons/modern/opt_standard.png new file mode 100644 index 00000000..c93c0c49 Binary files /dev/null and b/resources/icons/modern/opt_standard.png differ diff --git a/resources/icons/modern/opt_verbindung.png b/resources/icons/modern/opt_verbindung.png new file mode 100644 index 00000000..c4ade743 Binary files /dev/null and b/resources/icons/modern/opt_verbindung.png differ diff --git a/resources/icons/modern/optionen.png b/resources/icons/modern/optionen.png new file mode 100644 index 00000000..5c8213fe Binary files /dev/null and b/resources/icons/modern/optionen.png differ diff --git a/resources/icons/modern/os2symbol.png b/resources/icons/modern/os2symbol.png new file mode 100644 index 00000000..6a192f3b Binary files /dev/null and b/resources/icons/modern/os2symbol.png differ diff --git a/resources/icons/modern/partliste.png b/resources/icons/modern/partliste.png new file mode 100644 index 00000000..f82c0842 Binary files /dev/null and b/resources/icons/modern/partliste.png differ diff --git a/resources/icons/modern/pause.png b/resources/icons/modern/pause.png new file mode 100644 index 00000000..c49543e2 Binary files /dev/null and b/resources/icons/modern/pause.png differ diff --git a/resources/icons/modern/pdf.png b/resources/icons/modern/pdf.png new file mode 100644 index 00000000..7e233bb4 Binary files /dev/null and b/resources/icons/modern/pdf.png differ diff --git a/resources/icons/modern/server.png b/resources/icons/modern/server.png new file mode 100644 index 00000000..36fa1aa1 Binary files /dev/null and b/resources/icons/modern/server.png differ diff --git a/resources/icons/modern/serverloeschen.png b/resources/icons/modern/serverloeschen.png new file mode 100644 index 00000000..cf640c10 Binary files /dev/null and b/resources/icons/modern/serverloeschen.png differ diff --git a/resources/icons/modern/serverneu.png b/resources/icons/modern/serverneu.png new file mode 100644 index 00000000..d901cb2e Binary files /dev/null and b/resources/icons/modern/serverneu.png differ diff --git a/resources/icons/modern/serververbinden.png b/resources/icons/modern/serververbinden.png new file mode 100644 index 00000000..76c864e4 Binary files /dev/null and b/resources/icons/modern/serververbinden.png differ diff --git a/resources/icons/modern/serververbunden.png b/resources/icons/modern/serververbunden.png new file mode 100644 index 00000000..08f8b8c2 Binary files /dev/null and b/resources/icons/modern/serververbunden.png differ diff --git a/resources/icons/modern/serverversuche.png b/resources/icons/modern/serverversuche.png new file mode 100644 index 00000000..1c500ba3 Binary files /dev/null and b/resources/icons/modern/serverversuche.png differ diff --git a/resources/icons/modern/sharedwosub.png b/resources/icons/modern/sharedwosub.png new file mode 100644 index 00000000..ce754c1d Binary files /dev/null and b/resources/icons/modern/sharedwosub.png differ diff --git a/resources/icons/modern/sharedwsub.png b/resources/icons/modern/sharedwsub.png new file mode 100644 index 00000000..fe6f132a Binary files /dev/null and b/resources/icons/modern/sharedwsub.png differ diff --git a/resources/icons/modern/skull.png b/resources/icons/modern/skull.png new file mode 100644 index 00000000..2194ebbd Binary files /dev/null and b/resources/icons/modern/skull.png differ diff --git a/resources/icons/modern/somethingshared.png b/resources/icons/modern/somethingshared.png new file mode 100644 index 00000000..16090a9a Binary files /dev/null and b/resources/icons/modern/somethingshared.png differ diff --git a/resources/icons/modern/sound.png b/resources/icons/modern/sound.png new file mode 100644 index 00000000..0ca7e7a8 Binary files /dev/null and b/resources/icons/modern/sound.png differ diff --git a/resources/icons/modern/soundoff.png b/resources/icons/modern/soundoff.png new file mode 100644 index 00000000..b652d2a7 Binary files /dev/null and b/resources/icons/modern/soundoff.png differ diff --git a/resources/icons/modern/soundon.png b/resources/icons/modern/soundon.png new file mode 100644 index 00000000..6056d234 Binary files /dev/null and b/resources/icons/modern/soundon.png differ diff --git a/resources/icons/modern/speichern.png b/resources/icons/modern/speichern.png new file mode 100644 index 00000000..b57a3cae Binary files /dev/null and b/resources/icons/modern/speichern.png differ diff --git a/resources/icons/modern/splashscreen.png b/resources/icons/modern/splashscreen.png new file mode 100644 index 00000000..7498ad37 Binary files /dev/null and b/resources/icons/modern/splashscreen.png differ diff --git a/resources/icons/modern/splashscreen.properties b/resources/icons/modern/splashscreen.properties new file mode 100644 index 00000000..a73ef2ea --- /dev/null +++ b/resources/icons/modern/splashscreen.properties @@ -0,0 +1,6 @@ +#Icon-PropertyFile +#Tue Dec 07 22:09:12 CET 2004 +x=110 +y=170 +width=175 +height=15 diff --git a/resources/icons/modern/start.png b/resources/icons/modern/start.png new file mode 100644 index 00000000..c3702030 Binary files /dev/null and b/resources/icons/modern/start.png differ diff --git a/resources/icons/modern/suchen.png b/resources/icons/modern/suchen.png new file mode 100644 index 00000000..b29214a0 Binary files /dev/null and b/resources/icons/modern/suchen.png differ diff --git a/resources/icons/modern/sunossymbol.png b/resources/icons/modern/sunossymbol.png new file mode 100644 index 00000000..807fc711 Binary files /dev/null and b/resources/icons/modern/sunossymbol.png differ diff --git a/resources/icons/modern/text.png b/resources/icons/modern/text.png new file mode 100644 index 00000000..73e66ff1 Binary files /dev/null and b/resources/icons/modern/text.png differ diff --git a/resources/icons/modern/tree.png b/resources/icons/modern/tree.png new file mode 100644 index 00000000..cbde6182 Binary files /dev/null and b/resources/icons/modern/tree.png differ diff --git a/resources/icons/modern/treeIndirekt.png b/resources/icons/modern/treeIndirekt.png new file mode 100644 index 00000000..25eacb7c Binary files /dev/null and b/resources/icons/modern/treeIndirekt.png differ diff --git a/resources/icons/modern/treeRoot.png b/resources/icons/modern/treeRoot.png new file mode 100644 index 00000000..4fb49843 Binary files /dev/null and b/resources/icons/modern/treeRoot.png differ diff --git a/resources/icons/modern/treeUebertrage.png b/resources/icons/modern/treeUebertrage.png new file mode 100644 index 00000000..ae8cae80 Binary files /dev/null and b/resources/icons/modern/treeUebertrage.png differ diff --git a/resources/icons/modern/treeWarteschlange.png b/resources/icons/modern/treeWarteschlange.png new file mode 100644 index 00000000..25eacb7c Binary files /dev/null and b/resources/icons/modern/treeWarteschlange.png differ diff --git a/resources/icons/modern/umbenennen.png b/resources/icons/modern/umbenennen.png new file mode 100644 index 00000000..66027289 Binary files /dev/null and b/resources/icons/modern/umbenennen.png differ diff --git a/resources/icons/modern/unbekanntsymbol.png b/resources/icons/modern/unbekanntsymbol.png new file mode 100644 index 00000000..4f978c88 Binary files /dev/null and b/resources/icons/modern/unbekanntsymbol.png differ diff --git a/resources/icons/modern/update.png b/resources/icons/modern/update.png new file mode 100644 index 00000000..d21b4119 Binary files /dev/null and b/resources/icons/modern/update.png differ diff --git a/resources/icons/modern/upload.png b/resources/icons/modern/upload.png new file mode 100644 index 00000000..5bac0de4 Binary files /dev/null and b/resources/icons/modern/upload.png differ diff --git a/resources/icons/modern/verbinden.png b/resources/icons/modern/verbinden.png new file mode 100644 index 00000000..08f8b8c2 Binary files /dev/null and b/resources/icons/modern/verbinden.png differ diff --git a/resources/icons/modern/verbindungUnbekannt.png b/resources/icons/modern/verbindungUnbekannt.png new file mode 100644 index 00000000..567ece7e Binary files /dev/null and b/resources/icons/modern/verbindungUnbekannt.png differ diff --git a/resources/icons/modern/verzeichnislink.png b/resources/icons/modern/verzeichnislink.png new file mode 100644 index 00000000..455c3c5b Binary files /dev/null and b/resources/icons/modern/verzeichnislink.png differ diff --git a/resources/icons/modern/vlc.png b/resources/icons/modern/vlc.png new file mode 100644 index 00000000..45ee722e Binary files /dev/null and b/resources/icons/modern/vlc.png differ diff --git a/resources/icons/modern/warnung.png b/resources/icons/modern/warnung.png new file mode 100644 index 00000000..c5f97b42 Binary files /dev/null and b/resources/icons/modern/warnung.png differ diff --git a/resources/icons/modern/warten.png b/resources/icons/modern/warten.png new file mode 100644 index 00000000..43c3685a Binary files /dev/null and b/resources/icons/modern/warten.png differ diff --git a/resources/icons/modern/web.png b/resources/icons/modern/web.png new file mode 100644 index 00000000..68f21d30 Binary files /dev/null and b/resources/icons/modern/web.png differ diff --git a/resources/icons/modern/winsymbol.png b/resources/icons/modern/winsymbol.png new file mode 100644 index 00000000..1bc10ecc Binary files /dev/null and b/resources/icons/modern/winsymbol.png differ diff --git a/resources/icons/modern/wizardbanner.png b/resources/icons/modern/wizardbanner.png new file mode 100644 index 00000000..90c50fad Binary files /dev/null and b/resources/icons/modern/wizardbanner.png differ diff --git a/resources/icons/modern/zielordner.png b/resources/icons/modern/zielordner.png new file mode 100644 index 00000000..64606c28 Binary files /dev/null and b/resources/icons/modern/zielordner.png differ diff --git a/resources/icons/readme.txt b/resources/icons/readme.txt new file mode 100644 index 00000000..4b30ea9f --- /dev/null +++ b/resources/icons/readme.txt @@ -0,0 +1,8 @@ +Neues Iconpack einfach in eigenem Ordner ablegen. +Dies wird automatisch erkannt und zur Auswahl angeboten. + +Wichtig ist die richtige Schreibweise der Dateien, auch Groß-/Kleinschreibung ist zu beachten. +Es werden nur .png Dateien unterstützt. + +Fehlende Dateien sorgen für einen sofortigen Programmabbruch. +Am besten also ein vorhandenes IconPack duplizieren und die Dateien step by step austauschen. diff --git a/AJClientGUI/icons/deutsch.gif b/resources/language/deutsch.gif similarity index 100% rename from AJClientGUI/icons/deutsch.gif rename to resources/language/deutsch.gif diff --git a/AJClientGUI/language/deutsch.properties b/resources/language/deutsch.properties similarity index 63% rename from AJClientGUI/language/deutsch.properties rename to resources/language/deutsch.properties index bbb96228..969d7a32 100644 --- a/AJClientGUI/language/deutsch.properties +++ b/resources/language/deutsch.properties @@ -1,48 +1,48 @@ # #Mon Jan 12 09:26:29 CET 2009 -addserverform.caption=Server hinzuf\u00FCgen +addserverform.caption=Server hinzufügen addserverform.okbtn.caption=OK addserverform.portlbl.caption=Port addserverform.serverlbl.caption=DynIP vom Server -assistant.backbutton.caption=Zur\u00FCck +assistant.backbutton.caption=Zurück assistant.caption=Willkommen bei Applejuice -assistant.closebutton.caption=Schlie\u00DFen +assistant.closebutton.caption=Schließen assistant.finishtext=Ende assistant.Label1.caption=Willkommen bei appleJuice assistant.Label2.caption=Falls du appleJuice vorher noch nicht benutzt hast, kann dir dieser Assistent bei den Einstellungen helfen. -assistant.Label3.caption=Fortgeschrittene Anwender k\u00F6nnen die Einstellungen in den Optionen vornehmen. Klicke auf Schie\u00DFen um den Assistent jederzeit zu beenden. -assistant.Label4.caption=F\u00FCr die optimale Performance ben\u00F6tigt appleJuice noch ein paar kleine Informationen \u00FCber deine Internetverbindung. -assistant.Label5.caption=W\u00E4hle die Art der Verbindung\: -assistant.Label6.caption=Das wars \! appleJuice ist konfiguriert, um auf deinen Computer zu arbeiten. Solltest du die Einstellungen wieder \u00E4ndern wollen, kannst du den Assistenten durch den Link auf der Startseite wieder starten. Viel Spa\u00DF mit appleJuice \!\!\! ;-) +assistant.Label3.caption=Fortgeschrittene Anwender können die Einstellungen in den Optionen vornehmen. Klicke auf Schießen um den Assistent jederzeit zu beenden. +assistant.Label4.caption=Für die optimale Performance benötigt appleJuice noch ein paar kleine Informationen über deine Internetverbindung. +assistant.Label5.caption=Wäle die Art der Verbindung\: +assistant.Label6.caption=Das wars \! appleJuice ist konfiguriert, um auf deinen Computer zu arbeiten. Solltest du die Einstellungen wieder ändern wollen, kannst du den Assistenten durch den Link auf der Startseite wieder starten. Viel Spaß mit appleJuice \!\!\! ;-) assistant.Label7.caption=Bitte gebe deinen Benutzernamen ein. "nonick" ist ein nicht erlaubter Benutzername. -assistant.Label8.caption=Bitte w\u00E4hle eine Sprache. +assistant.Label8.caption=Bitte wäle eine Sprache. assistant.nextbutton.caption=Weiter assistant.nexttext=Weiter chatform.caption=Chat chatform.sendbtn.caption=Senden -closeform.caption=Schlie\u00DFen -closeform.closecoreradio.caption=GUI und Core schlie\u00DFen -closeform.closeradio.caption=GUI schlie\u00DFen +closeform.caption=Schließen +closeform.closecoreradio.caption=GUI und Core schließen +closeform.closeradio.caption=GUI schließen closeform.minimizeradio.caption=minimiere ins Tray closeform.neveraskbox.caption=Nie wieder Fragen closeform.okbtn.caption=OK closeform.reconnectradio.caption=Zum Core neu verbinden connect.Button1.caption=OK -connect.Button2.caption=Abbruch/Schlie\u00DFen +connect.Button2.caption=Abbruch/Schließen connect.caption=Verbinde zum Core.... connect.CheckBox1.caption=Nie wieder fragen -connect.infolabel.caption=Du hast 127.0.0.1 f\u00FCr den Core eingegeben, aber er wurde nicht gefunden. Der Core wird gestartet, wenn du auf OK klickst. +connect.infolabel.caption=Du hast 127.0.0.1 für den Core eingegeben, aber er wurde nicht gefunden. Der Core wird gestartet, wenn du auf OK klickst. connect.Label1.caption=Core -connect.Label2.caption=Pa\u00DFwort +connect.Label2.caption=Paßwort connect.remember.caption=Speichern einstform.autoconn.caption=Automatisch Verbinden einstform.browallow.caption=Erlaube das Browsen einstform.Button1.caption=OK einstform.Button2.caption=Abbruch -einstform.Button3.caption=Password \u00E4ndern +einstform.Button3.caption=Password ändern einstform.caption=Optionen einstform.closeask.caption=Fragen, wie Applejuice geschlossen werden soll? -einstform.connask.caption=\u00DCberpr\u00FCfe Verbindung +einstform.connask.caption=Überprüfe Verbindung einstform.connectionsheet.caption=Verbindung einstform.downcolumns.caption=Spalten in der Downloadliste einstform.dwncol1.caption=Bereits geladen @@ -50,17 +50,17 @@ einstform.dwncol2.caption=Prozent fertig geladen einstform.dwncol3.caption=Noch zu laden einstform.graphicview.caption=Graphische Anzeige, was schon geladen worden ist einstform.GroupBox1.caption=Statusbar -einstform.Label1.caption=Achtung\! Alle Benutzer k\u00F6nnen die Dateien sehen, die du anbietest\! +einstform.Label1.caption=Achtung\! Alle Benutzer können die Dateien sehen, die du anbietest\! einstform.Label10.caption=Sprache einstform.Label11.caption=Hier sind alle geladenen Plugins aufgelistet einstform.Label12.caption=Aktualisiere alle (in Sekunden) 0 \= Keine Aktualisierung einstform.Label13.caption=Max. Downloadgeschwindigkeit in kb/s -einstform.Label14.caption=Sendepriorit\u00E4t der Downloads -einstform.Label15.caption=Altes Pa\u00DFwort -einstform.Label16.caption=Neues Pa\u00DFwort -einstform.Label17.caption=Password best\u00E4tigen +einstform.Label14.caption=Sendepriorität der Downloads +einstform.Label15.caption=Altes Paßwort +einstform.Label16.caption=Neues Paßwort +einstform.Label17.caption=Password bestätigen einstform.Label18.caption=Ping Grenze wegen den Uploadslots in ms -einstform.Label19.caption=URL f\u00FCrs pingen wegen den Uploadslots +einstform.Label19.caption=URL fürs pingen wegen den Uploadslots einstform.Label2.caption=Temp-Verzeichnis einstform.Label3.caption=Core-Port einstform.Label4.caption=Max. Verbindungen @@ -70,21 +70,21 @@ einstform.Label7.caption=Fertige Dateien einstform.Label8.caption=Benutzername einstform.Label9.caption=Anzahl der Dateien beim Download einstform.languagesheet.caption=Sprache -einstform.pwsheet.caption=Pa\u00DFwort +einstform.pwsheet.caption=Paßwort einstform.questionsheet.caption=Abfrage einstform.securitysheet.caption=Sicherheit einstform.simplebar.caption=einfache Statusleiste einstform.standardsheet.caption=Standard einstform.TabSheet1.caption=Plugins einstform.visualsheet.caption=Anzeige -javagui.checkupdate.keineNeueVersion=Es ist keine neuere Version verf\u00FCgbar. -javagui.downloadform.aktiveuebertragung=aktive \u00DCbertragung +javagui.checkupdate.keineNeueVersion=Es ist keine neuere Version verfügbar. +javagui.downloadform.aktiveuebertragung=aktive Übertragung javagui.downloadform.bereitsgeladen='%s' bereits herunter geladen. javagui.downloadform.datawirderstellt=*.data wird erstellt javagui.downloadform.dreckigerrest=dreckiger Rest javagui.downloadform.eigeneslimiterreicht=Eigenes Limit erreicht -javagui.downloadform.einfuegen=Einf\u00FCgen -javagui.downloadform.falscherlink='%s' ist ung\u00FCltig. +javagui.downloadform.einfuegen=Einfügen +javagui.downloadform.falscherlink='%s' ist ungültig. javagui.downloadform.fehlerbeimfertigstellen=Fehler beim Fertigstellen javagui.downloadform.getlinkwithsources=Link mit Source in Ablage kopieren javagui.downloadform.indverbindungabgelehnt=indirekte Verbindung abgelehnt @@ -95,14 +95,14 @@ javagui.downloadform.partlisteanzeigen=Partliste anzeigen javagui.downloadform.quellen=\ Quelle(n) javagui.downloadform.sonstigerlinkfehlerkurz=Coreseitiger Fehler javagui.downloadform.sonstigerlinkfehlerlang=Es wurde coreseitig ein Fehler beim Starten des Downloads gemeldet. Bitte schauen Sie in die Core-Konsole. -javagui.downloadform.uebertragen=% \u00FCbertragen -javagui.downloadform.verbindungunmoeglich=keine Verbindung m\u00F6glich -javagui.downloadform.verfuegbar=%s% verf\u00FCgbar +javagui.downloadform.uebertragen=% übertragen +javagui.downloadform.verbindungunmoeglich=keine Verbindung möglich +javagui.downloadform.verfuegbar=%s% verfügbar javagui.downloadform.waitnodetext=bitte warten... javagui.downloadform.wartendedownloads=in Warteschlange javagui.downloadform.warteschlangevoll=Warteschlange voll javagui.downloadform.zielverzeichnis=Zielverzeichnis -javagui.downloadtab.btnOK=\u00DCbernehmen +javagui.downloadtab.btnOK=Übernehmen javagui.downloadtab.label1=Automatischer Powerdownload javagui.downloadtab.pdlAb=ab javagui.downloadtab.pdlBis=bis @@ -113,11 +113,11 @@ javagui.mainform.fortsetzen=Fortsetzen javagui.mainform.keinserver= javagui.mainform.nichtverbunden=Nicht verbunden... javagui.mainform.pause=Pause -javagui.mainform.themesupportnachricht=Bist du dir sicher? Das GUI m\u00FCsste neu gestartet werden. +javagui.mainform.neustartnachricht=Bist du dir sicher? Das GUI müsste neu gestartet werden. javagui.mainform.verbinden=Verbinden... javagui.mainform.verbunden=Verbunden... -javagui.menu.aktivieren=aktivieren -javagui.menu.bestaetigung=Bist du sicher, dass du den Core beenden willst? Du wirst die Kontrolle \u00FCber den Core verlieren\! +javagui.menu.aktivieren=Skins aktivieren +javagui.menu.bestaetigung=Bist du sicher, dass du den Core beenden willst? Du wirst die Kontrolle über den Core verlieren\! javagui.menu.corebeenden=Core beenden javagui.menu.corebeendenhint=Mit dieser Funktionen kannst du deinen Core beenden. javagui.menu.dateiliste=Dateiliste importieren @@ -125,6 +125,8 @@ javagui.menu.dateilistehint=Komplette ajl-Listen importieren. javagui.menu.deaktivieren=deaktivieren javagui.menu.extras=Extras javagui.menu.themes=Themes +javagui.menu.icons=Icons +javagui.menu.sound=Sound javagui.menu.verstecken=Verstecken javagui.menu.zeigen=Zeigen javagui.options.ansicht.aktiv=aktiv @@ -132,10 +134,10 @@ javagui.options.ansicht.caption=Ansicht javagui.options.ansicht.downloadansicht=Partliste bei Mausklick anzeigen javagui.options.ansicht.fertigerdownload=fertiger Download javagui.options.ansicht.hintergrundfarben=Hintergrundfarben -javagui.options.ansicht.hintergrundfarbewaehlen=Hintergrundfarbe w\u00E4hlen +javagui.options.ansicht.hintergrundfarbewaehlen=Hintergrundfarbe wälen javagui.options.ansicht.quelle=Quelle -javagui.options.ansicht.ttipp_farbewaehlen=Um die Farbe zu \u00E4ndern, klicke auf die Farbe|und w\u00E4hle eine neue Farbe aus. -javagui.options.ansicht.zeigestartscreen=Startscreen beim n\u00E4chsten Start des GUI anzeigen? +javagui.options.ansicht.ttipp_farbewaehlen=Um die Farbe zu ändern, klicke auf die Farbe|und wäle eine neue Farbe aus. +javagui.options.ansicht.zeigestartscreen=Startscreen beim nächsten Start des GUI anzeigen? javagui.options.ansicht.zeigetooltipps=Tooltipp anzeigen javagui.options.logging.debug=Debuginfos javagui.options.logging.info=Infos @@ -145,7 +147,7 @@ javagui.options.plugins.autor=Autor javagui.options.plugins.beschreibung=Beschreibung javagui.options.plugins.einstellungen=Einstellungen javagui.options.plugins.name=Name -javagui.options.plugins.schliessen=Schlie\u00DFen +javagui.options.plugins.schliessen=Schließen javagui.options.plugins.version=Version javagui.options.proxy.benutzername=Benutzername javagui.options.proxy.caption=Proxy @@ -154,22 +156,19 @@ javagui.options.proxy.passwort=Passwort javagui.options.proxy.port=Port javagui.options.proxy.verwenden=wird verwendet javagui.options.remote.caption=Fernzugriff -javagui.options.remote.fehlertext=Du hast ung\u00FCltige Angaben im Bereich Fernzugriff gemacht. Dieser Bereich wurde nicht gespeichert. +javagui.options.remote.fehlertext=Du hast ungültige Angaben im Bereich Fernzugriff gemacht. Dieser Bereich wurde nicht gespeichert. javagui.options.remote.host=Host javagui.options.remote.passwortAlt=Altes Passwort javagui.options.remote.passwortNeu=Neues Passwort javagui.options.remote.verwenden=Fernzugriff verwenden javagui.options.standard.ladeplugins=Plugins beim Start laden javagui.options.standard.standardbrowser=Standardbrowser -javagui.options.standard.startemitstandard=\u00D6ffne mit Standardprogramm -javagui.options.standard.ttipp_nick=Diese Einstellung wird erst nach einem|erneuten Verbindungsaufbau zu einem Server g\u00FCltig. -javagui.options.standard.ttipp_port=Eine \u00C4nderung hat die Beendigung aller|offenen Chatsessions, Uploads und eventuell|der aktuellen Downloads zur Folge.|Nach \u00C4nderung dieser Einstellung ist ein erneutes|Verbinden mit einem Server notwendig.|1024 javagui.mainform.nichtverbunden=not connected... javagui.mainform.pause=pause -javagui.mainform.themesupportnachricht=Are you sure? The GUI needs to be restartet. +javagui.mainform.neustartnachricht=Are you sure? The GUI needs to be restartet. javagui.mainform.verbinden...=connecting... javagui.mainform.verbunden=connected... -javagui.menu.aktivieren=activate +javagui.menu.aktivieren=Skin activate javagui.menu.bestaetigung=Are you sure you want shutdown your core? You will loose the control over the core. javagui.menu.corebeenden=Shutdown core javagui.menu.corebeendenhint=This function will shutdown your core. @@ -131,6 +131,8 @@ javagui.menu.dateilistehint=Import a complete ajl-list. javagui.menu.deaktivieren=deactivate javagui.menu.extras=Extras javagui.menu.themes=Themes +javagui.menu.icons=Icons +javagui.menu.sound=Sound javagui.menu.verstecken=Hide javagui.menu.zeigen=Show javagui.options.ansicht.aktiv=active @@ -199,12 +201,11 @@ javagui.startup.fehlversuch=Unable to connect to core javagui.startup.newversionnachricht=A new version was found (%s). Please do not use old versions. javagui.startup.newversiontitel=Found new version javagui.startup.showdialog=never show again -javagui.startup.sonstigeversionen=Other versions javagui.startup.trayfehler=TrayIcon12.dll not found. Application starts without TrayIcon. javagui.startup.ueberpruefeEinst=Please check your settings\: javagui.startup.updatefehlernachricht=You have to specify a correct webbrowser to use this feature. javagui.startup.verbindungsfehler=It was not possible to connect to the remote-core on '%s'. AppleJuice will close. -javagui.startup.windowsversion=Windowsversion +javagui.startup.newversion=Download javagui.tooltipps.autopowerdownload=By activation of the automatic power download you can fix, from which count of|credits the power download is activated and when it switches|off itself again. The power download always considers the mostly loaded files.|The GUI must run. javagui.tooltipps.powerdownload=Activation of powerdownload increases your chances to download.|The more credits you spend, the higher you slip in the queue. javagui.uploadform.columnwasserstand=watermark @@ -253,7 +254,7 @@ mainform.browsetree.col0caption=Name mainform.browsetree.col1caption=Size/Status mainform.canceldown.caption=Cancel mainform.cancelsearch.caption=Cancel Search -mainform.caption=appleJuice Client +mainform.caption=appleJuice GUI mainform.changetarget.caption=Change targetdir mainform.chat1.caption=Chat mainform.chat2.caption=chat @@ -492,23 +493,4 @@ targetdirform.Button2.caption=Cancel targetdirform.caption=change Targetdirectory targetdirform.Label1.caption=Please Enter a Subdirectory of your Incoming. This directory does not have to exist. Empty directory mean you want to save the file directly in the incoming directory. targetdirform=\n\t -releaseinfo.menu=Release-information -releaseinfo.categories=Categories: -releaseinfo.format=Format: -releaseinfo.viewed=Viewed: -releaseinfo.count=%all (current month: %month) -releaseinfo.clicks=Clicks: -releaseinfo.published=Published: -releaseinfo.today=Today -releaseinfo.yesterday=Yesterday -releaseinfo.languages=Languages: -releaseinfo.genres=Genres: -releaseinfo.rating.video=Video-Rating: -releaseinfo.rating.audio=Audio-Rating: -releaseinfo.fsk18=FSK 18: -releaseinfo.yes=yes -releaseinfo.no=no -releaseinfo.downloadimage=Download picture -releaseinfo.downloadimage.ok=Picture successfully downloaded. -releaseinfo.na=No release-information available. -releaseinfo.browse=Browse site \ No newline at end of file +releaseinfo.menu=search for more information diff --git a/AJClientGUI/language/italiano.gif b/resources/language/italiano.gif similarity index 100% rename from AJClientGUI/language/italiano.gif rename to resources/language/italiano.gif diff --git a/AJClientGUI/language/italiano.properties b/resources/language/italiano.properties similarity index 99% rename from AJClientGUI/language/italiano.properties rename to resources/language/italiano.properties index 64242dc9..6e1c53b0 100644 --- a/AJClientGUI/language/italiano.properties +++ b/resources/language/italiano.properties @@ -105,10 +105,10 @@ javagui.mainform.fortsetzen=Ricommincere javagui.mainform.keinserver= javagui.mainform.nichtverbunden=non connesso... javagui.mainform.pause=Pausa -javagui.mainform.themesupportnachricht=Sei sicuro? La GUI dovrebbe fare un restart +javagui.mainform.neustartnachricht=Sei sicuro? La GUI dovrebbe fare un restart javagui.mainform.verbinden=Connetere... javagui.mainform.verbunden=Connesso... -javagui.menu.aktivieren=attivare +javagui.menu.aktivieren=Skin attivare javagui.menu.bestaetigung=Sicuro di chiudere il Core? Lei non avra piu il controllo sul Core. javagui.menu.corebeenden=Chiudere il Core javagui.menu.corebeendenhint=Con questa impostazione puoi chiudere tuo core @@ -117,6 +117,8 @@ javagui.menu.dateilistehint=Importare lista completa di aj. javagui.menu.deaktivieren=deattivare javagui.menu.extras=Speciale javagui.menu.themes=Themes +javagui.menu.icons=Icons +javagui.menu.sound=Sound javagui.menu.verstecken=Nascondere javagui.menu.zeigen=Visualizzare javagui.options.ansicht.aktiv=attivo @@ -179,12 +181,11 @@ javagui.startup.fehlversuch=Connessione del Core non eseguito. javagui.startup.newversionnachricht=Una nuova Versione di Applejuice \u00E8 stata trovata (%s). Sie prega di non utlizzare versiopne vecchie javagui.startup.newversiontitel=Nova versione trovata javagui.startup.showdialog=non visualizzare mai piu -javagui.startup.sonstigeversionen=Altri javagui.startup.trayfehler=TrayIcon12.dll non fu trovato. Il programma si apre senza TrayIcon. javagui.startup.ueberpruefeEinst=Sie prega di controllare le impostazioni javagui.startup.updatefehlernachricht=Devi selezionare un browser per le pagine web che funzioni, per utilizzare questa funzione javagui.startup.verbindungsfehler=Non cera la possibilit\u00E0 di connetermi sul Core su '%s'. AppleJuice viene chiuso. -javagui.startup.windowsversion=Versione Windows +javagui.startup.newversion=Download javagui.tooltipps.autopowerdownload=Con l'attivazione del Powerdownload automatico puoi decidere quando il|Powerdownload inizia, e quando deve smettere.|Il Powerdownload sa sempre qui file che sono caricati tante volte.|Il GUI deve correre. javagui.tooltipps.powerdownload=Con l'attivazione del Powerdownload sale la possibilita di scaricare qualcosa.|Se paghi di piu Crediti, sali nella lista d'attesa del Cliente che ha il file che vuoi. javagui.uploadform.columnwasserstand=watermark @@ -232,7 +233,7 @@ mainform.browsetree.col0caption=Nome mainform.browsetree.col1caption=Grandezza/Status mainform.canceldown.caption=Annulla mainform.cancelsearch.caption=Annulla la cerca -mainform.caption=Cliente appleJuice +mainform.caption=appleJuice GUI mainform.changetarget.caption=cambia cartella mainform.chat1.caption=Chat mainform.chat2.caption=Chat diff --git a/AJClientGUI/language/tuerkce.gif b/resources/language/tuerkce.gif similarity index 100% rename from AJClientGUI/language/tuerkce.gif rename to resources/language/tuerkce.gif diff --git a/AJClientGUI/language/tuerkce.properties b/resources/language/tuerkce.properties similarity index 98% rename from AJClientGUI/language/tuerkce.properties rename to resources/language/tuerkce.properties index 14e48536..2adc8e23 100644 --- a/AJClientGUI/language/tuerkce.properties +++ b/resources/language/tuerkce.properties @@ -114,10 +114,10 @@ javagui.mainform.fortsetzen=Devam et javagui.mainform.keinserver= javagui.mainform.nichtverbunden=Ba\u011Fl\u0131 deyil... javagui.mainform.pause=Molada -javagui.mainform.themesupportnachricht=Eminmisin? GUI tekrar, yeniden \u00E7al\u0131st\u0131r\u0131lmas\u0131 laz\u0131m. +javagui.mainform.neustartnachricht=Eminmisin? GUI tekrar, yeniden \u00E7al\u0131st\u0131r\u0131lmas\u0131 laz\u0131m. javagui.mainform.verbinden=Ba\u011Flan... javagui.mainform.verbunden=Ba\u011Fland\u0131... -javagui.menu.aktivieren=aktif duruma getir +javagui.menu.aktivieren=Skin aktif duruma getir javagui.menu.bestaetigung=Coru kapatmakta eminmisiniz? Core \u00FCzerinde Kontrol\u00FC kaybedeceksiniz\! javagui.menu.corebeenden=Core Kapans\u0131n javagui.menu.corebeendenhint=Bu funksiyonla coru kapatabilirsin. @@ -126,6 +126,8 @@ javagui.menu.dateilistehint=Komple olan ajl-listesini ithal et. javagui.menu.deaktivieren=deaktif etme javagui.menu.extras=Ekstralar javagui.menu.themes=Themes +javagui.menu.icons=Icons +javagui.menu.sound=Sound javagui.menu.verstecken=Gizle javagui.menu.zeigen=G\u00F6ster javagui.options.ansicht.aktiv=Aktif @@ -192,12 +194,11 @@ javagui.startup.fehlversuch=Core ba\u011Flant\u0131s\u0131 yap\u0131lamad\u0131 javagui.startup.newversionnachricht=Yeni bir Applejuice bulundu (%s). L\u00FCtfen eski Version kullanmay\u0131n\u0131z. javagui.startup.newversiontitel=Yeni versiyon bulundu...... javagui.startup.showdialog=Hi\u00E7 bir daha g\u00F6sterme -javagui.startup.sonstigeversionen=Diyerleri javagui.startup.trayfehler=TrayIcon12.dll bulundu. Programm TrayIconsus \u00E7al\u0131\u015Facak. javagui.startup.ueberpruefeEinst=L\u00FCtfen vermi\u015F oldu\u011Fun de\u011Ferleri kontrol et\: javagui.startup.updatefehlernachricht=Bu funksiyonu kullanabilmen i\u00E7in. G\u00FCncel bir Webbrowser se\u00E7mek zorundas\u0131n\u0131z. Kulland\u0131\u011F\u0131n\u0131z BROWSER\u00B4\u0130 Ekstralar / Se\u00E7enekler \u00FCzerinden belleyebilirsiniz. javagui.startup.verbindungsfehler=Uzaktaki Cora ba\u011Flant\u0131 kurmak m\u00FCmk\u00FCn '%s' de\u011Fildi. AppleJuice kapat\u0131l\u0131yor. -javagui.startup.windowsversion=Windows versiyonu +javagui.startup.newversion=Download javagui.tooltipps.autopowerdownload=Otomatik Powerdownloadta, powerdownloadun download ba\u015F\u0131na |ne kadar kredi vermesini sabitle\u015Ftirmi\u015F ve ne zaman ac\u0131l\u0131p /|kapanaca\u011F\u0131n\u0131 belirlemi\u015F olursunuz. Powerdownload en \u00E7ok |indirilmi\u015F(mb) olan Dosyalara \u00F6ncelik sa\u011Flar. javagui.tooltipps.powerdownload=Powerdownloadu aktifle\u015Ftirirseniz indirme \u015Fans\u0131n\u0131z| y\u00FCkselecektir, ve ne kadar \u00E7ok kredi verirseniz, |bekleme kuyru\u011Funda o kadar yukar\u0131ya \u00E7\u0131kacaks\u0131n\u0131z. javagui.uploadform.columnwasserstand=watermark @@ -248,7 +249,7 @@ mainform.browsetree.col0caption=\u0130sim mainform.browsetree.col1caption=Miktar / Durum mainform.canceldown.caption=\u0130ptal/\u0130ndirmeyece\u011Fim mainform.cancelsearch.caption=Aramay\u0131 durdur -mainform.caption=AppleJuice klienti +mainform.caption=appleJuice GUI mainform.changetarget.caption=Arzu etti\u011Fin dosyay\u0131 de\u011Fi\u015Ftir mainform.chat1.caption=Chat mainform.chat2.caption=Chat diff --git a/ajcorefassade/.cvsignore b/resources/lib/.gitignore similarity index 100% rename from ajcorefassade/.cvsignore rename to resources/lib/.gitignore diff --git a/AJClientGUI/plugins/.cvsignore b/resources/plugins/.gitignore similarity index 88% rename from AJClientGUI/plugins/.cvsignore rename to resources/plugins/.gitignore index ff75d57c..be66e591 100644 --- a/AJClientGUI/plugins/.cvsignore +++ b/resources/plugins/.gitignore @@ -1,4 +1,5 @@ *.gif *.zip +*.jar serverwatcher.jar serverwatcher.xml diff --git a/resources/plugins/readme.txt b/resources/plugins/readme.txt new file mode 100644 index 00000000..f9e5f0a4 --- /dev/null +++ b/resources/plugins/readme.txt @@ -0,0 +1,3 @@ +In dieses Verzeichnis kommen die Plugins als jar-Archive rein. +Falls Du Linux oder macOS verwendest, wird dieses Verzeichnis nicht beachtet. +Dann gehören Plugins ins Verzeichnis ~/appleJuice/gui/plugins/ diff --git a/resources/pwdlpolicies/.gitignore b/resources/pwdlpolicies/.gitignore new file mode 100644 index 00000000..d392f0e8 --- /dev/null +++ b/resources/pwdlpolicies/.gitignore @@ -0,0 +1 @@ +*.jar diff --git a/AJClientGUI/pwdlpolicies/readme.txt b/resources/pwdlpolicies/readme.txt similarity index 100% rename from AJClientGUI/pwdlpolicies/readme.txt rename to resources/pwdlpolicies/readme.txt diff --git a/AJClientGUI/sounds/abgebrochen.wav b/resources/sounds/classic/abgebrochen.wav similarity index 100% rename from AJClientGUI/sounds/abgebrochen.wav rename to resources/sounds/classic/abgebrochen.wav diff --git a/AJClientGUI/sounds/gespeichert.wav b/resources/sounds/classic/gespeichert.wav similarity index 100% rename from AJClientGUI/sounds/gespeichert.wav rename to resources/sounds/classic/gespeichert.wav diff --git a/AJClientGUI/sounds/gestartet.wav b/resources/sounds/classic/gestartet.wav similarity index 100% rename from AJClientGUI/sounds/gestartet.wav rename to resources/sounds/classic/gestartet.wav diff --git a/AJClientGUI/sounds/komplett.wav b/resources/sounds/classic/komplett.wav similarity index 100% rename from AJClientGUI/sounds/komplett.wav rename to resources/sounds/classic/komplett.wav diff --git a/AJClientGUI/sounds/konkretisieren.wav b/resources/sounds/classic/konkretisieren.wav similarity index 100% rename from AJClientGUI/sounds/konkretisieren.wav rename to resources/sounds/classic/konkretisieren.wav diff --git a/AJClientGUI/sounds/laden.wav b/resources/sounds/classic/laden.wav similarity index 100% rename from AJClientGUI/sounds/laden.wav rename to resources/sounds/classic/laden.wav diff --git a/AJClientGUI/sounds/pwdl.wav b/resources/sounds/classic/pwdl.wav similarity index 100% rename from AJClientGUI/sounds/pwdl.wav rename to resources/sounds/classic/pwdl.wav diff --git a/AJClientGUI/sounds/suchen.wav b/resources/sounds/classic/suchen.wav similarity index 100% rename from AJClientGUI/sounds/suchen.wav rename to resources/sounds/classic/suchen.wav diff --git a/AJClientGUI/sounds/verbinden.wav b/resources/sounds/classic/verbinden.wav similarity index 100% rename from AJClientGUI/sounds/verbinden.wav rename to resources/sounds/classic/verbinden.wav diff --git a/AJClientGUI/sounds/verweigert.wav b/resources/sounds/classic/verweigert.wav similarity index 100% rename from AJClientGUI/sounds/verweigert.wav rename to resources/sounds/classic/verweigert.wav diff --git a/AJClientGUI/sounds/zuganggestattet.wav b/resources/sounds/classic/zuganggestattet.wav similarity index 100% rename from AJClientGUI/sounds/zuganggestattet.wav rename to resources/sounds/classic/zuganggestattet.wav diff --git a/resources/sounds/lcars/abgebrochen.wav b/resources/sounds/lcars/abgebrochen.wav new file mode 100644 index 00000000..66c1c82b Binary files /dev/null and b/resources/sounds/lcars/abgebrochen.wav differ diff --git a/resources/sounds/lcars/gespeichert.wav b/resources/sounds/lcars/gespeichert.wav new file mode 100644 index 00000000..d4035a90 Binary files /dev/null and b/resources/sounds/lcars/gespeichert.wav differ diff --git a/resources/sounds/lcars/komplett.wav b/resources/sounds/lcars/komplett.wav new file mode 100644 index 00000000..139fb544 Binary files /dev/null and b/resources/sounds/lcars/komplett.wav differ diff --git a/resources/sounds/lcars/konkretisieren.wav b/resources/sounds/lcars/konkretisieren.wav new file mode 100644 index 00000000..0d270f8c Binary files /dev/null and b/resources/sounds/lcars/konkretisieren.wav differ diff --git a/resources/sounds/lcars/laden.wav b/resources/sounds/lcars/laden.wav new file mode 100644 index 00000000..9c5ba465 Binary files /dev/null and b/resources/sounds/lcars/laden.wav differ diff --git a/resources/sounds/lcars/pwdl.wav b/resources/sounds/lcars/pwdl.wav new file mode 100644 index 00000000..b9406978 Binary files /dev/null and b/resources/sounds/lcars/pwdl.wav differ diff --git a/resources/sounds/lcars/suchen.wav b/resources/sounds/lcars/suchen.wav new file mode 100644 index 00000000..9c5ba465 Binary files /dev/null and b/resources/sounds/lcars/suchen.wav differ diff --git a/resources/sounds/lcars/verbinden.wav b/resources/sounds/lcars/verbinden.wav new file mode 100644 index 00000000..c3f35a22 Binary files /dev/null and b/resources/sounds/lcars/verbinden.wav differ diff --git a/resources/sounds/lcars/verweigert.wav b/resources/sounds/lcars/verweigert.wav new file mode 100644 index 00000000..146db7d3 Binary files /dev/null and b/resources/sounds/lcars/verweigert.wav differ diff --git a/resources/sounds/lcars/zuganggestattet.wav b/resources/sounds/lcars/zuganggestattet.wav new file mode 100644 index 00000000..4f082636 Binary files /dev/null and b/resources/sounds/lcars/zuganggestattet.wav differ diff --git a/resources/sounds/readme.txt b/resources/sounds/readme.txt new file mode 100644 index 00000000..776c6d74 --- /dev/null +++ b/resources/sounds/readme.txt @@ -0,0 +1,11 @@ +Neues Soundpack einfach in eigenem Ordner ablegen. + +Dies wird automatisch erkannt und zur Auswahl angeboten. + +Wichtig ist die richtige Schreibweise, auch Groß-/Kleinschreibung ist zu beachten. + +Getestete Formate: +PCM, 22050 Hz, 1 Channel, 8 bit +PCM, 22050 Hz, 2 Channels, 8 bit + +Falsche Formate werden mit einer Errormessage im Log belohnt. diff --git a/resources/sounds/warp/abgebrochen.wav b/resources/sounds/warp/abgebrochen.wav new file mode 100644 index 00000000..bd767257 Binary files /dev/null and b/resources/sounds/warp/abgebrochen.wav differ diff --git a/resources/sounds/warp/gespeichert.wav b/resources/sounds/warp/gespeichert.wav new file mode 100644 index 00000000..f0b0e7a8 Binary files /dev/null and b/resources/sounds/warp/gespeichert.wav differ diff --git a/resources/sounds/warp/komplett.wav b/resources/sounds/warp/komplett.wav new file mode 100644 index 00000000..aa436d53 Binary files /dev/null and b/resources/sounds/warp/komplett.wav differ diff --git a/resources/sounds/warp/konkretisieren.wav b/resources/sounds/warp/konkretisieren.wav new file mode 100644 index 00000000..a720f15a Binary files /dev/null and b/resources/sounds/warp/konkretisieren.wav differ diff --git a/resources/sounds/warp/laden.wav b/resources/sounds/warp/laden.wav new file mode 100644 index 00000000..eb90cd57 Binary files /dev/null and b/resources/sounds/warp/laden.wav differ diff --git a/resources/sounds/warp/pwdl.wav b/resources/sounds/warp/pwdl.wav new file mode 100644 index 00000000..0be6471d Binary files /dev/null and b/resources/sounds/warp/pwdl.wav differ diff --git a/AJClientGUI/sounds/readme.first b/resources/sounds/warp/readme.first similarity index 100% rename from AJClientGUI/sounds/readme.first rename to resources/sounds/warp/readme.first diff --git a/resources/sounds/warp/suchen.wav b/resources/sounds/warp/suchen.wav new file mode 100644 index 00000000..eb90cd57 Binary files /dev/null and b/resources/sounds/warp/suchen.wav differ diff --git a/resources/sounds/warp/verbinden.wav b/resources/sounds/warp/verbinden.wav new file mode 100644 index 00000000..3cfcd7d8 Binary files /dev/null and b/resources/sounds/warp/verbinden.wav differ diff --git a/resources/sounds/warp/verweigert.wav b/resources/sounds/warp/verweigert.wav new file mode 100644 index 00000000..4468cd71 Binary files /dev/null and b/resources/sounds/warp/verweigert.wav differ diff --git a/resources/sounds/warp/zuganggestattet.wav b/resources/sounds/warp/zuganggestattet.wav new file mode 100644 index 00000000..368c5ab8 Binary files /dev/null and b/resources/sounds/warp/zuganggestattet.wav differ diff --git a/resources/themes/WhistlerGreen.zip b/resources/themes/WhistlerGreen.zip new file mode 100644 index 00000000..3af1682b Binary files /dev/null and b/resources/themes/WhistlerGreen.zip differ diff --git a/resources/themes/alloy.zip b/resources/themes/alloy.zip new file mode 100644 index 00000000..c31beae3 Binary files /dev/null and b/resources/themes/alloy.zip differ diff --git a/resources/themes/amarach.zip b/resources/themes/amarach.zip new file mode 100644 index 00000000..e562aa3a Binary files /dev/null and b/resources/themes/amarach.zip differ diff --git a/AJClientGUI/themes/aquathemepack.zip b/resources/themes/aqua.zip similarity index 100% rename from AJClientGUI/themes/aquathemepack.zip rename to resources/themes/aqua.zip diff --git a/resources/themes/architectBlue.zip b/resources/themes/architectBlue.zip new file mode 100644 index 00000000..46b4f706 Binary files /dev/null and b/resources/themes/architectBlue.zip differ diff --git a/resources/themes/architectOlive.zip b/resources/themes/architectOlive.zip new file mode 100644 index 00000000..285446d9 Binary files /dev/null and b/resources/themes/architectOlive.zip differ diff --git a/resources/themes/b0sumi.zip b/resources/themes/b0sumi.zip new file mode 100644 index 00000000..50b0c884 Binary files /dev/null and b/resources/themes/b0sumi.zip differ diff --git a/resources/themes/b0sumiErgot.zip b/resources/themes/b0sumiErgot.zip new file mode 100644 index 00000000..46527f45 Binary files /dev/null and b/resources/themes/b0sumiErgot.zip differ diff --git a/resources/themes/beigeazul.zip b/resources/themes/beigeazul.zip new file mode 100644 index 00000000..5afc3429 Binary files /dev/null and b/resources/themes/beigeazul.zip differ diff --git a/resources/themes/blueMetal.zip b/resources/themes/blueMetal.zip new file mode 100644 index 00000000..4b5c82b6 Binary files /dev/null and b/resources/themes/blueMetal.zip differ diff --git a/resources/themes/blueTurquesa.zip b/resources/themes/blueTurquesa.zip new file mode 100644 index 00000000..0f5e29f3 Binary files /dev/null and b/resources/themes/blueTurquesa.zip differ diff --git a/resources/themes/chaNinja-Blue.zip b/resources/themes/chaNinja-Blue.zip new file mode 100644 index 00000000..281175ab Binary files /dev/null and b/resources/themes/chaNinja-Blue.zip differ diff --git a/resources/themes/coronaH.zip b/resources/themes/coronaH.zip new file mode 100644 index 00000000..5e88f919 Binary files /dev/null and b/resources/themes/coronaH.zip differ diff --git a/resources/themes/cougar.zip b/resources/themes/cougar.zip new file mode 100644 index 00000000..61303843 Binary files /dev/null and b/resources/themes/cougar.zip differ diff --git a/resources/themes/crystal2.zip b/resources/themes/crystal2.zip new file mode 100644 index 00000000..9ddd0899 Binary files /dev/null and b/resources/themes/crystal2.zip differ diff --git a/resources/themes/fatalE.zip b/resources/themes/fatalE.zip new file mode 100644 index 00000000..9f7e46de Binary files /dev/null and b/resources/themes/fatalE.zip differ diff --git a/resources/themes/gfxOasis.zip b/resources/themes/gfxOasis.zip new file mode 100644 index 00000000..3bb82698 Binary files /dev/null and b/resources/themes/gfxOasis.zip differ diff --git a/resources/themes/gorilla.zip b/resources/themes/gorilla.zip new file mode 100644 index 00000000..4eb4e7d0 Binary files /dev/null and b/resources/themes/gorilla.zip differ diff --git a/resources/themes/hmmXPBlue.zip b/resources/themes/hmmXPBlue.zip new file mode 100644 index 00000000..48b8efa5 Binary files /dev/null and b/resources/themes/hmmXPBlue.zip differ diff --git a/resources/themes/hmmXPMonoBlue.zip b/resources/themes/hmmXPMonoBlue.zip new file mode 100644 index 00000000..7e2510df Binary files /dev/null and b/resources/themes/hmmXPMonoBlue.zip differ diff --git a/resources/themes/iBar.zip b/resources/themes/iBar.zip new file mode 100644 index 00000000..6c8d0b7b Binary files /dev/null and b/resources/themes/iBar.zip differ diff --git a/resources/themes/lunaxp2485.zip b/resources/themes/lunaxp2485.zip new file mode 100644 index 00000000..2b887bac Binary files /dev/null and b/resources/themes/lunaxp2485.zip differ diff --git a/resources/themes/midnight.zip b/resources/themes/midnight.zip new file mode 100644 index 00000000..2d1f7da6 Binary files /dev/null and b/resources/themes/midnight.zip differ diff --git a/resources/themes/mmMagra-X.zip b/resources/themes/mmMagra-X.zip new file mode 100644 index 00000000..02e5f3ee Binary files /dev/null and b/resources/themes/mmMagra-X.zip differ diff --git a/resources/themes/modern.zip b/resources/themes/modern.zip new file mode 100644 index 00000000..8b363a65 Binary files /dev/null and b/resources/themes/modern.zip differ diff --git a/resources/themes/oliveGreenLunaXP.zip b/resources/themes/oliveGreenLunaXP.zip new file mode 100644 index 00000000..4af2ecd5 Binary files /dev/null and b/resources/themes/oliveGreenLunaXP.zip differ diff --git a/resources/themes/opusLunaBlue.zip b/resources/themes/opusLunaBlue.zip new file mode 100644 index 00000000..14ac9bed Binary files /dev/null and b/resources/themes/opusLunaBlue.zip differ diff --git a/resources/themes/opusLunaOlive.zip b/resources/themes/opusLunaOlive.zip new file mode 100644 index 00000000..91d0dfff Binary files /dev/null and b/resources/themes/opusLunaOlive.zip differ diff --git a/resources/themes/opusLunaSilver.zip b/resources/themes/opusLunaSilver.zip new file mode 100644 index 00000000..5cd67b1e Binary files /dev/null and b/resources/themes/opusLunaSilver.zip differ diff --git a/resources/themes/opusOSBlue.zip b/resources/themes/opusOSBlue.zip new file mode 100644 index 00000000..09e4cd69 Binary files /dev/null and b/resources/themes/opusOSBlue.zip differ diff --git a/resources/themes/opusOSDeep.zip b/resources/themes/opusOSDeep.zip new file mode 100644 index 00000000..5e413aa3 Binary files /dev/null and b/resources/themes/opusOSDeep.zip differ diff --git a/resources/themes/opusOSOlive.zip b/resources/themes/opusOSOlive.zip new file mode 100644 index 00000000..8a37392d Binary files /dev/null and b/resources/themes/opusOSOlive.zip differ diff --git a/resources/themes/preluna.zip b/resources/themes/preluna.zip new file mode 100644 index 00000000..55d9cb30 Binary files /dev/null and b/resources/themes/preluna.zip differ diff --git a/resources/themes/quickSilverR.zip b/resources/themes/quickSilverR.zip new file mode 100644 index 00000000..39f4e46f Binary files /dev/null and b/resources/themes/quickSilverR.zip differ diff --git a/resources/themes/readme.txt b/resources/themes/readme.txt new file mode 100644 index 00000000..5e853edc --- /dev/null +++ b/resources/themes/readme.txt @@ -0,0 +1,5 @@ +Alle Themes sind von + +https://github.com/l2fprod/javootoo.com/tree/master/plaf/skinlf/themepacks + +Es werden nur zip-Formate unterstützt! diff --git a/resources/themes/roueBlue.zip b/resources/themes/roueBlue.zip new file mode 100644 index 00000000..52eeb29e Binary files /dev/null and b/resources/themes/roueBlue.zip differ diff --git a/resources/themes/roueBrown.zip b/resources/themes/roueBrown.zip new file mode 100644 index 00000000..3318cde8 Binary files /dev/null and b/resources/themes/roueBrown.zip differ diff --git a/resources/themes/roueGreen.zip b/resources/themes/roueGreen.zip new file mode 100644 index 00000000..210b4211 Binary files /dev/null and b/resources/themes/roueGreen.zip differ diff --git a/resources/themes/royalInspirat.zip b/resources/themes/royalInspirat.zip new file mode 100644 index 00000000..e5aefb72 Binary files /dev/null and b/resources/themes/royalInspirat.zip differ diff --git a/resources/themes/silverLunaXP.zip b/resources/themes/silverLunaXP.zip new file mode 100644 index 00000000..131293a3 Binary files /dev/null and b/resources/themes/silverLunaXP.zip differ diff --git a/resources/themes/simplex.zip b/resources/themes/simplex.zip new file mode 100644 index 00000000..d92b15f5 Binary files /dev/null and b/resources/themes/simplex.zip differ diff --git a/resources/themes/solunaR.zip b/resources/themes/solunaR.zip new file mode 100644 index 00000000..10214620 Binary files /dev/null and b/resources/themes/solunaR.zip differ diff --git a/resources/themes/tiger.zip b/resources/themes/tiger.zip new file mode 100644 index 00000000..9f5715e4 Binary files /dev/null and b/resources/themes/tiger.zip differ diff --git a/resources/themes/tigerGraphite.zip b/resources/themes/tigerGraphite.zip new file mode 100644 index 00000000..6648eedd Binary files /dev/null and b/resources/themes/tigerGraphite.zip differ diff --git a/AJClientGUI/themes/toxicthemepack.zip b/resources/themes/toxic.zip similarity index 100% rename from AJClientGUI/themes/toxicthemepack.zip rename to resources/themes/toxic.zip diff --git a/resources/themes/underling.zip b/resources/themes/underling.zip new file mode 100644 index 00000000..4e96beac Binary files /dev/null and b/resources/themes/underling.zip differ diff --git a/resources/themes/whistler.zip b/resources/themes/whistler.zip new file mode 100644 index 00000000..040a0726 Binary files /dev/null and b/resources/themes/whistler.zip differ diff --git a/resources/themes/whistler2.zip b/resources/themes/whistler2.zip new file mode 100644 index 00000000..6e98d77c Binary files /dev/null and b/resources/themes/whistler2.zip differ diff --git a/resources/themes/xpluna.zip b/resources/themes/xpluna.zip new file mode 100644 index 00000000..a4a10522 Binary files /dev/null and b/resources/themes/xpluna.zip differ diff --git a/resources/themes/y2d.zip b/resources/themes/y2d.zip new file mode 100644 index 00000000..704bcb9b Binary files /dev/null and b/resources/themes/y2d.zip differ diff --git a/resources/wizard.xml b/resources/wizard.xml new file mode 100644 index 00000000..8c0a404c --- /dev/null +++ b/resources/wizard.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snap/gui/ajl-mime.xml b/snap/gui/ajl-mime.xml new file mode 100644 index 00000000..3f4db216 --- /dev/null +++ b/snap/gui/ajl-mime.xml @@ -0,0 +1,7 @@ + + + + appleJuice Link List + + + diff --git a/snap/gui/applejuice-gui.desktop b/snap/gui/applejuice-gui.desktop new file mode 100644 index 00000000..2ac32bf5 --- /dev/null +++ b/snap/gui/applejuice-gui.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=appleJuice GUI +GenericName=appleJuice GUI +Comment=appleJuice GUI (connect to appleJuice Client) +Exec=applejuice-gui.ajgui %u +Icon=${SNAP}/meta/gui/applejuice-gui.png +Terminal=false +Type=Application +Categories=Java;Application;Network; +MimeType=x-scheme-handler/ajfsp;application/x-ajl; +StartupWMClass=AJCoreGUI diff --git a/snap/gui/applejuice-gui.png b/snap/gui/applejuice-gui.png new file mode 100644 index 00000000..0bf9cf9e Binary files /dev/null and b/snap/gui/applejuice-gui.png differ diff --git a/snap/local/launcher b/snap/local/launcher new file mode 100755 index 00000000..917696fe --- /dev/null +++ b/snap/local/launcher @@ -0,0 +1,5 @@ +#!/bin/sh + +cd $SNAP/app/ + +java -Djava.net.preferIPv4Stack=true -Dsun.java2d.xrender=false -jar AJCoreGUI.jar "${@}" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..efc39add --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,65 @@ +name: applejuice-gui +title: appleJuice GUI +summary: appleJuice GUI for appleJuice Client +description: appleJuice GUI for appleJuice Client +version: 0.85.2 +icon: snap/gui/applejuice-gui.png +license: GPL-2.0 + +grade: stable +confinement: strict +base: core22 + +architectures: + - build-on: amd64 + - build-on: arm64 + +layout: + /usr/bin/xprop: + bind-file: $SNAP/usr/bin/xprop + +hooks: + configure: + plugs: [ home ] + +apps: + ajgui: + command: $SNAP/app/launcher + extensions: + - gnome + environment: + JAVA_HOME: $SNAP/usr/lib/jvm/java-21-openjdk-$SNAP_ARCH + PATH: $JAVA_HOME/bin:$PATH + plugs: + - home + - desktop + - network + - network-bind + - audio-playback + - x11 + +parts: + ajgui: + plugin: dump + source: https://github.com/applejuicenetz/gui-java/releases/download/$SNAPCRAFT_PROJECT_VERSION/AJCoreGUI.zip + organize: + '*': app/ + + jre: + plugin: nil + build-packages: + - ca-certificates + - ca-certificates-java + - openjdk-21-jre + stage-packages: + - openjdk-21-jre + - x11-utils + override-prime: | + snapcraftctl prime + rm -vf usr/lib/jvm/java-21-openjdk-*/lib/security/blacklisted.certs + + launcher: + plugin: dump + source: ./snap/local/ + organize: + '*': $SNAP/app/