diff --git a/README.md b/README.md
index 5900fd7a..10b4470d 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,21 @@
# EasyShell [](https://travis-ci.org/anb0s/EasyShell) [](https://sourceforge.net/projects/pluginbox/files/latest/download)
-This eclipse plugin allows to open a shell window or file manager from the popup menu in the navigation tree or editor view. The current directory of the opened shell is the directory which was selected with the popup menu. Additionally it is possible to run selected file in the system shell and copy file or directory path. Multiple selections are also supported.
+This Eclipse plugin allows to open a shell window or file manager from the popup menu in the navigation tree or editor view. Additionally it is possible to run selected file in the shell, copy file or directory path or run user defined external tools. Key shortcuts and multiple selections are also supported!
-
+
-
+")
+
+")
+
+
+
+
+
+
+
+
+
+
Installation:
-------------
@@ -20,63 +32,71 @@ OR
Features:
---------
-EasyShell does not support virtual folders, because they are not
-present in the file system!
-
-The plugin is platform-independent in principal. It just launches
-a (configurable) system command to open the shell. The following
-platform and shell combinations are supported as selections
-available from the drop-down-list in the preferences page:
+The plugin is platform independent in principal. It just launches a (configurable) system command to open the shell, file explorer or other user defined command. It also copies path etc. to clipboard. The following platform, shell combinations and tools are supported as selections available in the preferences page. The user can define own commands and menues or just adapt the predefined ones!
Windows:
-- DOS-Shell / Explorer
-- PowerShell / Explorer (check path of PowerShell executable!)
-- Cygwin (Bash) / Explorer (check path of Cygwin-bash executable!)
- http://cygwin.com
-- Console / Explorer
+- Command prompt (known as DOS shell or cmd.exe)
+- PowerShell
+- Bash (Cygwin, Git for Windows, etc.)
+ http://cygwin.com, https://git-for-windows.github.io
+- Console
https://sourceforge.net/projects/console
-- DOS-Shell / TotalCommander
- http://www.ghisler.com
-- Git (Bash) / Explorer (check path of Git-bash executable!)
- http://msysgit.github.io
-- ConEmu / Explorer (check path of ConEmu executable!)
+- ConEmu
https://code.google.com/p/conemu-maximus5/
-
-Unix / Linux:
-- KDE Konsole / Konqueror and Dolphin
-- Gnome Terminal / Nautilus
-- MAC OS X Terminal / Finder
-- CDE Xterm / Dtfile (not tested!)
-
-Other:
-- Default / Unknown (can be defined for all systems supported by Java)
-
-But you can configure any shell or command you like as long as you
-can figure out how to run a command to open the shell with given
-parameters. The following substitution variables are available
-for building the command:
-
-{0} = The drive letter (only Windows, not used on other platforms)
-{1} = The selected directory path
-{2} = The selected file or directory path
-{3} = The selected file name
-{4} = The project name of selected directory or path (for external files it's "Easy Shell")
-{5} = The line separator
-
-Option "Enable string tokenizer" with values "Yes, No" and default value "Yes".
-The whole command line string will be splitted (tokenized) to single strings before expansion
-of parameters {0} - {4} and passing to command line. With this solution there is no need to
-surround parameters {0} - {4} with quotes when space character is possible between command
-line option and parameter, e.g.: /D {1}. Otherwise maybe quotes are still needed,
-e.g.: --working-directory="{1}".
-
-Option "Add quotes to {1}, {2}, {3}*" with values "No, Single, Double, Automatic" and default
-value "No".
-If changed to other values, parameters will be eclosed with quotes.
-ATTENTION: use it carefully with "string tokenizer" and remove quotes from commands.
-
-Option "Enable debug output" with values "Yes, No" and default value "No".
-If changed to "Yes", debug messages will be printed to error console.
+- Cmder
+ https://github.com/cmderdev/cmder
+- Explorer
+- TotalCommander
+ http://www.ghisler.com
+
+If path to your tool is not added to PATH variable, please add it or adapt the command in EasyShell!
+
+Unix (BSD, Mac OS X) or Linux:
+- XDG Open
+- KDE Konsole
+- Konqueror
+- Gnome Terminal
+- Xfce Terminal
+- Sakura Terminal
+- ROXTerm
+- Pantheon Terminal
+- Dolphin
+- Nautilus
+- Nemo
+- Thunar
+- Pantheon
+- PCManFM
+
+MAC OS X
+ - Terminal
+ - Finder
+
+Copy to clipboard
+ - Full Path
+ - Full Path Unix (@Windows)
+ - Qualified Name
+ - ... more configurable...
+
+But you can configure any shell or command you like as long as you can figure out how to run a command to open the shell with given
+parameters or execute the tool you want. The following substitution variables are available for building the command:
+
+- ${easyshell:resource_loc} = absolute path of file or directory
+- ${easyshell:resource_name} = name of file or directory
+- ${easyshell:resource_basename} = name of file without extension
+- ${easyshell:resource_extension} = extension of file name (without '.')
+- ${easyshell:resource_path} = relative path to workspace of file or directory
+- ${easyshell:container_loc} = absolute path of file directory or directory itself
+- ${easyshell:container_name} = name of file directory or directory itself
+- ${easyshell:container_path} = relative path to workspace of file directory or directory itself
+- ${easyshell:project_loc} = absolute path of project
+- ${easyshell:project_name} = name of project
+- ${easyshell:project_path} = relative path to workspace of project
+- ${easyshell:windows_drive} = drive letter of file or directory on Windows
+- ${easyshell:qualified_name} = full qualified (class) name
+- ${easyshell:line_separator} = line separator, e.g. '\\n' (Unix) or '\\r\\n' (Windows)
+- ${easyshell:path_separator} = path separator, e.g. ':' (Unix) or ';' (Windows)
+- ${easyshell:file_separator} = file separator, e.g. '/' (Unix) or '\\' (Windows)
+- and all other available variables in Eclipse
License:
--------
diff --git a/feature/.settings/org.eclipse.core.resources.prefs b/feature/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..99f26c02
--- /dev/null
+++ b/feature/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/platform/Eclipse-3.8.target b/platform/Eclipse-3.8.target
index d391aef2..c145931f 100644
--- a/platform/Eclipse-3.8.target
+++ b/platform/Eclipse-3.8.target
@@ -2,7 +2,7 @@
-
+
diff --git a/platform/Eclipse-4.4.target b/platform/Eclipse-4.4.target
index eec49c78..ee854f33 100644
--- a/platform/Eclipse-4.4.target
+++ b/platform/Eclipse-4.4.target
@@ -2,7 +2,7 @@
-
+
diff --git a/platform/Eclipse-4.5.target b/platform/Eclipse-4.5.target
index 363dddce..7cc14be9 100644
--- a/platform/Eclipse-4.5.target
+++ b/platform/Eclipse-4.5.target
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/platform/Eclipse-4.6.target b/platform/Eclipse-4.6.target
index 18969b1b..ea7a6829 100644
--- a/platform/Eclipse-4.6.target
+++ b/platform/Eclipse-4.6.target
@@ -2,7 +2,7 @@
-
+
diff --git a/plugin/.settings/org.eclipse.core.resources.prefs b/plugin/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..99f26c02
--- /dev/null
+++ b/plugin/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/plugin/META-INF/MANIFEST.MF b/plugin/META-INF/MANIFEST.MF
index 6198ed11..6a3468bd 100644
--- a/plugin/META-INF/MANIFEST.MF
+++ b/plugin/META-INF/MANIFEST.MF
@@ -7,7 +7,10 @@ Bundle-Activator: de.anbos.eclipse.easyshell.plugin.Activator
Bundle-Vendor: Andre Bossert
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.core.resources
+ org.eclipse.core.resources,
+ org.eclipse.core.expressions,
+ org.eclipse.core.variables,
+ org.eclipse.jdt.core;resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: target/easyshell-library.jar
diff --git a/plugin/build.properties b/plugin/build.properties
index 240b2c74..4ac37c5b 100644
--- a/plugin/build.properties
+++ b/plugin/build.properties
@@ -3,7 +3,8 @@ bin.includes = icons/,\
releases/README.TXT,\
releases/CHANGES.TXT,\
META-INF/,\
- target/easyshell-library.jar
+ target/easyshell-library.jar,\
+ src/de/anbos/eclipse/easyshell/plugin/UIMessages.properties
src.includes = icons/,\
manpages/,\
releases/CHANGES.TXT,\
diff --git a/plugin/icons/clipboard.png b/plugin/icons/clipboard.png
new file mode 100644
index 00000000..b4cc0972
Binary files /dev/null and b/plugin/icons/clipboard.png differ
diff --git a/plugin/icons/clipboard1.png b/plugin/icons/clipboard1.png
new file mode 100644
index 00000000..bb5451c3
Binary files /dev/null and b/plugin/icons/clipboard1.png differ
diff --git a/plugin/icons/default.png b/plugin/icons/default.png
new file mode 100644
index 00000000..a3923ae2
Binary files /dev/null and b/plugin/icons/default.png differ
diff --git a/plugin/icons/easyshell.png b/plugin/icons/easyshell.png
new file mode 100644
index 00000000..69827201
Binary files /dev/null and b/plugin/icons/easyshell.png differ
diff --git a/plugin/icons/explore.png b/plugin/icons/explore.png
new file mode 100644
index 00000000..0cce2236
Binary files /dev/null and b/plugin/icons/explore.png differ
diff --git a/plugin/icons/explore1.png b/plugin/icons/explore1.png
new file mode 100644
index 00000000..c0aa2abb
Binary files /dev/null and b/plugin/icons/explore1.png differ
diff --git a/plugin/icons/explore2.png b/plugin/icons/explore2.png
new file mode 100644
index 00000000..4d07112d
Binary files /dev/null and b/plugin/icons/explore2.png differ
diff --git a/plugin/icons/macosx/explore.png b/plugin/icons/macosx/explore.png
new file mode 100644
index 00000000..e096946b
Binary files /dev/null and b/plugin/icons/macosx/explore.png differ
diff --git a/plugin/icons/open.png b/plugin/icons/open.png
new file mode 100644
index 00000000..1ae756ee
Binary files /dev/null and b/plugin/icons/open.png differ
diff --git a/plugin/icons/run.png b/plugin/icons/run.png
new file mode 100644
index 00000000..08571c1f
Binary files /dev/null and b/plugin/icons/run.png differ
diff --git a/plugin/icons/run1.png b/plugin/icons/run1.png
new file mode 100644
index 00000000..e0f8d8ac
Binary files /dev/null and b/plugin/icons/run1.png differ
diff --git a/plugin/icons/run2.gif b/plugin/icons/run2.gif
new file mode 100644
index 00000000..afb6fa93
Binary files /dev/null and b/plugin/icons/run2.gif differ
diff --git a/plugin/icons/unknown.png b/plugin/icons/unknown.png
new file mode 100644
index 00000000..7fc69518
Binary files /dev/null and b/plugin/icons/unknown.png differ
diff --git a/plugin/icons/user.png b/plugin/icons/user.png
new file mode 100644
index 00000000..01ec9729
Binary files /dev/null and b/plugin/icons/user.png differ
diff --git a/plugin/icons/windows/easyshell.png b/plugin/icons/windows/easyshell.png
new file mode 100644
index 00000000..8d053a69
Binary files /dev/null and b/plugin/icons/windows/easyshell.png differ
diff --git a/plugin/icons_example/gif/console_view.gif b/plugin/icons_example/gif/console_view.gif
new file mode 100644
index 00000000..a598f608
Binary files /dev/null and b/plugin/icons_example/gif/console_view.gif differ
diff --git a/plugin/icons_example/gif/copy.gif b/plugin/icons_example/gif/copy.gif
new file mode 100644
index 00000000..f962255b
Binary files /dev/null and b/plugin/icons_example/gif/copy.gif differ
diff --git a/plugin/icons/copy.gif b/plugin/icons_example/gif/copy_edit.gif
similarity index 100%
rename from plugin/icons/copy.gif
rename to plugin/icons_example/gif/copy_edit.gif
diff --git a/plugin/icons_example/gif/copy_edit_co.gif b/plugin/icons_example/gif/copy_edit_co.gif
new file mode 100644
index 00000000..7f5fe98a
Binary files /dev/null and b/plugin/icons_example/gif/copy_edit_co.gif differ
diff --git a/plugin/icons_example/gif/cpyqual_menu.gif b/plugin/icons_example/gif/cpyqual_menu.gif
new file mode 100644
index 00000000..55e2d04a
Binary files /dev/null and b/plugin/icons_example/gif/cpyqual_menu.gif differ
diff --git a/plugin/icons/prompt.gif b/plugin/icons_example/gif/easyshell.gif
similarity index 100%
rename from plugin/icons/prompt.gif
rename to plugin/icons_example/gif/easyshell.gif
diff --git a/plugin/icons/sample.gif b/plugin/icons_example/gif/eclipse.gif
similarity index 100%
rename from plugin/icons/sample.gif
rename to plugin/icons_example/gif/eclipse.gif
diff --git a/plugin/icons_example/gif/editor.gif b/plugin/icons_example/gif/editor.gif
new file mode 100644
index 00000000..c48d9a95
Binary files /dev/null and b/plugin/icons_example/gif/editor.gif differ
diff --git a/plugin/icons_example/gif/editor_area.gif b/plugin/icons_example/gif/editor_area.gif
new file mode 100644
index 00000000..64d79074
Binary files /dev/null and b/plugin/icons_example/gif/editor_area.gif differ
diff --git a/plugin/icons_example/gif/environment_obj.gif b/plugin/icons_example/gif/environment_obj.gif
new file mode 100644
index 00000000..31501623
Binary files /dev/null and b/plugin/icons_example/gif/environment_obj.gif differ
diff --git a/plugin/icons_example/gif/exclusion_filter_attrib.gif b/plugin/icons_example/gif/exclusion_filter_attrib.gif
new file mode 100644
index 00000000..92bce142
Binary files /dev/null and b/plugin/icons_example/gif/exclusion_filter_attrib.gif differ
diff --git a/plugin/icons_example/gif/external_tools.gif b/plugin/icons_example/gif/external_tools.gif
new file mode 100644
index 00000000..b05bf3e3
Binary files /dev/null and b/plugin/icons_example/gif/external_tools.gif differ
diff --git a/plugin/icons_example/gif/file_obj.gif b/plugin/icons_example/gif/file_obj.gif
new file mode 100644
index 00000000..061161ae
Binary files /dev/null and b/plugin/icons_example/gif/file_obj.gif differ
diff --git a/plugin/icons_example/gif/filenav_nav.gif b/plugin/icons_example/gif/filenav_nav.gif
new file mode 100644
index 00000000..4b98a62c
Binary files /dev/null and b/plugin/icons_example/gif/filenav_nav.gif differ
diff --git a/plugin/icons/folder.gif b/plugin/icons_example/gif/fldr_obj.gif
similarity index 100%
rename from plugin/icons/folder.gif
rename to plugin/icons_example/gif/fldr_obj.gif
diff --git a/plugin/icons_example/gif/folder.gif b/plugin/icons_example/gif/folder.gif
new file mode 100644
index 00000000..51e703b1
Binary files /dev/null and b/plugin/icons_example/gif/folder.gif differ
diff --git a/plugin/icons_example/gif/goto_input.gif b/plugin/icons_example/gif/goto_input.gif
new file mode 100644
index 00000000..2a6dea39
Binary files /dev/null and b/plugin/icons_example/gif/goto_input.gif differ
diff --git a/plugin/icons_example/gif/help.gif b/plugin/icons_example/gif/help.gif
new file mode 100644
index 00000000..9d70301d
Binary files /dev/null and b/plugin/icons_example/gif/help.gif differ
diff --git a/plugin/icons_example/gif/home_nav.gif b/plugin/icons_example/gif/home_nav.gif
new file mode 100644
index 00000000..4472e8ce
Binary files /dev/null and b/plugin/icons_example/gif/home_nav.gif differ
diff --git a/plugin/icons_example/gif/prompt.gif b/plugin/icons_example/gif/prompt.gif
new file mode 100644
index 00000000..cb98d710
Binary files /dev/null and b/plugin/icons_example/gif/prompt.gif differ
diff --git a/plugin/icons_example/gif/properties.gif b/plugin/icons_example/gif/properties.gif
new file mode 100644
index 00000000..1dc19a31
Binary files /dev/null and b/plugin/icons_example/gif/properties.gif differ
diff --git a/plugin/icons/run.gif b/plugin/icons_example/gif/run.gif
similarity index 100%
rename from plugin/icons/run.gif
rename to plugin/icons_example/gif/run.gif
diff --git a/plugin/icons_example/gif/run_exc.gif b/plugin/icons_example/gif/run_exc.gif
new file mode 100644
index 00000000..57f41022
Binary files /dev/null and b/plugin/icons_example/gif/run_exc.gif differ
diff --git a/plugin/icons_example/macosx/10.png b/plugin/icons_example/macosx/10.png
new file mode 100644
index 00000000..5fd4bb8d
Binary files /dev/null and b/plugin/icons_example/macosx/10.png differ
diff --git a/plugin/icons_example/macosx/Musett-Antares-IMac-OSX.ico b/plugin/icons_example/macosx/Musett-Antares-IMac-OSX.ico
new file mode 100644
index 00000000..c0428f7a
Binary files /dev/null and b/plugin/icons_example/macosx/Musett-Antares-IMac-OSX.ico differ
diff --git a/plugin/icons_example/macosx/Terminal-Befehle-Ubuntu-Linux.png b/plugin/icons_example/macosx/Terminal-Befehle-Ubuntu-Linux.png
new file mode 100644
index 00000000..95e76230
Binary files /dev/null and b/plugin/icons_example/macosx/Terminal-Befehle-Ubuntu-Linux.png differ
diff --git a/plugin/icons_example/macosx/Terminalicon.png b/plugin/icons_example/macosx/Terminalicon.png
new file mode 100644
index 00000000..c3284f1a
Binary files /dev/null and b/plugin/icons_example/macosx/Terminalicon.png differ
diff --git a/plugin/icons_example/macosx/allmyfiles.png b/plugin/icons_example/macosx/allmyfiles.png
new file mode 100644
index 00000000..38889027
Binary files /dev/null and b/plugin/icons_example/macosx/allmyfiles.png differ
diff --git a/plugin/icons_example/macosx/allmyfiles@2x.png b/plugin/icons_example/macosx/allmyfiles@2x.png
new file mode 100644
index 00000000..d9bb764d
Binary files /dev/null and b/plugin/icons_example/macosx/allmyfiles@2x.png differ
diff --git a/plugin/icons_example/macosx/finder.png b/plugin/icons_example/macosx/finder.png
new file mode 100644
index 00000000..f72bd14e
Binary files /dev/null and b/plugin/icons_example/macosx/finder.png differ
diff --git a/plugin/icons_example/macosx/finder@2x.png b/plugin/icons_example/macosx/finder@2x.png
new file mode 100644
index 00000000..8fcdf363
Binary files /dev/null and b/plugin/icons_example/macosx/finder@2x.png differ
diff --git a/plugin/icons_example/macosx/finder_16x16.png b/plugin/icons_example/macosx/finder_16x16.png
new file mode 100644
index 00000000..a436cc23
Binary files /dev/null and b/plugin/icons_example/macosx/finder_16x16.png differ
diff --git a/plugin/icons_example/macosx/icon_terminal_2x.jpg b/plugin/icons_example/macosx/icon_terminal_2x.jpg
new file mode 100644
index 00000000..f50eb9bb
Binary files /dev/null and b/plugin/icons_example/macosx/icon_terminal_2x.jpg differ
diff --git a/plugin/icons_example/macosx/mac-terminal-icon-4519.png b/plugin/icons_example/macosx/mac-terminal-icon-4519.png
new file mode 100644
index 00000000..84166bab
Binary files /dev/null and b/plugin/icons_example/macosx/mac-terminal-icon-4519.png differ
diff --git a/plugin/icons_example/macosx/terminal-app-icon-OS-X.png b/plugin/icons_example/macosx/terminal-app-icon-OS-X.png
new file mode 100644
index 00000000..2af6acd0
Binary files /dev/null and b/plugin/icons_example/macosx/terminal-app-icon-OS-X.png differ
diff --git a/plugin/icons_example/macosx/terminal-icon-osx-150x150.png b/plugin/icons_example/macosx/terminal-icon-osx-150x150.png
new file mode 100644
index 00000000..0567d0dc
Binary files /dev/null and b/plugin/icons_example/macosx/terminal-icon-osx-150x150.png differ
diff --git a/plugin/icons_example/macosx/terminal.png b/plugin/icons_example/macosx/terminal.png
new file mode 100644
index 00000000..03eee28c
Binary files /dev/null and b/plugin/icons_example/macosx/terminal.png differ
diff --git a/plugin/icons_example/macosx/terminal_icons_by_isgie-d2xgmyw.png b/plugin/icons_example/macosx/terminal_icons_by_isgie-d2xgmyw.png
new file mode 100644
index 00000000..e6c192be
Binary files /dev/null and b/plugin/icons_example/macosx/terminal_icons_by_isgie-d2xgmyw.png differ
diff --git a/plugin/icons_example/macosx/url 2.png b/plugin/icons_example/macosx/url 2.png
new file mode 100644
index 00000000..8a07c650
Binary files /dev/null and b/plugin/icons_example/macosx/url 2.png differ
diff --git a/plugin/icons_example/macosx/url.png b/plugin/icons_example/macosx/url.png
new file mode 100644
index 00000000..8a07c650
Binary files /dev/null and b/plugin/icons_example/macosx/url.png differ
diff --git a/plugin/icons_example/macosx/url@2x 2.png b/plugin/icons_example/macosx/url@2x 2.png
new file mode 100644
index 00000000..b0c92c88
Binary files /dev/null and b/plugin/icons_example/macosx/url@2x 2.png differ
diff --git a/plugin/icons_example/macosx/url@2x.png b/plugin/icons_example/macosx/url@2x.png
new file mode 100644
index 00000000..b0c92c88
Binary files /dev/null and b/plugin/icons_example/macosx/url@2x.png differ
diff --git a/plugin/icons_example/png/console_view.png b/plugin/icons_example/png/console_view.png
new file mode 100644
index 00000000..ca77aee5
Binary files /dev/null and b/plugin/icons_example/png/console_view.png differ
diff --git a/plugin/icons_example/png/copy.png b/plugin/icons_example/png/copy.png
new file mode 100644
index 00000000..bb5451c3
Binary files /dev/null and b/plugin/icons_example/png/copy.png differ
diff --git a/plugin/icons_example/png/copy_edit.png b/plugin/icons_example/png/copy_edit.png
new file mode 100644
index 00000000..41efe451
Binary files /dev/null and b/plugin/icons_example/png/copy_edit.png differ
diff --git a/plugin/icons_example/png/copy_edit_co.png b/plugin/icons_example/png/copy_edit_co.png
new file mode 100644
index 00000000..245ef858
Binary files /dev/null and b/plugin/icons_example/png/copy_edit_co.png differ
diff --git a/plugin/icons_example/png/copyviewtoclipboard_tsk.png b/plugin/icons_example/png/copyviewtoclipboard_tsk.png
new file mode 100644
index 00000000..e068d0fa
Binary files /dev/null and b/plugin/icons_example/png/copyviewtoclipboard_tsk.png differ
diff --git a/plugin/icons_example/png/cpyqual_menu.png b/plugin/icons_example/png/cpyqual_menu.png
new file mode 100644
index 00000000..7cb02568
Binary files /dev/null and b/plugin/icons_example/png/cpyqual_menu.png differ
diff --git a/plugin/icons_example/png/easyshell.png b/plugin/icons_example/png/easyshell.png
new file mode 100644
index 00000000..8d053a69
Binary files /dev/null and b/plugin/icons_example/png/easyshell.png differ
diff --git a/plugin/icons_example/png/easyshell2.png b/plugin/icons_example/png/easyshell2.png
new file mode 100644
index 00000000..69827201
Binary files /dev/null and b/plugin/icons_example/png/easyshell2.png differ
diff --git a/plugin/icons_example/png/easyshell_new.png b/plugin/icons_example/png/easyshell_new.png
new file mode 100644
index 00000000..69827201
Binary files /dev/null and b/plugin/icons_example/png/easyshell_new.png differ
diff --git a/plugin/icons_example/png/easyshell_old.png b/plugin/icons_example/png/easyshell_old.png
new file mode 100644
index 00000000..3546149a
Binary files /dev/null and b/plugin/icons_example/png/easyshell_old.png differ
diff --git a/plugin/icons_example/png/eclipse.png b/plugin/icons_example/png/eclipse.png
new file mode 100644
index 00000000..7fc69518
Binary files /dev/null and b/plugin/icons_example/png/eclipse.png differ
diff --git a/plugin/icons_example/png/editor_area.png b/plugin/icons_example/png/editor_area.png
new file mode 100644
index 00000000..a3923ae2
Binary files /dev/null and b/plugin/icons_example/png/editor_area.png differ
diff --git a/plugin/icons_example/png/environment_obj.png b/plugin/icons_example/png/environment_obj.png
new file mode 100644
index 00000000..01ec9729
Binary files /dev/null and b/plugin/icons_example/png/environment_obj.png differ
diff --git a/plugin/icons_example/png/exclusion_filter_attrib.png b/plugin/icons_example/png/exclusion_filter_attrib.png
new file mode 100644
index 00000000..3b6d9e22
Binary files /dev/null and b/plugin/icons_example/png/exclusion_filter_attrib.png differ
diff --git a/plugin/icons_example/png/external_tools.png b/plugin/icons_example/png/external_tools.png
new file mode 100644
index 00000000..2f6b0a5b
Binary files /dev/null and b/plugin/icons_example/png/external_tools.png differ
diff --git a/plugin/icons_example/png/file-new-16x16.png b/plugin/icons_example/png/file-new-16x16.png
new file mode 100644
index 00000000..a8424b85
Binary files /dev/null and b/plugin/icons_example/png/file-new-16x16.png differ
diff --git a/plugin/icons_example/png/file_obj.png b/plugin/icons_example/png/file_obj.png
new file mode 100644
index 00000000..723da774
Binary files /dev/null and b/plugin/icons_example/png/file_obj.png differ
diff --git a/plugin/icons_example/png/filenav_nav.png b/plugin/icons_example/png/filenav_nav.png
new file mode 100644
index 00000000..4d07112d
Binary files /dev/null and b/plugin/icons_example/png/filenav_nav.png differ
diff --git a/plugin/icons_example/png/fldr_obj.png b/plugin/icons_example/png/fldr_obj.png
new file mode 100644
index 00000000..c0aa2abb
Binary files /dev/null and b/plugin/icons_example/png/fldr_obj.png differ
diff --git a/plugin/icons_example/png/folder.png b/plugin/icons_example/png/folder.png
new file mode 100644
index 00000000..0cce2236
Binary files /dev/null and b/plugin/icons_example/png/folder.png differ
diff --git a/plugin/icons_example/png/goto_input.png b/plugin/icons_example/png/goto_input.png
new file mode 100644
index 00000000..b108c2e7
Binary files /dev/null and b/plugin/icons_example/png/goto_input.png differ
diff --git a/plugin/icons_example/png/help.png b/plugin/icons_example/png/help.png
new file mode 100644
index 00000000..3bfa9656
Binary files /dev/null and b/plugin/icons_example/png/help.png differ
diff --git a/plugin/icons_example/png/home_nav.png b/plugin/icons_example/png/home_nav.png
new file mode 100644
index 00000000..87ca6a2d
Binary files /dev/null and b/plugin/icons_example/png/home_nav.png differ
diff --git a/plugin/icons_example/png/prompt.png b/plugin/icons_example/png/prompt.png
new file mode 100644
index 00000000..8d053a69
Binary files /dev/null and b/plugin/icons_example/png/prompt.png differ
diff --git a/plugin/icons_example/png/prompt2.png b/plugin/icons_example/png/prompt2.png
new file mode 100644
index 00000000..1ae756ee
Binary files /dev/null and b/plugin/icons_example/png/prompt2.png differ
diff --git a/plugin/icons_example/png/prompt_old.png b/plugin/icons_example/png/prompt_old.png
new file mode 100644
index 00000000..82963a4f
Binary files /dev/null and b/plugin/icons_example/png/prompt_old.png differ
diff --git a/plugin/icons_example/png/prompt_old2.png b/plugin/icons_example/png/prompt_old2.png
new file mode 100644
index 00000000..a6a6460a
Binary files /dev/null and b/plugin/icons_example/png/prompt_old2.png differ
diff --git a/plugin/icons_example/png/properties.png b/plugin/icons_example/png/properties.png
new file mode 100644
index 00000000..78ef0c90
Binary files /dev/null and b/plugin/icons_example/png/properties.png differ
diff --git a/plugin/icons_example/png/run_exc.png b/plugin/icons_example/png/run_exc.png
new file mode 100644
index 00000000..08571c1f
Binary files /dev/null and b/plugin/icons_example/png/run_exc.png differ
diff --git a/plugin/icons_example/test/Command Prompt.png b/plugin/icons_example/test/Command Prompt.png
new file mode 100644
index 00000000..eeca4f1b
Binary files /dev/null and b/plugin/icons_example/test/Command Prompt.png differ
diff --git a/plugin/icons_example/test/Prompt.png b/plugin/icons_example/test/Prompt.png
new file mode 100644
index 00000000..7c8d0a86
Binary files /dev/null and b/plugin/icons_example/test/Prompt.png differ
diff --git a/plugin/icons_example/test/Terminal (2).png b/plugin/icons_example/test/Terminal (2).png
new file mode 100644
index 00000000..ac6ddd6d
Binary files /dev/null and b/plugin/icons_example/test/Terminal (2).png differ
diff --git a/plugin/icons_example/test/Terminal (3).png b/plugin/icons_example/test/Terminal (3).png
new file mode 100644
index 00000000..1d016e87
Binary files /dev/null and b/plugin/icons_example/test/Terminal (3).png differ
diff --git a/plugin/icons_example/test/app_terminal.png b/plugin/icons_example/test/app_terminal.png
new file mode 100644
index 00000000..d21bb429
Binary files /dev/null and b/plugin/icons_example/test/app_terminal.png differ
diff --git a/plugin/icons_example/test/app_terminal_16x16.png b/plugin/icons_example/test/app_terminal_16x16.png
new file mode 100644
index 00000000..5b9e72c0
Binary files /dev/null and b/plugin/icons_example/test/app_terminal_16x16.png differ
diff --git a/plugin/icons_example/test/terminal (1).png b/plugin/icons_example/test/terminal (1).png
new file mode 100644
index 00000000..cfefc582
Binary files /dev/null and b/plugin/icons_example/test/terminal (1).png differ
diff --git a/plugin/icons_example/test/terminal-19.png b/plugin/icons_example/test/terminal-19.png
new file mode 100644
index 00000000..0360cf7c
Binary files /dev/null and b/plugin/icons_example/test/terminal-19.png differ
diff --git a/plugin/icons_example/test/terminal-icon.png b/plugin/icons_example/test/terminal-icon.png
new file mode 100644
index 00000000..26e04bd4
Binary files /dev/null and b/plugin/icons_example/test/terminal-icon.png differ
diff --git a/plugin/icons_example/test/terminal.gif b/plugin/icons_example/test/terminal.gif
new file mode 100644
index 00000000..ab9ce4f6
Binary files /dev/null and b/plugin/icons_example/test/terminal.gif differ
diff --git a/plugin/icons_example/test/terminal.png b/plugin/icons_example/test/terminal.png
new file mode 100644
index 00000000..1d016e87
Binary files /dev/null and b/plugin/icons_example/test/terminal.png differ
diff --git a/plugin/icons_example/test/terminal.svg b/plugin/icons_example/test/terminal.svg
new file mode 100644
index 00000000..5eec6c4a
--- /dev/null
+++ b/plugin/icons_example/test/terminal.svg
@@ -0,0 +1,74 @@
+
+
+
+
diff --git a/plugin/icons_example/test/terminal_16x16.png b/plugin/icons_example/test/terminal_16x16.png
new file mode 100644
index 00000000..60bcc700
Binary files /dev/null and b/plugin/icons_example/test/terminal_16x16.png differ
diff --git a/plugin/plugin.xml b/plugin/plugin.xml
index a4201c36..555fce9a 100644
--- a/plugin/plugin.xml
+++ b/plugin/plugin.xml
@@ -5,94 +5,278 @@
+ id="de.anbos.eclipse.easyshell.plugin.commands.execute">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class="de.anbos.eclipse.easyshell.plugin.handlers.Execute"
+ commandId="de.anbos.eclipse.easyshell.plugin.commands.execute">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+ locationURI="popup:org.eclipse.ui.popup.any?after=group.open">
+
+
-
-
-
-
+ allPopups="true"
+ class="de.anbos.eclipse.easyshell.plugin.commands.DefineCommands"
+ locationURI="popup:de.anbos.eclipse.easyshell.plugin.menu">
+
+
+
+
-
-
-
-
-
-
+ category="de.anbos.eclipse.easyshell.plugin.preferences.MainPage"
+ class="de.anbos.eclipse.easyshell.plugin.preferences.MenuPage"
+ id="de.anbos.eclipse.easyshell.plugin.preferences.MenuPage"
+ name="(1) Menu">
+
+
+
+
+ class="de.anbos.eclipse.easyshell.plugin.preferences.Initializer">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java
index d2037bbe..9bb50fc7 100644
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
+ * Copyright (c) 2014 - 2016 Andre Bossert.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,21 +11,47 @@
package de.anbos.eclipse.easyshell.plugin;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.Debug;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "de.anbos.eclipse.easyshell.plugin"; //$NON-NLS-1$
-
- // The shared instance
+ // The shared instance
private static Activator plugin;
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ /**
+ * Storage for preferences.
+ */
+ private IPreferenceStore myPreferenceStore;
+
/**
* The constructor
*/
@@ -39,6 +65,13 @@ public Activator() {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ try {
+ //resourceBundle = Platform.getResourceBundle(context.getBundle());
+ resourceBundle = ResourceBundle.getBundle(Constants.PLUGIN_ID + ".UIMessages"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ getImageRegistry();
}
/*
@@ -66,7 +99,154 @@ public static Activator getDefault() {
* @param path the path
* @return the image descriptor
*/
+ /*
public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ return imageDescriptorFromPlugin(Constants.PLUGIN_ID, path);
}
+ */
+ public static ImageDescriptor getImageDescriptor(String id) {
+ return getDefault().getImageRegistry().getDescriptor(id);
+ }
+
+ protected void initializeImageRegistry(ImageRegistry registry) {
+ Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
+ OS os = Utils.getOS();
+ for (String iconName : Category.getIconsAsList()) {
+ String iconPath = Constants.IMAGE_PATH + os.getId() + "/" + iconName;
+ URL url = bundle.getEntry(iconPath);
+ if (url == null) {
+ iconPath = Constants.IMAGE_PATH + iconName;
+ }
+ addImageToRegistry(registry, bundle, iconPath, iconName);
+ }
+ addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_EASYSHELL, Constants.IMAGE_EASYSHELL);
+ }
+
+ protected void addImageToRegistry(ImageRegistry registry, Bundle bundle, String imagePath, String image_id) {
+ IPath path = new Path(imagePath);
+ URL url = FileLocator.find(bundle, path, null);
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ registry.put(image_id, desc);
+ }
+
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
+ }
+
+ public static String getResourceString(String key) {
+ ResourceBundle bundle = Activator.getDefault().getResourceBundle();
+ try {
+ return (bundle != null) ? bundle.getString(key) : key;
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ public static String getResourceString(String key, Object[] args) {
+ return MessageFormat.format(getResourceString(key),args);
+ }
+
+ public static void log(String msg) {
+ log(null, msg, null);
+ }
+
+ public static void log(String msg, Exception e) {
+ logInfo(null, msg, e, false);
+ }
+
+ public static void log(String title, String msg, Exception e) {
+ logInfo(title, msg, e, false);
+ }
+
+ public static void logSuccess(String title, String msg, Exception e, boolean tooltip) {
+ log(Status.OK, title != null ? title + ": " + msg : msg, e);
+ if (tooltip) {
+ tooltipSuccess(title, msg);
+ }
+ }
+
+ public static void logInfo(String title, String msg, Exception e, boolean tooltip) {
+ log(Status.INFO, title != null ? title + ": " + msg : msg, e);
+ if (tooltip) {
+ tooltipInfo(title, msg);
+ }
+ }
+
+ public static void logWarning(String title, String msg, Exception e, boolean tooltip) {
+ log(Status.WARNING, title != null ? title + ": " + msg : msg, e);
+ if (tooltip) {
+ tooltipWarning(title, msg);
+ }
+ }
+
+ public static void logError(String title, String msg, Exception e, boolean tooltip) {
+ log(Status.ERROR, title != null ? title + ": " + msg : msg, e);
+ if (tooltip) {
+ tooltipError(title, msg);
+ }
+ }
+
+ public static void logSuccess(String msg, Exception e) {
+ logSuccess(null, msg, null, false);
+ }
+
+ public static void logInfo(String msg, Exception e) {
+ logInfo(null, msg, null, false);
+ }
+
+ public static void logWarning(String msg, Exception e) {
+ logWarning(null, msg, null, false);
+ }
+
+ public static void logError(String msg, Exception e) {
+ logError(null, msg, null, false);
+ }
+
+ public static void log(int status, String msg, Exception e) {
+ getDefault().getLog().log(new Status(status, Constants.PLUGIN_ID, Status.OK, msg, e));
+ }
+
+ public static void tooltipSuccess(String title, String msg) {
+ Utils.showToolTipSuccess(null, getResourceString("easyshell.plugin.name") + ": " + title, msg);
+ }
+
+ public static void tooltipInfo(String title, String msg) {
+ Utils.showToolTipInfo(null, getResourceString("easyshell.plugin.name") + ": " + title, msg);
+ }
+
+ public static void tooltipWarning(String title, String msg) {
+ Utils.showToolTipWarning(null, getResourceString("easyshell.plugin.name") + ": " + title, msg);
+ }
+
+ public static void tooltipError(String title, String msg) {
+ Utils.showToolTipError(null, getResourceString("easyshell.plugin.name") + ": " + title, msg);
+ }
+
+ public static void logDebug(String string) {
+ // TODO: get from preferences store
+ Debug debug = Debug.debugNo;
+ if (debug == Debug.debugYes) {
+ log(Status.INFO, string, null);
+ }
+ }
+
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ // Create the preference store lazily.
+ if (myPreferenceStore == null) {
+ myPreferenceStore = getPreferenceStoreByVersion(Version.actual.name());
+ }
+ return myPreferenceStore;
+ }
+
+ public IPreferenceStore getPreferenceStoreByVersion(String version) {
+ String pluginNodeName = getBundle().getSymbolicName();
+ return new ScopedPreferenceStore(InstanceScope.INSTANCE, pluginNodeName + "/" + version, pluginNodeName);
+ }
+
+ public IPreferenceStore getLegacyPreferenceStore() {
+ String pluginNodeName = "com.tetrade.eclipse.plugins.easyshell";
+ return new ScopedPreferenceStore(InstanceScope.INSTANCE, pluginNodeName, pluginNodeName);
+ }
+
}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/Constants.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/Constants.java
new file mode 100644
index 00000000..a153a85f
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/Constants.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin;
+
+public interface Constants {
+
+ // Plugin
+ public static final String PLUGIN_ID = "de.anbos.eclipse.easyshell.plugin";
+
+ // Images
+ //public static final String IMAGE_EXT = "gif";
+ public static final String IMAGE_EXT = "png";
+ public static final String IMAGE_PATH = "icons/";
+ public static final String IMAGE_EASYSHELL = "easyshell." + IMAGE_EXT;
+ public static final String IMAGE_UNKNOWN = "unknown." + IMAGE_EXT;
+ public static final String IMAGE_DEFAULT = "default." + IMAGE_EXT;
+ public static final String IMAGE_OPEN = "open." + IMAGE_EXT;
+ public static final String IMAGE_RUN = "run." + IMAGE_EXT;
+ public static final String IMAGE_EXPLORE = "explore." + IMAGE_EXT;
+ public static final String IMAGE_CLIPBOARD = "clipboard." + IMAGE_EXT;
+ public static final String IMAGE_USER = "user." + IMAGE_EXT;
+
+ // Preferences
+ public static final String PREF_COMMANDS_PRESET = "COMMANDS_PRESET";
+ public static final String PREF_COMMANDS = "COMMANDS";
+ public static final String PREF_MENU = "MENU";
+ public static final String PREF_MIGRATED = "MIGRATED";
+
+ // Actions
+ public static final String ACTION_UNKNOWN = "de.anbos.eclipse.easyshell.plugin.commands.Unknown";
+ public static final String ACTION_EXECUTE = "de.anbos.eclipse.easyshell.plugin.commands.Execute";
+ public static final String ACTION_CLIPBOARD = "de.anbos.eclipse.easyshell.plugin.commands.Clipboard";
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/DynamicVariableResolver.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/DynamicVariableResolver.java
new file mode 100644
index 00000000..71dccdc8
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/DynamicVariableResolver.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IDynamicVariableResolver;
+
+import de.anbos.eclipse.easyshell.plugin.types.Converter;
+import de.anbos.eclipse.easyshell.plugin.types.Converters;
+import de.anbos.eclipse.easyshell.plugin.types.IConverter;
+import de.anbos.eclipse.easyshell.plugin.types.IVariableResolver;
+import de.anbos.eclipse.easyshell.plugin.types.Quotes;
+import de.anbos.eclipse.easyshell.plugin.types.Variable;
+import de.anbos.eclipse.easyshell.plugin.types.Variables;
+
+public class DynamicVariableResolver implements IDynamicVariableResolver {
+
+ static private Resource resource = null;
+ static Quotes quotes = Quotes.quotesNo;
+
+ @Override
+ public String resolveValue(IDynamicVariable variable, String argument)
+ throws CoreException {
+ String variableName = variable.getName();
+ if (variableName.equals("easyshell")) {
+ return handleOwnVariable(argument);
+ } else {
+ return handleEclipseVariable(variableName, argument);
+ }
+ }
+
+ private String handleOwnVariable(String argument) {
+ String variableArg = argument;
+ String converterName = "Unknown";
+ int converterIndex = argument.indexOf(":");
+ if (converterIndex != -1) {
+ // first try to find a variable that has same pattern
+ // e.g. var:conv = var_conv
+ String variableSubs = variableArg.replace(":", "_");
+ IVariableResolver variableSubsResolver = Variables.getMap().get(variableSubs);
+ if (variableSubsResolver != null) {
+ variableArg = variableSubs;
+ } else {
+ variableArg = argument.substring(0, converterIndex);
+ converterName = argument.substring(converterIndex + 1);
+ }
+ }
+ IConverter converter = Converters.getMap().get(converterName);
+ if (converter == null) {
+ converter = Converter.converterUnknown.getConverterImpl();
+ }
+ IVariableResolver resolver = Variables.getMap().get(variableArg);
+ if (resolver == null) {
+ resolver = Variable.varUnknown.getResolver();
+ }
+ return autoQuotes(converter.convert(resolver.resolve(resource)));
+ }
+
+ private String handleEclipseVariable(String variable, String argument) {
+ return autoQuotes(Variables.getMap().get(argument).resolve(resource));
+ }
+
+ public static Resource getResource() {
+ return resource;
+ }
+
+ public static void setResource(Resource resource) {
+ DynamicVariableResolver.resource = resource;
+ }
+
+ public static void setQuotes(Quotes quotes) {
+ DynamicVariableResolver.quotes = quotes;
+ }
+
+ private String autoQuotes(String str) {
+ String ret = str;
+ if (quotes == Quotes.quotesSingle) {
+ ret = "'" + str + "'";
+ }
+ else if (quotes == Quotes.quotesDouble) {
+ ret = "\"" + str + "\"";
+ }
+ else if (quotes == Quotes.quotesEscape) {
+ ret = str.replaceAll("\\s", "\\\\ ");
+ }
+ else if ( ((quotes == Quotes.quotesAuto) || (quotes == Quotes.quotesAutoSingle))
+ && (str.indexOf(" ") != -1) ) { // if space there
+ if ((quotes == Quotes.quotesAutoSingle) && str.indexOf("\"") == -1) { // if no single quotes
+ ret = "'" + str + "'";
+ } else if (str.indexOf("'") == -1){ // if no double quotes
+ ret = "\"" + str + "\"";
+ }
+ }
+ return ret;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/EditorPropertyTester.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/EditorPropertyTester.java
new file mode 100644
index 00000000..d823dd19
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/EditorPropertyTester.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+import de.anbos.eclipse.easyshell.plugin.actions.ActionDelegate;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class EditorPropertyTester extends PropertyTester {
+
+ public EditorPropertyTester() {
+ super();
+ }
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if("hasResourceSelection".equals(property) && receiver instanceof IWorkbenchPart){
+ if (args.length > 0 && args[0].equals("resourceType")) {
+ return getActionCommonResourceType((IWorkbenchPart)receiver, ResourceType.getFromEnum((String)expectedValue)) != null;
+ }
+ }
+ return false;
+ }
+
+ static public ActionDelegate getActionCommonResourceType(IWorkbenchPart part, ResourceType resType) {
+ ISelection selection = ResourceUtils.getResourceSelection(part);
+ if (selection != null) {
+ ActionDelegate action = new ActionDelegate();
+ action.selectionChanged(null, selection);
+ if (action.isEnabled(ResourceType.resourceTypeFileOrDirectory) && resType == action.getCommonResourceType()) {
+ return action;
+ }
+ }
+ return null;
+ }
+
+ static public ActionDelegate getActionExactResourceType(IWorkbenchPart part, ResourceType resType) {
+ ISelection selection = ResourceUtils.getResourceSelection(part);
+ if (selection != null) {
+ ActionDelegate action = new ActionDelegate();
+ action.selectionChanged(null, selection);
+ if (action.isEnabled(resType)) {
+ return action;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/Resource.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/Resource.java
new file mode 100644
index 00000000..ac7ef957
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/Resource.java
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.osgi.framework.Bundle;
+
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+
+public class Resource {
+
+ // internal
+ private File file = null;
+ private IResource resource = null;
+
+ // resolved
+ private String projectName = Activator.getResourceString("easyshell.plugin.name");
+
+ //Activator.logDebug("full_path : >" + fullPath + "<");
+ //Activator.logDebug("parent_path: >" + parentPath + "<");
+ //Activator.logDebug("file_name : >" + fileName + "<");
+
+ public Resource(Resource myRes) {
+ file = myRes.getFile();
+ }
+
+ public Resource(File file, IResource resource) {
+ this.file = file;
+ this.resource = resource;
+ }
+
+ public Resource(File file) {
+ this(file, null);
+ }
+
+ public Resource(IResource resource) {
+ this(resource.getLocation().toFile(), resource);
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public IResource getResource() {
+ return resource;
+ }
+
+ public String getWindowsDrive() {
+ String loc = getResourceLocation();
+ if (loc != null) {
+ int index = loc.indexOf(":");
+ if (index != -1) {
+ return loc.substring(0, index);
+ }
+ }
+ return "";
+ }
+
+ public String getContainerLocation() {
+ if (file.isDirectory()) {
+ return file.getPath();
+ }
+ return file.getParent();
+ }
+
+ public String getContainerName() {
+ if (resource != null) {
+ if (resource.getType() == IResource.FILE) {
+ return resource.getParent().getName();
+ } else {
+ return resource.getName();
+ }
+ } else {
+ if (file.isFile()) {
+ return file.getParentFile().getName();
+ } else {
+ return file.getName();
+ }
+ }
+ }
+
+ public String getContainerPath() {
+ if (resource != null) {
+ if (resource.getType() == IResource.FILE) {
+ return resource.getParent().getFullPath().toString();
+ } else {
+ return resource.getFullPath().toString();
+ }
+ }
+ return "";
+ }
+
+ public String getResourceLocation() {
+ return file.getPath();
+ }
+
+ public String getResourceName() {
+ if (resource != null) {
+ return resource.getName();
+ } else {
+ /*if (file.isDirectory()) {
+ resourceName = "";
+ } else {*/
+ return file.getName();
+ //}
+ }
+ }
+
+ public String getResourceBasename() {
+ return Utils.getFileBasename(getResourceName());
+ }
+
+ public String getResourceExtension() {
+ return Utils.getFileExtension(getResourceName());
+ }
+
+ public String getResourcePath() {
+ if (resource != null) {
+ return resource.getFullPath().toString();
+ }
+ return "";
+ }
+
+ public String getProjectLocation() {
+ if (resource != null) {
+ return resource.getProject().getLocation().toFile().toString();
+ }
+ return "";
+ }
+
+ public String getProjectName() {
+ if (resource != null) {
+ return resource.getProject().getName();
+ }
+ return projectName;
+ }
+
+ public String getProjectPath() {
+ if (resource != null) {
+ return resource.getProject().getFullPath().toString();
+ }
+ return "";
+ }
+
+ public String getLineSeparator(OS os) {
+ switch(os) {
+ case osUnix:
+ case osLinux:
+ case osMacOSX:
+ return new String ("\n");
+ case osWindows:
+ return new String ("\r\n");
+ default:
+ return System.getProperty("line.separator");
+ }
+ }
+
+ public String getPathSeparator(OS os) {
+ switch(os) {
+ case osUnix:
+ case osLinux:
+ case osMacOSX:
+ return new String (":");
+ case osWindows:
+ return new String (";");
+ default:
+ return File.pathSeparator; //System.getProperty("path.separator");
+ }
+ }
+
+ public String getFileSeparator(OS os) {
+ switch(os) {
+ case osUnix:
+ case osLinux:
+ case osMacOSX:
+ return new String ("/");
+ case osWindows:
+ return new String ("\\");
+ default:
+ return File.separator; //System.getProperty("file.separator");
+ }
+ }
+
+ public String getFullQualifiedName() {
+ if (resource != null) {
+ Bundle bundle = Platform.getBundle("org.eclipse.jdt.core");
+ if (bundle != null) {
+ IJavaElement element = JavaCore.create(resource);
+ if (element instanceof IPackageFragment) {
+ return ((IPackageFragment)element).getElementName();
+ } else if (element instanceof ICompilationUnit) {
+ IType type = ((ICompilationUnit)element).findPrimaryType();
+ if (type != null) {
+ return type.getFullyQualifiedName();
+ }
+ }
+ }
+ }
+ return getFullQualifiedPathName();
+ }
+
+ public String getFullQualifiedPathName() {
+ String fqcn = "";
+ if (resource != null) {
+
+ return resource.getFullPath().toString();
+ /*
+ String[] segments = iRes.getProjectRelativePath().segments();
+ for (int i=0;i resources = null;
+ private IStructuredSelection currentSelection;
+ private String commandValue = null;
+ private String commandWorkingDir = null;
+ private CommandType commandType = CommandType.commandTypeUnknown;
+ private ResourceType resourceType = ResourceType.resourceTypeUnknown;
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public CommandType getCommandType() {
+ return commandType;
+ }
+
+ public void setCommandType(CommandType commandType) {
+ this.commandType = commandType;
+ }
+
+ public String getCommandValue() {
+ return commandValue;
+ }
+
+ public void setCommandValue(String commandValue) {
+ this.commandValue = commandValue;
+ }
+
+ public void setCommandWorkingDir(String commandWorkingDir) {
+ this.commandWorkingDir = commandWorkingDir;
+ }
+
+ public ActionDelegate() {
+ super();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ // String for all commands in case of clipboard
+ String cmdAll = null;
+ if (commandType == CommandType.commandTypeClipboard) {
+ cmdAll = new String();
+ }
+ // get the manager for variables expansion
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+ // iterate over the reources
+ for (Resource resource : resources) {
+ // TODO: get from preferences store
+ //Quotes quotes = Activator.getQuotes(InstanceIDNum);
+ Quotes quotes = Quotes.quotesNo;
+ if (resource.resolve()) {
+ try {
+ // set arguments for resolving
+ DynamicVariableResolver.setResource(resource);
+ DynamicVariableResolver.setQuotes(quotes);
+ // validate the command
+ variableManager.validateStringVariables(commandValue);
+ Activator.logDebug(commandValue);
+ // handling copy to clipboard
+ if (commandType == CommandType.commandTypeClipboard) {
+ String cmd = variableManager.performStringSubstitution(commandValue, false);
+ Activator.logDebug("--- clp: >");
+ cmdAll += cmd;
+ Activator.logDebug(cmd);
+ Activator.logDebug("--- clp: <");
+ }
+ // handling command line
+ else {
+ handleExec(variableManager);
+ }
+ } catch (CoreException e) {
+ Activator.logError(Activator.getResourceString("easyshell.message.error.validation"), commandValue, e, true);
+ } catch (Exception e) {
+ Activator.logError(Activator.getResourceString("easyshell.message.error.execution"), commandValue, e, true);
+ }
+ } else {
+ Activator.logError(Activator.getResourceString("easyshell.message.error.internal"), commandValue, null, true);
+ }
+ }
+ // handling copy to clipboard
+ if ((commandType == CommandType.commandTypeClipboard) && (cmdAll != null) && (cmdAll.length() != 0)) {
+ Utils.copyToClipboard(cmdAll);
+ Activator.tooltipInfo(Activator.getResourceString("easyshell.message.copytoclipboard"), cmdAll);
+ }
+ }
+
+ private void handleExec(IStringVariableManager variableManager) throws CoreException, IOException {
+ String[] cmds = null;
+ // working directory
+ if (commandWorkingDir != null && !commandWorkingDir.isEmpty()) {
+ variableManager.validateStringVariables(commandWorkingDir);
+ }
+ Activator.logDebug(commandWorkingDir);
+ // string tokenizer enabled ?
+ // TODO: get from preferences store
+ //Tokenizer tokenizer = Activator.isTokenizer(InstanceIDNum);
+ Tokenizer tokenizer = Tokenizer.tokenizerYes;
+ if (tokenizer == Tokenizer.tokenizerYes)
+ {
+ StringTokenizer st = new StringTokenizer(commandValue);
+ cmds = new String[st.countTokens()];
+ int i = 0;
+ while (st.hasMoreElements()) {
+ cmds[i] = variableManager.performStringSubstitution(st.nextToken(), false);
+ i++;
+ }
+ }
+ // the old command line passing without string tokenizer
+ else {
+ cmds = new String[1];
+ cmds[0] = variableManager.performStringSubstitution(commandValue, false);
+ }
+ // log out
+ for (int i=0;i");
+ Activator.logDebug(cmds[i]);
+ Activator.logDebug("--- cmd: <");
+ }
+ // execute
+ //Utils.showToolTip(Display.getDefault().getActiveShell(), "EasyShell: executed", commandValue);
+ // ---------- RUN --------------
+ //Runtime.getRuntime().exec(cmds);
+ // create process builder with commands and
+ ProcessBuilder pb = new ProcessBuilder(cmds);
+ // set working directory and redirect error stream
+ if (commandWorkingDir != null && !commandWorkingDir.isEmpty()) {
+ pb.directory(new File(variableManager.performStringSubstitution(commandWorkingDir, false)));
+ }
+ // get passed system environment
+ //Map env = pb.environment();
+ // add own variables
+ pb.start();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentSelection = selection instanceof IStructuredSelection ? (IStructuredSelection)selection : null;
+ }
+
+ public boolean isEnabled(ResourceType resType)
+ {
+ resources = new ArrayList();
+ if (currentSelection != null)
+ {
+ Object[] selectedObjects = currentSelection.toArray();
+ if (selectedObjects.length >= 1)
+ {
+ for (Object object : selectedObjects) {
+ Resource resource = ResourceUtils.getResource(object);
+ if (resource != null) {
+ boolean resourceValid = true;
+ switch(resType) {
+ case resourceTypeFile:
+ resourceValid = resource.isFile();
+ break;
+ case resourceTypeDirectory:
+ resourceValid = resource.isDirectory();
+ break;
+ default:
+ break;
+ }
+ if (resourceValid) {
+ resources.add(resource);
+ }
+ }
+ }
+ }
+ }
+ return resources.size() > 0;
+ }
+
+ public ResourceType getCommonResourceType()
+ {
+ ResourceType resType = ResourceType.resourceTypeUnknown;
+ for (Resource resource : resources) {
+ ResourceType actResType = resource.isFile() ? ResourceType.resourceTypeFile : ResourceType.resourceTypeDirectory;
+ if (resType == ResourceType.resourceTypeUnknown) {
+ resType = actResType; // store the first valid type
+ } else if (resType != actResType) {
+ resType = ResourceType.resourceTypeFileOrDirectory; // if it changes then we have both types and can quit
+ break;
+ }
+ }
+ return resType;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommands.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommands.java
new file mode 100644
index 00000000..ff914dfd
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommands.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.commands;
+
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.menus.ExtensionContributionFactory;
+import org.eclipse.ui.menus.IContributionRoot;
+import org.eclipse.ui.services.IServiceLocator;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandDataStore;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataStore;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class DefineCommands extends ExtensionContributionFactory {
+
+ public DefineCommands() {
+ }
+
+ public ResourceType getWantedResourceType() {
+ return ResourceType.resourceTypeFileOrDirectory;
+ }
+
+ @Override
+ public void createContributionItems(IServiceLocator serviceLocator,
+ IContributionRoot additions) {
+ // load the preferences
+ CommandDataStore.instance().load();
+ MenuDataStore.instance().load();
+ MenuDataList items = MenuDataStore.instance().getEnabledCommandMenuDataList();
+ for (MenuData item : items) {
+ ResourceType resTypeWanted = getWantedResourceType();
+ ResourceType resTypeSupported = item.getCommandData().getResourceType();
+ if ( (resTypeSupported == ResourceType.resourceTypeFileOrDirectory) ||
+ (resTypeSupported == resTypeWanted)
+ )
+ {
+ addItem(serviceLocator, additions, item.getNameExpanded(), "de.anbos.eclipse.easyshell.plugin.commands.execute", Utils.getParameterMapFromMenuData(item), item.getCommandData().getCategory().getIcon(), true);
+ }
+ }
+ }
+
+ private void addItem(IServiceLocator serviceLocator, IContributionRoot additions,
+ String commandLabel, String commandId,
+ Map commandParamametersMap, String commandImageId, boolean visible) {
+ CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, "", commandId, SWT.PUSH);
+ param.label = commandLabel;
+ param.icon = Activator.getImageDescriptor(commandImageId);
+ param.parameters = commandParamametersMap;
+ CommandContributionItem item = new CommandContributionItem(param);
+ item.setVisible(visible);
+ additions.addContributionItem(item, null);
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceConstants.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForDirectory.java
similarity index 55%
rename from plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceConstants.java
rename to plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForDirectory.java
index d992dd82..16b69197 100644
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceConstants.java
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForDirectory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
+ * Copyright (c) 2014 - 2016 Andre Bossert.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,19 +9,14 @@
* Andre Bossert - initial API and implementation and/or initial documentation
*******************************************************************************/
-package de.anbos.eclipse.easyshell.plugin.preferences;
+package de.anbos.eclipse.easyshell.plugin.commands;
-/**
- * Constant definitions for plug-in preferences
- */
-public class PreferenceConstants {
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
- public static final String P_PATH = "pathPreference";
+public class DefineCommandsForDirectory extends DefineCommands {
- public static final String P_BOOLEAN = "booleanPreference";
-
- public static final String P_CHOICE = "choicePreference";
-
- public static final String P_STRING = "stringPreference";
+ public ResourceType getWantedResourceType() {
+ return ResourceType.resourceTypeDirectory;
+ }
}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForFile.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForFile.java
new file mode 100644
index 00000000..f604c0a5
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommandsForFile.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.commands;
+
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class DefineCommandsForFile extends DefineCommands {
+
+ public ResourceType getWantedResourceType() {
+ return ResourceType.resourceTypeFile;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandDialog.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandDialog.java
new file mode 100644
index 00000000..6b59fb43
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandDialog.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.Constants;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+
+public class ExecuteCommandDialog extends ElementListSelectionDialog {
+
+ private IWorkbench workbench;
+
+ public ExecuteCommandDialog(Shell parent, IWorkbench workbench, MenuDataList menuDataList, String title)
+ {
+ super(parent, new ExecuteCommandLabelProvider());
+ setTitle(title);
+ setHelpAvailable(false);
+ setMessage("select commands to execute...");
+ setIgnoreCase(true);
+ setImage(getDefaultImage());
+ setMatchEmptyString(true);
+ setMultipleSelection(true);
+ setImage(new Image(null, Activator.getImageDescriptor(Constants.IMAGE_EASYSHELL).getImageData()));
+ init(workbench, menuDataList);
+ }
+
+ @Override
+ protected void okPressed() {
+ executeCommandFromList();
+ // close this dialog
+ super.okPressed();
+ //this.close();
+ }
+
+ void init(IWorkbench workbench, MenuDataList menuDataList) {
+ this.workbench = workbench;
+ Object[] elements = new MenuData[menuDataList.size()];
+ for (int i=0;i menues = new ArrayList();
+ for (Object element : objects) {
+ menues.add((MenuData)element);
+ }
+ Utils.executeCommands(workbench, menues, true);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandLabelProvider.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandLabelProvider.java
new file mode 100644
index 00000000..3fc0cf54
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandLabelProvider.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.commands;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+
+public class ExecuteCommandLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ if(!(element instanceof MenuData)) {
+ return null;
+ }
+ MenuData data = (MenuData)element;
+ return new Image(null, Activator.getImageDescriptor(data.getCommandData().getCategory().getIcon()).getImageData());
+ }
+
+ @Override
+ public String getText(Object element) {
+ if(!(element instanceof MenuData)) {
+ return element.toString();
+ }
+ MenuData data = (MenuData)element;
+ return data.getNameExpanded();
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandPopup.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandPopup.java
new file mode 100644
index 00000000..b1419c6b
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/commands/ExecuteCommandPopup.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+
+public class ExecuteCommandPopup extends org.eclipse.jface.dialogs.PopupDialog implements SelectionListener, KeyListener {
+
+ private IWorkbench workbench;
+ private MenuDataList menuDataList;
+ private org.eclipse.swt.widgets.List listView;
+ private List chars;
+
+ public ExecuteCommandPopup(Shell parent, IWorkbench workbench, MenuDataList menuDataList, String title)
+ {
+ super(parent, INFOPOPUP_SHELLSTYLE, true, false, false, false, false, title, "...");
+ this.workbench = workbench;
+ this.menuDataList = menuDataList;
+ chars = new ArrayList();
+ for (Character ch='0';ch<='9';ch++) {
+ chars.add(ch);
+ }
+ for (Character ch='a';ch<='z';ch++) {
+ chars.add(ch);
+ }
+ int charsSize = menuDataList.size();
+ String info = "use '0'";
+ if (charsSize > 1) {
+ if( charsSize <= 10) {
+ info += " - '" + chars.get(charsSize-1) + "'";
+ } else {
+ info += " - '9' and 'a'";
+ if (charsSize > 11) {
+ info += " - '" + chars.get(charsSize-1) + "'";
+ }
+ }
+ }
+ info += " to execute";
+ setInfoText(info);
+ }
+
+ void init(IWorkbench workbench, MenuDataList menuDataList) {
+ this.workbench = workbench;
+ this.menuDataList = menuDataList;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ final Composite listViewComposite = (Composite)super.createDialogArea(parent);
+ listView = new org.eclipse.swt.widgets.List(listViewComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ listView.addSelectionListener(this);
+ listView.addKeyListener(this);
+ for (int i=0;i= menuDataList.size()) {
+ return;
+ }
+ listView.setSelection(index);
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ MenuData item = menuDataList.get(index);
+ // execute
+ Utils.executeCommand(workbench, item, true);
+ // close this dialog
+ this.close();
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
+ executeCommandFromList(-1);
+ } else if (((e.stateMask & SWT.ALT) == 0) && ((e.stateMask & SWT.CTRL) == 0) && ((e.stateMask & SWT.SHIFT) == 0)) {
+ if(e.keyCode >= '0' && e.keyCode <= '9') { //check digit
+ executeCommandFromList(e.keyCode - '0');
+ } else if(e.keyCode >= 'a' && e.keyCode <= 'z') { //check character
+ executeCommandFromList((e.keyCode - 'a') + ('9' - '0' + 1));
+ }
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ if (e.widget != listView) {
+ return;
+ }
+ executeCommandFromList(-1);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/All.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/All.java
new file mode 100644
index 00000000..de00c789
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/All.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.EditorPropertyTester;
+import de.anbos.eclipse.easyshell.plugin.actions.ActionDelegate;
+import de.anbos.eclipse.easyshell.plugin.commands.ExecuteCommandPopup;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.commands.ExecuteCommandDialog;
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandDataStore;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataStore;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class All extends AbstractHandler {
+
+ private Window dialog;
+ private MenuDataList list;
+ private boolean usePopup = true;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ // get resource type
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ ActionDelegate action = EditorPropertyTester.getActionExactResourceType(activePart, ResourceType.resourceTypeFileOrDirectory);
+ if (action != null) {
+ // load the preferences
+ list = getMenuDataList(action.getCommonResourceType());
+ if (list.size() > 0) {
+ IWorkbenchWindow workbenchWindow = activePart.getSite().getWorkbenchWindow();
+ if (list.size() == 1) {
+ Utils.executeCommand(workbenchWindow.getWorkbench(), list.get(0), false);
+ } else {
+ //create and open a new dialog
+ // close the old dialog
+ if (dialog != null)
+ {
+ dialog.close();
+ dialog = null;
+ }
+ if (usePopup) {
+ dialog = new ExecuteCommandPopup(workbenchWindow.getShell(), workbenchWindow.getWorkbench(), list, getTitle());
+ } else {
+ dialog = new ExecuteCommandDialog(workbenchWindow.getShell(), workbenchWindow.getWorkbench(), list, getTitle());
+ }
+ dialog.open();
+ }
+ }
+ }
+ return null;
+ }
+
+ public MenuDataList getMenuDataList(Category category) {
+ CommandDataStore.instance().load();
+ MenuDataStore.instance().load();
+ MenuDataList menuDataList = MenuDataStore.instance().getEnabledCommandMenuDataListByCategory(category);
+ return menuDataList;
+ }
+
+ public MenuDataList getMenuDataList(ResourceType resTypeWanted) {
+ MenuDataList menuDataList = getMenuDataList(getCategory());
+ MenuDataList menuDataListSupported = new MenuDataList();
+ for (MenuData menuData : menuDataList) {
+ ResourceType resTypeSupported = menuData.getCommandData().getResourceType();
+ if ( (resTypeSupported == ResourceType.resourceTypeFileOrDirectory) ||
+ (resTypeSupported == resTypeWanted)
+ )
+ {
+ menuDataListSupported.add(menuData);
+ }
+ }
+ return menuDataListSupported;
+ }
+
+ public Category getCategory() {
+ return Category.categoryUnknown;
+ }
+
+ public String getTitle() {
+ String postfix = getCategory() == Category.categoryUnknown ? "" : " - " + getCategory().getName();
+ return Activator.getResourceString("easyshell.plugin.name") + postfix;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ public void setUsePopup(boolean usePopup) {
+ this.usePopup = usePopup;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllMulti.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllMulti.java
new file mode 100644
index 00000000..059fc175
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllMulti.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+public class AllMulti extends All {
+
+ public AllMulti() {
+ super();
+ setUsePopup(false);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllSingle.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllSingle.java
new file mode 100644
index 00000000..298a2669
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/AllSingle.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+public class AllSingle extends All {
+
+ public AllSingle() {
+ super();
+ setUsePopup(true);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Clipboard.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Clipboard.java
new file mode 100644
index 00000000..420e28e4
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Clipboard.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class Clipboard extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryClipboard;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Default.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Default.java
new file mode 100644
index 00000000..4747cc24
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Default.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class Default extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryDefault;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Execute.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Execute.java
new file mode 100644
index 00000000..a41f83eb
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Execute.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import de.anbos.eclipse.easyshell.plugin.EditorPropertyTester;
+import de.anbos.eclipse.easyshell.plugin.actions.Action;
+import de.anbos.eclipse.easyshell.plugin.actions.ActionDelegate;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class Execute extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ String commandID = event.getCommand().getId();
+ ResourceType resourceType = ResourceType.getFromEnum(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.resource"));
+ CommandType commandType = CommandType.getFromAction(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.type"));
+ String commandValue = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.value");
+ String commandWorkingDir = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.workingdir");
+ ActionDelegate action = EditorPropertyTester.getActionExactResourceType(activePart, resourceType);
+ if (action != null) {
+ action.setResourceType(resourceType);
+ action.setCommandType(commandType);
+ action.setCommandValue(commandValue);
+ action.setCommandWorkingDir(commandWorkingDir);
+ Action act = new Action(commandID);
+ action.run((IAction)act);
+ }
+ action = null;
+ return null;
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Explore.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Explore.java
new file mode 100644
index 00000000..2bb9bcd8
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Explore.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class Explore extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryExplore;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Open.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Open.java
new file mode 100644
index 00000000..8468a0ee
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Open.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class Open extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryOpen;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Run.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Run.java
new file mode 100644
index 00000000..a8941433
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/Run.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class Run extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryRun;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/SampleHandler.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/SampleHandler.java
deleted file mode 100644
index d7f95c7d..00000000
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/SampleHandler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Bossert - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package de.anbos.eclipse.easyshell.plugin.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-/**
- * Our sample handler extends AbstractHandler, an IHandler base class.
- * @see org.eclipse.core.commands.IHandler
- * @see org.eclipse.core.commands.AbstractHandler
- */
-public class SampleHandler extends AbstractHandler {
- /**
- * The constructor.
- */
- public SampleHandler() {
- }
-
- /**
- * the command has been executed, so extract extract the needed information
- * from the application context.
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- MessageDialog.openInformation(
- window.getShell(),
- "EasyShell",
- "Hello, Eclipse world");
- return null;
- }
-}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/User.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/User.java
new file mode 100644
index 00000000..dbc30001
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/User.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.handlers;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class User extends AllSingle {
+
+ @Override
+ public Category getCategory() {
+ return Category.categoryUser;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Debug.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Debug.java
new file mode 100644
index 00000000..cfebc17e
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Debug.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+/**
+ * Debug.
+ */
+public enum Debug {
+ debugNo(0, "No"),
+ debugYes(1, "Yes");
+ // attributes
+ private final int id;
+ private final String mode;
+ // construct
+ Debug(int id, String mode) {
+ this.id = id;
+ this.mode = mode;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getMode() {
+ return mode;
+ }
+ public static Debug getFromId(int id) {
+ Debug ret = debugNo;
+ for(int i = 0; i < Debug.values().length; i++) {
+ if (Debug.values()[i].getId() == id) {
+ ret = Debug.values()[i];
+ }
+ }
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/LinuxDesktop.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/LinuxDesktop.java
new file mode 100644
index 00000000..6ab40a8c
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/LinuxDesktop.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+/**
+ * Linux desktops.
+ */
+public enum LinuxDesktop {
+ desktopUnknown(0, "Unknown"),
+ desktopKde(1, "KDE"),
+ desktopGnome(2, "Gnome"),
+ desktopCinnamon(3, "Cinnamon"),
+ desktopCde(4, "CDE"),
+ desktopXfce(5, "Xfce");
+ // attributes
+ private final int id;
+ private final String name;
+ // construct
+ LinuxDesktop(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public static LinuxDesktop getFromId(int id) {
+ LinuxDesktop ret = desktopUnknown;
+ for(int i = 0; i < LinuxDesktop.values().length; i++) {
+ if (LinuxDesktop.values()[i].getId() == id) {
+ ret = LinuxDesktop.values()[i];
+ }
+ }
+ return ret;
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PreferenceEntry.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PreferenceEntry.java
new file mode 100644
index 00000000..96325adf
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PreferenceEntry.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+/**
+ * Strings for preference store.
+ */
+public enum PreferenceEntry {
+ preferenceTargetOpen(0, "targetPreference"),
+ preferenceTargetRun(1, "targetRunPreference"),
+ preferenceTargetExplore(2, "targetExplorePreference"),
+ preferenceTargetCopyPath(3, "targetCopyPathPreference"),
+ preferenceListId(4, "listPreference"),
+ preferenceListString(5, "IdStr"),
+ preferenceQuotes(6, "QuotesStr"),
+ preferenceDebug(7, "DebugStr"),
+ preferenceTokenizer(8, "TokenizerStr"),
+ preferenceTargetEnabled(9, "targetEnabled");
+ // attributes
+ private final int id;
+ private final String preferenceString;
+ // construct
+ PreferenceEntry(int id, String pref) {
+ this.id = id;
+ this.preferenceString = pref;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getString() {
+ return preferenceString;
+ }
+ public String getString(int instId) {
+ if (instId == 0) {
+ return getString();
+ } else {
+ return getString() + (new Integer(instId)).toString();
+ }
+ }
+ public static PreferenceEntry getFromId(int id) {
+ PreferenceEntry ret = preferenceTargetOpen;
+ for(int i = 0; i < PreferenceEntry.values().length; i++) {
+ if (PreferenceEntry.values()[i].getId() == id) {
+ ret = PreferenceEntry.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+};
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_4.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_4.java
new file mode 100644
index 00000000..3fb630c7
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_4.java
@@ -0,0 +1,451 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandData;
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandDataList;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.MenuNameType;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class PrefsV1_4 {
+
+ /**
+ * Commands.
+ */
+ private enum Command {
+ cmdUnknown(0, "Unknown", "shell", "file browser", null,
+ "open {1}",
+ "cd {1} && run ./''{3}''",
+ "explore {2}",
+ "{2}{5}"
+ ),
+ cmdWinDOS(1, "Windows", "DOS-Shell", "Explorer", null,
+ "cmd.exe /C start \"{4}\" /D {1} cmd.exe /K",
+ "cmd.exe /C start \"{4}\" /D {1} {3}",
+ "explorer.exe /select, {2}",
+ "{2}{5}"
+ ),
+ cmdWinPower(2, "Windows", "PowerShell", "Explorer", null,
+ "cmd.exe /C start \"{4}\" /D {1} powershell.exe",
+ "cmd.exe /C start \"{4}\" /D {1} powershell.exe -command ./''{3}''",
+ "explorer.exe /select, {2}",
+ "{2}{5}"
+ ),
+ cmdWinCyg(3, "Windows", "Cygwin (Bash)", "Explorer", null,
+ "cmd.exe /C start \"{4}\" /D {1} \"C:\\Cygwin\\bin\\bash.exe\"",
+ "cmd.exe /C start \"{4}\" /D {1} \"C:\\Cygwin\\bin\\bash.exe\" -c ./''{3}''",
+ "explorer.exe /select, {2} ",
+ "{2}{5}"
+ ),
+ cmdKonsoleKDEKonqueror(4, "Linux", "KDE Konsole", "Konqueror", null,
+ "konsole --noclose --workdir {1}",
+ "konsole --noclose --workdir {1} -e ./''{3}''",
+ "konqueror file:\"{2}\"",
+ "{2}{5}"
+ ),
+ cmdKonsoleGnome(5, "Linux", "Gnome Terminal", "Nautilus", null,
+ "gnome-terminal --working-directory=\"{1}\"",
+ "gnome-terminal --working-directory=\"{1}\" --command=./''{3}''",
+ "nautilus {2}",
+ "{2}{5}"
+ ),
+ cmdXtermDtfile(6, "Linux", "CDE Xterm", "Dtfile", null,
+ "cd {1} && xterm",
+ "cd {1} && xterm -e ./''{3}''",
+ "cd {1} && dtfile",
+ "{2}{5}"
+ ),
+ cmdTerminalFinder(7, "MAC OS X", "Terminal", "Finder", null,
+ "open -a Terminal {1}",
+ "open -a Terminal {2}",
+ "open -R {2}",
+ "{2}{5}"
+ ),
+ cmdKonsoleKDEDolphin(8, "Linux", "KDE Konsole", "Dolphin", null,
+ "konsole --workdir {1}",
+ "konsole --workdir {1} --noclose -e {2}",
+ "dolphin --select {2}",
+ "{2}{5}"
+ ),
+ cmdWinConsole(9, "Windows", "Console", "Explorer", null,
+ "console.exe -w \"{4}\" -d {1}",
+ "console.exe -w \"{4}\" -d {1} -r \"/k\\\"{3}\\\"\"",
+ "explorer.exe /select, {2}",
+ "{2}{5}"
+ ),
+ cmdWinTotalCommander(10, "Windows", "DOS-Shell", "TotalCommander", null,
+ "cmd.exe /C start \"{4}\" /D {1} cmd.exe /K",
+ "cmd.exe /C start \"{4}\" /D {1} {3}",
+ "totalcmd.exe /O /T {1}",
+ "{2}{5}"
+ ),
+ cmdWinGitBash(11, "Windows", "Git-Bash", "Explorer", null,
+ "cmd.exe /C start \"{4}\" /D {1} \"C:\\Program Files (x86)\\Git\\bin\\bash.exe\" --login -i",
+ "cmd.exe /C start \"{4}\" /D {1} \"C:\\Program Files (x86)\\Git\\bin\\bash.exe\" --login -i -c ./''{3}''",
+ "explorer.exe /select, {2} ",
+ "{2}{5}"
+ ),
+ cmdWinConEmu(12, "Windows", "ConEmu", "Explorer", null,
+ "ConEmu.exe /Title \"{4}\" /Dir \"{1}\" /Single /cmd cmd",
+ "ConEmu.exe /Title \"{4}\" /Dir \"{1}\" /Single /cmd \"{3}\"",
+ "explorer.exe /select, {2} ",
+ "{2}{5}"
+ );
+ // attributes
+ private final int id;
+ private final String os;
+ private final String console;
+ private final String explorer;
+ private final String label;
+ private final String openCmd;
+ private final String runCmd;
+ private final String exploreCmd;
+ private final String copyPathCmd;
+ // construct
+ Command(int id, String os, String console, String explorer, String label, String openCmd, String runCmd, String exploreCmd, String copyPathCmd) {
+ this.id = id;
+ this.os = os;
+ this.console = console;
+ this.explorer = explorer;
+ if (label != null) {
+ this.label = label;
+ } else {
+ this.label = os + " " + console + " / " + explorer;
+ }
+ this.openCmd = openCmd;
+ this.runCmd = runCmd;
+ this.exploreCmd = exploreCmd;
+ this.copyPathCmd = copyPathCmd;
+ }
+ public int getId() {
+ return id;
+ }
+ @SuppressWarnings("unused")
+ public String getOS() {
+ return os;
+ }
+ public String getConsole() {
+ return console;
+ }
+ public String getExplorer() {
+ return explorer;
+ }
+ @SuppressWarnings("unused")
+ public String getLabel() {
+ return label;
+ }
+ public String getOpenCmd() {
+ return openCmd;
+ }
+ public String getRunCmd() {
+ return runCmd;
+ }
+ public String getExploreCmd() {
+ return exploreCmd;
+ }
+ public String getCopyPathCmd() {
+ return copyPathCmd;
+ }
+ @SuppressWarnings("unused")
+ static Command getFromId(int id) {
+ Command ret = cmdUnknown;
+ for(int i = 0; i < Command.values().length; i++) {
+ if (Command.values()[i].getId() == id) {
+ ret = Command.values()[i];
+ }
+ }
+ return ret;
+ }
+ }
+
+ public PrefsV1_4() {
+ }
+
+ /**
+ * Sets the default values of the preferences.
+ */
+ private static void initializeDefaults(IPreferenceStore store, Command cmd) {
+ // set default commands
+ store.setDefault(PreferenceEntry.preferenceTargetOpen.getString(), cmd.getOpenCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetRun.getString(), cmd.getRunCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetExplore.getString(), cmd.getExploreCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetCopyPath.getString(), cmd.getCopyPathCmd());
+ // set default selected preset
+ store.setDefault(PreferenceEntry.preferenceListId.getString(), cmd.getId() - 1);
+ store.setDefault(PreferenceEntry.preferenceListString.getString(), cmd.name());
+ // set default
+ store.setDefault(PreferenceEntry.preferenceQuotes.getString(), Quotes.quotesNo.name());
+ store.setDefault(PreferenceEntry.preferenceDebug.getString(), Debug.debugNo.name());
+ store.setDefault(PreferenceEntry.preferenceTokenizer.getString(), Tokenizer.EasyShellTokenizerYes.name());
+ }
+
+ public static List getPreferenceList() {
+ List list = new ArrayList();
+ //list.add(PreferenceEntry.preferenceListId.getString());
+ list.add(PreferenceEntry.preferenceListString.getString());
+ list.add(PreferenceEntry.preferenceTargetOpen.getString());
+ list.add(PreferenceEntry.preferenceTargetRun.getString());
+ list.add(PreferenceEntry.preferenceTargetExplore.getString());
+ list.add(PreferenceEntry.preferenceTargetCopyPath.getString());
+ //list.add(PreferenceEntry.preferenceQuotes.getString());
+ //list.add(PreferenceEntry.preferenceDebug.getString());
+ //list.add(PreferenceEntry.preferenceTokenizer.getString());
+ return list;
+ }
+
+ /**
+ * Loads the preference store and sets the data to controls.
+ *
+ * @return store loaded.
+ */
+ public static boolean loadStore(IPreferenceStore store, OS os, CommandDataList cmdDataList, MenuDataList menuDataList) {
+ // get proper command (detect)
+ Command cmdProper = getProperCommand();
+ // set defaults first
+ initializeDefaults(store, cmdProper);
+ // get the properties now
+ final String postfix = " (" + Version.v1_4.getName() + ")";
+ String IdStr = store.getString(PreferenceEntry.preferenceListString.getString());
+ Command command = Command.valueOf(IdStr);
+ int position = menuDataList.size();
+ // open
+ String openCmd = store.getString(PreferenceEntry.preferenceTargetOpen.getString());
+ CommandData cmdDataOpen = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryOpen, CommandType.commandTypeExecute, migrateCommandVariables(openCmd));
+ cmdDataList.add(cmdDataOpen);
+ MenuData menuDataOpen = new MenuData(cmdDataOpen.getId(), true, MenuNameType.menuNameTypeOpenHere, null, cmdDataOpen.getId());
+ menuDataOpen.setPosition(position++);
+ menuDataOpen.setNamePattern(menuDataOpen.getNamePattern() + postfix);
+ menuDataOpen.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataOpen);
+ // run
+ String runCmd = store.getString(PreferenceEntry.preferenceTargetRun.getString());
+ CommandData cmdDataRun = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryRun, CommandType.commandTypeExecute, migrateCommandVariables(runCmd));
+ cmdDataList.add(cmdDataRun);
+ MenuData menuDataRun = new MenuData(cmdDataRun.getId(), true, MenuNameType.menuNameTypeRunWith, null, cmdDataRun.getId());
+ menuDataRun.setPosition(position++);
+ menuDataRun.setNamePattern(menuDataRun.getNamePattern() + postfix);
+ menuDataRun.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataRun);
+ // explore
+ String exploreCmd = store.getString(PreferenceEntry.preferenceTargetExplore.getString());
+ CommandData cmdDataExplore = new CommandData(null, PresetType.presetUser, os, command.getExplorer(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryExplore, CommandType.commandTypeExecute, migrateCommandVariables(exploreCmd));
+ cmdDataList.add(cmdDataExplore);
+ MenuData menuDataExplore = new MenuData(cmdDataExplore.getId(), true, MenuNameType.menuNameTypeShowIn, null, cmdDataExplore.getId());
+ menuDataExplore.setPosition(position++);
+ menuDataExplore.setNamePattern(menuDataExplore.getNamePattern() + postfix);
+ menuDataExplore.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataExplore);
+ // copy to clipboard
+ String copyPathCmd = store.getString(PreferenceEntry.preferenceTargetCopyPath.getString());
+ CommandData cmdDataCopyPath = new CommandData(null, PresetType.presetUser, os, "Full Path", ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryClipboard, CommandType.commandTypeClipboard, migrateCommandVariables(copyPathCmd));
+ cmdDataList.add(cmdDataCopyPath);
+ MenuData menuDataCopyPath = new MenuData(cmdDataCopyPath.getId(), true, MenuNameType.menuNameTypeCopyToClipboard, null, cmdDataCopyPath.getId());
+ menuDataCopyPath.setPosition(position++);
+ menuDataCopyPath.setNamePattern(menuDataCopyPath.getNamePattern() + postfix);
+ menuDataCopyPath.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataCopyPath);
+ /*
+ String QuotesStr = store.getString(PreferenceEntry.preferenceQuotes.getString());
+ Quotes quotes = Quotes.valueOf(QuotesStr);
+ String DebugStr = store.getString(PreferenceEntry.preferenceDebug.getString());
+ Debug debug = Debug.valueOf(DebugStr);
+ String TokenizerStr = store.getString(PreferenceEntry.preferenceTokenizer.getString());
+ Tokenizer tokenizer = Tokenizer.valueOf(TokenizerStr);
+ */
+ return true;
+ }
+
+ public static String migrateCommandVariables(String cmdString) {
+ /*
+ {0} == ${easyshell:drive}
+ {1} == ${easyshell:container_loc}
+ {2} == ${easyshell:resource_loc}
+ {3} == ${easyshell:resource_name}
+ {4} == ${easyshell:project_name}
+ {5} == ${easyshell:line_separator}
+ */
+ String migratedString = cmdString;
+ migratedString = migratedString.replace("{0}", "${easyshell:drive}");
+ migratedString = migratedString.replace("{1}", "${easyshell:container_loc}");
+ migratedString = migratedString.replace("{2}", "${easyshell:resource_loc}");
+ migratedString = migratedString.replace("{3}", "${easyshell:resource_name}");
+ migratedString = migratedString.replace("{4}", "${easyshell:project_name}");
+ migratedString = migratedString.replace("{5}", "${easyshell:line_separator}");
+ return migratedString;
+ }
+
+ private static Command getProperCommand() {
+ Command cmd = Command.cmdUnknown;
+ /* possible OS string:
+ AIX
+ Digital UNIX
+ FreeBSD
+ HP UX
+ Irix
+ Linux
+ Mac OS
+ Mac OS X
+ MPE/iX
+ Netware 4.11
+ OS/2
+ Solaris
+ Windows 95
+ Windows 98
+ Windows NT
+ Windows Me
+ Windows 2000
+ Windows XP
+ Windows 2003
+ Windows CE
+ Windows Vista
+ Windows 7
+ */
+ String osname = System.getProperty("os.name", "").toLowerCase();
+ if (osname.indexOf("windows") != -1) {
+ cmd = Command.cmdWinDOS;
+ } else if (osname.indexOf("mac os x") != -1) {
+ cmd = Command.cmdTerminalFinder;
+ } else if (
+ osname.indexOf("unix") != -1
+ || osname.indexOf("irix") != -1
+ || osname.indexOf("freebsd") != -1
+ || osname.indexOf("hp-ux") != -1
+ || osname.indexOf("aix") != -1
+ || osname.indexOf("sunos") != -1
+ || osname.indexOf("linux") != -1
+ )
+ {
+ LinuxDesktop desktop = detectDesktopNew(); // old: detectDesktop()
+ if(desktop == LinuxDesktop.desktopKde) {
+ cmd = Command.cmdKonsoleKDEDolphin;
+ } else if(desktop == LinuxDesktop.desktopGnome) {
+ cmd = Command.cmdKonsoleGnome;
+ } else if(desktop == LinuxDesktop.desktopCde) {
+ cmd = Command.cmdXtermDtfile;
+ }
+ }
+ return cmd;
+ }
+
+ private static LinuxDesktop detectDesktopNew() {
+ LinuxDesktop resultCode = LinuxDesktop.desktopUnknown;
+ if (isKDE()) {
+ resultCode = LinuxDesktop.desktopKde;
+ } else if (isGnome()) {
+ resultCode = LinuxDesktop.desktopGnome;
+ }
+ return resultCode;
+ }
+
+ /**
+ * detects KDE desktop
+ *
+ * @see http://techbase.kde.org/KDE_System_Administration/Environment_Variables#KDE_FULL_SESSION
+ */
+ private static boolean isKDE() {
+ boolean kde = false;
+ String[] cmd = new String[2];
+ cmd [0] = "echo";
+ cmd [1] = "$KDE_FULL_SESSION";
+ kde = isExpectedCommandOutput(cmd, "true", true);
+ // if not found try another env
+ if (!kde) {
+ cmd [1] = "$DESKTOP_SESSION";
+ kde = isExpectedCommandOutput(cmd, "kde", true);
+ }
+ return kde;
+ }
+
+ /**
+ * detects Gnome desktop
+ */
+ private static boolean isGnome() {
+ boolean gnome = false;
+ String[] cmd = new String[2];
+ cmd [0] = "echo";
+ cmd [1] = "$GNOME_DESKTOP_SESSION_ID";
+ gnome = isExpectedCommandOutput(cmd, "*", true);
+ // if not found try another env
+ if (!gnome) {
+ cmd [1] = "$DESKTOP_SESSION";
+ gnome = isExpectedCommandOutput(cmd, "gnome", true);
+ }
+ return gnome;
+ }
+
+ /**
+ * Detects which desktop is used on a unix / linux system.
+ *
+ * @todo use regex
+ *
+ * @return The type of desktop.
+ * @see detectDesktop
+ */
+ private static boolean isExpectedCommandOutput(String[] command, String expectedOutput, boolean toLowerCase) {
+ boolean found = false;
+ try {
+ Process proc = Runtime.getRuntime().exec(command);
+ BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ while((line = in.readLine()) != null && !found) {
+ // in case of * just something should be returned
+ if (expectedOutput.indexOf("*") != -1)
+ {
+ if (line.isEmpty()) {
+ found = false;
+ break;
+ } else {
+ found = true;
+ }
+ } else {
+ if (toLowerCase)
+ line = line.toLowerCase();
+ if(line.indexOf(expectedOutput) != -1) {
+ found = true;
+ }
+ }
+ }
+ BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
+ line = null;
+ // If there is any error output, print it to
+ // stdout for debugging purposes
+ while((line = err.readLine()) != null) {
+ //EasyShellPlugin.getDefault().sysout(true, "detectDesktop stderr >" + line + "<");
+ }
+
+ int result = proc.waitFor();
+ if(result != 0) {
+ // If there is any error code, print it to
+ // stdout for debugging purposes
+ //EasyShellPlugin.getDefault().sysout(true, "detectDesktop return code: " + result);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return found;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_5.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_5.java
new file mode 100644
index 00000000..f05a61bd
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/PrefsV1_5.java
@@ -0,0 +1,513 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandData;
+import de.anbos.eclipse.easyshell.plugin.preferences.CommandDataList;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuDataList;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.MenuNameType;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class PrefsV1_5 {
+
+ /**
+ * Commands.
+ */
+ public enum Command {
+ cmdUnknown(0, "Unknown", "shell", "file browser", null,
+ "open ${easyshell:container_loc}",
+ "cd ${easyshell:container_loc} && run ./''${easyshell:resource_name}''",
+ "explore ${easyshell:resource_loc}",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinDOS(1, "Windows", "DOS-Shell", "Explorer", null,
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} cmd.exe /K",
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} ${easyshell:resource_name}",
+ "explorer.exe /select, ${easyshell:resource_loc}",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinPower(2, "Windows", "PowerShell", "Explorer", null,
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} powershell.exe",
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} powershell.exe -command ./''${easyshell:resource_name}''",
+ "explorer.exe /select, ${easyshell:resource_loc}",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinCyg(3, "Windows", "Cygwin (Bash)", "Explorer", null,
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} \"C:\\Cygwin\\bin\\bash.exe\"",
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} \"C:\\Cygwin\\bin\\bash.exe\" -c ./''${easyshell:resource_name}''",
+ "explorer.exe /select, ${easyshell:resource_loc} ",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdKonsoleKDEKonqueror(4, "Linux", "KDE Konsole", "Konqueror", null,
+ "konsole --noclose --workdir ${easyshell:container_loc}",
+ "konsole --noclose --workdir ${easyshell:container_loc} -e ./''${easyshell:resource_name}''",
+ "konqueror file:\"${easyshell:resource_loc}\"",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ cmdKonsoleGnome(5, "Linux", "Gnome Terminal", "Nautilus", null,
+ "gnome-terminal --working-directory=${easyshell:container_loc}",
+ "gnome-terminal --working-directory=${easyshell:container_loc} --command=./''${easyshell:resource_name}''",
+ "nautilus ${easyshell:resource_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ cmdXtermDtfile(6, "Linux" , "CDE Xterm", "Dtfile", null,
+ "cd ${easyshell:container_loc} && xterm",
+ "cd ${easyshell:container_loc} && xterm -e ./''${easyshell:resource_name}''",
+ "cd ${easyshell:container_loc} && dtfile",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ cmdTerminalFinder(7, "MAC OS X", "Terminal", "Finder", null,
+ "open -a Terminal ${easyshell:container_loc}",
+ "open -a Terminal ${easyshell:resource_loc}",
+ "open -R ${easyshell:resource_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ cmdKonsoleKDEDolphin(8, "Linux" , "KDE Konsole", "Dolphin", null,
+ "konsole --workdir ${easyshell:container_loc}",
+ "konsole --workdir ${easyshell:container_loc} --noclose -e ${easyshell:resource_loc}",
+ "dolphin --select ${easyshell:resource_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ cmdWinConsole(9, "Windows", "Console", "Explorer", null,
+ "console.exe -w \"${easyshell:project_name}\" -d ${easyshell:container_loc}",
+ "console.exe -w \"${easyshell:project_name}\" -d ${easyshell:container_loc} -r \"/k\\\"${easyshell:resource_name}\\\"\"",
+ "explorer.exe /select, ${easyshell:resource_loc}",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinTotalCommander(10, "Windows", "DOS-Shell", "TotalCommander", null,
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} cmd.exe /K",
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} ${easyshell:resource_name}",
+ "totalcmd.exe /O /T ${easyshell:container_loc}",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinGitBash(11, "Windows", "Git-Bash", "Explorer", null,
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} \"C:\\Program Files (x86)\\Git\\bin\\bash.exe\" --login -i",
+ "cmd.exe /C start \"${easyshell:project_name}\" /D ${easyshell:container_loc} \"C:\\Program Files (x86)\\Git\\bin\\bash.exe\" --login -i -c ./''${easyshell:resource_name}''",
+ "explorer.exe /select, ${easyshell:resource_loc} ",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ cmdWinConEmu(12, "Windows", "ConEmu", "Explorer", null,
+ "ConEmu.exe /Title \"${easyshell:project_name}\" /Dir \"${easyshell:container_loc}\" /Single /cmd cmd",
+ "ConEmu.exe /Title \"${easyshell:project_name}\" /Dir \"${easyshell:container_loc}\" /Single /cmd \"${easyshell:resource_name}\"",
+ "explorer.exe /select, ${easyshell:resource_loc} ",
+ "\"${easyshell:resource_loc}\"${easyshell:line_separator}"
+ ),
+ // https://sourceforge.net/p/pluginbox/feature-requests/18/
+ // https://github.com/anb0s/EasyShell/issues/17
+ cmdGnomeTermNemo(13, "Linux", "Gnome Terminal", "Nemo", null,
+ "gnome-terminal --working-directory=${easyshell:container_loc}",
+ "gnome-terminal --working-directory=${easyshell:container_loc} --command=./''${easyshell:resource_name}''",
+ "nemo ${easyshell:resource_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ // https://sourceforge.net/p/pluginbox/feature-requests/24/
+ // https://github.com/anb0s/EasyShell/issues/23
+ cmdGnomeTermThunar(14, "Linux", "Gnome Terminal", "Thunar", null,
+ "gnome-terminal --working-directory=${easyshell:container_loc}",
+ "gnome-terminal --working-directory=${easyshell:container_loc} --command=./''${easyshell:resource_name}''",
+ "thunar ${easyshell:container_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ ),
+ // https://sourceforge.net/p/pluginbox/feature-requests/22/
+ // https://github.com/anb0s/EasyShell/issues/21
+ cmdXfceTermThunar(15, "Linux", "Xfce Terminal", "Thunar", null,
+ "xfce4-terminal --working-directory=${easyshell:container_loc}",
+ "xfce4-terminal --working-directory=${easyshell:container_loc} --command=./''${easyshell:resource_name}'' --hold",
+ "thunar ${easyshell:container_loc}",
+ "${easyshell:resource_loc}${easyshell:line_separator}"
+ );
+ // attributes
+ private final int id;
+ private final String os;
+ private final String console;
+ private final String explorer;
+ private final String label;
+ private final String openCmd;
+ private final String runCmd;
+ private final String exploreCmd;
+ private final String copyPathCmd;
+ // construct
+ Command(int id, String os, String console, String explorer, String label, String openCmd, String runCmd, String exploreCmd, String copyPathCmd) {
+ this.id = id;
+ this.os = os;
+ this.console = console;
+ this.explorer = explorer;
+ if (label != null) {
+ this.label = label;
+ } else {
+ this.label = os + " " + console + " / " + explorer;
+ }
+ this.openCmd = openCmd;
+ this.runCmd = runCmd;
+ this.exploreCmd = exploreCmd;
+ this.copyPathCmd = copyPathCmd;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getOS() {
+ return os;
+ }
+ public String getConsole() {
+ return console;
+ }
+ public String getExplorer() {
+ return explorer;
+ }
+ public String getLabel() {
+ return label;
+ }
+ public String getOpenCmd() {
+ return openCmd;
+ }
+ public String getRunCmd() {
+ return runCmd;
+ }
+ public String getExploreCmd() {
+ return exploreCmd;
+ }
+ public String getCopyPathCmd() {
+ return copyPathCmd;
+ }
+ public static Command getFromId(int id) {
+ Command ret = cmdUnknown;
+ for(int i = 0; i < Command.values().length; i++) {
+ if (Command.values()[i].getId() == id) {
+ ret = Command.values()[i];
+ }
+ }
+ return ret;
+ }
+ }
+
+ /**
+ * Constructs the preference page.
+ */
+ public PrefsV1_5() {
+ }
+
+ /**
+ * Sets the default values of the preferences.
+ */
+ public static void initializeDefaults(IPreferenceStore store, Command cmd, int instId) {
+ // set default commands
+ store.setDefault(PreferenceEntry.preferenceTargetEnabled.getString(instId), false);
+ store.setDefault(PreferenceEntry.preferenceTargetOpen.getString(instId), cmd.getOpenCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetRun.getString(instId), cmd.getRunCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetExplore.getString(instId), cmd.getExploreCmd());
+ store.setDefault(PreferenceEntry.preferenceTargetCopyPath.getString(instId), cmd.getCopyPathCmd());
+ // set default selected preset
+ store.setDefault(PreferenceEntry.preferenceListId.getString(instId), cmd.getId() - 1);
+ store.setDefault(PreferenceEntry.preferenceListString.getString(instId), cmd.name());
+ // set default
+ store.setDefault(PreferenceEntry.preferenceQuotes.getString(instId), Quotes.quotesNo.name());
+ store.setDefault(PreferenceEntry.preferenceDebug.getString(instId), Debug.debugNo.name());
+ store.setDefault(PreferenceEntry.preferenceTokenizer.getString(instId), Tokenizer.EasyShellTokenizerYes.name());
+ }
+
+ public static List getPreferenceList() {
+ List list = new ArrayList();
+ list.add(PreferenceEntry.preferenceTargetEnabled.getString());
+ //list.add(PreferenceEntry.preferenceListId.getString());
+ //list.add(PreferenceEntry.preferenceListString.getString());
+ //list.add(PreferenceEntry.preferenceTargetOpen.getString());
+ //list.add(PreferenceEntry.preferenceTargetRun.getString());
+ //list.add(PreferenceEntry.preferenceTargetExplore.getString());
+ //list.add(PreferenceEntry.preferenceTargetCopyPath.getString());
+ //list.add(PreferenceEntry.preferenceQuotes.getString());
+ //list.add(PreferenceEntry.preferenceDebug.getString());
+ //list.add(PreferenceEntry.preferenceTokenizer.getString());
+ return list;
+ }
+
+ /**
+ * Loads the preference store and sets the data to controls.
+ *
+ * @return store loaded.
+ */
+ public static boolean loadStore(IPreferenceStore store, OS os, CommandDataList cmdDataList, MenuDataList menuDataList) {
+ /*
+ DebugStr=debugYes
+ DebugStr1=debugNo
+ DebugStr2=debugNo
+ IdStr1=cmdWinPower
+ IdStr2=cmdWinCyg
+ QuotesStr=quotesAuto
+ QuotesStr1=quotesNo
+ QuotesStr2=quotesNo
+ TokenizerStr=EasyShellTokenizerNo
+ TokenizerStr1=EasyShellTokenizerYes
+ TokenizerStr2=EasyShellTokenizerYes
+ eclipse.preferences.version=1
+ listPreference1=1
+ listPreference2=2
+ targetCopyPathPreference={2}{5} copy
+ targetEnabled=true
+ targetEnabled1=true
+ targetEnabled2=true
+ targetExplorePreference=explorer.exe /select, {2} my
+ targetExplorePreference2=explorer.exe /select, ${easyshell\:resource_loc}
+ targetPreference=cmd.exe /C start "{4}" /D {1} cmd.exe /K test
+ targetPreference1=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} powershell.exe
+ targetPreference2=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} "C\:\\Cygwin\\bin\\bash.exe"
+ targetRunPreference=cmd.exe /C start "{4}" /D {1} {3} hello
+ targetRunPreference1=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} powershell.exe -command ./''${easyshell\:resource_name}''
+ targetRunPreference2=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} "C\:\\Cygwin\\bin\\bash.exe" -c ./''${easyshell\:resource_name}''
+ */
+ // get proper command (detect)
+ Command cmdProper = getProperCommand();
+ // duplicate cache
+ List openCmdList = new ArrayList();
+ List runCmdList = new ArrayList();
+ List exploreCmdList = new ArrayList();
+ List copyPathList = new ArrayList();
+ // iterate over the instances
+ for (int instanceId=0;instanceId<3;instanceId++) {
+ // set defaults first
+ initializeDefaults(store, cmdProper, instanceId);
+ // get the properties now
+ if (store.getBoolean(PreferenceEntry.preferenceTargetEnabled.getString(instanceId))) {
+ final String postfix = " (" + Version.v1_5.getName() + ")";
+ String IdStr = store.getString(PreferenceEntry.preferenceListString.getString(instanceId));
+ Command command = Command.valueOf(IdStr);
+ int position = menuDataList.size();
+ // open
+ String openCmd = store.getString(PreferenceEntry.preferenceTargetOpen.getString(instanceId));
+ if (!openCmdList.contains(openCmd)) {
+ openCmdList.add(openCmd);
+ CommandData cmdDataOpen = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryOpen, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(openCmd));
+ cmdDataList.add(cmdDataOpen);
+ MenuData menuDataOpen = new MenuData(cmdDataOpen.getId(), true, MenuNameType.menuNameTypeOpenHere, null, cmdDataOpen.getId());
+ menuDataOpen.setPosition(position++);
+ menuDataOpen.setNamePattern(menuDataOpen.getNamePattern() + postfix);
+ menuDataOpen.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataOpen);
+ }
+ // run
+ String runCmd = store.getString(PreferenceEntry.preferenceTargetRun.getString(instanceId));
+ if (!runCmdList.contains(runCmd)) {
+ runCmdList.add(runCmd);
+ CommandData cmdDataRun = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryRun, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(runCmd));
+ cmdDataList.add(cmdDataRun);
+ MenuData menuDataRun = new MenuData(cmdDataRun.getId(), true, MenuNameType.menuNameTypeRunWith, null, cmdDataRun.getId());
+ menuDataRun.setPosition(position++);
+ menuDataRun.setNamePattern(menuDataRun.getNamePattern() + postfix);
+ menuDataRun.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataRun);
+ }
+ // explore
+ String exploreCmd = store.getString(PreferenceEntry.preferenceTargetExplore.getString(instanceId));
+ if (!exploreCmdList.contains(exploreCmd)) {
+ exploreCmdList.add(exploreCmd);
+ CommandData cmdDataExplore = new CommandData(null, PresetType.presetUser, os, command.getExplorer(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryExplore, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(exploreCmd));
+ cmdDataList.add(cmdDataExplore);
+ MenuData menuDataExplore = new MenuData(cmdDataExplore.getId(), true, MenuNameType.menuNameTypeShowIn, null, cmdDataExplore.getId());
+ menuDataExplore.setPosition(position++);
+ menuDataExplore.setNamePattern(menuDataExplore.getNamePattern() + postfix);
+ menuDataExplore.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataExplore);
+ }
+ // copy to clipboard
+ String copyPathCmd = store.getString(PreferenceEntry.preferenceTargetCopyPath.getString(instanceId));
+ if (!copyPathList.contains(copyPathCmd)) {
+ copyPathList.add(copyPathCmd);
+ CommandData cmdDataCopyPath = new CommandData(null, PresetType.presetUser, os, "Full Path", ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryClipboard, CommandType.commandTypeClipboard, PrefsV1_4.migrateCommandVariables(copyPathCmd));
+ cmdDataList.add(cmdDataCopyPath);
+ MenuData menuDataCopyPath = new MenuData(cmdDataCopyPath.getId(), true, MenuNameType.menuNameTypeCopyToClipboard, null, cmdDataCopyPath.getId());
+ menuDataCopyPath.setPosition(position++);
+ menuDataCopyPath.setNamePattern(menuDataCopyPath.getNamePattern() + postfix);
+ menuDataCopyPath.setNameType(MenuNameType.menuNameTypeUser);
+ menuDataList.add(menuDataCopyPath);
+ }
+ /*
+ String QuotesStr = store.getString(PreferenceEntry.preferenceQuotes.getString(instanceId));
+ Quotes quotes = Quotes.valueOf(QuotesStr);
+ String DebugStr = store.getString(PreferenceEntry.preferenceDebug.getString(instanceId));
+ Debug debug = Debug.valueOf(DebugStr);
+ String TokenizerStr = store.getString(PreferenceEntry.preferenceTokenizer.getString(instanceId));
+ Tokenizer tokenizer = Tokenizer.valueOf(TokenizerStr);
+ */
+ }
+ }
+ return true;
+ }
+
+ private static Command getProperCommand() {
+ Command cmd = Command.cmdUnknown;
+ /* possible OS string:
+ AIX
+ Digital UNIX
+ FreeBSD
+ HP UX
+ Irix
+ Linux
+ Mac OS
+ Mac OS X
+ MPE/iX
+ Netware 4.11
+ OS/2
+ Solaris
+ Windows 95
+ Windows 98
+ Windows NT
+ Windows Me
+ Windows 2000
+ Windows XP
+ Windows 2003
+ Windows CE
+ Windows Vista
+ Windows 7
+ */
+ String osname = System.getProperty("os.name", "").toLowerCase();
+ if (osname.indexOf("windows") != -1) {
+ cmd = Command.cmdWinDOS;
+ } else if (osname.indexOf("mac os x") != -1) {
+ cmd = Command.cmdTerminalFinder;
+ } else if (
+ osname.indexOf("unix") != -1
+ || osname.indexOf("irix") != -1
+ || osname.indexOf("freebsd") != -1
+ || osname.indexOf("hp-ux") != -1
+ || osname.indexOf("aix") != -1
+ || osname.indexOf("sunos") != -1
+ || osname.indexOf("linux") != -1
+ )
+ {
+ // try to detect the desktop
+ LinuxDesktop desktop = detectLinuxDesktop();
+ //Activator.getDefault().sysout(true, "Detected linux (Unix) desktop: >" + desktop.getName() + "<");
+ switch (desktop) {
+ case desktopKde: cmd = Command.cmdKonsoleKDEDolphin; break;
+ case desktopCinnamon: cmd = Command.cmdGnomeTermNemo; break;
+ case desktopGnome: cmd = Command.cmdKonsoleGnome; break;
+ case desktopCde: cmd = Command.cmdXtermDtfile; break;
+ case desktopXfce: cmd = Command.cmdXfceTermThunar; break;
+ default: cmd = Command.cmdUnknown;
+ }
+ }
+ return cmd;
+ }
+
+ private static LinuxDesktop detectLinuxDesktop() {
+ LinuxDesktop resultCode = detectDesktopSession();
+ if (resultCode == LinuxDesktop.desktopUnknown)
+ {
+ if (isCde())
+ resultCode = LinuxDesktop.desktopCde;
+ }
+ return resultCode;
+ }
+
+ /**
+ * detects desktop from $DESKTOP_SESSION
+ */
+ private static LinuxDesktop detectDesktopSession() {
+ ArrayList command = new ArrayList();
+ command.add("sh");
+ command.add("-c");
+ command.add("echo \"$DESKTOP_SESSION\"");
+ // fill the map
+ Map desktops = new HashMap();
+ desktops.put("kde", LinuxDesktop.desktopKde);
+ desktops.put("gnome", LinuxDesktop.desktopGnome);
+ desktops.put("cinnamon", LinuxDesktop.desktopCinnamon);
+ desktops.put("xfce", LinuxDesktop.desktopXfce);
+ // execute
+ String desktop = isExpectedCommandOutput(command, desktops, true);
+ if (desktop != null && !desktop.isEmpty()) {
+ return (LinuxDesktop)desktops.get(desktop);
+ }
+ return LinuxDesktop.desktopUnknown;
+ }
+
+ /**
+ * TODO: detects CDE desktop
+ */
+ private static boolean isCde() {
+ return false;
+ }
+
+ /**
+ * Detects which desktop is used on a unix / linux system.
+ *
+ * @todo use regex
+ *
+ * @return The type of desktop.
+ * @see detectDesktop
+ */
+ private static String isExpectedCommandOutput(ArrayList command, Map expectedOutput, boolean toLowerCase) {
+ boolean found = false;
+ String expectedLine = null;
+ try {
+ Process proc = Runtime.getRuntime().exec(command.toArray(new String[1]));
+ BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ while((line = in.readLine()) != null && !found) {
+ for(String key: expectedOutput.keySet()) {
+ // in case of * just something should be returned
+ if (key.indexOf("*") != -1)
+ {
+ if (line.isEmpty()) {
+ found = false;
+ break;
+ } else {
+ found = true;
+ }
+ } else {
+ if (toLowerCase)
+ line = line.toLowerCase();
+ if(line.indexOf(key) != -1) {
+ found = true;
+ }
+ }
+ if (found) {
+ expectedLine = line;
+ break;
+ }
+ }
+ }
+ line = null;
+ BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
+ // If there is any error output, print it to
+ // stdout for debugging purposes
+ while((line = err.readLine()) != null) {
+ //Activator.getDefault().sysout(true, "detectDesktop stderr >" + line + "<");
+ }
+
+ int result = proc.waitFor();
+ if(result != 0) {
+ // If there is any error code, print it to
+ // stdout for debugging purposes
+ //Activator.getDefault().sysout(true, "detectDesktop return code: " + result);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return expectedLine;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Quotes.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Quotes.java
new file mode 100644
index 00000000..4b5853a8
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Quotes.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+/**
+ * Quotes.
+ */
+public enum Quotes {
+ quotesNo(0, "No"),
+ quotesSingle(1, "Single"),
+ quotesDouble(2, "Double"),
+ quotesAuto(3, "Double (automatic)"), // check if no quotes and space in string, then add
+ quotesAutoSingle(4, "Single (automatic)"), // check if no quotes and space in string, then add
+ quotesEscape(5, "Escape"); // check if no quotes and space in string, then escape
+ // attributes
+ private final int id;
+ private final String mode;
+ // construct
+ Quotes(int id, String mode) {
+ this.id = id;
+ this.mode = mode;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getMode() {
+ return mode;
+ }
+ public static Quotes getFromId(int id) {
+ Quotes ret = quotesNo;
+ for(int i = 0; i < Quotes.values().length; i++) {
+ if (Quotes.values()[i].getId() == id) {
+ ret = Quotes.values()[i];
+ }
+ }
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Tokenizer.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Tokenizer.java
new file mode 100644
index 00000000..6c45e05d
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/legacy/Tokenizer.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.legacy;
+
+/**
+ * Tokenizer.
+ */
+public enum Tokenizer {
+ EasyShellTokenizerNo(0, "No"),
+ EasyShellTokenizerYes(1, "Yes");
+ // attributes
+ private final int id;
+ private final String mode;
+ // construct
+ Tokenizer(int id, String mode) {
+ this.id = id;
+ this.mode = mode;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getMode() {
+ return mode;
+ }
+ public static Tokenizer getFromId(int id) {
+ Tokenizer ret = EasyShellTokenizerYes;
+ for(int i = 0; i < Tokenizer.values().length; i++) {
+ if (Tokenizer.values()[i].getId() == id) {
+ ret = Tokenizer.values()[i];
+ }
+ }
+ return ret;
+ }
+};
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/misc/Utils.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/misc/Utils.java
new file mode 100644
index 00000000..e6fd84ad
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/misc/Utils.java
@@ -0,0 +1,306 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.misc;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ToolTip;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.preferences.MenuData;
+import de.anbos.eclipse.easyshell.plugin.types.LinuxDesktop;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+
+public class Utils {
+
+ public static OS getOS() {
+ OS os = OS.osUnknown;
+ /* possible OS string:
+ AIX
+ Digital UNIX
+ FreeBSD
+ HP UX
+ Irix
+ Linux
+ Mac OS
+ Mac OS X
+ MPE/iX
+ Netware 4.11
+ OS/2
+ Solaris
+ Windows 95
+ Windows 98
+ Windows NT
+ Windows Me
+ Windows 2000
+ Windows XP
+ Windows 2003
+ Windows CE
+ Windows Vista
+ Windows 7
+ */
+ String osname = System.getProperty("os.name", "").toLowerCase();
+ if (osname.indexOf("windows") != -1) {
+ os = OS.osWindows;
+ } else if (osname.indexOf("mac os x") != -1) {
+ os = OS.osMacOSX;
+ } else if (
+ osname.indexOf("unix") != -1
+ || osname.indexOf("irix") != -1
+ || osname.indexOf("freebsd") != -1
+ || osname.indexOf("hp-ux") != -1
+ || osname.indexOf("aix") != -1
+ || osname.indexOf("sunos") != -1
+ || osname.indexOf("linux") != -1
+ )
+ {
+ os = OS.osLinux;
+ }
+ return os;
+ }
+
+ public static LinuxDesktop detectLinuxDesktop() {
+ LinuxDesktop resultCode = Utils.detectDesktopSession();
+ /*
+ if (resultCode == LinuxDesktop.desktopUnknown)
+ {
+ if (isCde())
+ resultCode = LinuxDesktop.desktopCde;
+ }
+ */
+ return resultCode;
+ }
+
+ /**
+ * detects desktop from $DESKTOP_SESSION
+ */
+ public static LinuxDesktop detectDesktopSession() {
+ ArrayList command = new ArrayList();
+ command.add("sh");
+ command.add("-c");
+ command.add("echo \"$DESKTOP_SESSION\"");
+ // fill the map
+ Map desktops = new HashMap();
+ desktops.put("kde", LinuxDesktop.desktopKde);
+ desktops.put("gnome", LinuxDesktop.desktopGnome);
+ desktops.put("cinnamon", LinuxDesktop.desktopCinnamon);
+ desktops.put("xfce", LinuxDesktop.desktopXfce);
+ // execute
+ Object desktop = Utils.isExpectedCommandOutput(command, desktops);
+ if (desktop != null) {
+ return (LinuxDesktop)desktop;
+ }
+ return LinuxDesktop.desktopUnknown;
+ }
+
+ /**
+ * detects programs from $DESKTOP_SESSION
+ */
+ public static Object detectLinuxDefaultFileBrowser(Map fileBrowsers) {
+ ArrayList command = new ArrayList();
+ command.add("xdg-mime");
+ command.add("query");
+ command.add("default");
+ command.add("inode/directory");
+ // fill the map
+ if (fileBrowsers == null) {
+ fileBrowsers = new HashMap();
+ fileBrowsers.put(".*", "*");
+ }
+ // execute
+ return Utils.isExpectedCommandOutput(command, fileBrowsers);
+ }
+
+ private static Object isExpectedCommandOutput(ArrayList command, Map expectedOutput) {
+ Object obj = null;
+ boolean found = false;
+ String expectedLine = null;
+ try {
+ Process proc = Runtime.getRuntime().exec(command.toArray(new String[1]));
+ BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ while((line = in.readLine()) != null && !found) {
+ for(String key: expectedOutput.keySet()) {
+ if (line.matches(key)) {
+ obj = expectedOutput.get(key);
+ if (obj instanceof String && ((String) obj).indexOf("*") == 0) {
+ obj = line;
+ }
+ expectedLine = line;
+ break;
+ }
+ }
+ }
+ Activator.logInfo("isExpectedCommandOutput: answer: >" + expectedLine + "<", null);
+ line = null;
+ BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
+ // If there is any error output, print it to
+ // stdout for debugging purposes
+ while((line = err.readLine()) != null) {
+ Activator.logError("isExpectedCommandOutput: stderr: >" + line + "<", null);
+ }
+
+ int result = proc.waitFor();
+ if(result != 0) {
+ // If there is any error code, print it to
+ // stdout for debugging purposes
+ Activator.logError("isExpectedCommandOutput: return code: " + result, null);
+ }
+ } catch(Exception e) {
+ Activator.logError("isExpectedCommandOutput: exception", e);
+ }
+ return obj;
+ }
+
+ public static void copyToClipboard(String cmdAll) {
+ Clipboard clipboard = new Clipboard(Display.getCurrent());
+ TextTransfer textTransfer = TextTransfer.getInstance();
+ Transfer[] transfers = new Transfer[]{textTransfer};
+ Object[] data = new Object[]{cmdAll};
+ clipboard.setContents(data, transfers);
+ clipboard.dispose();
+ }
+
+ public static void showToolTipSuccess(Control control, String title, String message) {
+ showToolTip(control, SWT.ICON_WORKING, title, message);
+ }
+
+ public static void showToolTipInfo(Control control, String title, String message) {
+ showToolTip(control, SWT.ICON_INFORMATION, title, message);
+ }
+
+ public static void showToolTipWarning(Control control, String title, String message) {
+ showToolTip(control, SWT.ICON_WARNING, title, message);
+ }
+
+ public static void showToolTipError(Control control, String title, String message) {
+ showToolTip(control, SWT.ICON_ERROR, title, message);
+ }
+
+ public static void showToolTip(Control control, int style, String title, String message) {
+ if (control == null) {
+ control = Display.getDefault().getActiveShell();
+ }
+ ToolTip tooltip = new ToolTip(control.getShell(), /*SWT.BALLOON | */ style);
+ tooltip.setAutoHide(true);
+ tooltip.setLocation(control.toDisplay(control.getSize().x/2, control.getSize().y + 5));
+ tooltip.setText(title);
+ tooltip.setMessage(message);
+ tooltip.setVisible(true);
+ }
+
+ public static void executeCommands(final IWorkbench workbench, final List menuData, boolean asynch) {
+ if (asynch) {
+ Display.getDefault().asyncExec( new Runnable(){
+ @Override
+ public void run() {
+ for (MenuData element : menuData) {
+ executeCommand(workbench, element, false);
+ }
+ }
+ });
+ } else {
+ for (MenuData element : menuData) {
+ executeCommand(workbench, element, false);
+ }
+ }
+ }
+
+ public static Map getParameterMapFromMenuData(MenuData menuData) {
+ Map params = new HashMap();
+ params.put("de.anbos.eclipse.easyshell.plugin.commands.parameter.resource",
+ menuData.getCommandData().getResourceType().toString());
+ params.put("de.anbos.eclipse.easyshell.plugin.commands.parameter.type",
+ menuData.getCommandData().getCommandType().getAction());
+ params.put("de.anbos.eclipse.easyshell.plugin.commands.parameter.value",
+ menuData.getCommandData().getCommand());
+ params.put("de.anbos.eclipse.easyshell.plugin.commands.parameter.workingdir",
+ menuData.getCommandData().isUseWorkingDirectory() ? menuData.getCommandData().getWorkingDirectory() : "");
+ return params;
+ }
+
+ public static void executeCommand(IWorkbench workbench, MenuData menuData, boolean asynch) {
+ executeCommand(workbench, "de.anbos.eclipse.easyshell.plugin.commands.execute", getParameterMapFromMenuData(menuData), asynch);
+ }
+
+ public static void executeCommand(final IWorkbench workbench, final String commandName, final Map params, boolean asynch) {
+ if (asynch) {
+ Display.getDefault().asyncExec( new Runnable(){
+ @Override
+ public void run() {
+ Utils.executeCommand(workbench, commandName, params);
+ }
+ });
+ } else {
+ Utils.executeCommand(workbench, commandName, params);
+ }
+ }
+
+ private static void executeCommand(IWorkbench workbench, String commandName, Map params) {
+ if (workbench == null) {
+ workbench = PlatformUI.getWorkbench();
+ }
+ // get command
+ ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
+ Command command = commandService != null ? commandService.getCommand(commandName) : null;
+ // get handler service
+ //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
+ //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
+ IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
+ if (command != null && handlerService != null) {
+ ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
+ try {
+ handlerService.executeCommand(paramCommand, null);
+ } catch (Exception e) {
+ Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
+ }
+ }
+ }
+
+ public static String getFileExtension(String fileName) {
+ String extension = "";
+ int i = fileName.lastIndexOf('.');
+ if (i > -1 && (fileName.length() > (i + 1))) {
+ extension = fileName.substring(i+1);
+ }
+ return extension;
+ }
+
+ public static String getFileBasename(String fileName) {
+ String basename = fileName;
+ int i = fileName.lastIndexOf('.');
+ if (i > 0) {
+ basename = fileName.substring(0, i);
+ } else if (i == 0) {
+ basename = "";
+ }
+ return basename;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/popup/actions/NewAction.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/popup/actions/NewAction.java
deleted file mode 100644
index 999b36d1..00000000
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/popup/actions/NewAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Bossert - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package de.anbos.eclipse.easyshell.plugin.popup.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class NewAction implements IObjectActionDelegate {
-
- private Shell shell;
-
- /**
- * Constructor for Action1.
- */
- public NewAction() {
- super();
- }
-
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- shell = targetPart.getSite().getShell();
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- MessageDialog.openInformation(
- shell,
- "EasyShell",
- "New Action was executed.");
- }
-
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
-}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandData.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandData.java
new file mode 100644
index 00000000..9a11e5bc
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandData.java
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.StringTokenizer;
+import java.util.UUID;
+
+import org.eclipse.swt.graphics.Image;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class CommandData extends Data {
+
+ // command
+ private CommandDataBasic basicData = null;
+ private PresetType presetType = PresetType.presetUnknown;
+ private OS os = OS.osUnknown;
+ private Category category = Category.categoryUnknown;
+ private CommandType commandType = CommandType.commandTypeUnknown;
+ private CommandDataBasic userData = null;
+
+ public CommandData(String id, CommandDataBasic basicData, PresetType presetType, OS os, Category category, CommandType cmdType, CommandDataBasic userData) {
+ super(id);
+ setBasicData(basicData);
+ setPresetType(presetType);
+ setOs(os);
+ setCategory(category);
+ setCommandType(cmdType);
+ setUserData(userData);
+ }
+
+ public CommandData(String id, PresetType presetType, OS os, String name, ResourceType resType, boolean useWorkingDirectory, String workingDirectory, Category category, CommandType cmdType, String command) {
+ this(id, new CommandDataBasic(name, resType, useWorkingDirectory, workingDirectory, command), presetType, os, category, cmdType, null);
+ }
+
+ public CommandData(String id, PresetType presetType, OS os, String name, ResourceType resType, Category category, CommandType cmdType, String command) {
+ this(id, presetType, os, name, resType, false, null, category, cmdType, command);
+ }
+
+ public CommandData(CommandData commandData, String newId) {
+ this(newId, commandData.getBasicData(), commandData.getPresetType(), commandData.getOs(), commandData.getCategory(), commandData.getCommandType(), commandData.getUserData());
+ }
+
+ public CommandData(CommandData commandData, boolean generateNewId) {
+ this(commandData, generateNewId ? UUID.randomUUID().toString() : commandData.getId());
+ }
+
+ public CommandData() {
+ basicData = new CommandDataBasic();
+ }
+
+ public CommandDataBasic getBasicData() {
+ return basicData;
+ }
+
+ public CommandDataBasic getUserData() {
+ return userData;
+ }
+
+ public String getName() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ return userData.getName();
+ } else {
+ return basicData.getName();
+ }
+ }
+
+ public OS getOs() {
+ return os;
+ }
+
+ public PresetType getPresetType() {
+ return presetType;
+ }
+
+ public ResourceType getResourceType() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ return userData.getResourceType();
+ } else {
+ return basicData.getResourceType();
+ }
+ }
+
+ public boolean isUseWorkingDirectory() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ return userData.isUseWorkingDirectory();
+ } else {
+ return basicData.isUseWorkingDirectory();
+ }
+ }
+
+ public String getWorkingDirectory() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ return userData.getWorkingDirectory();
+ } else {
+ return basicData.getWorkingDirectory();
+ }
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public CommandType getCommandType() {
+ return commandType;
+ }
+
+ public String getCommand() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ return userData.getCommand();
+ } else {
+ return basicData.getCommand();
+ }
+ }
+
+ public Image getCategoryImage() {
+ return new Image(null, Activator.getImageDescriptor(getCategory().getIcon()).getImageData());
+ }
+
+ public String getCommandAsComboName() {
+ return getCategory().getName() + " - " + getName() + " (" + getPresetType().getName() + ")" /*+ getOs().getName() + " - "*/;
+ }
+
+ public boolean checkIfUserDataOverridesPreset(CommandDataBasic userData) {
+ if (getPresetType() == PresetType.presetPlugin) {
+ return !basicData.equals(userData);
+ }
+ return false;
+ }
+
+ public void setBasicData(CommandDataBasic basicData) {
+ this.basicData = basicData;
+ }
+
+ public void setUserData(CommandDataBasic userData) {
+ this.userData = userData;
+ }
+
+ public void addUserData(CommandDataBasic userData) {
+ if (getPresetType() != PresetType.presetPluginAndUser) {
+ setPresetType(PresetType.presetPluginAndUser);
+ }
+ setUserData(userData);
+ }
+
+ public void removeUserData() {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ setPresetType(PresetType.presetPlugin);
+ }
+ setUserData(null);
+ }
+
+ public void setName(String name) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ userData.setName(name);
+ } else {
+ basicData.setName(name);
+ }
+ }
+
+ public void setOs(OS os) {
+ this.os = os;
+ }
+
+ public void setPresetType(PresetType presetType) {
+ this.presetType = presetType;
+ }
+
+ public void setResourceType(ResourceType resType) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ userData.setResourceType(resType);
+ } else {
+ basicData.setResourceType(resType);
+ }
+ }
+
+ public void setUseWorkingDirectory(boolean useWorkingDirectory) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ userData.setUseWorkingDirectory(useWorkingDirectory);
+ } else {
+ basicData.setUseWorkingDirectory(useWorkingDirectory);
+ }
+ }
+
+ public void setWorkingDirectory(String workingDirectory) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ userData.setWorkingDirectory(workingDirectory);
+ } else {
+ basicData.setWorkingDirectory(workingDirectory);
+ }
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public void setCommandType(CommandType cmdType) {
+ this.commandType = cmdType;
+ }
+
+ public void setCommand(String command) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ userData.setCommand(command);
+ } else {
+ basicData.setCommand(command);
+ }
+ }
+
+ public boolean equals(Object object) {
+ if(!(object instanceof CommandData)) {
+ return false;
+ }
+ CommandData data = (CommandData)object;
+ if(data.getId().equals(this.getId())
+ /*data.getPosition() == this.getPosition() &&
+ data.getBasicData().equals(this.getBasicData()) &&
+ data.getPresetType() == this.getPresetType() &&
+ data.getOS() == this.getOS() &&
+ data.getCategory() == this.getCategory() &&
+ data.getCommandType() == this.getCommandType() &&*/
+ )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean deserialize(Version version, String value, StringTokenizer tokenizer, String delimiter) {
+ if((value == null || value.length() <= 0) && tokenizer == null) {
+ return false;
+ }
+ if (tokenizer == null) {
+ tokenizer = new StringTokenizer(value,delimiter);
+ }
+ // set internal members
+ setPosition(Integer.parseInt(tokenizer.nextToken()));
+ setId(tokenizer.nextToken());
+ // set command data members
+ presetType = PresetType.getFromEnum(tokenizer.nextToken());
+ setOs(OS.getFromEnum(tokenizer.nextToken()));
+ basicData.setName(tokenizer.nextToken());
+ // handling of resource Type
+ String resourceTypeStr = tokenizer.nextToken();
+ if (version.getId() < Version.v2_0_006.getId() && resourceTypeStr.equals("resourceTypeFolder")) {
+ resourceTypeStr = "resourceTypeDirectory";
+ }
+ basicData.setResourceType(ResourceType.getFromEnum(resourceTypeStr));
+ // handling of working directory
+ if (version.getId() >= Version.v2_0_003.getId()) {
+ basicData.setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
+ basicData.setWorkingDirectory(tokenizer.nextToken());
+ String categoryStr = tokenizer.nextToken();
+ if (version.getId() < Version.v2_0_005.getId() && categoryStr.equals("categoryOther")) {
+ categoryStr = "categoryUser";
+ }
+ setCategory(Category.getFromEnum(categoryStr));
+ setCommandType(CommandType.getFromEnum(tokenizer.nextToken()));
+ } else {
+ basicData.setUseWorkingDirectory(false);
+ basicData.setWorkingDirectory("${easyshell:container_loc}");
+ String commandTypeStr = tokenizer.nextToken();
+ setCategory(Category.getFromDeprecatedCommandTypeEnum(commandTypeStr));
+ setCommandType(CommandType.getFromDeprecatedCommandTypeEnum(commandTypeStr));
+ }
+ // go on compatible
+ basicData.setCommand(tokenizer.nextToken());
+ if (version.getId() >= Version.v2_0_005.getId()) {
+ // let read userData if there
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ setUserData(new CommandDataBasic());
+ userData.deserialize(version, null, tokenizer, delimiter);
+ }
+ }
+ return true;
+ }
+
+ public boolean deserialize(String value, StringTokenizer tokenizer, String delimiter) {
+ return deserialize(Version.actual, value, tokenizer, delimiter);
+ }
+
+ public String serialize(Version version, String delimiter) {
+ String ret = Integer.toString(getPosition()) + delimiter;
+ ret += getId() + delimiter;
+ ret += getPresetType().toString() + delimiter;
+ ret += getOs().toString() + delimiter;
+ ret += basicData.getName() + delimiter;
+ ret += basicData.getResourceType().toString() + delimiter;
+ if (version.getId() >= Version.v2_0_003.getId()) {
+ ret += Boolean.toString(basicData.isUseWorkingDirectory()) + delimiter;
+ ret += basicData.getWorkingDirectory() + delimiter;
+ ret += getCategory().toString() + delimiter;
+ }
+ ret += getCommandType().toString() + delimiter;
+ ret += basicData.getCommand() + delimiter;
+ if (version.getId() >= Version.v2_0_005.getId()) {
+ if (getPresetType() == PresetType.presetPluginAndUser) {
+ ret += userData.serialize(version, delimiter);
+ }
+ }
+ return ret;
+ }
+
+ public String serialize(String delimiter) {
+ return serialize(Version.actual, delimiter);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataBasic.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataBasic.java
new file mode 100644
index 00000000..e7a0325f
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataBasic.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.StringTokenizer;
+
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class CommandDataBasic {
+
+ // command
+ private String name = "";
+ private ResourceType resourceType = ResourceType.resourceTypeUnknown;
+ private boolean useWorkingDirectory = false;
+ private String workingDirectory = "";
+ private String command = "";
+
+ public CommandDataBasic(String name, ResourceType resType, boolean useWorkingDirectory, String workingDirectory, String command) {
+ setName(name);
+ setResourceType(resType);
+ setUseWorkingDirectory(useWorkingDirectory);
+ setWorkingDirectory(workingDirectory);
+ setCommand(command);
+ }
+
+
+ public CommandDataBasic(CommandDataBasic commandData) {
+ this(commandData.getName(), commandData.getResourceType(), commandData.isUseWorkingDirectory(), commandData.getWorkingDirectory(), commandData.getCommand());
+ }
+
+ public CommandDataBasic() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public boolean isUseWorkingDirectory() {
+ return useWorkingDirectory;
+ }
+
+ public String getWorkingDirectory() {
+ return workingDirectory;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setResourceType(ResourceType resType) {
+ this.resourceType = resType;
+ }
+
+ public void setUseWorkingDirectory(boolean useWorkingDirectory) {
+ this.useWorkingDirectory = useWorkingDirectory;
+ }
+
+ public void setWorkingDirectory(String workingDirectory) {
+ if (workingDirectory != null) {
+ this.workingDirectory = workingDirectory;
+ } else {
+ this.workingDirectory = "${easyshell:container_loc}";
+ }
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public boolean equals(Object object) {
+ if(!(object instanceof CommandDataBasic)) {
+ return false;
+ }
+ CommandDataBasic data = (CommandDataBasic)object;
+ if(data.getName().equals(this.getName()) &&
+ data.getResourceType() == this.getResourceType() &&
+ data.isUseWorkingDirectory() == this.isUseWorkingDirectory() &&
+ data.getWorkingDirectory().equals(this.getWorkingDirectory()) &&
+ data.getCommand().equals(this.getCommand())
+ )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean deserialize(Version version, String value, StringTokenizer tokenizer, String delimiter) {
+ if((value == null || value.length() <= 0) && tokenizer == null) {
+ return false;
+ }
+ if (tokenizer == null) {
+ tokenizer = new StringTokenizer(value,delimiter);
+ }
+ // set command data members
+ setName(tokenizer.nextToken());
+ // handling of resource Type
+ String resourceTypeStr = tokenizer.nextToken();
+ if (version.getId() < Version.v2_0_006.getId() && resourceTypeStr.equals("resourceTypeFolder")) {
+ resourceTypeStr = "resourceTypeDirectory";
+ }
+ setResourceType(ResourceType.getFromEnum(resourceTypeStr));
+ // handling of working directory
+ setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
+ setWorkingDirectory(tokenizer.nextToken());
+ // command
+ setCommand(tokenizer.nextToken());
+ return true;
+ }
+
+ public boolean deserialize(String value, StringTokenizer tokenizer, String delimiter) {
+ return deserialize(Version.actual, value, tokenizer, delimiter);
+ }
+
+ public String serialize(Version version, String delimiter) {
+ String ret = getName() + delimiter;
+ ret += getResourceType().toString() + delimiter;
+ ret += Boolean.toString(isUseWorkingDirectory()) + delimiter;
+ ret += getWorkingDirectory() + delimiter;
+ ret += getCommand() + delimiter;
+ return ret;
+ }
+
+ public String serialize(String delimiter) {
+ return serialize(Version.actual, delimiter);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataContentProvider.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataContentProvider.java
new file mode 100644
index 00000000..ef16a8bf
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataContentProvider.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class CommandDataContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ return ((CommandDataStore)inputElement).getAllCommandsArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDefaultCollection.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDefaultCollection.java
new file mode 100644
index 00000000..002e0d4e
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDefaultCollection.java
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.LinuxDesktop;
+import de.anbos.eclipse.easyshell.plugin.types.OS;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Variable;
+
+public class CommandDataDefaultCollection {
+
+ private CommandDataList list = new CommandDataList();
+ private static CommandDataDefaultCollection instance = new CommandDataDefaultCollection();
+
+ public static CommandDataList getAllCommandsStatic() {
+ return instance.getCommands();
+ }
+
+ public static MenuDataList getCommandsNativeAsMenu(boolean sorted) {
+ CommandDataList list = getDefaultCommands();
+ MenuDataList ret = new MenuDataList();
+ for (int i=0;i" + desktop.getName() + "<");
+ switch (desktop) {
+ case desktopKde: addNotNull(listDefault, getCommandData(listOS, ".*KDE.*", Category.categoryOpen));
+ addNotNull(listDefault, getCommandData(listOS, ".*KDE.*", Category.categoryRun));
+ //addNotNull(listDefault, getCommandData(listOS, "Dolphin", Category.categoryExplore));
+ break;
+ case desktopCinnamon: addNotNull(listDefault, getCommandData(listOS, ".*Gnome.*", Category.categoryOpen));
+ addNotNull(listDefault, getCommandData(listOS, ".*Gnome.*", Category.categoryRun));
+ //addNotNull(listDefault, getCommandData(listOS, "Nemo", Category.categoryExplore));
+ break;
+ case desktopGnome: addNotNull(listDefault, getCommandData(listOS, ".*Gnome.*", Category.categoryOpen));
+ addNotNull(listDefault, getCommandData(listOS, ".*Gnome.*", Category.categoryRun));
+ //addNotNull(listDefault, getCommandData(listOS, "Nautilus", Category.categoryExplore));
+ break;
+ case desktopXfce: addNotNull(listDefault, getCommandData(listOS, ".*Xfce.*", Category.categoryOpen));
+ addNotNull(listDefault, getCommandData(listOS, ".*Xfce.*", Category.categoryRun));
+ //addNotNull(listDefault, getCommandData(listOS, "Thunar", Category.categoryExplore));
+ break;
+ default:;
+ }
+ // try to detect the default file browser
+ if (desktop != LinuxDesktop.desktopUnknown) {
+ Map fileBrowsers = new HashMap();
+ for (CommandData data : getCommandDataList(listOS, Category.categoryExplore)) {
+ fileBrowsers.put("(?i).*" + data.getName() + ".*", data);
+ }
+ Object fileBrowser = Utils.detectLinuxDefaultFileBrowser(fileBrowsers);
+ if (fileBrowser != null) {
+ CommandData data = (CommandData)fileBrowser;
+ Activator.logInfo("Detected linux (Unix) default file browser: >" + data.getName() + "<", null);
+ addNotNull(listDefault, data);
+ }
+ }
+ break;
+ case osMacOSX:
+ addNotNull(listDefault, getCommandData(listOS, "Terminal", Category.categoryOpen));
+ addNotNull(listDefault, getCommandData(listOS, "Terminal", Category.categoryRun));
+ addNotNull(listDefault, getCommandData(listOS, "Finder", Category.categoryExplore));
+ break;
+ case osUnix:
+ // no op
+ break;
+ default:
+ break;
+ }
+ // add clipboard
+ addNotNull(listDefault, getCommandData(listOS, ".*Path", Category.categoryClipboard));
+ addNotNull(listDefault, getCommandData(listOS, ".*Name", Category.categoryClipboard));
+ return listDefault;
+ }
+
+ private static void addNotNull(CommandDataList list, CommandData data) {
+ if (data != null) {
+ list.add(data);
+ }
+ }
+
+ public static CommandDataList getCommandData(CommandDataList list, OS os) {
+ CommandDataList listOut = new CommandDataList();
+ for (CommandData entry : list) {
+ if (entry.getOs() == os) {
+ CommandData newData = new CommandData(entry, false);
+ listOut.add(newData);
+ }
+ }
+ return listOut;
+ }
+
+ private static CommandData getCommandData(CommandDataList list, String name, Category category) {
+ for (CommandData entry : list) {
+ if (entry.getCategory() == category && entry.getName().matches(name)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+
+ private static CommandDataList getCommandDataList(CommandDataList list, Category category) {
+ CommandDataList listOut = new CommandDataList();
+ for (CommandData entry : list) {
+ if (entry.getCategory() == category) {
+ CommandData newData = new CommandData(entry, false);
+ listOut.add(newData);
+ }
+ }
+ return listOut;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDialog.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDialog.java
new file mode 100644
index 00000000..9b82cc9f
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataDialog.java
@@ -0,0 +1,547 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.Converter;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Variable;
+
+public class CommandDataDialog extends StatusDialog {
+
+ // experimental features
+ boolean useExtendedContentAssists = true;
+ boolean showVariablesInfo = false;
+ boolean showConvertersInfo = false;
+ // TODO: to be enabled again, see https://github.com/anb0s/EasyShell/issues/61
+ boolean showHelpButton = false;
+
+ private CommandData data;
+ private Combo resourceTypeCombo;
+ private Label categoryImage;
+ private Combo categoryCombo;
+ private Combo commandTypeCombo;
+ private Text nameText;
+ private Button dirCheckBox;
+ private Text dirText;
+ private ContentProposalAdapter dirTextAssist;
+ private Text valueText;
+ private ContentProposalAdapter valueTextAssist;
+
+ @Override
+ public void create() {
+ super.create();
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+
+ public CommandDataDialog(Shell parent, CommandData data, String title) {
+ super(parent);
+ this.data = data;
+ // do layout and title
+ setShellStyle(getShellStyle() | SWT.MAX);
+ // set title
+ setTitle(title);
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ public Control createDialogArea(Composite parent) {
+ Composite pageComponent = new Composite(parent,SWT.NULL);
+ GridLayout layout0 = new GridLayout();
+ layout0.numColumns = 1;
+ layout0.makeColumnsEqualWidth = false;
+ layout0.marginWidth = 5;
+ layout0.marginHeight = 4;
+ pageComponent.setLayout(layout0);
+ GridData data0 = new GridData(GridData.FILL_HORIZONTAL);
+ data0.widthHint = 640;
+ pageComponent.setLayoutData(data0);
+ pageComponent.setFont(parent.getFont());
+
+ createCommandGroup(pageComponent);
+
+ if (showVariablesInfo) {
+ createVariablesOverview(pageComponent);
+ }
+
+ if (showConvertersInfo) {
+ createConvertersOverview(pageComponent);
+ }
+
+ setHelpAvailable(showHelpButton);
+
+ refreshResourceTypeCombo();
+
+ refreshDirCheckBox();
+
+ refreshCategoryCombo();
+
+ refreshCommandTypeCombo();
+
+ return pageComponent;
+ }
+
+ private void createCommandGroup(Composite pageComponent) {
+ // define group1
+ Group pageGroup1 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
+ pageGroup1.setText(Activator.getResourceString("easyshell.command.editor.dialog.title.group1"));
+ pageGroup1.setToolTipText(Activator.getResourceString("easyshell.command.editor.dialog.tooltip.group1"));
+ GridLayout layout1 = new GridLayout();
+ layout1.numColumns = 3;
+ layout1.makeColumnsEqualWidth = false;
+ layout1.marginWidth = 5;
+ layout1.marginHeight = 4;
+ pageGroup1.setLayout(layout1);
+ GridData data1 = new GridData(GridData.FILL_HORIZONTAL);
+ pageGroup1.setLayoutData(data1);
+ pageGroup1.setFont(pageComponent.getFont());
+
+ // create resource type combo
+ createResourceTypeCombo(pageGroup1);
+ // create category combo
+ createCategoryCombo(pageGroup1);
+ // create command type combo
+ createCommandTypeCombo(pageGroup1);
+ //create input nameText field
+ nameText = createTextField(pageGroup1, Activator.getResourceString("easyshell.command.editor.dialog.label.name"), data.getName(), true);
+ // create directory checkbox
+ createDirCheckBox(pageGroup1);
+ // create input dirText field and add content assist
+ dirText = createTextField(pageGroup1, null, data.getWorkingDirectory(), false);
+ dirTextAssist = addContentAssist(dirText);
+ // create input valueText field and add content assist
+ valueText = createTextField(pageGroup1, Activator.getResourceString("easyshell.command.editor.dialog.label.value"), data.getCommand(), true);
+ valueTextAssist = addContentAssist(valueText);
+ valueTextAssist.setEnabled(true);
+ }
+
+ private ContentProposalAdapter addContentAssistSimple(Text textControl) {
+ char[] autoActivationCharacters = new char[] { '$', '{' };
+ KeyStroke keyStroke = null;
+ try {
+ keyStroke = KeyStroke.getInstance("Ctrl+Space");
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // assume that myTextControl has already been created in some way
+ List variables = Variable.getVisibleVariables();
+ String[] proposals = new String [variables.size()];
+ for(int i=0;i proposals = new LinkedHashMap();
+ // add own variables
+ proposals.putAll(Variable.getVariableInfoMap());
+ // add eclipse variables
+ proposals.putAll(Variable.getEclipseVariableInfoMap());
+ ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl, new CommandVariableContentAdapter(),
+ new CommandVariableContentProposalProvider(proposals), null,
+ autoActivationCharacters, true);
+ adapter.setPropagateKeys(false);
+ adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
+ return adapter;
+ }
+
+ private ContentProposalAdapter addContentAssist(Text textControl) {
+ // add content assist to command text editor field
+ if (useExtendedContentAssists) {
+ return addContentAssistExtended(textControl);
+ } else {
+ return addContentAssistSimple(textControl);
+ }
+ }
+
+ private void createVariablesOverview(Composite pageComponent) {
+ // define group2
+ Group pageGroup2 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
+ pageGroup2.setText(Activator.getResourceString("easyshell.command.editor.dialog.title.group2"));
+ pageGroup2.setToolTipText(Activator.getResourceString("easyshell.command.editor.dialog.tooltip.group2"));
+ GridLayout layout2 = new GridLayout();
+ layout2.numColumns = 2;
+ layout2.makeColumnsEqualWidth = false;
+ layout2.marginWidth = 5;
+ layout2.marginHeight = 4;
+ pageGroup2.setLayout(layout2);
+ GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
+ pageGroup2.setLayoutData(data2);
+ pageGroup2.setFont(pageComponent.getFont());
+ // create variable labels
+ for(int i=Variable.getFirstIndex();i {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6519662599078432983L;
+
+ public CommandDataList() {
+ }
+
+ public CommandDataList(List list) {
+ addAll(list);
+ }
+
+ @Override
+ public boolean add(CommandData e) {
+ e.setPosition(this.size());
+ return super.add(e);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataStore.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataStore.java
new file mode 100644
index 00000000..c0b1abc4
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandDataStore.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.Constants;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+
+public class CommandDataStore extends DataStore {
+
+ private static CommandDataStore instance = null;
+
+ public static CommandDataStore instance() {
+ if (instance == null) {
+ instance = new CommandDataStore(Activator.getDefault().getPreferenceStore());
+ }
+ return instance;
+ }
+
+ public CommandDataStore(IPreferenceStore store) {
+ super(store);
+ store.addPropertyChangeListener(new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(Constants.PREF_COMMANDS) || event.getProperty().equals(Constants.PREF_COMMANDS_PRESET)) {
+ load();
+ }
+ }
+ });
+ }
+
+ private CommandDataList getUserCommands() {
+ CommandDataList userItems = new CommandDataList();
+ for (CommandData data : getDataList()) {
+ if (data.getPresetType() == PresetType.presetUser) {
+ userItems.add(data);
+ }
+ }
+ return userItems;
+ }
+
+ private CommandDataList getPresetCommands() {
+ CommandDataList presetItems = new CommandDataList();
+ for (CommandData data : getDataList()) {
+ if (data.getPresetType() == PresetType.presetPlugin || data.getPresetType() == PresetType.presetPluginAndUser) {
+ presetItems.add(data);
+ }
+ }
+ return presetItems;
+ }
+
+ public CommandData[] getAllCommandsArray() {
+ CommandDataList allItems = new CommandDataList(getDataList());
+ if(allItems.size() <= 0) {
+ return new CommandData[0];
+ }
+ CommandData[] allArray = new CommandData[allItems.size()];
+ for(int i = 0 ; i < allArray.length ; i++) {
+ allArray[i] = (CommandData)allItems.get(i);
+ }
+ return allArray;
+ }
+
+ @Override
+ public void save() {
+ super.save();
+ getStore().setValue(Constants.PREF_COMMANDS_PRESET,PreferenceValueConverter.asCommandDataString(getPresetCommands()));
+ getStore().setValue(Constants.PREF_COMMANDS,PreferenceValueConverter.asCommandDataString(getUserCommands()));
+ }
+
+ @Override
+ public void loadDefaults() {
+ getStore().setToDefault(Constants.PREF_COMMANDS_PRESET);
+ getStore().setToDefault(Constants.PREF_COMMANDS);
+ load();
+ }
+
+ @Override
+ public void load() {
+ CommandData[] arrayPreset = PreferenceValueConverter.asCommandDataArray(getStore().getString(Constants.PREF_COMMANDS_PRESET));
+ CommandData[] arrayUser = PreferenceValueConverter.asCommandDataArray(getStore().getString(Constants.PREF_COMMANDS));
+ removeAll();
+ for(int i = 0 ; i < arrayPreset.length ; i++) {
+ addInternal(arrayPreset[i]);
+ }
+ for(int i = 0 ; i < arrayUser.length ; i++) {
+ addInternal(arrayUser[i]);
+ }
+ super.load();
+ }
+
+ public CommandData getCommandDataByName(String name) {
+ for (CommandData data : getDataList()) {
+ if (data.getName().equals(name)) {
+ return data;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandPage.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandPage.java
new file mode 100644
index 00000000..92cd9547
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandPage.java
@@ -0,0 +1,517 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+
+public class CommandPage extends org.eclipse.jface.preference.PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ private Text searchText;
+ private CommandTableFilter filter;
+ private TableViewer tableViewer;
+ private Button addNewButton;
+ private Button addCopyButton;
+ private Button editButton;
+ private Button removeButton;
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ public boolean performOk() {
+ boolean save = true;
+ if (!CommandDataStore.instance().isMigrated()) {
+ String title = Activator.getResourceString("easyshell.command.page.dialog.migration.title");
+ String question = Activator.getResourceString("easyshell.command.page.dialog.migration.question");
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.WARNING,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ CommandDataStore.instance().setMigrated(true);
+ } else {
+ save = false;
+ }
+ }
+ if (save) {
+ CommandDataStore.instance().save();
+ MenuDataStore.instance().save();
+ }
+ return save;
+ }
+
+ @Override
+ protected void performApply() {
+ performOk();
+ }
+
+ @Override
+ protected void performDefaults() {
+ // get the selected commands and referenced menus as lists
+ CommandDataList commands = new CommandDataList(CommandDataStore.instance().getDataList());
+ List menus = new ArrayList();
+ for(CommandData command : commands) {
+ if (command.getPresetType() == PresetType.presetUser) {
+ List menusForOne = MenuDataStore.instance().getRefencedBy(command.getId());
+ menus.addAll(menusForOne);
+ }
+ }
+ String title = Activator.getResourceString("easyshell.command.page.dialog.defaults.title");
+ String question = Activator.getResourceString("easyshell.command.page.dialog.defaults.question");
+ int dialogImageType = MessageDialog.QUESTION;
+ if (menus.size() >= 0) {
+ dialogImageType = MessageDialog.WARNING;
+ String menuNames = "";
+ for (MenuData menu : menus) {
+ menuNames += menu.getNameExpanded() + "\n";
+ }
+ question = MessageFormat.format(Activator.getResourceString("easyshell.command.page.dialog.defaults.menu.question"),
+ menuNames);
+ }
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ dialogImageType,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ if (menus.size() >= 0) {
+ for (MenuData menu : menus) {
+ MenuDataStore.instance().delete(menu);
+ }
+ //MenuDataStore.instance().save();
+ }
+ CommandDataStore.instance().loadDefaults();
+ tableViewer.refresh();
+ }
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ // main page composite
+ Composite pageComponent = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ pageComponent.setLayout(layout);
+ //parent.setLayout(layout);
+
+ // search
+ createSearchField(pageComponent);
+
+ // command store
+ CommandDataStore.instance().load();
+
+ // menu store
+ MenuDataStore.instance().load();
+
+ // table viewer
+ createTableViewer(pageComponent);
+
+ // buttons
+ createButtons(pageComponent);
+
+ // send event to refresh tableViewer
+ Event event = new Event();
+ event.item = null;
+ tableViewer.refresh();
+ tableViewer.getTable().notifyListeners(SWT.Selection, event);
+
+ return pageComponent;
+ }
+
+ private void createSearchField(Composite parent) {
+ /*
+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
+ group.setText(Activator.getResourceString("easyshell.command.page.text.text.search"));
+ group.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
+ GridLayout layout2 = new GridLayout();
+ layout2.numColumns = 1;
+ layout2.makeColumnsEqualWidth = false;
+ layout2.marginWidth = 5;
+ layout2.marginHeight = 4;
+ group.setLayout(layout2);
+ GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(data2);
+ group.setFont(parent.getFont());*/
+
+ //Label searchLabel = new Label(parent, SWT.NONE);
+ //searchLabel.setText("Search: ");
+ filter = new CommandTableFilter();
+ searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
+ searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ searchText.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent ke) {
+ filter.setSearchText(searchText.getText());
+ tableViewer.refresh();
+ }
+
+ });
+ searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
+ // fake
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("");
+ }
+
+ private void createButtons(Composite pageComponent) {
+ Font font = pageComponent.getFont();
+ // button pageComponent
+ Composite groupComponent = new Composite(pageComponent, SWT.NULL);
+ GridLayout groupLayout = new GridLayout();
+ groupLayout.marginWidth = 0;
+ groupLayout.marginHeight = 0;
+ groupComponent.setLayout(groupLayout);
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalAlignment = GridData.FILL;
+ groupComponent.setLayoutData(gridData);
+ groupComponent.setFont(font);
+
+ // buttons
+ createNewButton(font, gridData, groupComponent);
+ createEditButton(font, gridData, groupComponent);
+ createCopyButton(font, gridData, groupComponent);
+ createRemoveButton(font, gridData, groupComponent);
+ }
+
+ private void createTableViewer(Composite parent) {
+ tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ createColumns(parent, tableViewer);
+ final Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ tableViewer.setLabelProvider(new CommandDataLabelProvider());
+ tableViewer.setContentProvider(new CommandDataContentProvider());
+ if (filter != null) {
+ tableViewer.addFilter(filter);
+ }
+
+ // Get the content for the viewer, setInput will call getElements in the
+ // contentProvider
+ tableViewer.setInput(CommandDataStore.instance());
+
+ // Layout the viewer
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ tableViewer.getControl().setLayoutData(gridData);
+
+ tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ editDialog();
+ }
+ });
+
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ int selected = selection.size();
+ boolean presetSelectedOrNotEqualType = false;
+ Iterator> elements = selection.iterator();
+ PresetType type = PresetType.presetUnknown;
+ while (elements.hasNext()) {
+ CommandData data = (CommandData) elements.next();
+ if (type == PresetType.presetUnknown) {
+ type = data.getPresetType();
+ }
+ if (data.getPresetType() == PresetType.presetPlugin || type != data.getPresetType()) {
+ presetSelectedOrNotEqualType = true;
+ break;
+ }
+ }
+ editButton.setEnabled(selected == 1);
+ addCopyButton.setEnabled(selected == 1);
+ removeButton.setEnabled(selected > 0 && !presetSelectedOrNotEqualType);
+ }
+ });
+
+ tableViewer.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(Viewer viewer, Object object1, Object object2) {
+ if (!(object1 instanceof CommandData) || !(object2 instanceof CommandData)) {
+ return super.compare(viewer, object1, object2);
+ }
+ CommandData data1 = (CommandData) object1;
+ CommandData data2 = (CommandData) object2;
+ if (data1.getPosition() > data2.getPosition()) {
+ return 1;
+ }
+ if (data1.getPosition() < data2.getPosition()) {
+ return -1;
+ }
+ if (data1.getPosition() == data2.getPosition()) {
+ return 0;
+ }
+ return super.compare(viewer, object1, object2);
+ }
+ @Override
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+ });
+ }
+
+ private void createColumns(final Composite parent, final TableViewer viewer) {
+ String[] titles = {
+ Activator.getResourceString("easyshell.command.page.header.title.column0"),
+ Activator.getResourceString("easyshell.command.page.header.title.column1"),
+ Activator.getResourceString("easyshell.command.page.header.title.column2"),
+ Activator.getResourceString("easyshell.command.page.header.title.column3")
+ };
+ int[] bounds = { 100, 100, 80, 400 };
+ // create
+ for (int i=0;i commands = new ArrayList();
+ List menus = new ArrayList();
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ Iterator> elements = selection.iterator();
+ while (elements.hasNext()) {
+ CommandData data = (CommandData) elements.next();
+ commands.add(data);
+ List menusForOne = MenuDataStore.instance().getRefencedBy(data.getId());
+ menus.addAll(menusForOne);
+ }
+ // ask user
+ String commandNames = "";
+ PresetType type = PresetType.presetUnknown;
+ for (CommandData command : commands) {
+ if (type == PresetType.presetUnknown) {
+ type = command.getPresetType();
+ }
+ commandNames += command.getCommandAsComboName() + "\n";
+ }
+ String title = null;
+ String question = null;
+ if (type == PresetType.presetPluginAndUser) {
+ title = Activator.getResourceString("easyshell.command.page.dialog.remove.user.title");
+ question = MessageFormat.format(
+ Activator.getResourceString("easyshell.command.page.dialog.remove.user.question"),
+ commandNames);
+ } else {
+ title = Activator.getResourceString("easyshell.command.page.dialog.remove.title");
+ question = MessageFormat.format(
+ Activator.getResourceString("easyshell.command.page.dialog.remove.question"),
+ commandNames);
+ }
+ int dialogImageType = MessageDialog.QUESTION;
+ if (menus.size() > 0) {
+ dialogImageType = MessageDialog.WARNING;
+ String menuNames = "";
+ for (MenuData menu : menus) {
+ menuNames += menu.getNameExpanded() + "\n";
+ }
+ if (type == PresetType.presetPluginAndUser) {
+ title = Activator.getResourceString("easyshell.command.page.dialog.remove.menu.user.title");
+ question = MessageFormat.format(Activator.getResourceString("easyshell.command.page.dialog.remove.menu.user.question"),
+ commandNames, menuNames);
+ } else {
+ title = Activator.getResourceString("easyshell.command.page.dialog.remove.menu.title");
+ question = MessageFormat.format(Activator.getResourceString("easyshell.command.page.dialog.remove.menu.question"),
+ commandNames, menuNames);
+ }
+ }
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ dialogImageType,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ if (menus.size() >= 0 && type == PresetType.presetUser) {
+ for (MenuData menu : menus) {
+ MenuDataStore.instance().delete(menu);
+ }
+ //MenuDataStore.instance().save();
+ }
+ for (CommandData command : commands) {
+ if (command.getPresetType() == PresetType.presetUser) {
+ CommandDataStore.instance().delete(command);
+ } else if (command.getPresetType() == PresetType.presetPluginAndUser) {
+ command.removeUserData();
+ CommandDataStore.instance().replace(command);
+ }
+ }
+ tableViewer.refresh();
+ }
+ }
+
+ private void refreshTableViewer(CommandData data) {
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(data));
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandTableFilter.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandTableFilter.java
new file mode 100644
index 00000000..98384034
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandTableFilter.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class CommandTableFilter extends ViewerFilter {
+
+ private String searchString;
+
+ public void setSearchText(String s) {
+ // add pre and post fix that it can be used for case-insensitive matching
+ this.searchString = "(?i).*" + s + ".*";
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (searchString == null || searchString.length() == 0) {
+ return true;
+ }
+ CommandData data = (CommandData) element;
+ if (data.getCategory().getName().matches(searchString)) {
+ return true;
+ }
+ if (data.getName().matches(searchString)) {
+ return true;
+ }
+ if (data.getPresetType().getName().matches(searchString)) {
+ return true;
+ }
+ if (data.getCommand().matches(searchString)) {
+ return true;
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentAdapter.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentAdapter.java
new file mode 100644
index 00000000..c84a77c7
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentAdapter.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.swt.graphics.Point;
+//import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+
+public class CommandVariableContentAdapter extends TextContentAdapter {
+
+ /*
+ @Override
+ public void setControlContents(Control control, String contents, int cursorPosition) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void insertControlContents(Control control, String contents, int cursorPosition) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getControlContents(Control control) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getCursorPosition(Control control) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Rectangle getInsertionBounds(Control control) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setCursorPosition(Control control, int index) {
+ // TODO Auto-generated method stub
+
+ }
+ */
+
+ @Override
+ public Point getSelection(Control control) {
+ Point point = ((Text) control).getSelection();
+ if (point.x > 0) {
+ String text = ((Text) control).getText(point.x-1, point.y);
+ if (text.equals("$") || text.equals("{")) {
+ point.x = point.x-1;
+ if (point.x > 0 && ((Text) control).getText(point.x-1, point.y).equals("${")) {
+ point.x = point.x-1;
+ }
+ }
+ ((Text) control).setSelection(point);
+ }
+ return point;
+ }
+
+ /*
+ @Override
+ public void setSelection(Control control, Point range) {
+ // TODO Auto-generated method stub
+
+ }
+ */
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentProposalProvider.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentProposalProvider.java
new file mode 100644
index 00000000..cca916ec
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandVariableContentProposalProvider.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.Map;
+
+import org.eclipse.jface.fieldassist.ContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+
+public class CommandVariableContentProposalProvider implements IContentProposalProvider {
+
+ private ContentProposal[] contentProposals;
+
+ public CommandVariableContentProposalProvider(Map proposals) {
+ setProposals(proposals);
+ }
+
+ @Override
+ public IContentProposal[] getProposals(String contents, int position) {
+ return contentProposals;
+ }
+
+ private void setProposals(Map proposals) {
+ contentProposals = new ContentProposal[proposals.size()];
+ int i = 0;
+ for (Map.Entry entry : proposals.entrySet())
+ {
+ ContentProposal proposal = new ContentProposal(entry.getKey(), entry.getValue());
+ contentProposals[i++] = proposal;
+ }
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Data.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Data.java
new file mode 100644
index 00000000..387d18a4
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Data.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.UUID;
+
+public class Data implements IData {
+
+ // internal
+ private int position = 0;
+ private String id = null;
+
+ public Data(String id) {
+ if (id == null || id.isEmpty()) {
+ this.id = UUID.randomUUID().toString();
+ } else {
+ this.id = id;
+ }
+ }
+
+ public Data(String id, int position) {
+ this(id);
+ setPosition(position);
+ }
+
+ public Data(IData data, boolean generateNewId) {
+ this(generateNewId ? null : data.getId());
+ }
+
+ public Data(IData data) {
+ this(data.getId());
+ }
+
+ public Data() {
+ this(null, true);
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IData#getPosition()
+ */
+ @Override
+ public int getPosition() {
+ return position;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IData#getId()
+ */
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IData#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object object) {
+ if(!(object instanceof Data)) {
+ return false;
+ }
+ IData data = (IData)object;
+ if( data.getId().equals(this.getId())
+ /*data.getPosition() == this.getPosition()*/
+ )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IData#setPosition(int)
+ */
+ @Override
+ public void setPosition(int position) {
+ this.position = position;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IData#setId(java.lang.String)
+ */
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataMover.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataMover.java
new file mode 100644
index 00000000..a42db6ac
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataMover.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+public class DataMover {
+
+ private IDataStore store;
+ private IData data;
+
+ public DataMover(IDataStore store) {
+ this.store = store;
+ }
+
+ public void setData(IData data) {
+ this.data = data;
+ }
+
+ public void moveCurrentSelectionUp() {
+ if(data == null) {
+ return;
+ }
+ IData previousElement = store.getPreviousElement(data);
+ if(previousElement == null) {
+ return;
+ }
+ int newPosition = previousElement.getPosition();
+ int oldPosition = data.getPosition();
+ previousElement.setPosition(oldPosition);
+ data.setPosition(newPosition);
+ store.sort();
+ }
+
+ public void moveCurrentSelectionDown() {
+ if(data == null) {
+ return;
+ }
+ IData nextElement = store.getNextElement(data);
+ if(nextElement == null) {
+ return;
+ }
+ int newPosition = nextElement.getPosition();
+ int oldPosition = data.getPosition();
+ nextElement.setPosition(oldPosition);
+ data.setPosition(newPosition);
+ store.sort();
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataStore.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataStore.java
new file mode 100644
index 00000000..06dfaac5
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/DataStore.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import de.anbos.eclipse.easyshell.plugin.Constants;
+
+public class DataStore implements IDataStore {
+
+ private IPreferenceStore store;
+ private List items;
+ private DataObjectComparator comparator;
+
+ public DataStore(IPreferenceStore store) {
+ this.items = new ArrayList();
+ this.store = store;
+ }
+
+ public List getDataList() {
+ return items;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#getPreviousElement(de.anbos.eclipse.easyshell.plugin.preferences.IData)
+ */
+ @Override
+ public IData getPreviousElement(IData data) {
+ for(int i = 0 ; i < items.size() ; i++) {
+ IData item = (IData)items.get(i);
+ if(item.equals(data)) {
+ try {
+ return (IData)items.get(i - 1);
+ } catch(Throwable t) {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#getNextElement(de.anbos.eclipse.easyshell.plugin.preferences.IData)
+ */
+ @Override
+ public IData getNextElement(IData data) {
+ for(int i = 0 ; i < items.size() ; i++) {
+ IData item = (IData)items.get(i);
+ if(item.equals(data)) {
+ try {
+ return (IData)items.get(i + 1);
+ } catch(Throwable t) {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#getLastElement()
+ */
+ @Override
+ public IData getLastElement() {
+ int index = items.size() - 1;
+ if(index < 0) {
+ return null;
+ }
+ return (IData)items.get(index);
+ }
+
+ public void add(T data) {
+ int position = 0;
+ IData lastElement = getLastElement();
+ if(lastElement != null) {
+ position = lastElement.getPosition() + 1;
+ }
+ data.setPosition(position);
+ addInternal(data);
+ }
+
+ public void replace(T data) {
+ items.set(items.indexOf(data), data);
+ }
+
+ public void delete(IData data) {
+ items.remove(data);
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#save()
+ */
+ @Override
+ public void save() {
+ sort();
+ renumber();
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#loadDefaults()
+ */
+ @Override
+ public void loadDefaults() {
+ load();
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#load()
+ */
+ @Override
+ public void load() {
+ sort();
+ renumber();
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#removeAll()
+ */
+ @Override
+ public void removeAll() {
+ items.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#isMigrated()
+ */
+ @Override
+ public boolean isMigrated() {
+ return store.getBoolean(Constants.PREF_MIGRATED);
+ }
+
+ /* (non-Javadoc)
+ * @see de.anbos.eclipse.easyshell.plugin.preferences.IDataStore#setMigrated(boolean)
+ */
+ @Override
+ public void setMigrated(boolean migrated) {
+ store.setValue(Constants.PREF_MIGRATED, migrated);
+ }
+
+ public T getByPosition(int position) {
+ return items.get(position);
+ }
+
+ public T getById(String id) {
+ for (T data : getDataList()) {
+ if (data.getId().equals(id)) {
+ return data;
+ }
+ }
+ return null;
+ }
+
+ protected IPreferenceStore getStore() {
+ return store;
+ }
+
+ @Override
+ public void sort() {
+ if(comparator == null) {
+ comparator = new DataObjectComparator();
+ }
+ Collections.sort(items, comparator);
+ }
+
+ @Override
+ public void renumber() {
+ for (int i=0;i {
+ public int compare(Object object1, Object object2) {
+ IData data1 = null;
+ IData data2 = null;
+ data1 = (IData)object1;
+ data2 = (IData)object2;
+ if(data1 == null || data2 == null) {
+ return -1;
+ }
+ if(data1.getPosition() > data2.getPosition()) {
+ return 1;
+ }
+ if(data1.getPosition() == data2.getPosition()) {
+ return 0;
+ }
+ if(data1.getPosition() < data2.getPosition()) {
+ return -1;
+ }
+ return -1;
+ }
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IData.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IData.java
new file mode 100644
index 00000000..faffca0e
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IData.java
@@ -0,0 +1,15 @@
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+public interface IData {
+
+ int getPosition();
+
+ String getId();
+
+ boolean equals(Object object);
+
+ void setPosition(int position);
+
+ void setId(String id);
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IDataStore.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IDataStore.java
new file mode 100644
index 00000000..69258ed5
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/IDataStore.java
@@ -0,0 +1,27 @@
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+public interface IDataStore {
+
+ IData getPreviousElement(IData data);
+
+ IData getNextElement(IData data);
+
+ IData getLastElement();
+
+ void save();
+
+ void loadDefaults();
+
+ void load();
+
+ void removeAll();
+
+ boolean isMigrated();
+
+ void setMigrated(boolean migrated);
+
+ void renumber();
+
+ void sort();
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Initializer.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Initializer.java
new file mode 100644
index 00000000..3e318752
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/Initializer.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.Constants;
+import de.anbos.eclipse.easyshell.plugin.legacy.PrefsV1_4;
+import de.anbos.eclipse.easyshell.plugin.legacy.PrefsV1_5;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class Initializer extends AbstractPreferenceInitializer {
+
+ public void initializeDefaultPreferences() {
+ // get the actual preference store
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ // set default values
+ setDefaults(store);
+ // migrate from old store
+ migrate(store);
+ }
+
+ private void setDefaults(IPreferenceStore store) {
+ String defaultCommandsPreset = PreferenceValueConverter.asCommandDataString(CommandDataDefaultCollection.getCommandsNative(null));
+ String defaultCommands = "";
+ String defaultMenu = PreferenceValueConverter.asMenuDataString(CommandDataDefaultCollection.getCommandsNativeAsMenu(true));
+ store.setDefault(Constants.PREF_COMMANDS_PRESET, defaultCommandsPreset);
+ store.setDefault(Constants.PREF_COMMANDS, defaultCommands);
+ store.setDefault(Constants.PREF_MENU, defaultMenu);
+ store.setDefault(Constants.PREF_MIGRATED, false);
+ }
+
+ private void migrate(IPreferenceStore store) {
+ if (!store.getBoolean(Constants.PREF_MIGRATED)) {
+ int migrateState = -1; // -1 = old store not found, 0 (Yes) = migrated, 1 (No) = no migration wanted by user, 2 (Cancel) = try to migrate again
+ for (int i=Version.values().length-2;i>0;i--) {
+ Version version = Version.values()[i];
+ String versionName = version.getName();
+ if (version.toString().startsWith("v1_")) {
+ migrateState = migrate_from_v1(store, version, migrateState);
+ } else {
+ migrateState = migrate_from_v2(store, version, migrateState);
+ }
+ // if no old store for this version found continue, else break
+ if (migrateState != -1) {
+ switch(migrateState) {
+ case 0: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format(
+ Activator.getResourceString("easyshell.message.warning.migrated.yes"),
+ versionName));
+
+ break;
+ case 1: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format(
+ Activator.getResourceString("easyshell.message.warning.migrated.no"),
+ versionName));
+ break;
+ case 2: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format(
+ Activator.getResourceString("easyshell.message.warning.migrated.cancel"),
+ versionName));
+ break;
+
+ }
+ break;
+ }
+ }
+ // we have first startup without old store
+ if (migrateState == -1) {
+ Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), Activator.getResourceString("easyshell.message.warning.migrated.default"));
+ }
+ // do not set migration flag if user canceled and want to do it later
+ if (migrateState != 2) {
+ store.setValue(Constants.PREF_MIGRATED, true);
+ }
+ }
+ }
+
+ private int migrate_from_v2(IPreferenceStore store, Version version, int migrateState) {
+ // get the old v2 store
+ IPreferenceStore oldStore = Activator.getDefault().getPreferenceStoreByVersion(version.name());
+ // check preferences for default values
+ migrateState = migrate_check_pref_and_ask_user(oldStore, version, new ArrayList(Arrays.asList(Constants.PREF_COMMANDS)), migrateState);
+ if (migrateState == 0) {
+ store.setValue(Constants.PREF_COMMANDS, PreferenceValueConverter.migrateCommandDataList(version, oldStore.getString(Constants.PREF_COMMANDS)));
+ }
+ migrateState = migrate_check_pref_and_ask_user(oldStore, version, new ArrayList(Arrays.asList(Constants.PREF_MENU)), migrateState);
+ if (migrateState == 0) {
+ store.setValue(Constants.PREF_MENU, PreferenceValueConverter.migrateMenuDataList(version, oldStore.getString(Constants.PREF_MENU)));
+ }
+ return migrateState;
+ }
+
+ private int migrate_check_pref_and_ask_user(IPreferenceStore store, Version version, List prefList, int migrateState) {
+ // if cancel or no just skip this time
+ if (migrateState == 1 || migrateState == 2) {
+ return migrateState;
+ }
+ boolean migrationPossible = false;
+ for (String pref : prefList) {
+ if (!store.isDefault(pref)) {
+ migrationPossible = true;
+ break;
+ }
+ }
+ if (migrationPossible) {
+ // ask user if not already asked and said yes
+ if (migrateState != 0) {
+ String title = Activator.getResourceString("easyshell.plugin.name");
+ String question = MessageFormat.format(
+ Activator.getResourceString("easyshell.question.migrate"),
+ version.getName());
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.QUESTION,
+ new String[] {"Yes", "No", "Cancel"},
+ 0); // no is the default
+ migrateState = dialog.open();
+ }
+ }
+ return migrateState;
+ }
+
+ private int migrate_from_v1(IPreferenceStore store, Version version, int migrateState) {
+ // get the old v1_5 store
+ IPreferenceStore oldStore = Activator.getDefault().getLegacyPreferenceStore();
+ // check if we want version 1.5 or 1.4
+ if (version == Version.v1_5) {
+ // check preferences for default values
+ migrateState = migrate_check_pref_and_ask_user(oldStore, version, PrefsV1_5.getPreferenceList(), migrateState);
+ if (migrateState == 0) {
+ CommandDataList cmdDataList = new CommandDataList();
+ MenuDataList menuDataList = CommandDataDefaultCollection.getCommandsNativeAsMenu(true);
+ if (PrefsV1_5.loadStore(oldStore, Utils.getOS(), cmdDataList, menuDataList)) {
+ store.setValue(Constants.PREF_COMMANDS, PreferenceValueConverter.asCommandDataString(cmdDataList));
+ store.setValue(Constants.PREF_MENU, PreferenceValueConverter.asMenuDataString(menuDataList));
+ }
+ }
+ } else if (version == Version.v1_4) {
+ // check preferences for default values
+ migrateState = migrate_check_pref_and_ask_user(oldStore, version, PrefsV1_4.getPreferenceList(), migrateState);
+ CommandDataList cmdDataList = new CommandDataList();
+ MenuDataList menuDataList = CommandDataDefaultCollection.getCommandsNativeAsMenu(true);
+ if (PrefsV1_4.loadStore(oldStore, Utils.getOS(), cmdDataList, menuDataList)) {
+ store.setValue(Constants.PREF_COMMANDS, PreferenceValueConverter.asCommandDataString(cmdDataList));
+ store.setValue(Constants.PREF_MENU, PreferenceValueConverter.asMenuDataString(menuDataList));
+ }
+ }
+ return migrateState;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MainPage.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MainPage.java
new file mode 100644
index 00000000..137e3955
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MainPage.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+
+public class MainPage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private IWorkbench workbench;
+
+ public MainPage() {
+ }
+
+ public MainPage(String title) {
+ super(title);
+ }
+
+ public MainPage(String title, ImageDescriptor image) {
+ super(title, image);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ this.workbench = workbench;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Map params = new HashMap();
+ params.put("preferencePageId","de.anbos.eclipse.easyshell.plugin.preferences.MenuPage");
+ Utils.executeCommand(workbench, "org.eclipse.ui.window.preferences", params, true);
+ return null;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuData.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuData.java
new file mode 100644
index 00000000..c4a7d87c
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuData.java
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.StringTokenizer;
+import java.util.UUID;
+
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.MenuNameType;
+import de.anbos.eclipse.easyshell.plugin.types.Variable;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class MenuData extends Data {
+
+ // menu
+ private boolean enabled = true;
+ private MenuNameType nameType = MenuNameType.menuNameTypeUnknown;
+ private String namePattern = "";
+ // copy of or reference to command
+ private String commandId = null;
+
+ public MenuData(String id, boolean enabled, MenuNameType nameType, String namePattern,String commandId) {
+ super(id);
+ setEnabled(enabled);
+ setNameType(nameType);
+ setNamePattern(namePattern);
+ setCommandId(commandId);
+ }
+
+ public MenuData(String newId, String commandId) {
+ super(newId);
+ setNameType(MenuNameType.menuNameTypeGeneric1);
+ setCommandId(commandId);
+ }
+
+ public MenuData(String commandId, boolean generateNewId) {
+ this(generateNewId ? UUID.randomUUID().toString() : commandId, commandId);
+ }
+
+ public MenuData(String newId, MenuData data) {
+ this(newId, data.getCommandId());
+ this.enabled = data.isEnabled();
+ this.nameType = data.getNameType();
+ this.namePattern = data.getNamePattern();
+ }
+
+ public MenuData(MenuData data, boolean generateNewId) {
+ this(generateNewId ? UUID.randomUUID().toString() : data.getId(), data);
+ }
+
+ public MenuData() {
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public MenuNameType getNameType() {
+ return nameType;
+ }
+
+ public String getNamePattern() {
+ return namePattern;
+ }
+
+ public String getNameExpanded() {
+ String expanded = namePattern;
+ for (Variable variable : Variable.getInternalVariables()) {
+ expanded = expanded.replace(variable.getFullVariableName(), variable.getResolver().resolve(getCommandData()));
+ }
+ /*
+ expanded = expanded.replace("${easyshell:command_category}", getCommandData().getCategory().getName());
+ expanded = expanded.replace("${easyshell:command_type}", getCommandData().getCommandType().getName());
+ expanded = expanded.replace("${easyshell:command_name}", getCommandData().getName());
+ expanded = expanded.replace("${easyshell:command_os}", getCommandData().getOs().getName());
+ */
+ return expanded;
+ }
+
+ public String toString() {
+ return getNameExpanded();
+ }
+
+ public String getCommandId() {
+ return commandId;
+ }
+
+ public boolean equals(Object object) {
+ if(!(object instanceof MenuData)) {
+ return false;
+ }
+ MenuData data = (MenuData)object;
+ if( data.getId().equals(this.getId())
+ /*data.getPosition() == this.getPosition() &&
+ data.getName().equals(this.getName()) &&
+ data.getCommandData().equals(this.getCommandData())*/
+ )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean deserialize(Version version, String value, StringTokenizer tokenizer, String delimiter) {
+ if((value == null || value.length() <= 0) && tokenizer == null) {
+ return false;
+ }
+ if (tokenizer == null) {
+ tokenizer = new StringTokenizer(value,delimiter);
+ }
+ // set internal members
+ setPosition(Integer.parseInt(tokenizer.nextToken()));
+ setId(tokenizer.nextToken());
+ // set menu data members
+ setEnabled(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
+ // menu name type handling
+ MenuNameType nameType = MenuNameType.menuNameTypeUser;
+ if (version.getId() >= Version.v2_0_002.getId()) {
+ nameType = MenuNameType.getFromEnum(tokenizer.nextToken());
+ }
+ String namePatternReaded = tokenizer.nextToken();
+ // -------------------------------------------------
+ // read new id
+ if (version.getId() >= Version.v2_0_003.getId()) {
+ // read the new one
+ setCommandId(tokenizer.nextToken());
+ setNameType(nameType);
+ } else {
+ // read previous command data members
+ CommandData oldData = new CommandData();
+ oldData.deserialize(version, null, tokenizer, delimiter);
+ setCommandId(oldData.getId());
+ // menu name type handling
+ // set name type and read the old name as pattern and convert to new
+ if (version.getId() >= Version.v2_0_002.getId()) {
+ setNameType(nameType);
+ } else {
+ // check if readed name is the same, like expanded from patterns
+ for (MenuNameType type : MenuNameType.getAsList()) {
+ setNamePattern(type.getPattern()); // set temporary
+ if (getNameExpanded().equals(namePatternReaded)) {
+ nameType = type;
+ break;
+ }
+ }
+ setNameType(nameType);
+ }
+ }
+ if (nameType == MenuNameType.menuNameTypeUser) {
+ setNamePattern(namePatternReaded);
+ } else if (version.getId() < Version.v2_0_004.getId()) {
+ // convert to new names types
+ if (nameType == MenuNameType.menuNameTypeGeneric1) {
+ setNameTypeFromCategory();
+ }
+ }
+ return true;
+ }
+
+ public boolean deserialize(String value, StringTokenizer tokenizer, String delimiter) {
+ return deserialize(Version.actual, value, tokenizer, delimiter);
+ }
+
+ public String serialize(Version version, String delimiter) {
+ String ret = Integer.toString(getPosition()) + delimiter;
+ ret += getId() + delimiter;
+ ret += Boolean.toString(isEnabled()) + delimiter;
+ if (version.getId() >= Version.v2_0_002.getId()) {
+ ret += getNameType().toString() + delimiter;
+ }
+ ret += getNamePattern() + delimiter;
+ if (version.getId() >= Version.v2_0_003.getId()) {
+ ret += getCommandId() + delimiter;
+ } else {
+ ret += getCommandData().serialize(version, delimiter);
+ }
+ return ret;
+ }
+
+ public String serialize(String delimiter) {
+ return serialize(Version.actual, delimiter);
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void setNameType(MenuNameType nameType) {
+ this.nameType = nameType;
+ if (nameType != MenuNameType.menuNameTypeUser) {
+ setNamePattern(nameType.getPattern());
+ }
+ }
+
+ public void setNamePattern(String namePattern) {
+ if (namePattern != null) {
+ this.namePattern = namePattern;
+ }
+ }
+
+ public void setCommandId(String commandId) {
+ this.commandId = commandId;
+ }
+
+ public CommandData getCommandData() {
+ return CommandDataStore.instance().getById(getCommandId());
+ }
+
+ public void setNameTypeFromCategory() {
+ CommandData newData = getCommandData();
+ if (newData != null) {
+ setNameTypeFromCategory(newData.getCategory());
+ }
+ }
+
+ public void setNameTypeFromCategory(Category category) {
+ switch (category) {
+ case categoryDefault:
+ setNameType(MenuNameType.menuNameTypeDefaultApplication);
+ break;
+ case categoryOpen:
+ setNameType(MenuNameType.menuNameTypeOpenHere);
+ break;
+ case categoryRun:
+ setNameType(MenuNameType.menuNameTypeGeneric2);
+ break;
+ case categoryExplore:
+ setNameType(MenuNameType.menuNameTypeShowIn);
+ break;
+ case categoryClipboard:
+ setNameType(MenuNameType.menuNameTypeCopyToClipboard);
+ break;
+ case categoryUser:
+ setNameType(MenuNameType.menuNameTypeGeneric1);
+ break;
+ case categoryUnknown:
+ setNameType(MenuNameType.menuNameTypeGeneric1);
+ break;
+ default:
+ setNameType(MenuNameType.menuNameTypeGeneric1);
+ break;
+ }
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataContentProvider.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataContentProvider.java
new file mode 100644
index 00000000..071d46e8
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataContentProvider.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class MenuDataContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ return ((MenuDataStore)inputElement).getCommandMenuDataArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataDialog.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataDialog.java
new file mode 100644
index 00000000..7c6def35
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataDialog.java
@@ -0,0 +1,567 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.misc.Utils;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+import de.anbos.eclipse.easyshell.plugin.types.CommandType;
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.ResourceType;
+import de.anbos.eclipse.easyshell.plugin.types.Variable;
+import de.anbos.eclipse.easyshell.plugin.types.MenuNameType;
+
+public class MenuDataDialog extends StatusDialog {
+
+ private MenuData menuData;
+ private List cmdList;
+
+ private Button enabledCheckBox;
+ private Combo commandCombo;
+ private Combo nameTypeCombo;
+ private Text namePatternText;
+ ContentProposalAdapter namePatternTextAssist;
+ private Text menuNameText;
+ private Text commandText;
+
+ private Button addNewButton;
+ private Button addCopyButton;
+ private Button editButton;
+ private Button removeButton;
+
+ public MenuDataDialog(Shell parent, MenuData menuData, List cmdList, boolean edit) {
+ super(parent);
+ this.menuData = menuData;
+ this.cmdList = cmdList;
+ // do layout and title
+ setShellStyle(getShellStyle() | SWT.MAX);
+ // set title
+ String title = null;
+ if(edit) {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.edit"); //$NON-NLS-1$
+ } else {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.new"); //$NON-NLS-1$
+ }
+ setTitle(title);
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ public Control createDialogArea(Composite parent) {
+ Font font = parent.getFont();
+ Composite pageComponent = new Composite(parent,SWT.NULL);
+ GridLayout layout0 = new GridLayout();
+ layout0.numColumns = 1;
+ layout0.makeColumnsEqualWidth = false;
+ layout0.marginWidth = 5;
+ layout0.marginHeight = 4;
+ pageComponent.setLayout(layout0);
+ GridData gridData0 = new GridData(GridData.FILL_HORIZONTAL);
+ gridData0.widthHint = 640;
+ pageComponent.setLayoutData(gridData0);
+ pageComponent.setFont(font);
+ // define group1
+ Group pageGroup1 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
+ pageGroup1.setText(Activator.getResourceString("easyshell.menu.editor.dialog.title.group1"));
+ GridLayout layout1 = new GridLayout();
+ layout1.numColumns = 2;
+ layout1.makeColumnsEqualWidth = false;
+ layout1.marginWidth = 5;
+ layout1.marginHeight = 4;
+ pageGroup1.setLayout(layout1);
+ GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
+ pageGroup1.setLayoutData(gridData1);
+ pageGroup1.setFont(font);
+ // create activity checkbox
+ createEnabledCheckBox(pageGroup1);
+ // type combo
+ createNameTypeCombo(pageGroup1);
+ // create input nameText field
+ namePatternText = createTextField(pageGroup1, Activator.getResourceString("easyshell.menu.editor.dialog.label.pattern"), menuData.getNamePattern(), true);
+ namePatternTextAssist = addContentAssistExtended(namePatternText);
+ namePatternText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ boolean isUserDefined = menuData.getNameType() == MenuNameType.menuNameTypeUser;
+ if (isUserDefined) {
+ Text text = (Text)e.widget;
+ menuData.setNamePattern(text.getText());
+ menuNameText.setText(menuData.getNameExpanded());
+ }
+ }
+ });
+
+ // create output menuNameText field
+ menuNameText = createTextField(pageGroup1, Activator.getResourceString("easyshell.menu.editor.dialog.label.name"), menuData.getNameExpanded(), false);
+
+ // define group2
+ Group pageGroup2 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
+ pageGroup2.setText(Activator.getResourceString("easyshell.menu.editor.dialog.title.group2"));
+ GridLayout layout2 = new GridLayout();
+ layout2.numColumns = 3;
+ layout2.makeColumnsEqualWidth = false;
+ layout2.marginWidth = 5;
+ layout2.marginHeight = 4;
+ pageGroup2.setLayout(layout2);
+ GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
+ pageGroup2.setLayoutData(gridData2);
+ pageGroup2.setFont(font);
+
+ // create selected command combo
+ createCommandCombo(pageGroup2); createNewButton(font, pageGroup2, gridData2);
+ // create input commandText field
+ commandText = createTextField(pageGroup2, Activator.getResourceString("easyshell.menu.editor.dialog.label.command"), menuData.getCommandData().getCommand(), false);
+ createEditButton(font, pageGroup2, gridData2);
+ createLabel(pageGroup2, "");createLabel(pageGroup2, "");
+ createCopyButton(font, pageGroup2, gridData2);
+ createLabel(pageGroup2, "");createLabel(pageGroup2, "");
+ createRemoveButton(font, pageGroup2, gridData2);
+
+ // TODO: to be enabled again, see https://github.com/anb0s/EasyShell/issues/61
+ setHelpAvailable(false);
+
+ refreshCommandCombo();
+
+ return pageComponent;
+ }
+
+ private void createLabel(Composite parent, String name) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ label.setText(name);
+ }
+
+ private void createRemoveButton(Font font, Group pageGroup1, GridData gridData1) {
+ removeButton = new Button(pageGroup1, SWT.PUSH);
+ removeButton.setText(Activator.getResourceString("easyshell.menu.editor.dialog.button.text.remove"));
+ removeButton.setToolTipText(Activator.getResourceString("easyshell.menu.editor.dialog.button.tooltip.remove"));
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ removeDialog();
+ }
+ });
+ removeButton.setLayoutData(gridData1);
+ removeButton.setFont(font);
+ setButtonLayoutData(removeButton);
+ }
+
+ private void createEditButton(Font font, Group pageGroup1, GridData gridData1) {
+ editButton = new Button(pageGroup1, SWT.PUSH);
+ editButton.setText(Activator.getResourceString("easyshell.menu.editor.dialog.button.text.edit"));
+ editButton.setToolTipText(Activator.getResourceString("easyshell.menu.editor.dialog.button.tooltip.edit"));
+ editButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ editDialog();
+ }
+ });
+ editButton.setLayoutData(gridData1);
+ editButton.setFont(font);
+ setButtonLayoutData(editButton);
+ }
+
+ private void createCopyButton(Font font, Group pageGroup1, GridData gridData1) {
+ addCopyButton = new Button(pageGroup1, SWT.PUSH);
+ addCopyButton.setText(Activator.getResourceString("easyshell.menu.editor.dialog.button.text.copy"));
+ addCopyButton.setToolTipText(Activator.getResourceString("easyshell.menu.editor.dialog.button.tooltip.copy"));
+ addCopyButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ addCopyDialog();
+ }
+ });
+ addCopyButton.setLayoutData(gridData1);
+ addCopyButton.setFont(font);
+ setButtonLayoutData(addCopyButton);
+ }
+
+ private void createNewButton(Font font, Group pageGroup1, GridData gridData1) {
+ addNewButton = new Button(pageGroup1, SWT.PUSH);
+ addNewButton.setText(Activator.getResourceString("easyshell.menu.editor.dialog.button.text.new"));
+ addNewButton.setToolTipText(Activator.getResourceString("easyshell.menu.editor.dialog.button.tooltip.new"));
+ addNewButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ addNewDialog();
+ }
+ });
+ addNewButton.setLayoutData(gridData1);
+ addNewButton.setFont(font);
+ setButtonLayoutData(addNewButton);
+ }
+
+ private ContentProposalAdapter addContentAssistExtended(Text textControl) {
+ char[] autoActivationCharacters = new char[] { '$', '{' };
+ Map proposals = new LinkedHashMap();
+ // add internal variables
+ proposals.putAll(Variable.getInternalVariableInfoMap());
+ ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl, new CommandVariableContentAdapter(),
+ new CommandVariableContentProposalProvider(proposals), null,
+ autoActivationCharacters, true);
+ adapter.setPropagateKeys(false);
+ adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
+ return adapter;
+ }
+
+ protected void okPressed() {
+ if (!validateValues()) {
+ return;
+ }
+ menuData.setEnabled(enabledCheckBox.getSelection());
+ menuData.setNameType(getAllNameTypes()[nameTypeCombo.getSelectionIndex()]);
+ menuData.setNamePattern(namePatternText.getText());
+ menuData.setCommandId(cmdList.get(commandCombo.getSelectionIndex()).getId());
+ super.okPressed();
+ }
+
+ private void addDialog(CommandData data, boolean copy) {
+ String title = Activator.getResourceString("easyshell.command.editor.dialog.title.new");
+ if (copy) {
+ title = Activator.getResourceString("easyshell.command.editor.dialog.title.copy");
+ }
+ CommandDataDialog dialog = new CommandDataDialog(getShell(), data, title);
+ if (dialog.open() == Window.OK) {
+ addCommand(data);
+ refreshCommandCombo();
+ }
+ }
+
+ private void addCommand(CommandData data) {
+ CommandDataStore.instance().add(data);
+ //CommandDataStore.instance().save();
+ cmdList.add(data);
+ String[] names = getAllCommandsAsComboNames(cmdList);
+ commandCombo.setItems(names);
+ commandCombo.select(names.length-1);
+ }
+
+ private void replaceCommand(int index, CommandData data) {
+ CommandDataStore.instance().replace(data);
+ commandCombo.setItem(index, data.getCommandAsComboName());
+ commandCombo.select(index);
+ }
+
+ private void removeCommand(int index, CommandData data) {
+ if (data.getPresetType() == PresetType.presetUser) {
+ CommandDataStore.instance().delete(data);
+ cmdList.remove(index);
+ String[] names = getAllCommandsAsComboNames(cmdList);
+ commandCombo.setItems(names);
+ commandCombo.select(names.length-1);
+ } else if (data.getPresetType() == PresetType.presetPluginAndUser) {
+ data.removeUserData();
+ replaceCommand(index, data);
+ }
+ }
+
+ private void addNewDialog() {
+ CommandData data = new CommandData(null, PresetType.presetUser, Utils.getOS(), "MyNewCommand", ResourceType.resourceTypeFileOrDirectory, Category.categoryUser, CommandType.commandTypeExecute, "my_new_command");
+ addDialog(data, false);
+ }
+
+ private void addCopyDialog() {
+ int index = commandCombo.getSelectionIndex();
+ CommandData data = new CommandData(cmdList.get(index), true);
+ data.setPresetType(PresetType.presetUser);
+ addDialog(data, true);
+ }
+
+ private void editDialog() {
+ int index = commandCombo.getSelectionIndex();
+ CommandData dataSelected = cmdList.get(index);
+ CommandData dataNew = new CommandData(dataSelected, false);
+ dataNew.setPosition(dataSelected.getPosition());
+ String title = MessageFormat.format(Activator.getResourceString("easyshell.command.editor.dialog.title.edit"), dataNew.getPresetType().getName());
+ CommandDataDialog dialog = new CommandDataDialog(getShell(), dataNew, title);
+ if (dialog.open() == Window.OK) {
+ replaceCommand(index, dataNew);
+ refreshCommandCombo();
+ } else {
+ dataNew = null;
+ }
+ }
+
+ private void removeDialog() {
+ // get the selected commands and referenced menus as lists
+ List commands = new ArrayList();
+ List menus = new ArrayList();
+ // get the selected
+ int index = commandCombo.getSelectionIndex();
+ CommandData data = cmdList.get(index);
+ commands.add(data);
+ // get referenced menus and remove the the actual menus
+ menus.addAll(MenuDataStore.instance().getRefencedBy(data.getId()));
+ menus.remove(this.menuData);
+ // ask user
+ String commandNames = commandCombo.getItem(index);
+ String title = null;
+ String question = null;
+ if (data.getPresetType() == PresetType.presetPluginAndUser) {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.user.remove");
+ question = MessageFormat.format(
+ Activator.getResourceString("easyshell.menu.editor.dialog.question.user.remove"),
+ commandNames);
+ } else {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove");
+ question = MessageFormat.format(
+ Activator.getResourceString("easyshell.menu.editor.dialog.question.remove"),
+ commandNames);
+ }
+ int dialogImageType = MessageDialog.QUESTION;
+ if (menus.size() > 0) {
+ dialogImageType = MessageDialog.WARNING;
+ String menuNames = "";
+ for (MenuData menu : menus) {
+ menuNames += menu.getNameExpanded() + "\n";
+ }
+ if (data.getPresetType() == PresetType.presetPluginAndUser) {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.user.menu");
+ question = MessageFormat.format(Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.user.menu"),
+ commandNames, menuNames);
+ } else {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.menu");
+ question = MessageFormat.format(Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.menu"),
+ commandNames, menuNames);
+ }
+ }
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ dialogImageType,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ for (MenuData menu : menus) {
+ MenuDataStore.instance().delete(menu);
+ }
+ removeCommand(index, data);
+ refreshCommandCombo();
+ }
+ }
+
+ private void refreshCommandCombo() {
+ // send event to refresh
+ Event event = new Event();
+ event.item = null;
+ commandCombo.notifyListeners(SWT.Selection, event);
+ }
+
+ private void refreshNameTypeCombo() {
+ // send event to refresh
+ Event event = new Event();
+ event.item = null;
+ nameTypeCombo.notifyListeners(SWT.Selection, event);
+ }
+
+ private boolean validateValues() {
+
+ String title = Activator.getResourceString("easyshell.menu.editor.dialog.error.incompletedata.title");
+
+ // check type
+ if ( (commandCombo.getText() == null) || (commandCombo.getText().length() <= 0)) {
+ MessageDialog.openError(getShell(), title, Activator.getResourceString("easyshell.menu.editor.dialog.error.type.text"));
+ return false;
+ }
+
+ boolean valid = true;
+
+ // check name
+ String text = Activator.getResourceString("easyshell.menu.editor.dialog.error.text.name");
+ if ( (namePatternText.getText() == null) || (namePatternText.getText().length() <= 0)) {
+ valid = false;
+ }
+
+ // show error message
+ if (!valid) {
+ MessageDialog.openError(getShell(), title, text);
+ } else {
+ int index = commandCombo.getSelectionIndex();
+ CommandData data = cmdList.get(index);
+ List menus = MenuDataStore.instance().getRefencedBy(data.getId());
+ menus.remove(this.menuData);
+ if (menus.size() >0) {
+ title = Activator.getResourceString("easyshell.menu.editor.dialog.title.duplicate");
+ String commandNames = commandCombo.getItem(index);
+ String menuNames = "";
+ for (MenuData menu : menus) {
+ menuNames += menu.getNameExpanded() + "\n";
+ }
+ String question = MessageFormat.format(Activator.getResourceString("easyshell.menu.editor.dialog.question.duplicate"),
+ commandNames, menuNames);
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.WARNING,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result != 0) {
+ valid = false;
+ }
+ }
+ }
+
+ return valid;
+ }
+
+ private void createEnabledCheckBox(Composite parent) {
+ // draw label
+ createLabel(parent, Activator.getResourceString("easyshell.menu.editor.dialog.label.active"));
+ // draw checkbox
+ enabledCheckBox = new Button(parent,SWT.CHECK);
+ enabledCheckBox.setSelection(this.menuData.isEnabled());
+ }
+
+ private String[] getAllCommandsAsComboNames(List list) {
+ String[] arr = new String[list.size()];
+ for (int i=0;i {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4274345194237037872L;
+
+ public MenuDataList() {
+ }
+
+ public MenuDataList(List list) {
+ addAll(list);
+ }
+
+ @Override
+ public boolean add(MenuData e) {
+ e.setPosition(this.size());
+ return super.add(e);
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataMover.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataMover.java
new file mode 100644
index 00000000..075ac7da
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataMover.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class MenuDataMover extends DataMover implements SelectionListener {
+
+ private Table table;
+
+ public MenuDataMover(Table table, IDataStore store) {
+ super(store);
+ this.table = table;
+ this.table.addSelectionListener(this);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ TableItem item = null;
+ try {
+ item = table.getSelection()[0];
+ } catch(Throwable t) {
+ setData(null);
+ return;
+ }
+ if(item == null || !(item.getData() instanceof MenuData)) {
+ setData(null);
+ return;
+ }
+ setData((IData)item.getData());
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataStore.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataStore.java
new file mode 100644
index 00000000..493acd9b
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuDataStore.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+import de.anbos.eclipse.easyshell.plugin.Constants;
+import de.anbos.eclipse.easyshell.plugin.types.Category;
+
+public class MenuDataStore extends DataStore {
+
+ private static MenuDataStore instance = null;
+
+ public static MenuDataStore instance() {
+ if (instance == null) {
+ instance = new MenuDataStore(Activator.getDefault().getPreferenceStore());
+ }
+ return instance;
+ }
+
+ public MenuDataStore(IPreferenceStore store) {
+ super(store);
+ store.addPropertyChangeListener(new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(Constants.PREF_MENU)) {
+ load((String)event.getNewValue());
+ }
+ }
+ });
+ }
+
+ public MenuData[] getCommandMenuDataArray() {
+ MenuDataList allItems = new MenuDataList(getDataList());
+ if(allItems.size() <= 0) {
+ return new MenuData[0];
+ }
+ MenuData[] allArray = new MenuData[allItems.size()];
+ for(int i = 0 ; i < allArray.length ; i++) {
+ allArray[i] = allItems.get(i);
+ }
+ return allArray;
+ }
+
+ public MenuDataList getEnabledCommandMenuDataListByCategory(Category category) {
+ MenuDataList checkedItems = new MenuDataList();
+ Iterator dataIterator = getDataList().iterator();
+ while(dataIterator.hasNext()) {
+ MenuData data = (MenuData)dataIterator.next();
+ if(data.isEnabled() && (category == Category.categoryUnknown || data.getCommandData().getCategory() == category)) {
+ checkedItems.add(data);
+ }
+ }
+ return checkedItems;
+ }
+
+ public MenuDataList getEnabledCommandMenuDataList() {
+ return getEnabledCommandMenuDataListByCategory(Category.categoryUnknown);
+ }
+
+ public MenuData[] getEnabledCommandMenuDataArray() {
+ MenuDataList checkedItems = getEnabledCommandMenuDataList();
+ if(checkedItems.size() <= 0) {
+ return new MenuData[0];
+ }
+ MenuData[] checked = new MenuData[checkedItems.size()];
+ for(int i = 0 ; i < checked.length ; i++) {
+ checked[i] = (MenuData)checkedItems.get(i);
+ }
+ return checked;
+ }
+
+ @Override
+ public void save() {
+ super.save();
+ getStore().setValue(Constants.PREF_MENU,PreferenceValueConverter.asMenuDataString(getDataList()));
+ }
+
+ @Override
+ public void loadDefaults() {
+ getStore().setToDefault(Constants.PREF_MENU);
+ load();
+ }
+
+ public void load(String prefMenu) {
+ if (prefMenu == null) {
+ prefMenu = getStore().getString(Constants.PREF_MENU);
+ }
+ MenuData[] items = PreferenceValueConverter.asMenuDataArray(prefMenu);
+ removeAll();
+ for(int i = 0 ; i < items.length ; i++) {
+ addInternal(items[i]);
+ }
+ super.load();
+ }
+
+ @Override
+ public void load() {
+ load(null);
+ }
+
+ public MenuDataList getRefencedBy(String id) {
+ MenuDataList ref = new MenuDataList();
+ Iterator dataIterator = getDataList().iterator();
+ while(dataIterator.hasNext()) {
+ MenuData data = (MenuData)dataIterator.next();
+ if(data.getCommandId().equals(id)) {
+ ref.add(data);
+ }
+ }
+ return ref;
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuPage.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuPage.java
new file mode 100644
index 00000000..2b02675c
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuPage.java
@@ -0,0 +1,497 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import de.anbos.eclipse.easyshell.plugin.Activator;
+
+public class MenuPage extends org.eclipse.jface.preference.PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ List commandList;
+ private MenuDataMover itemMover;
+ private Text searchText;
+ private MenuTableFilter filter;
+ private CheckboxTableViewer tableViewer;
+ private Button addNewButton;
+ private Button addCopyButton;
+ private Button editButton;
+ private Button upButton;
+ private Button downButton;
+ private Button removeButton;
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ public boolean performOk() {
+ boolean save = true;
+ if (!MenuDataStore.instance().isMigrated()) {
+ String title = Activator.getResourceString("easyshell.menu.page.dialog.migration.title");
+ String question = Activator.getResourceString("easyshell.menu.page.dialog.migration.question");
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.WARNING,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ MenuDataStore.instance().setMigrated(true);
+ } else {
+ save = false;
+ }
+ }
+ if (save) {
+ CommandDataStore.instance().save();
+ MenuDataStore.instance().save();
+ }
+ return save;
+ }
+
+ @Override
+ protected void performApply() {
+ performOk();
+ }
+
+ @Override
+ protected void performDefaults() {
+ String title = Activator.getResourceString("easyshell.menu.page.dialog.defaults.title");
+ String question = Activator.getResourceString("easyshell.menu.page.dialog.defaults.question");
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.WARNING,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ MenuDataStore.instance().loadDefaults();
+ refreshTableViewer();
+ }
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ // main page composite
+ Composite pageComponent = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ pageComponent.setLayout(layout);
+ //parent.setLayout(layout);
+
+ // search
+ createSearchField(pageComponent);
+
+ // command store
+ CommandDataStore.instance().load();
+
+ // get the native commands list
+ commandList = CommandDataDefaultCollection.getCommandsNative(new CommandDataList(CommandDataStore.instance().getDataList()));
+
+ // menu store
+ MenuDataStore.instance().load();
+
+ // table viewer
+ createTableViewer(pageComponent);
+
+ // buttons
+ createButtons(pageComponent);
+
+ // refresh the viewer
+ refreshTableViewer();
+
+ // send event to refresh tableViewer selection
+ Event event = new Event();
+ event.item = null;
+ tableViewer.getTable().notifyListeners(SWT.Selection, event);
+
+ return pageComponent;
+ }
+
+ private void createSearchField(Composite parent) {
+ /*
+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
+ group.setText(Activator.getResourceString("easyshell.command.page.text.text.search"));
+ group.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
+ GridLayout layout2 = new GridLayout();
+ layout2.numColumns = 1;
+ layout2.makeColumnsEqualWidth = false;
+ layout2.marginWidth = 5;
+ layout2.marginHeight = 4;
+ group.setLayout(layout2);
+ GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(data2);
+ group.setFont(parent.getFont());*/
+
+ //Label searchLabel = new Label(parent, SWT.NONE);
+ //searchLabel.setText("Search: ");
+ filter = new MenuTableFilter();
+ searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
+ searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ searchText.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent ke) {
+ filter.setSearchText(searchText.getText());
+ refreshTableViewer();
+ }
+
+ });
+ searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
+ // fake
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("");
+ }
+
+ private void createButtons(Composite pageComponent) {
+ Font font = pageComponent.getFont();
+ // button pageComponent
+ Composite groupComponent = new Composite(pageComponent, SWT.NULL);
+ GridLayout groupLayout = new GridLayout();
+ groupLayout.marginWidth = 0;
+ groupLayout.marginHeight = 0;
+ groupComponent.setLayout(groupLayout);
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalAlignment = GridData.FILL;
+ groupComponent.setLayoutData(gridData);
+ groupComponent.setFont(font);
+
+ // buttons
+ createNewButton(font, gridData, groupComponent);
+ createEditButton(font, gridData, groupComponent);
+ createCopyButton(font, gridData, groupComponent);
+ createRemoveButton(font, gridData, groupComponent);
+ createUpButton(font, gridData, groupComponent);
+ createDownButton(font, gridData, groupComponent);
+ }
+
+ private void createTableViewer(Composite parent) {
+ tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ createColumns(parent, tableViewer);
+ final Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ tableViewer.setLabelProvider(new MenuDataLabelProvider());
+ tableViewer.setContentProvider(new MenuDataContentProvider());
+ if (filter != null) {
+ tableViewer.addFilter(filter);
+ }
+
+ // Get the content for the viewer, setInput will call getElements in the
+ // contentProvider
+ tableViewer.setInput(MenuDataStore.instance());
+
+ // Layout the viewer
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ tableViewer.getControl().setLayoutData(gridData);
+
+ tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ editDialog();
+ }
+ });
+
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ MenuData data = (MenuData) event.getElement();
+ data.setEnabled(event.getChecked());
+ }
+ });
+
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ int selected = selection.size();
+ addCopyButton.setEnabled(selected == 1);
+ editButton.setEnabled(selected == 1);
+ removeButton.setEnabled(selected > 0);
+ upButton.setEnabled(selected == 1);
+ downButton.setEnabled(selected == 1);
+ }
+ });
+
+ tableViewer.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(Viewer viewer, Object object1, Object object2) {
+ if (!(object1 instanceof MenuData) || !(object2 instanceof MenuData)) {
+ return super.compare(viewer, object1, object2);
+ }
+ MenuData data1 = (MenuData) object1;
+ MenuData data2 = (MenuData) object2;
+ if (data1.getPosition() > data2.getPosition()) {
+ return 1;
+ }
+ if (data1.getPosition() < data2.getPosition()) {
+ return -1;
+ }
+ if (data1.getPosition() == data2.getPosition()) {
+ return 0;
+ }
+ return super.compare(viewer, object1, object2);
+ }
+ @Override
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+ });
+
+ itemMover = new MenuDataMover(table, MenuDataStore.instance());
+ }
+
+ private void createColumns(final Composite parent, final TableViewer viewer) {
+ TableViewerColumn viewerColumn1 = new TableViewerColumn(viewer,
+ SWT.NONE);
+ TableColumn column1 = viewerColumn1.getColumn();
+ column1.setText(Activator.getResourceString("easyshell.menu.page.header.title.column0"));
+ column1.setWidth(200);
+ column1.setResizable(true);
+ column1.setMoveable(true);
+
+ TableViewerColumn viewerColumn2 = new TableViewerColumn(viewer,
+ SWT.NONE);
+ TableColumn column2 = viewerColumn2.getColumn();
+ column2.setText(Activator.getResourceString("easyshell.menu.page.header.title.column1"));
+ column2.setWidth(400);
+ column2.setResizable(true);
+ column2.setMoveable(true);
+ }
+
+ private void createDownButton(Font font, GridData gridData, Composite groupComponent) {
+ downButton = new Button(groupComponent, SWT.PUSH);
+ downButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.down"));
+ downButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.down"));
+ downButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ down();
+ }
+ });
+ downButton.setLayoutData(gridData);
+ downButton.setFont(font);
+ setButtonLayoutData(downButton);
+ }
+
+ private void createUpButton(Font font, GridData gridData, Composite groupComponent) {
+ upButton = new Button(groupComponent, SWT.PUSH);
+ upButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.up"));
+ upButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.up"));
+ upButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ up();
+ }
+ });
+ upButton.setLayoutData(gridData);
+ upButton.setFont(font);
+ setButtonLayoutData(upButton);
+ }
+
+ private void createRemoveButton(Font font, GridData gridData, Composite groupComponent) {
+ removeButton = new Button(groupComponent, SWT.PUSH);
+ removeButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.remove"));
+ removeButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.remove"));
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ removeDialog();
+ }
+ });
+ removeButton.setLayoutData(gridData);
+ removeButton.setFont(font);
+ setButtonLayoutData(removeButton);
+ }
+
+ private void createEditButton(Font font, GridData gridData, Composite groupComponent) {
+ editButton = new Button(groupComponent, SWT.PUSH);
+ editButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.edit"));
+ editButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.edit"));
+ editButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ editDialog();
+ }
+ });
+ editButton.setLayoutData(gridData);
+ editButton.setFont(font);
+ setButtonLayoutData(editButton);
+ }
+
+ private void createCopyButton(Font font, GridData gridData, Composite groupComponent) {
+ addCopyButton = new Button(groupComponent, SWT.PUSH);
+ addCopyButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.copy"));
+ addCopyButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.copy"));
+ addCopyButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ addCopyDialog();
+ }
+ });
+ addCopyButton.setLayoutData(gridData);
+ addCopyButton.setFont(font);
+ setButtonLayoutData(addCopyButton);
+ }
+
+ private void createNewButton(Font font, GridData gridData, Composite groupComponent) {
+ addNewButton = new Button(groupComponent, SWT.PUSH);
+ addNewButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.new"));
+ addNewButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.new"));
+ addNewButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ addNewDialog();
+ }
+ });
+ addNewButton.setLayoutData(gridData);
+ addNewButton.setFont(font);
+ setButtonLayoutData(addNewButton);
+ }
+
+ private void addDialog(MenuData data) {
+ MenuDataDialog dialog = new MenuDataDialog(getShell(), data, commandList, false);
+ if (dialog.open() == Window.OK) {
+ MenuDataStore.instance().add(data);
+ refreshTableViewer();
+ } else {
+ data = null;
+ }
+ }
+
+ private void addNewDialog() {
+ MenuData dataNew = new MenuData(commandList.get(0).getId(), true);
+ addDialog(dataNew);
+ }
+
+ private void addCopyDialog() {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ MenuData dataSelected = (MenuData)selection.getFirstElement();
+ MenuData dataNew = new MenuData(dataSelected, true);
+ addDialog(dataNew);
+ }
+
+ private void editDialog() {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ MenuData dataSelected = (MenuData)selection.getFirstElement();
+ MenuData dataNew = new MenuData(dataSelected, false);
+ dataNew.setPosition(dataSelected.getPosition());
+ MenuDataDialog dialog = new MenuDataDialog(getShell(), dataNew, commandList, true);
+ if (dialog.open() == Window.OK) {
+ MenuDataStore.instance().replace(dataNew);
+ refreshTableViewer();
+ } else {
+ dataNew = null;
+ }
+ }
+
+ private void removeDialog() {
+ // get the selected menus as lists
+ List menus = new ArrayList();
+ IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
+ Iterator> elements = selection.iterator();
+ while (elements.hasNext()) {
+ MenuData data = (MenuData) elements.next();
+ menus.add(data);
+ }
+ if (menus.size() > 0) {
+ String title = Activator.getResourceString("easyshell.menu.page.dialog.remove.title");
+ String menuNames = "";
+ for (MenuData menu : menus) {
+ menuNames += menu.getNameExpanded() + "\n";
+ }
+ String question = MessageFormat.format(Activator.getResourceString("easyshell.menu.page.dialog.remove.question"),
+ menuNames);
+ MessageDialog dialog = new MessageDialog(
+ null, title, null, question,
+ MessageDialog.QUESTION,
+ new String[] {"Yes", "No"},
+ 1); // no is the default
+ int result = dialog.open();
+ if (result == 0) {
+ for (MenuData menu : menus) {
+ MenuDataStore.instance().delete(menu);
+ }
+ refreshTableViewer();
+ }
+ }
+ }
+
+ private void up() {
+ itemMover.moveCurrentSelectionUp();
+ tableViewer.refresh();
+ }
+
+ private void down() {
+ itemMover.moveCurrentSelectionDown();
+ tableViewer.refresh();
+ }
+
+ /*
+ private void refreshTableViewer(MenuData data) {
+ tableViewer.refresh();
+ tableViewer.setChecked(data, data.isEnabled());
+ tableViewer.setSelection(new StructuredSelection(data));
+ }
+ */
+
+ private void refreshTableViewer() {
+ tableViewer.refresh();
+ // update/set checked elements
+ tableViewer.setAllChecked(false);
+ tableViewer.setCheckedElements(MenuDataStore.instance().getEnabledCommandMenuDataArray());
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuTableFilter.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuTableFilter.java
new file mode 100644
index 00000000..6cde154e
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/MenuTableFilter.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class MenuTableFilter extends ViewerFilter {
+
+ private String searchString;
+
+ public void setSearchText(String s) {
+ // add pre and post fix that it can be used for case-insensitive matching
+ this.searchString = "(?i).*" + s + ".*";
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (searchString == null || searchString.length() == 0) {
+ return true;
+ }
+ MenuData data = (MenuData) element;
+ if (data.getNameExpanded().matches(searchString)) {
+ return true;
+ }
+ if (data.getCommandData().getName().matches(searchString)) {
+ return true;
+ }
+ if (data.getCommandData().getCommand().matches(searchString)) {
+ return true;
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceInitializer.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceInitializer.java
deleted file mode 100644
index 91412695..00000000
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceInitializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Bossert - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package de.anbos.eclipse.easyshell.plugin.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import de.anbos.eclipse.easyshell.plugin.Activator;
-
-/**
- * Class used to initialize default preference values.
- */
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.P_BOOLEAN, true);
- store.setDefault(PreferenceConstants.P_CHOICE, "choice2");
- store.setDefault(PreferenceConstants.P_STRING,
- "Default value");
- }
-
-}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceValueConverter.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceValueConverter.java
new file mode 100644
index 00000000..6ea265a4
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PreferenceValueConverter.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.preferences;
+
+import java.util.List;
+import java.util.StringTokenizer;
+
+import de.anbos.eclipse.easyshell.plugin.types.PresetType;
+import de.anbos.eclipse.easyshell.plugin.types.Version;
+
+public class PreferenceValueConverter {
+
+ // Constant ----------------------------------------------------------------
+
+ public static String VALUE_DELIMITER = "|"; //$NON-NLS-1$
+ public static String ITEM_DELIMITER = "#"; //$NON-NLS-1$
+
+ // Static ------------------------------------------------------------------
+
+ public static String asCommandDataString(List items) {
+ StringBuffer buffer = new StringBuffer();
+ for(CommandData item : items) {
+ buffer.append(asCommandDataString(item));
+ buffer.append(ITEM_DELIMITER);
+ }
+ return buffer.toString();
+ }
+
+ public static String asMenuDataString(List items) {
+ StringBuffer buffer = new StringBuffer();
+ for(MenuData item : items) {
+ buffer.append(asMenuDataString(item));
+ buffer.append(ITEM_DELIMITER);
+ }
+ return buffer.toString();
+ }
+
+ public static final String asCommandDataString(CommandData data) {
+ return data.serialize(VALUE_DELIMITER);
+ }
+
+ public static final String asMenuDataString(MenuData data) {
+ return data.serialize(VALUE_DELIMITER);
+ }
+
+ public static CommandData[] asCommandDataArray(String value) {
+ StringTokenizer tokenizer = new StringTokenizer(value,ITEM_DELIMITER);
+ CommandData[] items = new CommandData[tokenizer.countTokens()];
+ for(int i = 0 ; i < items.length ; i++) {
+ items[i] = asCommandData(tokenizer.nextToken());
+ }
+ return items;
+ }
+
+ public static MenuData[] asMenuDataArray(String value) {
+ StringTokenizer tokenizer = new StringTokenizer(value,ITEM_DELIMITER);
+ MenuData[] items = new MenuData[tokenizer.countTokens()];
+ for(int i = 0 ; i < items.length ; i++) {
+ items[i] = asMenuData(tokenizer.nextToken());
+ }
+ return items;
+ }
+
+ public static CommandData asCommandData(String value) {
+ CommandData data = new CommandData();
+ data.deserialize(value, null, VALUE_DELIMITER);
+ return data;
+ }
+
+ public static MenuData asMenuData(String value) {
+ MenuData data = new MenuData();
+ data.deserialize(value, null, VALUE_DELIMITER);
+ return data;
+ }
+
+ public static CommandData migrateCommandData(Version version, String value) {
+ CommandData data = new CommandData();
+ data.deserialize(version, value, null, VALUE_DELIMITER);
+ // special handling
+ if (version == Version.v2_0_001) {
+ // skip commands from preset
+ if (data.getPresetType() == PresetType.presetPlugin) {
+ data = null;
+ }
+ }
+ return data;
+ }
+
+ public static MenuData migrateMenuData(Version version, String value) {
+ MenuData data = new MenuData();
+ data.deserialize(version, value, null, VALUE_DELIMITER);
+ return data;
+ }
+
+ public static String migrateCommandDataList(Version version, String value) {
+ StringBuffer buffer = new StringBuffer();
+ StringTokenizer tokenizer = new StringTokenizer(value, ITEM_DELIMITER);
+ int num = tokenizer.countTokens();
+ for(int i = 0 ; i < num; i++) {
+ CommandData data = migrateCommandData(version, tokenizer.nextToken());
+ if (data != null) {
+ buffer.append(asCommandDataString(data));
+ buffer.append(ITEM_DELIMITER);
+ }
+ }
+ return buffer.toString();
+ }
+
+ public static String migrateMenuDataList(Version version, String value) {
+ StringBuffer buffer = new StringBuffer();
+ StringTokenizer tokenizer = new StringTokenizer(value, ITEM_DELIMITER);
+ int num = tokenizer.countTokens();
+ for(int i = 0 ; i < num; i++) {
+ MenuData data = migrateMenuData(version, tokenizer.nextToken());
+ if (data != null) {
+ buffer.append(asMenuDataString(data));
+ buffer.append(ITEM_DELIMITER);
+ }
+ }
+ return buffer.toString();
+ }
+
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/SamplePreferencePage.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/SamplePreferencePage.java
index 628deeb7..1c5640ff 100644
--- a/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/SamplePreferencePage.java
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/SamplePreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Andre Bossert.
+ * Copyright (c) 2014 - 2016 Andre Bossert.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,6 +47,7 @@ public SamplePreferencePage() {
* restore itself.
*/
public void createFieldEditors() {
+ /*
addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
"&Directory preference:", getFieldEditorParent()));
addField(
@@ -64,6 +65,7 @@ public void createFieldEditors() {
}, getFieldEditorParent()));
addField(
new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
+ */
}
/* (non-Javadoc)
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Category.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Category.java
new file mode 100644
index 00000000..30d141e4
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Category.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import de.anbos.eclipse.easyshell.plugin.Constants;
+
+public enum Category {
+ categoryUnknown(-1, "Unknown", Constants.IMAGE_UNKNOWN),
+ categoryDefault(0, "Default", Constants.IMAGE_DEFAULT),
+ categoryOpen(1, "Open", Constants.IMAGE_OPEN),
+ categoryRun(2, "Run", Constants.IMAGE_RUN),
+ categoryExplore(3, "Explore", Constants.IMAGE_EXPLORE),
+ categoryClipboard(4, "Clipboard", Constants.IMAGE_CLIPBOARD),
+ categoryUser(5, "User", Constants.IMAGE_USER);
+ // attributes
+ private final int id;
+ private final String name;
+ private final String icon;
+ // construct
+ Category(int id, String name, String icon) {
+ this.id = id;
+ this.name = name;
+ this.icon = icon;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getIcon() {
+ return icon;
+ }
+ public static Category getFromId(int id) {
+ Category ret = categoryUnknown;
+ for(int i = 0; i < Category.values().length; i++) {
+ if (Category.values()[i].getId() == id) {
+ ret = Category.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static Category getFromName(String name) {
+ Category ret = categoryUnknown;
+ for(int i = 0; i < Category.values().length; i++) {
+ if (Category.values()[i].getName().equals(name)) {
+ ret = Category.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static Category getFromEnum(String name) {
+ return Category.valueOf(name);
+ }
+ public static Category getFromDeprecatedCommandTypeEnum(String name) {
+ // set mapping
+ Map map = new HashMap();
+ map.put("commandTypeOpen", categoryOpen);
+ map.put("commandTypeRun", categoryRun);
+ map.put("commandTypeExplore", categoryExplore);
+ map.put("commandTypeClipboard", categoryClipboard);
+ map.put("commandTypeOther", categoryUser);
+ // find the key
+ for(String key: map.keySet()) {
+ if (name.equals(key)) {
+ return (Category)map.get(key);
+ }
+ }
+ return categoryUnknown;
+ }
+
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < Category.values().length; i++) {
+ if (Category.values()[i] != categoryUnknown) {
+ list.add(Category.values()[i].getName());
+ }
+ }
+ return list;
+ }
+ public static String[] getNamesAsArray() {
+ List list = getNamesAsList();
+ String[] arr = new String[list.size()];
+ for (int i=0;i getIconsAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < Category.values().length; i++) {
+ if (Category.values()[i] != categoryUnknown) {
+ list.add(Category.values()[i].getIcon());
+ }
+ }
+ return list;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/CommandType.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/CommandType.java
new file mode 100644
index 00000000..19b545e1
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/CommandType.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import de.anbos.eclipse.easyshell.plugin.Constants;
+
+public enum CommandType {
+ commandTypeUnknown(-1, "Unknown", Constants.ACTION_UNKNOWN),
+ commandTypeExecute(0, "Execute", Constants.ACTION_EXECUTE),
+ commandTypeClipboard(1, "Clipboard", Constants.ACTION_CLIPBOARD);
+ // attributes
+ private final int id;
+ private final String name;
+ private final String action;
+ // construct
+ CommandType(int id, String name, String action) {
+ this.id = id;
+ this.name = name;
+ this.action = action;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getAction() {
+ return action;
+ }
+ public static CommandType getFromId(int id) {
+ CommandType ret = commandTypeUnknown;
+ for(int i = 0; i < CommandType.values().length; i++) {
+ if (CommandType.values()[i].getId() == id) {
+ ret = CommandType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static CommandType getFromName(String name) {
+ CommandType ret = commandTypeUnknown;
+ for(int i = 0; i < CommandType.values().length; i++) {
+ if (CommandType.values()[i].getName().equals(name)) {
+ ret = CommandType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static CommandType getFromEnum(String name) {
+ return CommandType.valueOf(name);
+ }
+ public static CommandType getFromDeprecatedCommandTypeEnum(String name) {
+ // set mapping
+ Map map = new HashMap();
+ map.put("commandTypeOpen", commandTypeExecute);
+ map.put("commandTypeRun", commandTypeExecute);
+ map.put("commandTypeExplore", commandTypeExecute);
+ map.put("commandTypeClipboard", commandTypeClipboard);
+ map.put("commandTypeOther", commandTypeExecute);
+ // find the key
+ for(String key: map.keySet()) {
+ if (name.equals(key)) {
+ return (CommandType)map.get(key);
+ }
+ }
+ return commandTypeUnknown;
+ }
+ public static CommandType getFromAction(String action) {
+ CommandType ret = commandTypeUnknown;
+ for(int i = 0; i < CommandType.values().length; i++) {
+ if (CommandType.values()[i].getAction().equals(action)) {
+ ret = CommandType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < CommandType.values().length; i++) {
+ if (CommandType.values()[i] != commandTypeUnknown) {
+ list.add(CommandType.values()[i].getName());
+ }
+ }
+ return list;
+ }
+ public static String[] getNamesAsArray() {
+ List list = getNamesAsList();
+ String[] arr = new String[list.size()];
+ for (int i=0;i getActionsAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < CommandType.values().length; i++) {
+ if (CommandType.values()[i] != commandTypeUnknown) {
+ list.add(CommandType.values()[i].getAction());
+ }
+ }
+ return list;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converter.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converter.java
new file mode 100644
index 00000000..a59c0e9b
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum Converter {
+ converterUnknown(-1, false, OS.osUnknown, "unknown", "unknown", new IConverter() {
+ @Override
+ public String convert(String input) {
+ return input;
+ }
+ }),
+ converterUnix(0, OS.osUnknown, "unix", "converts all separators to Unix (line '\\n', file '/', path ':')", new IConverter() {
+ @Override
+ public String convert(String input) {
+ String result = input;
+ for (Converter converter : getFromOS(OS.osUnix)) {
+ result = converter.getConverterImpl().convert(result);
+ }
+ return result;
+ }
+ }),
+ converterWindows(1, OS.osUnknown, "windows", "converts all separators to Windows (line '\\r\\n', file '\\', path ';')", new IConverter() {
+ @Override
+ public String convert(String input) {
+ String result = input;
+ for (Converter converter : getFromOS(OS.osWindows)) {
+ result = converter.getConverterImpl().convert(result);
+ }
+ return result;
+ }
+ }),
+ converterLineSeparatorLF(2, OS.osUnix, "lf", "converts line separator to Unix '\\n'", new IConverter() {
+ @Override
+ public String convert(String input) {
+ return input.replace("\r\n", "\n");
+ }
+ }),
+ converterLineSeparatorCRLF(3, OS.osWindows, "crlf", "converts line separator to Windows '\\r\\n'", new IConverter() {
+ @Override
+ public String convert(String input) {
+ return input.replace("\r\n", "\n").replace("\n", "\r\n");
+ }
+ }),
+ converterFileSeparatorSlash(4, OS.osUnix, "slash", "converts file separator to Unix '/'", new IConverter() {
+ @Override
+ public String convert(String input) {
+ return input.replace("\\", "/");
+ }
+ }),
+ converterFileSeparatorBackslash(5, OS.osWindows, "backslash", "converts file separator to Windows '\\'", new IConverter() {
+ @Override
+ public String convert(String input) {
+ return input.replace("/", "\\");
+ }
+ });
+ // attributes
+ private final int id;
+ private final boolean visible;
+ private final OS os;
+ private final String name;
+ private final String description;
+ private IConverter converterImpl = null;
+ // construct
+ Converter(int id, boolean visible, OS os, String name, String description, IConverter converterImpl) {
+ this.id = id;
+ this.visible = visible;
+ this.os = os;
+ this.name = name;
+ this.description = description;
+ this.converterImpl = converterImpl;
+ }
+ Converter(int id, OS os, String name, String description, IConverter converterImpl) {
+ this(id, true, os, name, description, converterImpl);
+ }
+ public int getId() {
+ return id;
+ }
+ public boolean isVisible() {
+ return visible;
+ }
+ public OS getOS() {
+ return os;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public IConverter getConverterImpl() {
+ return converterImpl;
+ }
+ public static Converter getFromId(int id) {
+ Converter ret = converterUnknown;
+ for(int i = 0; i < Converter.values().length; i++) {
+ if (Converter.values()[i].getId() == id) {
+ ret = Converter.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static List getFromOS(OS os) {
+ List ret = new ArrayList<>();
+ for(int i = 0; i < Converter.values().length; i++) {
+ if (Converter.values()[i].getOS() == os) {
+ ret.add(Converter.values()[i]);
+ }
+ }
+ return ret;
+ }
+ public static Converter getFromName(String name) {
+ Converter ret = converterUnknown;
+ for(int i = 0; i < Converter.values().length; i++) {
+ if (Converter.values()[i].getName().equals(name)) {
+ ret = Converter.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static Converter getFromEnum(String name) {
+ return Converter.valueOf(name);
+ }
+ public static int getFirstIndex() {
+ return 0;
+ }
+};
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converters.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converters.java
new file mode 100644
index 00000000..8f51cfb9
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Converters.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Converters {
+ static Map map = new HashMap();
+ public static Map getMap() {
+ return map;
+ }
+ static {
+ for(int i=0;i Here", "Open ${easyshell:command_name} Here"),
+ menuNameTypeRunWith( 3, "Run with ", "Run with ${easyshell:command_name}"),
+ menuNameTypeShowIn( 4, "Show in ", "Show in ${easyshell:command_name}"),
+ menuNameTypeCopyToClipboard( 5, "Copy to Clipboard", "Copy ${easyshell:command_name} to Clipboard"),
+ menuNameTypeGeneric1( 6, ": ", "${easyshell:command_category}: ${easyshell:command_name}"),
+ menuNameTypeGeneric2( 7, " with ", "${easyshell:command_category} with ${easyshell:command_name}"),
+ menuNameTypeGeneric3( 9, " with ", "${easyshell:command_category} with ${easyshell:command_os} ${easyshell:command_name}");
+ // attributes
+ private final int id;
+ private final String name;
+ private final String pattern;
+ // construct
+ MenuNameType(int id, String name, String pattern) {
+ this.id = id;
+ this.name = name;
+ this.pattern = pattern;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getPattern() {
+ return pattern;
+ }
+ public static MenuNameType getFromId(int id) {
+ MenuNameType ret = menuNameTypeUnknown;
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i].getId() == id) {
+ ret = MenuNameType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static MenuNameType getFromName(String name) {
+ MenuNameType ret = menuNameTypeUnknown;
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i].getName().equals(name)) {
+ ret = MenuNameType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static MenuNameType getFromEnum(String name) {
+ return MenuNameType.valueOf(name);
+ }
+ public static MenuNameType getFromPattern(String pattern) {
+ MenuNameType ret = menuNameTypeUnknown;
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i].getPattern().equals(pattern)) {
+ ret = MenuNameType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i] != menuNameTypeUnknown) {
+ list.add(MenuNameType.values()[i].getName());
+ }
+ }
+ return list;
+ }
+ public static List getAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i] != menuNameTypeUnknown) {
+ list.add(MenuNameType.values()[i]);
+ }
+ }
+ return list;
+ }
+ public static String[] getNamesAsArray() {
+ List list = getNamesAsList();
+ String[] arr = new String[list.size()];
+ for (int i=0;i list = getAsList();
+ MenuNameType[] arr = new MenuNameType[list.size()];
+ for (int i=0;i getPatternsAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < MenuNameType.values().length; i++) {
+ if (MenuNameType.values()[i] != menuNameTypeUnknown) {
+ list.add(MenuNameType.values()[i].getPattern());
+ }
+ }
+ return list;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/OS.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/OS.java
new file mode 100644
index 00000000..a037aa6b
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/OS.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum OS {
+ osUnknown("unknown", "Unknown"),
+ osWindows("windows", "Windows"),
+ osLinux("linux", "Linux"),
+ osMacOSX("macosx", "MAC OS X"),
+ osUnix("unix", "Unix"); // all Unix based, e.g. Linux and Max OS X etc.
+ // attributes
+ private final String id;
+ private final String name;
+ // construct
+ OS(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public String getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public static OS getFromId(String id) {
+ OS ret = osUnknown;
+ for(int i = 0; i < OS.values().length; i++) {
+ if (OS.values()[i].getId().equals(id)) {
+ ret = OS.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static OS getFromName(String name) {
+ OS ret = osUnknown;
+ for(int i = 0; i < OS.values().length; i++) {
+ if (OS.values()[i].getName().equals(name)) {
+ ret = OS.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static OS getFromEnum(String name) {
+ return OS.valueOf(name);
+ }
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < OS.values().length; i++) {
+ list.add(OS.values()[i].getName());
+ }
+ return list;
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/PresetType.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/PresetType.java
new file mode 100644
index 00000000..cd602215
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/PresetType.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum PresetType {
+ presetUnknown(-1, "Unknown"),
+ presetPlugin(0, "Plugin"),
+ presetUser(1, "User"),
+ presetPluginAndUser(2, "Plugin+User");
+ // attributes
+ private final int id;
+ private final String name;
+ // construct
+ PresetType(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public static PresetType getFromId(int id) {
+ PresetType ret = presetUnknown;
+ for(int i = 0; i < PresetType.values().length; i++) {
+ if (PresetType.values()[i].getId() == id) {
+ ret = PresetType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static PresetType getFromName(String name) {
+ PresetType ret = presetUnknown;
+ for(int i = 0; i < PresetType.values().length; i++) {
+ if (PresetType.values()[i].getName().equals(name)) {
+ ret = PresetType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static PresetType getFromEnum(String name) {
+ return PresetType.valueOf(name);
+ }
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < PresetType.values().length; i++) {
+ list.add(PresetType.values()[i].getName());
+ }
+ return list;
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Quotes.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Quotes.java
new file mode 100644
index 00000000..640d1b23
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Quotes.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+/**
+ * Quotes.
+ */
+public enum Quotes {
+ quotesUnknown(-1, "Unknown"),
+ quotesNo(0, "No"),
+ quotesSingle(1, "Single"),
+ quotesDouble(2, "Double"),
+ quotesAuto(3, "Double (automatic)"), // check if no quotes and space in string, then add
+ quotesAutoSingle(4, "Single (automatic)"), // check if no quotes and space in string, then add
+ quotesEscape(5, "Escape"); // check if no quotes and space in string, then escape
+ // attributes
+ private final int id;
+ private final String name;
+ // construct
+ Quotes(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public static Quotes getFromId(int id) {
+ Quotes ret = quotesUnknown;
+ for(int i = 0; i < Quotes.values().length; i++) {
+ if (Quotes.values()[i].getId() == id) {
+ ret = Quotes.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static Quotes getFromName(String name) {
+ Quotes ret = quotesUnknown;
+ for(int i = 0; i < Quotes.values().length; i++) {
+ if (Quotes.values()[i].getName().equals(name)) {
+ ret = Quotes.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static Quotes getFromEnum(String name) {
+ return Quotes.valueOf(name);
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/ResourceType.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/ResourceType.java
new file mode 100644
index 00000000..dde0c833
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/ResourceType.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum ResourceType {
+ resourceTypeUnknown(-1, "Unknown"),
+ resourceTypeFile(0, "File"),
+ resourceTypeDirectory(1, "Directory"),
+ resourceTypeFileOrDirectory(2, "File or Directory");
+ // attributes
+ private final int id;
+ private final String name;
+ // construct
+ ResourceType(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ public int getId() {
+ return id;
+ }
+ public String getName() {
+ return name;
+ }
+ public static ResourceType getFromId(int id) {
+ ResourceType ret = resourceTypeUnknown;
+ for(int i = 0; i < ResourceType.values().length; i++) {
+ if (ResourceType.values()[i].getId() == id) {
+ ret = ResourceType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static ResourceType getFromName(String name) {
+ ResourceType ret = resourceTypeUnknown;
+ for(int i = 0; i < ResourceType.values().length; i++) {
+ if (ResourceType.values()[i].getName().equals(name)) {
+ ret = ResourceType.values()[i];
+ break;
+ }
+ }
+ return ret;
+ }
+ public static ResourceType getFromEnum(String name) {
+ return ResourceType.valueOf(name);
+ }
+ public static List getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < ResourceType.values().length; i++) {
+ if (ResourceType.values()[i] != resourceTypeUnknown) {
+ list.add(ResourceType.values()[i].getName());
+ }
+ }
+ return list;
+ }
+ public static String[] getNamesAsArray() {
+ List list = getNamesAsList();
+ String[] arr = new String[list.size()];
+ for (int i=0;i getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < Variable.values().length; i++) {
+ list.add(Variable.values()[i].getName());
+ }
+ return list;
+ }
+ public static List getVariables(boolean visibleOnly, boolean internal) {
+ List list = new ArrayList<>();
+ for(int i = 0; i < Variable.values().length; i++) {
+ if (!visibleOnly || (visibleOnly && Variable.values()[i].isVisible())) {
+ if (internal == Variable.values()[i].isInternal()) {
+ list.add(Variable.values()[i]);
+ }
+ }
+ }
+ return list;
+ }
+ public static List getVisibleVariables() {
+ return getVariables(true, false);
+ }
+ public static List getInternalVariables() {
+ return getVariables(false, true);
+ }
+ public static Map getVariableInfoMap(boolean visibleOnly, boolean internal) {
+ Map map = new LinkedHashMap();
+ for(Variable variable : getVariables(visibleOnly, internal)) {
+ map.put(variable.getFullVariableName(), variable.getDescription());
+ }
+ return map;
+ }
+ public static Map getVariableInfoMap() {
+ return getVariableInfoMap(true, false);
+ }
+ public static Map getInternalVariableInfoMap() {
+ return getVariableInfoMap(false, true);
+ }
+ public static Map getEclipseVariableInfoMap() {
+ Map map = new LinkedHashMap();
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+ IValueVariable[] valueVariables = variableManager.getValueVariables();
+ for (IValueVariable variable : valueVariables) {
+ map.put(varBegin + variable.getName() + varEnd, variable.getDescription());
+ }
+ IDynamicVariable[] dynamicVariables = variableManager.getDynamicVariables();
+ for (IDynamicVariable variable : dynamicVariables) {
+ map.put(varBegin + variable.getName() + varEnd, variable.getDescription());
+ }
+ return map;
+ }
+ public static int getFirstIndex() {
+ return 0;
+ }
+}
diff --git a/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Variables.java b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Variables.java
new file mode 100644
index 00000000..733e8711
--- /dev/null
+++ b/plugin/src/de/anbos/eclipse/easyshell/plugin/types/Variables.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - 2016 Andre Bossert.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package de.anbos.eclipse.easyshell.plugin.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Variables {
+ static Map map = new HashMap();
+ public static Map getMap() {
+ return map;
+ }
+ static {
+ for(int i=0;i getNamesAsList() {
+ List list = new ArrayList();
+ for(int i = 0; i < Version.values().length; i++) {
+ list.add(Version.values()[i].getName());
+ }
+ return list;
+ }
+}
diff --git a/pom.xml b/pom.xml
index 84f76aaa..0589ebfe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
0.24.0
- Eclipse-4.5
+ Eclipse-4.6
UTF-8
diff --git a/site/images/EasyShell_2.0_context_menu_windows.png b/site/images/EasyShell_2.0_context_menu_windows.png
new file mode 100644
index 00000000..a67531a6
Binary files /dev/null and b/site/images/EasyShell_2.0_context_menu_windows.png differ
diff --git a/site/images/EasyShell_2.0_multi-selection_dialog_windows.png b/site/images/EasyShell_2.0_multi-selection_dialog_windows.png
new file mode 100644
index 00000000..0e21634f
Binary files /dev/null and b/site/images/EasyShell_2.0_multi-selection_dialog_windows.png differ
diff --git a/site/images/EasyShell_2.0_popup_menu_windows.png b/site/images/EasyShell_2.0_popup_menu_windows.png
new file mode 100644
index 00000000..db7143e1
Binary files /dev/null and b/site/images/EasyShell_2.0_popup_menu_windows.png differ
diff --git a/site/images/EasyShell_2.0_preferences_command.png b/site/images/EasyShell_2.0_preferences_command.png
new file mode 100644
index 00000000..b1bd0ca2
Binary files /dev/null and b/site/images/EasyShell_2.0_preferences_command.png differ
diff --git a/site/images/EasyShell_2.0_preferences_command_new.png b/site/images/EasyShell_2.0_preferences_command_new.png
new file mode 100644
index 00000000..0306decf
Binary files /dev/null and b/site/images/EasyShell_2.0_preferences_command_new.png differ
diff --git a/site/images/EasyShell_2.0_preferences_menu.png b/site/images/EasyShell_2.0_preferences_menu.png
new file mode 100644
index 00000000..70f2adb5
Binary files /dev/null and b/site/images/EasyShell_2.0_preferences_menu.png differ
diff --git a/site/images/EasyShell_2.0_preferences_menu_new.png b/site/images/EasyShell_2.0_preferences_menu_new.png
new file mode 100644
index 00000000..d3381ca5
Binary files /dev/null and b/site/images/EasyShell_2.0_preferences_menu_new.png differ
diff --git a/site/images/EasyShell_2.0_preferences_menu_new_content_assist.png b/site/images/EasyShell_2.0_preferences_menu_new_content_assist.png
new file mode 100644
index 00000000..03fab811
Binary files /dev/null and b/site/images/EasyShell_2.0_preferences_menu_new_content_assist.png differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160603-2346/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160603-2346/artifacts.jar
deleted file mode 100644
index a777f211..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160603-2346/artifacts.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160603-2346/content.jar b/site/updates/testing/2.0/2.0.0.v20160603-2346/content.jar
deleted file mode 100644
index 83fa8747..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160603-2346/content.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160603-2346/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160603-2346.jar b/site/updates/testing/2.0/2.0.0.v20160603-2346/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160603-2346.jar
deleted file mode 100644
index 237e98f4..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160603-2346/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160603-2346.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160603-2346/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160603-2346.jar b/site/updates/testing/2.0/2.0.0.v20160603-2346/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160603-2346.jar
deleted file mode 100644
index 25e62ed7..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160603-2346/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160603-2346.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160608-1116/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160608-1116/artifacts.jar
deleted file mode 100644
index 902c4473..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160608-1116/artifacts.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160608-1116/content.jar b/site/updates/testing/2.0/2.0.0.v20160608-1116/content.jar
deleted file mode 100644
index 28967df8..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160608-1116/content.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160608-1116/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160608-1116.jar b/site/updates/testing/2.0/2.0.0.v20160608-1116/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160608-1116.jar
deleted file mode 100644
index 84815f02..00000000
Binary files a/site/updates/testing/2.0/2.0.0.v20160608-1116/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160608-1116.jar and /dev/null differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160719-1230/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160719-1230/artifacts.jar
new file mode 100644
index 00000000..46838646
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160719-1230/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160719-1230/content.jar b/site/updates/testing/2.0/2.0.0.v20160719-1230/content.jar
new file mode 100644
index 00000000..2c418cf2
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160719-1230/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160719-1230/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160719-1230.jar b/site/updates/testing/2.0/2.0.0.v20160719-1230/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160719-1230.jar
new file mode 100644
index 00000000..4349377a
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160719-1230/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160719-1230.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160719-1230/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160719-1230.jar b/site/updates/testing/2.0/2.0.0.v20160719-1230/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160719-1230.jar
new file mode 100644
index 00000000..6c64c61a
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160719-1230/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160719-1230.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2110/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160726-2110/artifacts.jar
new file mode 100644
index 00000000..683d20fa
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2110/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2110/content.jar b/site/updates/testing/2.0/2.0.0.v20160726-2110/content.jar
new file mode 100644
index 00000000..8ebcff4f
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2110/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160608-1116/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160608-1116.jar b/site/updates/testing/2.0/2.0.0.v20160726-2110/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2110.jar
similarity index 67%
rename from site/updates/testing/2.0/2.0.0.v20160608-1116/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160608-1116.jar
rename to site/updates/testing/2.0/2.0.0.v20160726-2110/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2110.jar
index 06c59547..8f7f5861 100644
Binary files a/site/updates/testing/2.0/2.0.0.v20160608-1116/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160608-1116.jar and b/site/updates/testing/2.0/2.0.0.v20160726-2110/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2110.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2110/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2110.jar b/site/updates/testing/2.0/2.0.0.v20160726-2110/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2110.jar
new file mode 100644
index 00000000..e2947a1d
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2110/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2110.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2133/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160726-2133/artifacts.jar
new file mode 100644
index 00000000..0ce5b942
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2133/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2133/content.jar b/site/updates/testing/2.0/2.0.0.v20160726-2133/content.jar
new file mode 100644
index 00000000..ee83d9f5
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2133/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2133/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2133.jar b/site/updates/testing/2.0/2.0.0.v20160726-2133/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2133.jar
new file mode 100644
index 00000000..6c85b4d7
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2133/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160726-2133.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160726-2133/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2133.jar b/site/updates/testing/2.0/2.0.0.v20160726-2133/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2133.jar
new file mode 100644
index 00000000..e7e199cb
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160726-2133/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160726-2133.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160823-1756/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160823-1756/artifacts.jar
new file mode 100644
index 00000000..ee2c8207
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160823-1756/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160823-1756/content.jar b/site/updates/testing/2.0/2.0.0.v20160823-1756/content.jar
new file mode 100644
index 00000000..dd0f6839
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160823-1756/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160823-1756/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160823-1756.jar b/site/updates/testing/2.0/2.0.0.v20160823-1756/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160823-1756.jar
new file mode 100644
index 00000000..35424e90
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160823-1756/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160823-1756.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160823-1756/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160823-1756.jar b/site/updates/testing/2.0/2.0.0.v20160823-1756/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160823-1756.jar
new file mode 100644
index 00000000..db01ef8f
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160823-1756/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160823-1756.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160919-1856/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160919-1856/artifacts.jar
new file mode 100644
index 00000000..3038c61c
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160919-1856/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160919-1856/content.jar b/site/updates/testing/2.0/2.0.0.v20160919-1856/content.jar
new file mode 100644
index 00000000..8b89da62
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160919-1856/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160919-1856/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160919-1856.jar b/site/updates/testing/2.0/2.0.0.v20160919-1856/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160919-1856.jar
new file mode 100644
index 00000000..b22b96d5
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160919-1856/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160919-1856.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160919-1856/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160919-1856.jar b/site/updates/testing/2.0/2.0.0.v20160919-1856/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160919-1856.jar
new file mode 100644
index 00000000..1f79ebd4
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160919-1856/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160919-1856.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160923-1117/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160923-1117/artifacts.jar
new file mode 100644
index 00000000..182a1d9e
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160923-1117/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160923-1117/content.jar b/site/updates/testing/2.0/2.0.0.v20160923-1117/content.jar
new file mode 100644
index 00000000..7fa26097
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160923-1117/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160923-1117/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160923-1117.jar b/site/updates/testing/2.0/2.0.0.v20160923-1117/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160923-1117.jar
new file mode 100644
index 00000000..a4ec51ce
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160923-1117/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160923-1117.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160923-1117/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160923-1117.jar b/site/updates/testing/2.0/2.0.0.v20160923-1117/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160923-1117.jar
new file mode 100644
index 00000000..d2eca8ca
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160923-1117/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160923-1117.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160927-2006/artifacts.jar b/site/updates/testing/2.0/2.0.0.v20160927-2006/artifacts.jar
new file mode 100644
index 00000000..bbb26ab0
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160927-2006/artifacts.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160927-2006/content.jar b/site/updates/testing/2.0/2.0.0.v20160927-2006/content.jar
new file mode 100644
index 00000000..525c1bc4
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160927-2006/content.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160927-2006/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160927-2006.jar b/site/updates/testing/2.0/2.0.0.v20160927-2006/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160927-2006.jar
new file mode 100644
index 00000000..c42e244f
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160927-2006/features/de.anbos.eclipse.easyshell.feature_2.0.0.v20160927-2006.jar differ
diff --git a/site/updates/testing/2.0/2.0.0.v20160927-2006/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160927-2006.jar b/site/updates/testing/2.0/2.0.0.v20160927-2006/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160927-2006.jar
new file mode 100644
index 00000000..c72c012f
Binary files /dev/null and b/site/updates/testing/2.0/2.0.0.v20160927-2006/plugins/de.anbos.eclipse.easyshell.plugin_2.0.0.v20160927-2006.jar differ
diff --git a/site/updates/testing/2.0/compositeArtifacts.xml b/site/updates/testing/2.0/compositeArtifacts.xml
index 2a44a521..9deabd55 100644
--- a/site/updates/testing/2.0/compositeArtifacts.xml
+++ b/site/updates/testing/2.0/compositeArtifacts.xml
@@ -2,11 +2,16 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
diff --git a/site/updates/testing/2.0/compositeContent.xml b/site/updates/testing/2.0/compositeContent.xml
index c20f2b11..c09cc8ac 100644
--- a/site/updates/testing/2.0/compositeContent.xml
+++ b/site/updates/testing/2.0/compositeContent.xml
@@ -2,11 +2,16 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
diff --git a/uuids.txt b/uuids.txt
new file mode 100644
index 00000000..6bae00bb
--- /dev/null
+++ b/uuids.txt
@@ -0,0 +1,118 @@
+UUIDs V4 generated by https://www.uuidgenerator.net/
+
+EasyShell Defaults 2.0
+
+Windows:
+cd361a40-bb37-4fa2-9d2e-b62794294a59
+f740984b-e9d5-4ebc-b9b5-c6b8527f886c
+ae0e5b6e-0b20-4c52-9708-ba7e317d1dee
+9cb0d29e-93aa-4139-93d2-079ba63ff726
+af2968d0-3a1a-40db-b3cb-e2e16293a285
+5b1e3806-a9ab-4866-b660-823ac388a575
+2002e587-70a3-4204-b1a5-6faf6271ad08
+60fd43d2-d837-41d1-aaa3-3f5cab6bf0fb
+af6d97f2-f0a8-46e2-8234-74c0ee3e6007
+24419204-c8e5-4d79-a7b8-b14e93077cf0
+ee790c7f-9c6d-40f9-84f6-51a948a59d45
+d2726c3f-6da3-46b5-8029-1c63d0ff6bd2
+03e6678b-f67f-42ed-b65f-6b6f06ec0e8f
+1bd62e22-cd93-4136-b643-1cbb9579c195
+c2b73077-ffd9-4fb7-9793-189be9f13ebb
+c57a5d9f-491a-4b21-8a8b-9941b01cc049
+e487327c-dfdb-42e7-bf16-3b81a34e5703
+
+
+Linux:
+51ed300a-35d0-4e67-a5f8-6ebd7012a564
+c2b1612b-9037-484a-a763-d013679bdbe7
+e634b20a-cf57-47f0-aa27-b8fc95917f35
+8873342e-e02b-4feb-8f56-9f52524c0f46
+53f7b6a3-f8d5-4682-b0ef-1d6ceec5cc8a
+c6126958-32f2-4f96-9933-69ddd956f2e9
+8175f9a7-4e54-4367-a6b6-251aedc187df
+adf40e10-0ee9-4abe-8282-aff7d51bb68d
+8e366a34-5ce2-4430-bc21-20e176e0128c
+2a979af5-86a7-440e-b4f0-8442e85412e4
+f573a4de-22fa-467f-a433-042d0992ab28
+1cc39e61-8d8d-4493-8baa-7a11ff01c06c
+e5b3b0f6-e27c-4a2d-aa1a-caef784dd3da
+22ec69ee-e39e-4fa6-a241-4e950d3235af
+025e2f56-3d2e-47e1-8daa-c2c74049b150
+cb9a8c00-89bc-453c-aeff-ae94c0d9e44a
+1747b189-ed7f-4546-8c98-f99a3c1fb13b
+4fbfa632-5455-4384-9f9e-773603a12bea
+8e14d26d-2981-4b81-b8e5-6a942c6f2c59
+cf8d4d60-10f4-4a31-a423-676d02d974e0
+
+MacOSX:
+e6918fe0-38b8-450b-a4be-d9eecc0dc0b4
+db61d61e-8bf4-41d0-a1d8-00379e4d1db1 // Mac OS X Run disabled now!
+f6bcdd71-4687-46d8-bf34-2780bafd762a
+
+All:
+33043fe3-1a5f-46d7-b94e-9a02ef204e7d
+67aa9dff-6bbb-4b47-8b43-8a82a7a279fa
+88989d78-cf17-4750-91fc-6260055743ae
+cd32fa5a-34d7-4551-8bd0-3aae0dc444d0 // reused: was MAC OS X clipboard before
+e6de32cc-342a-46a0-a766-ac74e7e4000d
+95cacf98-9dfc-473f-b5d3-fe4961e66ae1
+
+Do not use
+-
+
+Free
+
+771c0bac-cdb2-47fe-a030-6b830d366da1
+61c4fef4-470a-45b1-98df-ccf9d7d91143
+40eee8f2-b29e-490b-8612-59c2b76a704d
+9a11b3eb-497c-44dd-9813-a841a32465c1
+d07df65d-ccc5-4c71-82f8-3a17e608516b
+f2b970ed-ef98-4ce2-861c-20f44a471f49
+8770e3c5-cd60-4c01-b1c0-8b7754b91b27
+94b0c584-0316-4dac-bd40-2ab1a0428d32
+554d1dc7-4f26-4be9-bc2a-86d5a41ec606
+1df6da5c-5455-4372-a2ae-6b1b3f910e76
+d93cd39e-1f78-47e2-90d3-88b8c8495c61
+d13ad020-aeb8-4b48-acc6-4e09dea4913a
+a6728fb1-89f3-4c3a-8ab0-5c57b6d7ee48
+3c3358b2-3541-4d13-b5bc-137ba239dae7
+837716a1-5475-42fa-b40b-6d3da56197a1
+7137aada-940a-4b03-90b2-f468d696019a
+4942a4bd-536e-47f4-9e98-f893a5d40a91
+5695fab2-db44-42af-a305-720fd0828557
+d8ea14e6-f21f-417c-ba9b-3c1657e0b2ee
+35a4c2ac-a6b9-42b9-8fae-aa5ae16cd785
+aac5d88b-d404-4d6b-84f9-1c8446bd7714
+84ec453c-f4b3-4610-9210-6b02cde111d4
+015a75a8-5993-46a3-8307-18bdbd94bc17
+b9ded5f2-1dcc-40e5-be01-990b64a21e93
+2e2fc87e-d513-4864-8124-e6a12675445e
+d7602663-d0b6-472f-a8e7-f80224142615
+ebd16ef0-0b5d-41d9-87d6-53081a534ebd
+45f55881-f931-45eb-b050-6fd6bf33108c
+9dea18e6-6fd2-4445-84ef-db6d23d107c3
+6ae09ecc-04b5-4c4e-a9e5-a2a787208eb1
+3484a83d-7988-497d-b068-cc96e74717b1
+213e0ae1-d548-4362-bb97-9b27e615d939
+939ff127-1b7d-4528-8d40-bd9607f5b3d2
+b3f7360a-6a37-4eb9-9b70-9387caffe969
+1cb91d59-02b7-4245-b783-fd963d597c47
+53455bec-58b3-4d21-ab6f-bdfb4fb1a950
+4d7c100b-3918-4fc9-9f39-9c3d188abd0b
+2cfc91d5-4449-46ed-bc6e-0e2ea300aadb
+a9eb9cc0-948b-4ca7-b86c-ad5116396c3f
+7f8492a5-3423-4ffe-9e4c-0aa76319475a
+fdf63c8c-f6c1-4392-8f09-c3bdef6ffe34
+48722b08-dc70-4059-915b-a3454a75eca9
+5ca27361-092a-4955-b8b4-0db7b6d6f1ba
+0494f4e4-d0ea-4700-86eb-ea9ac58cb74f
+fefa90d8-3b72-4313-bc48-e743ca5d903e
+6e08abbc-d9ee-407a-a7ad-5e14dafc0fa2
+22da92a3-05df-4179-b9a5-3b75131a4e0b
+4bfb0295-476e-4503-af55-e9eb89eb72ab
+ce55f175-74a3-447d-9bba-9b24aeaa2b0d
+fe0192d8-e884-4463-bc93-2746f44be0a3
+6c528020-02c1-4245-9eab-60dff12f89b0
+f01bbb14-70ae-4b24-a112-73a71496c6b8
+a2a9c831-bb20-42db-bbe1-c71b6b5019c7
+ee2db486-4df3-42c1-b19e-03761ffac105