From b72db77c2582c6eb3042dc2df08b995ef38a6a45 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sat, 7 Jul 2012 22:42:25 +0300 Subject: [PATCH] initial commit --- .classpath | 7 + .gitignore | 1 + .project | 23 ++ .settings/org.eclipse.core.resources.prefs | 3 + .settings/org.eclipse.jdt.core.prefs | 292 ++++++++++++++++++ .settings/org.eclipse.jdt.ui.prefs | 3 + .settings/org.eclipse.m2e.core.prefs | 5 + install | 13 + instantlauncher | 7 + pom.xml | 95 ++++++ run.sh | 5 + .../instantlauncher/Configuration.java | 67 ++++ .../FileAssociationManager.java | 83 +++++ .../instantlauncher/InstantLauncher.java | 28 ++ .../eu/svjatoslav/instantlauncher/Main.java | 17 + .../svjatoslav/instantlauncher/MainFrame.java | 92 ++++++ .../eu/svjatoslav/instantlauncher/Utils.java | 34 ++ .../svjatoslav/instantlauncher/menu/Menu.java | 249 +++++++++++++++ .../instantlauncher/menu/MenuListener.java | 9 + .../instantlauncher/menu/MultiLevelMenu.java | 169 ++++++++++ src/main/resources/log4j.xml | 16 + 21 files changed, 1218 insertions(+) create mode 100755 .classpath create mode 100755 .gitignore create mode 100755 .project create mode 100755 .settings/org.eclipse.core.resources.prefs create mode 100755 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.jdt.ui.prefs create mode 100755 .settings/org.eclipse.m2e.core.prefs create mode 100755 install create mode 100755 instantlauncher create mode 100755 pom.xml create mode 100755 run.sh create mode 100644 src/main/java/eu/svjatoslav/instantlauncher/Configuration.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/Main.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/Utils.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/menu/MenuListener.java create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java create mode 100755 src/main/resources/log4j.xml diff --git a/.classpath b/.classpath new file mode 100755 index 0000000..595a5bf --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..2f7896d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/.project b/.project new file mode 100755 index 0000000..1abd1b7 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + instantlauncher + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100755 index 0000000..56fd5c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Sat Feb 25 12:11:19 EET 2012 +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100755 index 0000000..611fd94 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,292 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=8 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=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_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..457d985 --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +formatter_profile=_Svjatoslav +formatter_settings_version=12 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100755 index 0000000..efd85ca --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Sat Feb 25 12:11:08 EET 2012 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=false +version=1 diff --git a/install b/install new file mode 100755 index 0000000..8be652b --- /dev/null +++ b/install @@ -0,0 +1,13 @@ +#!/bin/bash + +#sudo apt-get install "maven2" + +mvn clean package + +sudo mkdir /opt/instantlauncher +sudo cp target/instantlauncher-1.0.jar /opt/instantlauncher/ +sudo cp instantlauncher /opt/instantlauncher/ +sudo ln -s /opt/instantlauncher/instantlauncher /usr/bin/ + + + diff --git a/instantlauncher b/instantlauncher new file mode 100755 index 0000000..f73b76a --- /dev/null +++ b/instantlauncher @@ -0,0 +1,7 @@ +#!/bin/bash + +set -f + +java -jar /opt/instantlauncher/instantlauncher-1.0.jar $@ + + diff --git a/pom.xml b/pom.xml new file mode 100755 index 0000000..1d2e412 --- /dev/null +++ b/pom.xml @@ -0,0 +1,95 @@ + + 4.0.0 + eu.svjatoslav + instantlauncher + 1.0 + jar + Instant Launcher + popup panel with shortcuts for quick application launching + + + + eu.svjatoslav + svjatoslavcommons + 1.0-SNAPSHOT + + + + log4j + log4j + 1.2.16 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.1 + + 1.6 + 1.6 + true + UTF-8 + + + + + maven-assembly-plugin + + + + eu.svjatoslav.instantlauncher.Main + + + + jar-with-dependencies + + + + + + + package-jar-with-dependencies + package + + single + + + false + + jar-with-dependencies + + + + eu.svjatoslav.instantlauncher.Main + + + + + + + + + + + + + svjatoslav.eu + Svjatoslav repository + http://svjatoslav.eu/static/maven/ + + + + + svjatoslav.eu + http://svjatoslav.eu + + + + + \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..1726ba2 --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +cd ~/workspace/instantlauncher + +# For faster subsequent startup we use offline mode +mvn -o exec:java -Dexec.mainClass="eu.svjatoslav.instantlauncher.Main" + diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Configuration.java b/src/main/java/eu/svjatoslav/instantlauncher/Configuration.java new file mode 100644 index 0000000..28f2f82 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/Configuration.java @@ -0,0 +1,67 @@ +package eu.svjatoslav.instantlauncher; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +public class Configuration { + + private static final String KEY_ROOT_DIRECTORY = "KEY_ROOT_DIRECTORY"; + private static final String CONFIG_FILE_NAME = ".instantlauncher"; + Properties properties = new Properties(); + + boolean propertiesChanged = false; + + public Configuration() throws FileNotFoundException, IOException { + initialize(); + } + + public File getPropertiesFile() { + return new File(System.getProperty("user.home") + "/" + CONFIG_FILE_NAME); + } + + public File getRootDirectory() { + + if (properties.containsKey(KEY_ROOT_DIRECTORY)) { + return new File(properties.getProperty(KEY_ROOT_DIRECTORY)); + } else { + properties.put(KEY_ROOT_DIRECTORY, System.getProperty("user.home") + "/"); + propertiesChanged = true; + return getRootDirectory(); + } + + } + + public void initialize() throws FileNotFoundException, IOException { + + loadIfFileExists(); + + validatePropertiesFile(); + + if (propertiesChanged) { + saveFile(); + } + } + + public void loadIfFileExists() throws FileNotFoundException, IOException { + final File propertiesFile = getPropertiesFile(); + + if (propertiesFile.exists()) { + final FileInputStream inStream = new FileInputStream(propertiesFile); + properties.load(inStream); + inStream.close(); + } + } + + public void saveFile() throws FileNotFoundException, IOException { + properties.store(new FileOutputStream(getPropertiesFile()), "Instantlauncher configuration file."); + } + + public void validatePropertiesFile() { + getRootDirectory(); + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java b/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java new file mode 100755 index 0000000..eefbd80 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java @@ -0,0 +1,83 @@ +package eu.svjatoslav.instantlauncher; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; + +import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; + +public class FileAssociationManager { + + private static final String TEXT_EDITOR = "kwrite"; + + private static final String FILE_INDICATOR = ""; + + public static HashMap extensionToApplication = new HashMap(); + + public FileAssociationManager() { + + extensionToApplication.put("txt", new String[] { TEXT_EDITOR, FILE_INDICATOR }); + extensionToApplication.put("xml", new String[] { TEXT_EDITOR, FILE_INDICATOR }); + extensionToApplication.put("properties", new String[] { TEXT_EDITOR, FILE_INDICATOR }); + extensionToApplication.put("ini", new String[] { TEXT_EDITOR, FILE_INDICATOR }); + extensionToApplication.put("", new String[] { TEXT_EDITOR, FILE_INDICATOR }); + + extensionToApplication.put("jpg", new String[] { "eog", FILE_INDICATOR }); + extensionToApplication.put("jpeg", new String[] { "eog", FILE_INDICATOR }); + extensionToApplication.put("png", new String[] { "eog", FILE_INDICATOR }); + + extensionToApplication.put("pdf", new String[] { "evince", FILE_INDICATOR }); + + extensionToApplication.put("mp3", new String[] { "banshee", FILE_INDICATOR }); + extensionToApplication.put("ogg", new String[] { "banshee", FILE_INDICATOR }); + + extensionToApplication.put("avi", new String[] { "vlc", FILE_INDICATOR }); + extensionToApplication.put("mkv", new String[] { "vlc", FILE_INDICATOR }); + extensionToApplication.put("ogv", new String[] { "vlc", FILE_INDICATOR }); + extensionToApplication.put("mp4", new String[] { "vlc", FILE_INDICATOR }); + extensionToApplication.put("flv", new String[] { "vlc", FILE_INDICATOR }); + extensionToApplication.put("wmv", new String[] { "vlc", FILE_INDICATOR }); + + extensionToApplication.put("ods", new String[] { "localc", FILE_INDICATOR }); + + } + + public static boolean openFile(final File file) { + + final String fileExtension = Utils.getFileExtension(file); + + System.out.println("About to open file with extension: " + fileExtension); + + if (extensionToApplication.containsKey(fileExtension)) { + + System.out.println("Commands found"); + + final String[] commands = extensionToApplication.get(fileExtension); + + final String[] c = new String[commands.length]; + + for (int i = 0; i < commands.length; i++) { + + if (commands[i].equals(FILE_INDICATOR)) { + c[i] = file.getAbsolutePath(); + } else { + c[i] = commands[i]; + } + } + + try { + Runtime.getRuntime().exec(c); + InstantLauncher.exitProgram(); + + } catch (final IOException e) { + ExceptionDialog.showException(e); + } + + return true; + } else { + return false; + } + + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java new file mode 100755 index 0000000..b13b585 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java @@ -0,0 +1,28 @@ +package eu.svjatoslav.instantlauncher; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.log4j.Logger; + +public class InstantLauncher { + + public Configuration configuration; + + FileAssociationManager associationManager = new FileAssociationManager(); + + public static final Logger LOGGER = Logger.getLogger(InstantLauncher.class); + + public void run() throws FileNotFoundException, IOException { + configuration = new Configuration(); + + final MainFrame mainFrame = new MainFrame(this); + mainFrame.show(); + } + + public static void exitProgram() { + LOGGER.info("Closing InstantLauncher"); + System.exit(0); + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Main.java b/src/main/java/eu/svjatoslav/instantlauncher/Main.java new file mode 100755 index 0000000..acab4e3 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/Main.java @@ -0,0 +1,17 @@ +package eu.svjatoslav.instantlauncher; + +import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; + +public class Main { + + public static void main(final String[] args) { + + try { + final InstantLauncher instantLauncher = new InstantLauncher(); + instantLauncher.run(); + } catch (final Exception e) { + ExceptionDialog.showException(e); + } + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java b/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java new file mode 100755 index 0000000..8e3dd3a --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java @@ -0,0 +1,92 @@ +package eu.svjatoslav.instantlauncher; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import javax.swing.JFrame; + +import eu.svjatoslav.instantlauncher.menu.MultiLevelMenu; + +public class MainFrame { + + public static class FrameWindowListener implements WindowListener { + + @Override + public void windowActivated(final WindowEvent e) { + } + + @Override + public void windowClosed(final WindowEvent e) { + } + + @Override + public void windowClosing(final WindowEvent e) { + InstantLauncher.exitProgram(); + } + + @Override + public void windowDeactivated(final WindowEvent e) { + } + + @Override + public void windowDeiconified(final WindowEvent e) { + } + + @Override + public void windowIconified(final WindowEvent e) { + } + + @Override + public void windowOpened(final WindowEvent e) { + } + + } + + private JFrame frame; + + private boolean isShowing; + + public static final Dimension CONTENT_PANEL_SIZE = new Dimension(1100, 850); + public static final Point INITIAL_LOCATION = new Point(100, 30); + + private final InstantLauncher instantLauncher; + + public MainFrame(final InstantLauncher instantLauncher) { + this.instantLauncher = instantLauncher; + } + + private void buildContentPane() { + + final MultiLevelMenu multiLevelMenu = new MultiLevelMenu(instantLauncher); + frame.getContentPane().add(multiLevelMenu.buildContentPanel(), BorderLayout.CENTER); + + } + + public void show() { + + if (!isShowing) { + // initialize frame + frame = new JFrame("InstantLauncher"); + + buildContentPane(); + + frame.setSize(CONTENT_PANEL_SIZE); + frame.setVisible(true); + frame.setLocation(INITIAL_LOCATION); + + // registor window listener + final FrameWindowListener windowListener = new FrameWindowListener(); + frame.addWindowListener(windowListener); + + // maximize window + frame.setExtendedState(JFrame.MAXIMIZED_BOTH); + + isShowing = true; + } + + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java new file mode 100755 index 0000000..b82f623 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java @@ -0,0 +1,34 @@ +package eu.svjatoslav.instantlauncher; + +import java.awt.Dimension; +import java.io.File; + +import javax.swing.JComponent; + +public class Utils { + + public static String getFileExtension(File file) { + // extract file name without file name extension + String fullFileName = file.getName(); + + int dot = fullFileName.lastIndexOf('.'); + String fileExtension; + if (dot == -1) { + fileExtension = ""; + } else { + fileExtension = fullFileName.substring(dot + 1); + fileExtension = fileExtension.toLowerCase(); + } + + return fileExtension; + } + + public static final void setComponentSize(JComponent component, Dimension size) { + component.setMinimumSize(size); + component.setMaximumSize(size); + component.setSize(size); + component.setPreferredSize(size); + + } + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java new file mode 100755 index 0000000..f14caef --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java @@ -0,0 +1,249 @@ +package eu.svjatoslav.instantlauncher.menu; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; +import eu.svjatoslav.instantlauncher.Utils; + +public class Menu { + + public static final Color BUTTON_BG_DIRECTORY = new Color(0, 0, 60); + public static final Color BUTTON_BG_DIRECTORY_SELECTED = new Color(0, 0, 100); + + public static final Color BUTTON_BG_LINK = new Color(60, 60, 0); + public static final Color BUTTON_BG_LINK_SELECTED = new Color(100, 100, 0); + + public static final Color BUTTON_BG_EXECUTABLE_FILE = new Color(60, 0, 0); + public static final Color BUTTON_BG_EXECUTABLE_FILE_SELECTED = new Color(100, 0, 0); + + public static final Color BUTTON_BG_NONEXECUTABLE_FILE = new Color(0, 60, 0); + public static final Color BUTTON_BG_NONEXECUTABLE_FILE_SELECTED = new Color(0, 100, 0); + + public static final Dimension SIZE_BUTTON = new Dimension(200, 30); + public static final Dimension SIZE_MENU_PANEL = new Dimension(210, 900); + + private JPanel menuPanel; + + public JButton selectedButton; + public File selectedFile; + + private final Set menuListeners = new HashSet(); + + public Menu(final File directory) { + buildContentPanel(directory); + }; + + /** + *
+     * Assign specific colors to:
+     *    Directory
+     *    Executable file
+     *    Non executable file
+     * 
+ */ + public static Color getFileColor(final File file, final boolean selected) { + if (file.isDirectory()) { + if (selected) { + return BUTTON_BG_DIRECTORY_SELECTED; + } else { + return BUTTON_BG_DIRECTORY; + } + } + + if (file.isFile()) { + if (file.canExecute()) { + if (selected) { + return BUTTON_BG_EXECUTABLE_FILE_SELECTED; + } else { + return BUTTON_BG_EXECUTABLE_FILE; + } + } else { + if (selected) { + return BUTTON_BG_NONEXECUTABLE_FILE_SELECTED; + } else { + return BUTTON_BG_NONEXECUTABLE_FILE; + } + } + } + + if (selected) { + return BUTTON_BG_LINK_SELECTED; + } else { + return BUTTON_BG_LINK; + } + } + + public void addMenuListener(final MenuListener menuListener) { + menuListeners.add(menuListener); + } + + public JButton buildButton(final File file) { + JButton button; + if (file.isDirectory()) { + button = new JButton("[ " + file.getName() + " ]"); + } else { + button = new JButton(file.getName()); + } + + button.setBackground(getFileColor(file, false)); + button.setForeground(new Color(255, 255, 255)); + + button.setBorder(new EmptyBorder(5, 10, 5, 10)); + + final Menu.ButtonMouseListener mouseListener = new ButtonMouseListener(button, this, file); + button.addMouseListener(mouseListener); + + button.setHorizontalTextPosition(SwingConstants.CENTER); + + // set button size + Utils.setComponentSize(button, SIZE_BUTTON); + + return button; + } + + private void buildContentPanel(final File directory) { + menuPanel = new JPanel(); + + Utils.setComponentSize(menuPanel, SIZE_MENU_PANEL); + + final BoxLayout layout = new BoxLayout(menuPanel, BoxLayout.Y_AXIS); + menuPanel.setLayout(layout); + menuPanel.setBackground(Color.BLACK); + + final File[] listFiles = directory.listFiles(); + + // Sort files by name + Arrays.sort(listFiles, new Comparator() { + @Override + public int compare(final File f1, final File f2) { + + // directories come before files + if (f1.isFile() && f2.isDirectory()) { + return 1; + } + if (f2.isFile() && f1.isDirectory()) { + return -1; + } + + // order by file name + return f1.getName().toUpperCase().compareTo(f2.getName().toUpperCase()); + } + }); + + // add files to the panel + for (final File file : listFiles) { + // ignore hidden files + if (!file.getName().startsWith(".")) { + menuPanel.add(Box.createVerticalStrut(10)); + menuPanel.add(buildButton(file)); + } + } + } + + public JPanel getMenuPanel() { + return menuPanel; + } + + public JButton getSelectedButton() { + return selectedButton; + } + + public File getSelectedFile() { + return selectedFile; + } + + public void notifyAlternativeEventListeners(final File chosenFile) { + for (final MenuListener menuListener : menuListeners) { + menuListener.menuItemSelectedAlternative(this, chosenFile); + } + } + + public void notifyEventListeners(final File chosenFile) { + for (final MenuListener menuListener : menuListeners) { + menuListener.menuItemSelected(this, chosenFile); + } + } + + public void setSelected(final JButton selectedButton, final File selectedFile) { + this.selectedButton = selectedButton; + this.selectedFile = selectedFile; + } + + public static class ButtonMouseListener implements MouseListener { + + JButton parentButton; + Menu parentMenu; + File file; + + public ButtonMouseListener(final JButton button, final Menu parentMenu, final File file) { + parentButton = button; + this.parentMenu = parentMenu; + this.file = file; + } + + @Override + public void mouseClicked(final MouseEvent e) { + try { + + if (e.getButton() == 1) { + parentMenu.notifyEventListeners(file); + } + if (e.getButton() == 3) { + parentMenu.notifyAlternativeEventListeners(file); + } + } catch (final Exception ex) { + ExceptionDialog.showException(ex); + } + } + + @Override + public void mouseEntered(final MouseEvent e) { + try { + if (parentButton != parentMenu.getSelectedButton()) { + + if (parentMenu.getSelectedButton() != null) { + parentMenu.getSelectedButton().setBackground(getFileColor(parentMenu.getSelectedFile(), false)); + } + + parentMenu.setSelected(parentButton, file); + parentButton.setBackground(getFileColor(file, true)); + + if (file.isDirectory()) { + parentMenu.notifyEventListeners(file); + } + } + } catch (final Exception ex) { + ExceptionDialog.showException(ex); + } + } + + @Override + public void mouseExited(final MouseEvent e) { + } + + @Override + public void mousePressed(final MouseEvent e) { + } + + @Override + public void mouseReleased(final MouseEvent e) { + } + + } + +} \ No newline at end of file diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/MenuListener.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/MenuListener.java new file mode 100755 index 0000000..40cb680 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/MenuListener.java @@ -0,0 +1,9 @@ +package eu.svjatoslav.instantlauncher.menu; + +public interface MenuListener { + + public void menuItemSelected(Menu menu, java.io.File chosenFile); + + public void menuItemSelectedAlternative(Menu menu, java.io.File chosenFile); + +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java new file mode 100755 index 0000000..fa200da --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java @@ -0,0 +1,169 @@ +package eu.svjatoslav.instantlauncher.menu; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JPanel; + +import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; +import eu.svjatoslav.instantlauncher.FileAssociationManager; +import eu.svjatoslav.instantlauncher.InstantLauncher; +import eu.svjatoslav.instantlauncher.Utils; + +public class MultiLevelMenu implements MenuListener { + + private final InstantLauncher instantLauncher; + + private static final int VERTICAL_MENUS_COUNT = 5; + + public static final Dimension CONTENT_PANEL_SIZE = new Dimension(1024, 900); + + ArrayList menus = new ArrayList(); + + ArrayList panels = new ArrayList(); + JPanel contentPane; + + public MultiLevelMenu(final InstantLauncher instantLauncher) { + this.instantLauncher = instantLauncher; + } + + /** + * Adds new vertical menu. + * + * @return true if operation succeeded, or false + * if there was not enough space left for a new menu. + */ + public boolean addMenu(final File directory) { + final int newMenuHorizontalIndex = menus.size(); + + if (newMenuHorizontalIndex >= VERTICAL_MENUS_COUNT) + return false; + + final Menu menu = new Menu(directory); + menu.addMenuListener(this); + + final JPanel placeholderPanel = panels.get(newMenuHorizontalIndex); + final JPanel menuPanel = menu.getMenuPanel(); + placeholderPanel.add(menuPanel, BorderLayout.CENTER); + + menus.add(menu); + return true; + } + + public JPanel buildContentPanel() { + + contentPane = new JPanel(); + contentPane.setBackground(Color.BLACK); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); + Utils.setComponentSize(contentPane, CONTENT_PANEL_SIZE); + + // initialize panels + for (int i = 0; i < VERTICAL_MENUS_COUNT; i++) { + contentPane.add(Box.createHorizontalStrut(10)); + + final JPanel panel = new JPanel(new BorderLayout()); + panel.setBackground(Color.BLACK); + + Utils.setComponentSize(panel, Menu.SIZE_MENU_PANEL); + + panels.add(panel); + contentPane.add(panel); + } + + final File directory = instantLauncher.configuration.getRootDirectory(); + addMenu(directory); + + return contentPane; + } + + public int getMenuIndex(final Menu menu) { + int i = 0; + for (final Menu m : menus) { + if (m == menu) + return i; + i++; + } + return -1; + } + + @Override + public void menuItemSelected(final Menu menu, final File chosenFile) { + + if (chosenFile.isDirectory()) { + final int menuIndex = getMenuIndex(menu); + + if (menuIndex >= 0) { + removeMenus(menuIndex + 1); + if (addMenu(chosenFile)) { + contentPane.validate(); + contentPane.repaint(); + } + } + } + + if (chosenFile.isFile()) { + + if (chosenFile.canExecute()) { + try { + // Execute a command without arguments + final String command = chosenFile.getAbsolutePath(); + + final String[] c = new String[1]; + c[0] = command; + + Runtime.getRuntime().exec(c); + InstantLauncher.exitProgram(); + } catch (final IOException e) { + ExceptionDialog.showException(e); + } + + } else { + final boolean fileOpened = FileAssociationManager.openFile(chosenFile); + if (fileOpened) { + InstantLauncher.exitProgram(); + } + } + } + } + + @Override + public void menuItemSelectedAlternative(final Menu menu, final File chosenFile) { + if (chosenFile.isDirectory()) { + // Execute a command without arguments + final String directoryPath = chosenFile.getAbsolutePath(); + + final String[] c = new String[2]; + c[0] = "nautilus"; + c[1] = directoryPath; + + try { + Runtime.getRuntime().exec(c); + InstantLauncher.exitProgram(); + + } catch (final IOException e) { + ExceptionDialog.showException(e); + } + } else { + chosenFile.setExecutable(!chosenFile.canExecute()); + } + } + + public void removeMenus(final int fromIndex) { + + for (int i = fromIndex; i < menus.size(); i++) { + final JPanel jPanel = panels.get(i); + jPanel.removeAll(); + } + + while (menus.size() > fromIndex) { + menus.remove(fromIndex); + } + } + +} diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml new file mode 100755 index 0000000..b7e0f6c --- /dev/null +++ b/src/main/resources/log4j.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + \ No newline at end of file -- 2.20.1