diff options
Diffstat (limited to 'com.gluster.storage.management.gui')
164 files changed, 10193 insertions, 0 deletions
diff --git a/com.gluster.storage.management.gui/.classpath b/com.gluster.storage.management.gui/.classpath new file mode 100644 index 00000000..f9a8d357 --- /dev/null +++ b/com.gluster.storage.management.gui/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="lib" path="/data/downloads/xstream/xstream-1.3.1/lib/xstream-1.3.1.jar"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/com.gluster.storage.management.gui/.project b/com.gluster.storage.management.gui/.project new file mode 100644 index 00000000..84ab78e4 --- /dev/null +++ b/com.gluster.storage.management.gui/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>com.gluster.storage.management.gui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/com.gluster.storage.management.gui/.settings/org.eclipse.jdt.core.prefs b/com.gluster.storage.management.gui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..abf7cf5a --- /dev/null +++ b/com.gluster.storage.management.gui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Nov 11 15:40:30 IST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/com.gluster.storage.management.gui/META-INF/MANIFEST.MF b/com.gluster.storage.management.gui/META-INF/MANIFEST.MF new file mode 100644 index 00000000..7c0ba23a --- /dev/null +++ b/com.gluster.storage.management.gui/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: glustersp-gui +Bundle-SymbolicName: com.gluster.storage.management.gui;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.gluster.storage.management.gui.Activator +Bundle-Vendor: Gluster +Require-Bundle: org.eclipse.ui;bundle-version="3.6.1", + org.eclipse.core.runtime;bundle-version="3.6.0", + org.eclipse.ui.forms;bundle-version="3.5.2", + org.eclipse.rcp;bundle-version="3.6.0", + com.gluster.storage.management.core;bundle-version="1.0.0", + com.gluster.storage.management.client;bundle-version="1.0.0", + org.eclipse.core.databinding;bundle-version="1.3.100", + org.eclipse.jface.databinding;bundle-version="1.4.0", + org.eclipse.core.databinding.property;bundle-version="1.3.0", + org.eclipse.core.databinding.beans;bundle-version="1.2.100", + org.eclipse.birt.chart.engine;bundle-version="2.6.1", + org.eclipse.birt.chart.engine.extension;bundle-version="2.6.1", + org.eclipse.birt.chart.device.extension;bundle-version="2.6.1", + org.eclipse.birt.chart.device.swt;bundle-version="2.6.1", + com.ibm.icu;bundle-version="4.2.1", + com.richclientgui.rcptoolbox;bundle-version="1.0.5", + org.eclipse.core.resources +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: lib/jersey-client-1.4.jar, + lib/jersey-core-1.4.jar, + . diff --git a/com.gluster.storage.management.gui/build.properties b/com.gluster.storage.management.gui/build.properties new file mode 100644 index 00000000..83944c06 --- /dev/null +++ b/com.gluster.storage.management.gui/build.properties @@ -0,0 +1,17 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + icons/,\ + product_lg.gif,\ + splash.bmp,\ + lib/jersey-client-1.4.jar,\ + lib/jersey-core-1.4.jar,\ + splash/,\ + images/,\ + plugin.xml,\ + preferences.ini +src.includes = icons/,\ + splash.bmp,\ + images/,\ + preferences.ini diff --git a/com.gluster.storage.management.gui/icons/arrow-down.png b/com.gluster.storage.management.gui/icons/arrow-down.png Binary files differnew file mode 100644 index 00000000..7f23e3f4 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/arrow-down.png diff --git a/com.gluster.storage.management.gui/icons/arrow-up.png b/com.gluster.storage.management.gui/icons/arrow-up.png Binary files differnew file mode 100644 index 00000000..b8ad3050 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/arrow-up.png diff --git a/com.gluster.storage.management.gui/icons/cluster.png b/com.gluster.storage.management.gui/icons/cluster.png Binary files differnew file mode 100644 index 00000000..c9348a21 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/cluster.png diff --git a/com.gluster.storage.management.gui/icons/disk-migrate.png b/com.gluster.storage.management.gui/icons/disk-migrate.png Binary files differnew file mode 100644 index 00000000..2de348dc --- /dev/null +++ b/com.gluster.storage.management.gui/icons/disk-migrate.png diff --git a/com.gluster.storage.management.gui/icons/disk-uninitialized.png b/com.gluster.storage.management.gui/icons/disk-uninitialized.png Binary files differnew file mode 100644 index 00000000..b982d118 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/disk-uninitialized.png diff --git a/com.gluster.storage.management.gui/icons/disk.png b/com.gluster.storage.management.gui/icons/disk.png Binary files differnew file mode 100644 index 00000000..99d532e8 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/disk.png diff --git a/com.gluster.storage.management.gui/icons/disks.png b/com.gluster.storage.management.gui/icons/disks.png Binary files differnew file mode 100644 index 00000000..fc5a52f5 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/disks.png diff --git a/com.gluster.storage.management.gui/icons/folder.png b/com.gluster.storage.management.gui/icons/folder.png Binary files differnew file mode 100644 index 00000000..784e8fa4 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/folder.png diff --git a/com.gluster.storage.management.gui/icons/gluster_icon.png b/com.gluster.storage.management.gui/icons/gluster_icon.png Binary files differnew file mode 100644 index 00000000..f92e472d --- /dev/null +++ b/com.gluster.storage.management.gui/icons/gluster_icon.png diff --git a/com.gluster.storage.management.gui/icons/group.png b/com.gluster.storage.management.gui/icons/group.png Binary files differnew file mode 100644 index 00000000..7fb4e1f1 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/group.png diff --git a/com.gluster.storage.management.gui/icons/gsn.png b/com.gluster.storage.management.gui/icons/gsn.png Binary files differnew file mode 100644 index 00000000..68f21d30 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/gsn.png diff --git a/com.gluster.storage.management.gui/icons/mail.ico b/com.gluster.storage.management.gui/icons/mail.ico Binary files differnew file mode 100644 index 00000000..b0000611 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/mail.ico diff --git a/com.gluster.storage.management.gui/icons/minus-white.png b/com.gluster.storage.management.gui/icons/minus-white.png Binary files differnew file mode 100644 index 00000000..8efd5d33 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/minus-white.png diff --git a/com.gluster.storage.management.gui/icons/network-interface.png b/com.gluster.storage.management.gui/icons/network-interface.png Binary files differnew file mode 100644 index 00000000..24ca7370 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/network-interface.png diff --git a/com.gluster.storage.management.gui/icons/network-interfaces.png b/com.gluster.storage.management.gui/icons/network-interfaces.png Binary files differnew file mode 100644 index 00000000..752968bb --- /dev/null +++ b/com.gluster.storage.management.gui/icons/network-interfaces.png diff --git a/com.gluster.storage.management.gui/icons/network-interfaces1.png b/com.gluster.storage.management.gui/icons/network-interfaces1.png Binary files differnew file mode 100644 index 00000000..af438028 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/network-interfaces1.png diff --git a/com.gluster.storage.management.gui/icons/plus-white.png b/com.gluster.storage.management.gui/icons/plus-white.png Binary files differnew file mode 100644 index 00000000..c765946e --- /dev/null +++ b/com.gluster.storage.management.gui/icons/plus-white.png diff --git a/com.gluster.storage.management.gui/icons/preferences.png b/com.gluster.storage.management.gui/icons/preferences.png Binary files differnew file mode 100644 index 00000000..7b93eb05 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/preferences.png diff --git a/com.gluster.storage.management.gui/icons/progress-bar.png b/com.gluster.storage.management.gui/icons/progress-bar.png Binary files differnew file mode 100644 index 00000000..c7db00ae --- /dev/null +++ b/com.gluster.storage.management.gui/icons/progress-bar.png diff --git a/com.gluster.storage.management.gui/icons/question.png b/com.gluster.storage.management.gui/icons/question.png Binary files differnew file mode 100644 index 00000000..30a47032 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/question.png diff --git a/com.gluster.storage.management.gui/icons/sample.gif b/com.gluster.storage.management.gui/icons/sample.gif Binary files differnew file mode 100644 index 00000000..34fb3c9d --- /dev/null +++ b/com.gluster.storage.management.gui/icons/sample.gif diff --git a/com.gluster.storage.management.gui/icons/sample.icns b/com.gluster.storage.management.gui/icons/sample.icns Binary files differnew file mode 100644 index 00000000..1e92ccce --- /dev/null +++ b/com.gluster.storage.management.gui/icons/sample.icns diff --git a/com.gluster.storage.management.gui/icons/sample2.gif b/com.gluster.storage.management.gui/icons/sample2.gif Binary files differnew file mode 100644 index 00000000..252d7ebc --- /dev/null +++ b/com.gluster.storage.management.gui/icons/sample2.gif diff --git a/com.gluster.storage.management.gui/icons/sample3.gif b/com.gluster.storage.management.gui/icons/sample3.gif Binary files differnew file mode 100644 index 00000000..b949ac94 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/sample3.gif diff --git a/com.gluster.storage.management.gui/icons/search.png b/com.gluster.storage.management.gui/icons/search.png Binary files differnew file mode 100644 index 00000000..b4b23129 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/search.png diff --git a/com.gluster.storage.management.gui/icons/server-add-big.png b/com.gluster.storage.management.gui/icons/server-add-big.png Binary files differnew file mode 100644 index 00000000..d96b8175 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/server-add-big.png diff --git a/com.gluster.storage.management.gui/icons/server-add.png b/com.gluster.storage.management.gui/icons/server-add.png Binary files differnew file mode 100644 index 00000000..db604ee3 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/server-add.png diff --git a/com.gluster.storage.management.gui/icons/server-remove.png b/com.gluster.storage.management.gui/icons/server-remove.png Binary files differnew file mode 100644 index 00000000..5e9b2683 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/server-remove.png diff --git a/com.gluster.storage.management.gui/icons/server.png b/com.gluster.storage.management.gui/icons/server.png Binary files differnew file mode 100644 index 00000000..9bc37dce --- /dev/null +++ b/com.gluster.storage.management.gui/icons/server.png diff --git a/com.gluster.storage.management.gui/icons/servers.png b/com.gluster.storage.management.gui/icons/servers.png Binary files differnew file mode 100644 index 00000000..b18a74d9 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/servers.png diff --git a/com.gluster.storage.management.gui/icons/star-small.png b/com.gluster.storage.management.gui/icons/star-small.png Binary files differnew file mode 100644 index 00000000..fef14263 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/star-small.png diff --git a/com.gluster.storage.management.gui/icons/status-offline-circle.png b/com.gluster.storage.management.gui/icons/status-offline-circle.png Binary files differnew file mode 100644 index 00000000..20d6f5ea --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-offline-circle.png diff --git a/com.gluster.storage.management.gui/icons/status-offline-small.png b/com.gluster.storage.management.gui/icons/status-offline-small.png Binary files differnew file mode 100644 index 00000000..39d47690 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-offline-small.png diff --git a/com.gluster.storage.management.gui/icons/status-offline.png b/com.gluster.storage.management.gui/icons/status-offline.png Binary files differnew file mode 100644 index 00000000..6b9fa6dd --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-offline.png diff --git a/com.gluster.storage.management.gui/icons/status-online-circle.png b/com.gluster.storage.management.gui/icons/status-online-circle.png Binary files differnew file mode 100644 index 00000000..210b1a6c --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-online-circle.png diff --git a/com.gluster.storage.management.gui/icons/status-online-small.png b/com.gluster.storage.management.gui/icons/status-online-small.png Binary files differnew file mode 100644 index 00000000..8e87f2e5 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-online-small.png diff --git a/com.gluster.storage.management.gui/icons/status-online.png b/com.gluster.storage.management.gui/icons/status-online.png Binary files differnew file mode 100644 index 00000000..2414885b --- /dev/null +++ b/com.gluster.storage.management.gui/icons/status-online.png diff --git a/com.gluster.storage.management.gui/icons/stop.png b/com.gluster.storage.management.gui/icons/stop.png Binary files differnew file mode 100644 index 00000000..0cfd5859 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/stop.png diff --git a/com.gluster.storage.management.gui/icons/ui-check-box-mix.png b/com.gluster.storage.management.gui/icons/ui-check-box-mix.png Binary files differnew file mode 100644 index 00000000..3c961711 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/ui-check-box-mix.png diff --git a/com.gluster.storage.management.gui/icons/ui-check-box-uncheck.png b/com.gluster.storage.management.gui/icons/ui-check-box-uncheck.png Binary files differnew file mode 100644 index 00000000..ba447358 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/ui-check-box-uncheck.png diff --git a/com.gluster.storage.management.gui/icons/ui-check-box.png b/com.gluster.storage.management.gui/icons/ui-check-box.png Binary files differnew file mode 100644 index 00000000..07f3522a --- /dev/null +++ b/com.gluster.storage.management.gui/icons/ui-check-box.png diff --git a/com.gluster.storage.management.gui/icons/volume-create-big.png b/com.gluster.storage.management.gui/icons/volume-create-big.png Binary files differnew file mode 100644 index 00000000..231bae5b --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-create-big.png diff --git a/com.gluster.storage.management.gui/icons/volume-create.png b/com.gluster.storage.management.gui/icons/volume-create.png Binary files differnew file mode 100644 index 00000000..9c8a9da4 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-create.png diff --git a/com.gluster.storage.management.gui/icons/volume-delete.png b/com.gluster.storage.management.gui/icons/volume-delete.png Binary files differnew file mode 100644 index 00000000..86f7fbc2 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-delete.png diff --git a/com.gluster.storage.management.gui/icons/volume-edit.png b/com.gluster.storage.management.gui/icons/volume-edit.png Binary files differnew file mode 100644 index 00000000..291bfc76 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-edit.png diff --git a/com.gluster.storage.management.gui/icons/volume-rebalance.png b/com.gluster.storage.management.gui/icons/volume-rebalance.png Binary files differnew file mode 100644 index 00000000..e213cd5b --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-rebalance.png diff --git a/com.gluster.storage.management.gui/icons/volume-start.png b/com.gluster.storage.management.gui/icons/volume-start.png Binary files differnew file mode 100644 index 00000000..aace63ad --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-start.png diff --git a/com.gluster.storage.management.gui/icons/volume-stop-1.png b/com.gluster.storage.management.gui/icons/volume-stop-1.png Binary files differnew file mode 100644 index 00000000..0cfd5859 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-stop-1.png diff --git a/com.gluster.storage.management.gui/icons/volume-stop.png b/com.gluster.storage.management.gui/icons/volume-stop.png Binary files differnew file mode 100644 index 00000000..7af3a518 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume-stop.png diff --git a/com.gluster.storage.management.gui/icons/volume.png b/com.gluster.storage.management.gui/icons/volume.png Binary files differnew file mode 100644 index 00000000..46b7564a --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume.png diff --git a/com.gluster.storage.management.gui/icons/volume1.png b/com.gluster.storage.management.gui/icons/volume1.png Binary files differnew file mode 100644 index 00000000..5e23dbc8 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volume1.png diff --git a/com.gluster.storage.management.gui/icons/volumes.png b/com.gluster.storage.management.gui/icons/volumes.png Binary files differnew file mode 100644 index 00000000..80dfa195 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volumes.png diff --git a/com.gluster.storage.management.gui/icons/volumes1.png b/com.gluster.storage.management.gui/icons/volumes1.png Binary files differnew file mode 100644 index 00000000..448e46fd --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volumes1.png diff --git a/com.gluster.storage.management.gui/icons/volumes2.png b/com.gluster.storage.management.gui/icons/volumes2.png Binary files differnew file mode 100644 index 00000000..0905f933 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volumes2.png diff --git a/com.gluster.storage.management.gui/icons/volumes3.png b/com.gluster.storage.management.gui/icons/volumes3.png Binary files differnew file mode 100644 index 00000000..7e90d397 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/volumes3.png diff --git a/com.gluster.storage.management.gui/icons/world.png b/com.gluster.storage.management.gui/icons/world.png Binary files differnew file mode 100644 index 00000000..68f21d30 --- /dev/null +++ b/com.gluster.storage.management.gui/icons/world.png diff --git a/com.gluster.storage.management.gui/images/gauge.png b/com.gluster.storage.management.gui/images/gauge.png Binary files differnew file mode 100644 index 00000000..6f5764ea --- /dev/null +++ b/com.gluster.storage.management.gui/images/gauge.png diff --git a/com.gluster.storage.management.gui/images/gauge_small.png b/com.gluster.storage.management.gui/images/gauge_small.png Binary files differnew file mode 100644 index 00000000..71e424fe --- /dev/null +++ b/com.gluster.storage.management.gui/images/gauge_small.png diff --git a/com.gluster.storage.management.gui/images/progress_image_empty.png b/com.gluster.storage.management.gui/images/progress_image_empty.png Binary files differnew file mode 100644 index 00000000..590097ad --- /dev/null +++ b/com.gluster.storage.management.gui/images/progress_image_empty.png diff --git a/com.gluster.storage.management.gui/images/progress_image_filled_danger.png b/com.gluster.storage.management.gui/images/progress_image_filled_danger.png Binary files differnew file mode 100644 index 00000000..97704230 --- /dev/null +++ b/com.gluster.storage.management.gui/images/progress_image_filled_danger.png diff --git a/com.gluster.storage.management.gui/images/progress_image_filled_safe.png b/com.gluster.storage.management.gui/images/progress_image_filled_safe.png Binary files differnew file mode 100644 index 00000000..ae4e3c69 --- /dev/null +++ b/com.gluster.storage.management.gui/images/progress_image_filled_safe.png diff --git a/com.gluster.storage.management.gui/images/progress_image_left.png b/com.gluster.storage.management.gui/images/progress_image_left.png Binary files differnew file mode 100644 index 00000000..97704230 --- /dev/null +++ b/com.gluster.storage.management.gui/images/progress_image_left.png diff --git a/com.gluster.storage.management.gui/images/progress_image_right.png b/com.gluster.storage.management.gui/images/progress_image_right.png Binary files differnew file mode 100644 index 00000000..97704230 --- /dev/null +++ b/com.gluster.storage.management.gui/images/progress_image_right.png diff --git a/com.gluster.storage.management.gui/plugin.xml b/com.gluster.storage.management.gui/plugin.xml new file mode 100644 index 00000000..8097f4ef --- /dev/null +++ b/com.gluster.storage.management.gui/plugin.xml @@ -0,0 +1,824 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + id="application" + point="org.eclipse.core.runtime.applications"> + <application> + <run + class="com.gluster.storage.management.gui.Application"> + </run> + </application> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + name="Gluster Perspective" + class="com.gluster.storage.management.gui.Perspective" + id="com.gluster.storage.management.gui.perspective"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.views"> + <view + class="com.gluster.storage.management.gui.views.navigator.NavigationView" + icon="icons/world.png" + id="com.gluster.storage.management.gui.views.navigator" + name="Cluster Navigation Tree" + restorable="true"> + </view> + <view + allowMultiple="false" + class="com.gluster.storage.management.gui.views.details.DetailsView" + icon="icons/gluster_icon.png" + id="com.gluster.storage.management.gui.views.details" + name="Details" + restorable="true"> + </view> + <view + category="org.eclipse.ui" + class="org.eclipse.ui.ExtensionFactory:progressView" + icon="icons/progress-bar.png" + id="org.eclipse.ui.views.ProgressView" + name="Tasks in Progress" + restorable="true"> + </view> + </extension> + <extension + point="org.eclipse.ui.commands"> + <category + name="Gluster Commands" + id="com.gluster.storage.management.gui.category"> + </category> + <command + name="Create Volume" + description="Create a new Volume" + categoryId="com.gluster.storage.management.gui.category" + id="com.gluster.storage.management.gui.commands.CreateVolume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Delete Volume" + id="com.gluster.storage.management.gui.commands.DeleteVolume" + name="Delete Volume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Start Volume" + id="com.gluster.storage.management.gui.commands.StartVolume" + name="Start Volume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Stop Volume" + id="com.gluster.storage.management.gui.commands.StopVolume" + name="Stop Volume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Edit Volume" + id="com.gluster.storage.management.gui.commands.EditVolume" + name="Edit Volume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Rebalance Volume" + id="com.gluster.storage.management.gui.commands.RebalanceVolume" + name="Rebalance Volume"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Add Server(s) to Cluster" + id="com.gluster.storage.management.gui.commands.AddServer" + name="Add Server(s)"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Remove Server(s) from Cluster" + id="com.gluster.storage.management.gui.commands.RemoveServer" + name="Remove Server(s)"> + </command> + <command + categoryId="com.gluster.storage.management.gui.category" + description="Migrate Disk" + id="com.gluster.storage.management.gui.commands.MigrateDisk" + name="Migrate Disk"> + </command> + </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="com.gluster.storage.management.gui.commands.CreateVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+C"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.DeleteVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+D"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.StartVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+S"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.StopVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+T"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.EditVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+E"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.RebalanceVolume" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+B"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.AddServer" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+A"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.RemoveServer" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+R"> + </key> + <key + commandId="com.gluster.storage.management.gui.commands.MigrateDisk" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+M"> + </key> + <key + commandId="org.eclipse.ui.window.preferences" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+P"> + </key> + <key + commandId="org.eclipse.ui.window.showKeyAssist" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="CTRL+SHIFT+L"> + </key> + <key + commandId="org.eclipse.ui.navigate.nextTab" + contextId="org.eclipse.ui.contexts.window" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="ALT+ARROW_RIGHT"> + </key> + <key + commandId="org.eclipse.ui.navigate.previousTab" + contextId="org.eclipse.ui.contexts.window" + schemeId="com.gluster.storage.management.gui.KeyConfig" + sequence="ALT+ARROW_LEFT"> + </key> + <scheme + description="Default Key Bindings Scheme for Gluster Management Console" + id="com.gluster.storage.management.gui.KeyConfig" + name="Gluster"> + </scheme> + </extension> + <extension + id="product" + name="Gluster Management Console" + point="org.eclipse.core.runtime.products"> + <product + application="com.gluster.storage.management.gui.application" + name="Gluster Management Console"> + <property + name="aboutText" + value="GlusterFS is an open source clustered storage solution. The software is a powerful and flexible solution that simplifies the task of managing unstructured file data whether you have a few terabytes of storage or multiple petabytes. Gluster Management Console is a powerful GUI management interface for the GlusterFS."> + </property> + <property + name="windowImages" + value="icons/gluster_icon.png"> + </property> + <property + name="aboutImage" + value="splash/gluster_about.jpg"> + </property> + <property + name="appName" + value="about"> + </property> + <property + name="preferenceCustomization" + value="preferences.ini"> + </property> + </product> + </extension> + <extension + point="org.eclipse.ui.editors"> + <editor + class="com.gluster.storage.management.gui.editor.GlusterMultiPageEditor" + default="false" + icon="icons/gluster_icon.png" + id="com.gluster.storage.management.gui.editor.GlusterMultiPageEditor" + name="Gluster Storage Platform"> + </editor> + </extension> + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + description="Set of Actions in "Edit" menu" + id="com.gluster.storage.management.gui.actionsets.edit" + label="Edit Action Set" + visible="true"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.PreferencesAction" + definitionId="org.eclipse.ui.window.preferences" + icon="icons/preferences.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="&Preferences" + menubarPath="com.gluster.storage.management.gui.menu.edit/edit" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Preferences"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.edit" + label="&Edit" + path="additions"> + <groupMarker + name="edit"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed on multiple Volumes" + id="com.gluster.storage.management.gui.actionsets.volumes" + label="Volumes Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.DeleteVolume" + icon="icons/volume-delete.png" + id="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + label="&Delete Volume(s)" + menubarPath="com.gluster.storage.management.gui.menu.volumes/volumes" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Delete Volume(s)"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StopVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StopVolume" + icon="icons/volume-stop.png" + id="com.gluster.storage.management.gui.actions.StopVolumeAction" + label="S&top Volume(s)" + menubarPath="com.gluster.storage.management.gui.menu.volumes/volumes" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Stop Volume(s)"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StartVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StartVolume" + icon="icons/volume-start.png" + id="com.gluster.storage.management.gui.actions.StartVolumeAction" + label="&Start Volume(s)" + menubarPath="com.gluster.storage.management.gui.menu.volumes/volumes" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Start Volume(s)"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.CreateVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.CreateVolume" + icon="icons/volume-create.png" + id="com.gluster.storage.management.gui.actions.CreateVolumeAction" + label="&Create Volume" + menubarPath="com.gluster.storage.management.gui.menu.volumes/volumes" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Create a new Volume"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.volumes" + label="&Gluster" + path="additions"> + <groupMarker + name="volumes"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed on a single volume" + id="com.gluster.storage.management.gui.actionsets.volume" + label="Volume Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.MigrateDiskAction" + definitionId="com.gluster.storage.management.gui.commands.MigrateDisk" + icon="icons/disk-migrate.png" + id="com.gluster.storage.management.gui.actions.MigrateDiskAction" + label="&Migrate Disk" + menubarPath="com.gluster.storage.management.gui.menu.glusterserver/glusterserver" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Migrate Disk"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.DeleteVolume" + icon="icons/volume-delete.png" + id="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + label="&Delete Volume" + menubarPath="com.gluster.storage.management.gui.menu.volume/volume" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Delete Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.RebalanceVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.RebalanceVolume" + icon="icons/volume-rebalance.png" + id="com.gluster.storage.management.gui.actions.RebalanceVolumeAction" + label="&Rebalance Volume" + menubarPath="com.gluster.storage.management.gui.menu.volume/volume" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Rebalance Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StopVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StopVolume" + icon="icons/volume-stop.png" + id="com.gluster.storage.management.gui.actions.StopVolumeAction" + label="S&top Volume" + menubarPath="com.gluster.storage.management.gui.menu.volume/volume" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Stop Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StartVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StartVolume" + icon="icons/volume-start.png" + id="com.gluster.storage.management.gui.actions.StartVolumeAction" + label="&Start Volume" + menubarPath="com.gluster.storage.management.gui.menu.volume/volume" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Start Volume"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.volume" + label="&Gluster" + path="additions"> + <groupMarker + name="volume"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed from "Cluster" context" + id="com.gluster.storage.management.gui.actionsets.gluster" + label="Cluster Action Set" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.CreateVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.CreateVolume" + icon="icons/volume-create.png" + id="com.gluster.storage.management.gui.actions.CreateVolumeAction" + label="Create &Volume" + menubarPath="com.gluster.storage.management.gui.menu.cluster/cluster" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Create a new Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.AddServerAction" + definitionId="com.gluster.storage.management.gui.commands.AddServer" + icon="icons/server-add.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="Add &Server(s)" + menubarPath="com.gluster.storage.management.gui.menu.cluster/cluster" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Add Server(s) to Cluster"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.cluster" + label="&Gluster"> + <groupMarker + name="cluster"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed on multiple Gluster Servers" + id="com.gluster.storage.management.gui.actionsets.glusterservers" + label="Gluster Servers Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.RemoveServerAction" + definitionId="com.gluster.storage.management.gui.commands.RemoveServer" + icon="icons/server-remove.png" + id="com.gluster.storage.management.gui.actions.RemoveServerAction" + label="&Remove Server(s)" + menubarPath="com.gluster.storage.management.gui.menu.servers/servers" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Remove Server(s)"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.AddServerAction" + definitionId="com.gluster.storage.management.gui.commands.AddServer" + icon="icons/server-add.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="&Add Server(s)" + menubarPath="com.gluster.storage.management.gui.menu.servers/servers" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Add Server(s) to Cluster"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.servers" + label="&Gluster" + path="additions"> + <groupMarker + name="servers"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed in the "Gluster Server" contextt; context" + id="com.gluster.storage.management.gui.actionsets.glusterserver" + label="Gluster Server Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.RemoveServerAction" + definitionId="com.gluster.storage.management.gui.commands.RemoveServer" + icon="icons/server-remove.png" + id="com.gluster.storage.management.gui.actions.RemoveServerAction" + label="&Remove Server" + menubarPath="com.gluster.storage.management.gui.menu.glusterserver/glusterserver" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Remove Server"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.glusterserver" + label="&Gluster" + path="additions"> + <groupMarker + name="glusterserver"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed on multiple Discovered Servers" + id="com.gluster.storage.management.gui.actionsets.serversdiscovered" + label="Discovered Servers Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.AddServerAction" + definitionId="com.gluster.storage.management.gui.commands.AddServer" + icon="icons/server-add.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="&Add Server(s)" + menubarPath="com.gluster.storage.management.gui.menu.discoveredservers/discoveredservers" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Add Server(s) to Cluster"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.discoveredservers" + label="&Gluster" + path="additions"> + <groupMarker + name="discoveredservers"> + </groupMarker> + </menu> + </actionSet> + <actionSet + description="Set of actions that can be performed on single Discovered Server" + id="com.gluster.storage.management.gui.actionsets.serverdiscovered" + label="Discovered Server Actions" + visible="false"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.AddServerAction" + definitionId="com.gluster.storage.management.gui.commands.AddServer" + icon="icons/server-add.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="&Add Server" + menubarPath="com.gluster.storage.management.gui.menu.discoveredserver/discoveredserver" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Add Server(s) to Cluster"> + </action> + <menu + id="com.gluster.storage.management.gui.menu.discoveredserver" + label="&Gluster" + path="additions"> + <groupMarker + name="discoveredserver"> + </groupMarker> + </menu> + </actionSet> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="*"> + <view + closeable="false" + id="com.gluster.storage.management.gui.views.navigator" + minimized="false" + moveable="false" + ratio="0.30f" + relationship="left" + relative="org.eclipse.ui.editorss" + showTitle="false" + standalone="true" + visible="true"> + </view> + <view + closeable="false" + id="com.gluster.storage.management.gui.views.details" + minimized="false" + moveable="false" + ratio="0.70f" + relationship="right" + relative="org.eclipse.ui.editorss" + showTitle="false" + standalone="true" + visible="true"> + </view> + <view + closeable="true" + id="org.eclipse.ui.views.ProgressView" + minimized="false" + moveable="false" + ratio="0.80f" + relationship="bottom" + relative="com.gluster.storage.management.gui.views.details" + showTitle="true" + standalone="true" + visible="false"> + </view> + </perspectiveExtension> + </extension> + <extension + point="org.eclipse.ui.decorators"> + <decorator + adaptable="false" + class="com.gluster.storage.management.gui.views.navigator.NavigationTreeLabelDecorator" + id="com.gluster.storage.management.gui.views.navigator.decorator" + label="Navigation Tree Decorator" + lightweight="true" + location="BOTTOM_LEFT" + state="true"> + </decorator> + </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + class="com.gluster.storage.management.gui.preferences.GlusterPreferencePage" + id="com.gluster.storage.management.gui.preferences.GlusterPreferencePage" + name="Gluster"> + </page> + <page + category="com.gluster.storage.management.gui.preferences.GlusterPreferencePage" + class="com.gluster.storage.management.gui.preferences.ClusterPreferencePage" + id="com.gluster.storage.management.gui.preferences.ClusterPreferencePage" + name="Cluster"> + </page> + <page + category="com.gluster.storage.management.gui.preferences.GlusterPreferencePage" + class="com.gluster.storage.management.gui.preferences.ConsolePreferencePage" + id="com.gluster.storage.management.gui.preferences.ConsolePreferencePage" + name="Console"> + </page> + <page + category="com.gluster.storage.management.gui.preferences.GlusterPreferencePage" + class="org.eclipse.ui.ExtensionFactory:newKeysPreferencePage" + id="org.eclipse.ui.NewKeysPreferencePage" + name="Keys"> + </page> + </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="com.gluster.storage.management.gui.preferences.PreferenceInitializer"> + </initializer> + </extension> + <extension + point="org.eclipse.ui.popupMenus"> + <objectContribution + id="gluster.context.menu.glusterserver" + objectClass="com.gluster.storage.management.core.model.GlusterServer"> + <action + class="com.gluster.storage.management.gui.actions.RemoveServerAction" + definitionId="com.gluster.storage.management.gui.commands.RemoveServer" + enablesFor="1" + icon="icons/server-remove.png" + id="com.gluster.storage.management.gui.actions.RemoveServerAction" + label="&Remove Server" + menubarPath="additions"> + </action> + </objectContribution> + <objectContribution + id="gluster.context.menu.volume" + objectClass="com.gluster.storage.management.core.model.Volume"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.MigrateDiskAction" + definitionId="com.gluster.storage.management.gui.commands.MigrateDisk" + icon="icons/disk-migrate.png" + id="com.gluster.storage.management.gui.actions.MigrateDiskAction" + label="&Migrate Disk" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Migrate Disk"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.DeleteVolume" + icon="icons/volume-delete.png" + id="com.gluster.storage.management.gui.actions.DeleteVolumeAction" + label="&Delete Volume" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Delete Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.RebalanceVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.RebalanceVolume" + icon="icons/volume-rebalance.png" + id="com.gluster.storage.management.gui.actions.RebalanceVolumeAction" + label="&Rebalance Volume" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Rebalance Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StopVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StopVolume" + icon="icons/volume-stop.png" + id="com.gluster.storage.management.gui.actions.StopVolumeAction" + label="S&top Volume" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Stop Volume"> + </action> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.StartVolumeAction" + definitionId="com.gluster.storage.management.gui.commands.StartVolume" + icon="icons/volume-start.png" + id="com.gluster.storage.management.gui.actions.StartVolumeAction" + label="&Start Volume" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Start Volume"> + </action> + </objectContribution> + <objectContribution + id="gluster.context.menu.server" + objectClass="com.gluster.storage.management.core.model.Server"> + <action + allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.AddServerAction" + definitionId="com.gluster.storage.management.gui.commands.AddServer" + enablesFor="+" + icon="icons/server-add.png" + id="com.gluster.storage.management.gui.actions.AddServerAction" + label="&Add Server(s)" + menubarPath="additions" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Add Server(s) to Cluster"> + </action> + <visibility> + <not> + <objectClass + name="com.gluster.storage.management.core.model.GlusterServer"> + </objectClass> + </not> + </visibility> + </objectContribution> + </extension> + +</plugin> diff --git a/com.gluster.storage.management.gui/preferences.ini b/com.gluster.storage.management.gui/preferences.ini new file mode 100644 index 00000000..91228592 --- /dev/null +++ b/com.gluster.storage.management.gui/preferences.ini @@ -0,0 +1 @@ +org.eclipse.ui/KEY_CONFIGURATION_ID = com.gluster.storage.management.gui.KeyConfig
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/splash.bmp b/com.gluster.storage.management.gui/splash.bmp Binary files differnew file mode 100644 index 00000000..059c28f9 --- /dev/null +++ b/com.gluster.storage.management.gui/splash.bmp diff --git a/com.gluster.storage.management.gui/splash/gluster_about.jpg b/com.gluster.storage.management.gui/splash/gluster_about.jpg Binary files differnew file mode 100644 index 00000000..242fa560 --- /dev/null +++ b/com.gluster.storage.management.gui/splash/gluster_about.jpg diff --git a/com.gluster.storage.management.gui/splash/splash-dialog.bmp b/com.gluster.storage.management.gui/splash/splash-dialog.bmp Binary files differnew file mode 100644 index 00000000..2de2897f --- /dev/null +++ b/com.gluster.storage.management.gui/splash/splash-dialog.bmp diff --git a/com.gluster.storage.management.gui/splash/splash-dialog.png b/com.gluster.storage.management.gui/splash/splash-dialog.png Binary files differnew file mode 100644 index 00000000..789eafb0 --- /dev/null +++ b/com.gluster.storage.management.gui/splash/splash-dialog.png diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Activator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Activator.java new file mode 100644 index 00000000..44b4a061 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Activator.java @@ -0,0 +1,65 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.gluster.storage.management.gui"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + public void editorOpened() { + System.err.println("Editor opened!"); + } + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java new file mode 100644 index 00000000..70e1f2bb --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java @@ -0,0 +1,98 @@ +package com.gluster.storage.management.gui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.gui.login.LoginDialog; + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + public static final String PLUGIN_ID = "com.gluster.storage.management.gui"; + private static Application instance; + private List<IEntityListener> entityListeners = Collections.synchronizedList(new ArrayList<IEntityListener>()); + + public Application() { + instance = this; + } + + public static Application getApplication() { + return instance; + } + + private boolean login() { + LoginDialog loginDialog = new LoginDialog(new Shell(Display.getDefault())); + return (loginDialog.open() == Window.OK); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) { + Display display = PlatformUI.createDisplay(); + + final boolean[] loginSuccess = new boolean[1]; + Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { + public void run() { + loginSuccess[0] = login(); + } + }); + + if (!loginSuccess[0]) { + return IApplication.EXIT_OK; + } + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + if (!PlatformUI.isWorkbenchRunning()) + return; + final IWorkbench workbench = PlatformUI.getWorkbench(); + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } + + public void addEntityListener(IEntityListener listener) { + entityListeners.add(listener); + } + + public void entityChanged(Entity entity, String[] paremeters) { + for (IEntityListener listener : entityListeners) { + listener.entityChanged(entity, paremeters); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java new file mode 100644 index 00000000..1910da79 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java @@ -0,0 +1,79 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.ICoolBarManager; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.gluster.storage.management.gui.utils.GUIHelper; + +/** + * An action bar advisor is responsible for creating, adding, and disposing of the actions added to a workbench window. + * Each window will be populated with new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + private IWorkbenchWindow window; + /* + * Actions - important to allocate these only in makeActions, and then use them in the fill methods. This ensures + * that the actions aren't recreated when fillActionBars is called with FILL_PROXY. + */ + private IWorkbenchAction exitAction; + private IWorkbenchAction aboutAction; + + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + this.window = window; + /* + * Creates the actions and registers them. Registering is needed to ensure that key bindings work. The + * corresponding commands keybindings are defined in the plugin.xml file. Registering also provides automatic + * disposal of the actions when the window is closed. + */ + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + aboutAction = ActionFactory.ABOUT.create(window); + aboutAction.setText("&About"); + aboutAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.HELP)); + register(aboutAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + // File + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // Help + MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + helpMenu.add(aboutAction); + + menuBar.add(fileMenu); + // Add a group marker indicating where action set menus will appear. + // All action sets from plugin.xml will get added here + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + + MenuManager addMenu = new MenuManager("&New"); + fileMenu.add(addMenu); + } + + protected void fillCoolBar(ICoolBarManager coolBar) { + // All our actions are added to toolbar through the extension point org.eclipse.ui.actionSets + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java new file mode 100644 index 00000000..2f345902 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,27 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.ui.application.IWorkbenchConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +/** + * This workbench advisor creates the window advisor, and specifies + * the perspective id for the initial window. + */ +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return Perspective.ID; + } + + @Override + public void initialize(IWorkbenchConfigurer configurer) { + super.initialize(configurer); + configurer.setSaveAndRestore(false); // we don't need save/restore as of now + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 00000000..1d9d1537 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,42 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + private final static int DEFAULT_WIDTH = 1024; + private final static int DEFAULT_HEIGHT = 768; + private final GUIHelper guiHelper = GUIHelper.getInstance(); + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + @Override + public void preWindowOpen() { + super.preWindowOpen(); + + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT)); + configurer.setShowCoolBar(true); + configurer.setShowStatusLine(true); + configurer.setShowMenuBar(true); + configurer.setShowProgressIndicator(true); // shows progress indicator in status bar + } + + @Override + public void postWindowCreate() { + super.postWindowCreate(); + guiHelper.centerShellInScreen(getWindowConfigurer().getWindow().getShell()); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java new file mode 100644 index 00000000..308b5f1c --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java @@ -0,0 +1,70 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.swt.graphics.Image; + +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Disk.DISK_STATUS; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.DisksPage.DISK_TABLE_COLUMN_INDICES; + +public class DiskTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + Disk disk = (Disk) element; + if (columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + DISK_STATUS status = disk.getStatus(); + switch (status) { + case READY: + return guiHelper.getImage(IImageKeys.STATUS_ONLINE); + case OFFLINE: + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); + case UNINITIALIZED: + return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED); + case INITIALIZING: + return guiHelper.getImage(IImageKeys.WORK_IN_PROGRESS); + default: + throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); + } + } + + return null; + } + + private String getDiskSpaceInUse(Disk disk) { + if (disk.isReady()) { + return NumberUtil.formatNumber(disk.getSpaceInUse()); + } else { + return "NA"; + } + } + + private String getDiskSpace(Disk disk) { + if (disk.isOffline()) { + return "NA"; + } else { + return NumberUtil.formatNumber(disk.getSpace()); + } + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + Disk disk = (Disk) element; + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? disk.getServer().getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.DISK.ordinal() ? disk.getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE.ordinal() ? getDiskSpace(disk) + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal() ? getDiskSpaceInUse(disk) + : columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal() ? disk.getStatusStr() : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/EntityGroupContentProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/EntityGroupContentProvider.java new file mode 100644 index 00000000..d5dfe3d3 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/EntityGroupContentProvider.java @@ -0,0 +1,26 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import com.gluster.storage.management.core.model.EntityGroup; + +public class EntityGroupContentProvider<T> implements + IStructuredContentProvider { + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + + } + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof EntityGroup) { + return ((EntityGroup) inputElement).getChildren().toArray(); + } + return null; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterServerTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterServerTableLabelProvider.java new file mode 100644 index 00000000..2346b99c --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterServerTableLabelProvider.java @@ -0,0 +1,57 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.swt.graphics.Image; + +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.GlusterServersPage.GLUSTER_SERVER_TABLE_COLUMN_INDICES; + +public class GlusterServerTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof GlusterServer)) { + return null; + } + + GlusterServer server = (GlusterServer) element; + if(columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + SERVER_STATUS status = server.getStatus(); + if(status == SERVER_STATUS.ONLINE) { + return guiHelper.getImage(IImageKeys.STATUS_ONLINE); + } else { + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); + } + } + + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof GlusterServer)) { + return null; + } + + GlusterServer server = (GlusterServer) element; + + if (server.getStatus() == SERVER_STATUS.OFFLINE + && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() + && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + return "NA"; + } + + return (columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal() ? server.getStatusStr() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK.ordinal() ? server.getPreferredNetworkInterface().getName() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + server.getNumOfCPUs() + //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + server.getTotalMemory() + //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + server.getMemoryInUse() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE.ordinal() ? NumberUtil.formatNumber(server.getTotalDiskSpace()) + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ICommandIds.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ICommandIds.java new file mode 100644 index 00000000..0c94dc8f --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ICommandIds.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui; + +/** + * Interface defining the application's command IDs. + * Key bindings can be defined for specific commands. + * To associate an action with a command, use IAction.setActionDefinitionId(commandId). + * + * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) + */ +public interface ICommandIds { + + public static final String CMD_OPEN = "com.gluster.storage.management.gui.open"; + public static final String CMD_OPEN_MESSAGE = "com.gluster.storage.management.gui.openMessage"; + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IEntityListener.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IEntityListener.java new file mode 100644 index 00000000..46f12962 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IEntityListener.java @@ -0,0 +1,19 @@ +package com.gluster.storage.management.gui; + +import com.gluster.storage.management.core.model.Entity; + +/** + * Any class that is interested in changes to entities in application scope should implement this interface and register + * with the application using {@link Application#addEntityListener(IEntityListener)} + * + * @author root + * + */ +public interface IEntityListener { + /** + * This method is called whenever any attribute of an entity in application scope changes + * @param entity Entity that has changed + * @param paremeters List of attribute names that have changed. This can be null. + */ + public void entityChanged(Entity entity, String[] paremeters); +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java new file mode 100644 index 00000000..cef276a9 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java @@ -0,0 +1,44 @@ +package com.gluster.storage.management.gui; + +public interface IImageKeys { + public static final String CLUSTER = "icons/cluster.png"; + public static final String VOLUMES = "icons/volumes.png"; + public static final String SERVERS = "icons/servers.png"; + public static final String VOLUME = "icons/volume.png"; + public static final String SERVER = "icons/server.png"; + public static final String GSN = "icons/gsn.png"; + public static final String SETTINGS = "icons/settings.png"; + public static final String ADD = "icons/plus-white.png"; + public static final String REMOVE = "icons/minus-white.png"; + public static final String CREATE_VOLUME = "icons/volume-create.png"; + public static final String CREATE_VOLUME_BIG = "icons/volume-create-big.png"; + public static final String REMOVE_VOLUME = "icons/volume-delete.png"; + public static final String ADD_SERVER = "icons/server-add.png"; + public static final String ADD_SERVER_BIG = "icons/server-add-big.png"; + public static final String REMOVE_SERVER = "icons/server-remove.png"; + public static final String HELP = "icons/question.png"; + public static final String STATUS_OFFLINE = "icons/status-offline.png"; + public static final String STATUS_ONLINE = "icons/status-online.png"; + public static final String STATUS_CANCELLED = "icons/status-offline.png"; + public static final String STATUS_SUCCESS = "icons/status-online.png"; + public static final String WORK_IN_PROGRESS = "icons/progress-bar.png"; + public static final String CHECKBOX_UNCHECKED = "icons/ui-check-box-uncheck.png"; + public static final String CHECKBOX_CHECKED = "icons/ui-check-box.png"; + public static final String DISK_UNINITIALIZED = "icons/disk-uninitialized.png"; + public static final String SEARCH = "icons/search.png"; + public static final String ARROW_UP = "icons/arrow-up.png"; + public static final String ARROW_DOWN = "icons/arrow-down.png"; + + public static final String OVERLAY_OFFLINE = "icons/status-offline-small.png"; + public static final String OVERLAY_ONLINE = "icons/status-online-small.png"; + public static final String OVERLAY_STAR = "icons/star-small.png"; + + public static final String SPLASH_IMAGE = "splash.bmp"; + public static final String DIALOG_SPLASH_IMAGE = "splash/splash-dialog.bmp"; + + public static final String PROGRESS_BAR_LEFT = "images/progress_image_left.png"; + public static final String PROGRESS_BAR_RIGHT = "images/progress_image_right.png"; + public static final String PROGRESS_BAR_FILLED = "images/progress_image_filled_safe.png"; + public static final String PROGRESS_BAR_EMPTY = "images/progress_image_empty.png"; + public static final String GAUGE_SMALL = "images/gauge_small.png"; +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/NetworkInterfaceTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/NetworkInterfaceTableLabelProvider.java new file mode 100644 index 00000000..1292cb9a --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/NetworkInterfaceTableLabelProvider.java @@ -0,0 +1,22 @@ +package com.gluster.storage.management.gui; + + +import com.gluster.storage.management.core.model.NetworkInterface; +import com.gluster.storage.management.gui.views.details.tabcreators.GlusterServerTabCreator.NETWORK_INTERFACE_TABLE_COLUMN_INDICES; + +public class NetworkInterfaceTableLabelProvider extends TableLabelProviderAdapter { + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof NetworkInterface)) { + return null; + } + + NetworkInterface networkInterface = (NetworkInterface) element; + return (columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE.ordinal() ? networkInterface.getName() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS.ordinal() ? networkInterface.getIpAddress() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK.ordinal() ? networkInterface.getNetMask() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY.ordinal() ? networkInterface.getDefaultGateway() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.PREFERRED.ordinal() ? (networkInterface.isPreferred() ? "Yes" : "No") + : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Perspective.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Perspective.java new file mode 100644 index 00000000..5b0c6e19 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Perspective.java @@ -0,0 +1,21 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +import com.gluster.storage.management.gui.views.details.DetailsView; +import com.gluster.storage.management.gui.views.navigator.NavigationView; + +public class Perspective implements IPerspectiveFactory { + + /** + * The ID of the perspective as specified in the extension. + */ + public static final String ID = "com.gluster.storage.management.gui.perspective"; + + public void createInitialLayout(IPageLayout layout) { + layout.setEditorAreaVisible(false); + //layout.addStandaloneView(ClusterView.ID, false, IPageLayout.LEFT, 0.30f, layout.getEditorArea()); + //layout.addStandaloneView(DetailsView.ID, false, IPageLayout.RIGHT, 0.70f, layout.getEditorArea()); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java new file mode 100644 index 00000000..889bf771 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java @@ -0,0 +1,72 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.swt.graphics.Image; + +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Disk.DISK_STATUS; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.ServerDisksPage.SERVER_DISK_TABLE_COLUMN_INDICES; + +public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + Disk disk = (Disk) element; + if (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + DISK_STATUS status = disk.getStatus(); + switch (status) { + case READY: + return guiHelper.getImage(IImageKeys.STATUS_ONLINE); + case OFFLINE: + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); + case UNINITIALIZED: + return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED); + case INITIALIZING: + return guiHelper.getImage(IImageKeys.WORK_IN_PROGRESS); + default: + throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); + } + } + + return null; + } + + private String getDiskSpaceInUse(Disk disk) { + if(disk.isReady()) { + return NumberUtil.formatNumber(disk.getSpaceInUse()); + } else { + return "NA"; + } + } + + private String getDiskSpace(Disk disk) { + if(disk.isOffline()) { + return "NA"; + } else { + return NumberUtil.formatNumber(disk.getSpace()); + } + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + + Disk disk = (Disk) element; + return (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.DISK.ordinal() ? disk.getName() + : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.SPACE.ordinal() ? getDiskSpace(disk) + : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal() ? getDiskSpaceInUse(disk) + : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal() ? disk.getStatusStr() + : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerTableLabelProvider.java new file mode 100644 index 00000000..d002c15f --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerTableLabelProvider.java @@ -0,0 +1,30 @@ +package com.gluster.storage.management.gui; + + +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.ServersPage.SERVER_TABLE_COLUMN_INDICES; + +public class ServerTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Server)) { + return null; + } + + Server server = (Server) element; + return (columnIndex == SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() + : columnIndex == SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() + : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS.ordinal() ? "" + server.getNumOfDisks() + : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE.ordinal() ? NumberUtil.formatNumber(server.getTotalDiskSpace()) +// : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + server.getNumOfCPUs() +// : columnIndex == SERVER_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() +// : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + server.getTotalMemory() +// : columnIndex == SERVER_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + server.getMemoryInUse() +// : columnIndex == SERVER_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE.ordinal() ? "" + server.getDiskSpaceInUse() + : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TableLabelProviderAdapter.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TableLabelProviderAdapter.java new file mode 100644 index 00000000..54bc5ce6 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TableLabelProviderAdapter.java @@ -0,0 +1,40 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; + +public class TableLabelProviderAdapter implements ITableLabelProvider { + + @Override + public void addListener(ILabelProviderListener listener) { + // do nothing + + } + + @Override + public void dispose() { + // do nothing + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return true; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + // do nothing + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + return null; + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeLogTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeLogTableLabelProvider.java new file mode 100644 index 00000000..8685a965 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeLogTableLabelProvider.java @@ -0,0 +1,30 @@ +package com.gluster.storage.management.gui; + + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.LogMessage; +import com.gluster.storage.management.core.utils.DateUtil; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.VolumeLogsPage.LOG_TABLE_COLUMN_INDICES; + +public class VolumeLogTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + private String getFormattedDiskName(Disk disk) { + return disk.getServer().getName() + ":" + disk.getName(); + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof LogMessage)) { + return null; + } + + LogMessage logMessage = (LogMessage) element; + return (columnIndex == LOG_TABLE_COLUMN_INDICES.DATE.ordinal() ? DateUtil.formatDate(logMessage.getTimestamp()) + : columnIndex == LOG_TABLE_COLUMN_INDICES.TIME.ordinal() ? DateUtil.formatTime(logMessage.getTimestamp()) + : columnIndex == LOG_TABLE_COLUMN_INDICES.DISK.ordinal() ? getFormattedDiskName(logMessage.getDisk()) + : columnIndex == LOG_TABLE_COLUMN_INDICES.SEVERITY.ordinal() ? "" + logMessage.getSeverity() + : columnIndex == LOG_TABLE_COLUMN_INDICES.MESSAGE.ordinal() ? logMessage.getMessage() : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java new file mode 100644 index 00000000..3c24b3f4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java @@ -0,0 +1,24 @@ +package com.gluster.storage.management.gui; + +import java.util.Map.Entry; + +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.VolumeOptionsPage.OPTIONS_TABLE_COLUMN_INDICES; + +public class VolumeOptionsTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Entry)) { + return null; + } + + Entry<String, String> entry = (Entry) element; + String key = entry.getKey(); + String value = entry.getValue(); + return (columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal() ? key + : columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal() ? value + : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeTableLabelProvider.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeTableLabelProvider.java new file mode 100644 index 00000000..63241961 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeTableLabelProvider.java @@ -0,0 +1,64 @@ +package com.gluster.storage.management.gui; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; + +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.VolumesPage.VOLUME_TABLE_COLUMN_INDICES; + +public class VolumeTableLabelProvider implements ITableLabelProvider { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Volume)) { + return null; + } + + Volume volume = (Volume) element; + if(columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal()) { + VOLUME_STATUS status = volume.getStatus(); + if(status == VOLUME_STATUS.ONLINE) { + return guiHelper.getImage(IImageKeys.STATUS_ONLINE); + } else { + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); + } + } + + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Volume)) { + return null; + } + + Volume volume = (Volume) element; + return (columnIndex == VOLUME_TABLE_COLUMN_INDICES.NAME.ordinal() ? volume.getName() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_TYPE.ordinal() ? volume.getVolumeTypeStr() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE.ordinal() ? volume.getTransportTypeStr() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.NUM_OF_DISKS.ordinal() ? "" + volume.getNumOfDisks() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal() ? volume.getStatusStr() : "Invalid"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java new file mode 100644 index 00000000..ddcb91c0 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java @@ -0,0 +1,38 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import com.gluster.storage.management.core.model.Entity; + +/** + * All action delegates in the application should extend from this class. It provides common functionality of grabbing + * the Window object on initialization and extracting the selected entity in case of selection change on the navigation + * tree. + */ +public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDelegate { + protected IWorkbenchWindow window; + protected Entity selectedEntity; + + @Override + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof StructuredSelection) { + Entity selectedEntity = (Entity) ((StructuredSelection) selection).getFirstElement(); + + if (this.selectedEntity == selectedEntity) { + // entity selection has not changed. do nothing. + return; + } + + this.selectedEntity = selectedEntity; + } + } + + @Override + public void init(IWorkbenchWindow window) { + this.window = window; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java new file mode 100644 index 00000000..9a278c74 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java @@ -0,0 +1,18 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class AddServerAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java new file mode 100644 index 00000000..ea5ac084 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java @@ -0,0 +1,23 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.wizard.WizardDialog; + +import com.gluster.storage.management.gui.dialogs.CreateVolumeWizard; + +public class CreateVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + CreateVolumeWizard wizard = new CreateVolumeWizard(); + + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(500, 550); + dialog.open(); + } + + @Override + public void dispose() { + window = null; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java new file mode 100644 index 00000000..d9446238 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; + +public class DeleteVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/EditVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/EditVolumeAction.java new file mode 100644 index 00000000..47a0cc56 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/EditVolumeAction.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; + +public class EditVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/IActionSetIDs.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/IActionSetIDs.java new file mode 100644 index 00000000..cdc05128 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/IActionSetIDs.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +public interface IActionSetIDs { + public static final String ACTION_SET_CLUSTER = "com.gluster.storage.management.gui.actionsets.gluster"; + public static final String ACTION_SET_VOLUMES = "com.gluster.storage.management.gui.actionsets.volumes"; + public static final String ACTION_SET_VOLUME = "com.gluster.storage.management.gui.actionsets.volume"; + public static final String ACTION_SET_DISKS = "com.gluster.storage.management.gui.actionsets.disks"; + public static final String ACTION_SET_DISK = "com.gluster.storage.management.gui.actionsets.disk"; + public static final String ACTION_SET_GLUSTER_SERVERS = "com.gluster.storage.management.gui.actionsets.glusterservers"; + public static final String ACTION_SET_GLUSTER_SERVER = "com.gluster.storage.management.gui.actionsets.glusterserver"; + public static final String ACTION_SET_DISCOVERED_SERVERS = "com.gluster.storage.management.gui.actionsets.serversdiscovered"; + public static final String ACTION_SET_DISCOVERED_SERVER = "com.gluster.storage.management.gui.actionsets.serverdiscovered"; + + public static final String ACTION_SET_EDIT = "com.gluster.storage.management.gui.actionsets.edit"; +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateDiskAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateDiskAction.java new file mode 100644 index 00000000..3d59f179 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateDiskAction.java @@ -0,0 +1,53 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.dialogs.MigrateDiskWizard; + +public class MigrateDiskAction extends AbstractActionDelegate { + private Volume volume; + private Disk disk; + + @Override + public void run(IAction action) { +// MigrateDiskDialog dialog = new MigrateDiskDialog(window.getShell(), volume, disk); +// dialog.create(); +// dialog.open(); + MigrateDiskWizard wizard = new MigrateDiskWizard(volume, disk); + + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(1024, 600); + dialog.open(); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + + if(selectedEntity == null) { + // this happens when user clicks on the "Disks" tab + return; + } + + action.setEnabled(false); + if (selectedEntity instanceof Volume) { + volume = (Volume) selectedEntity; + action.setEnabled(true); + } else if (selectedEntity instanceof Disk) { + disk = (Disk) selectedEntity; + action.setEnabled(((StructuredSelection) selection).size() <= 1); + } + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateVolumeAction.java new file mode 100644 index 00000000..ebe961b4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/MigrateVolumeAction.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; + +public class MigrateVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PreferencesAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PreferencesAction.java new file mode 100644 index 00000000..482d8c8c --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PreferencesAction.java @@ -0,0 +1,18 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.actions.ActionFactory; + +public class PreferencesAction extends AbstractActionDelegate { + + @Override + public void dispose() { + + } + + @Override + public void run(IAction action) { + ActionFactory.PREFERENCES.create(window).run(); + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RebalanceVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RebalanceVolumeAction.java new file mode 100644 index 00000000..dfdc6724 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RebalanceVolumeAction.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; + +public class RebalanceVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java new file mode 100644 index 00000000..7bd81038 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java @@ -0,0 +1,18 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class RemoveServerAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java new file mode 100644 index 00000000..1492a890 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java @@ -0,0 +1,18 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class StartVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java new file mode 100644 index 00000000..7c3b75dc --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java @@ -0,0 +1,15 @@ +package com.gluster.storage.management.gui.actions; + +import org.eclipse.jface.action.IAction; + +public class StopVolumeAction extends AbstractActionDelegate { + @Override + public void run(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java new file mode 100644 index 00000000..daadb76c --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java @@ -0,0 +1,44 @@ +package com.gluster.storage.management.gui.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 TestPopupMenuAction implements IObjectActionDelegate { + + private Shell shell; + + /** + * Constructor for Action1. + */ + public TestPopupMenuAction() { + 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, + "glustersp-gui", + "New Action was executed."); + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeDisksPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeDisksPage.java new file mode 100644 index 00000000..a238fca5 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeDisksPage.java @@ -0,0 +1,159 @@ +package com.gluster.storage.management.gui.dialogs; + +import java.util.List; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.TableLabelProviderAdapter; +import com.gluster.storage.management.gui.utils.EntityViewerFilter; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.richclientgui.toolbox.duallists.CustomTableDualListComposite; +import com.richclientgui.toolbox.duallists.RemovableContentProvider; +import com.richclientgui.toolbox.duallists.TableColumnData; + +public class CreateVolumeDisksPage extends Composite { + private enum DISK_TABLE_COLUMN_INDICES { + SERVER, DISK, SPACE, SPACE_USED + } + + private static final String[] DISK_TABLE_COLUMNS_NAMES = { "Server", "Disk", "Space (GB)", "Used Space (GB)" }; + + private GUIHelper guiHelper = GUIHelper.getInstance(); + private CustomTableDualListComposite<Disk> dualTableViewer; + private Text filterText; + + public CreateVolumeDisksPage(final Composite parent, int style, List<Disk> disks) { + super(parent, style); + + createPage(disks); + + parent.layout(); + } + + private TableLabelProviderAdapter getDiskLabelProvider() { + return new TableLabelProviderAdapter() { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + Disk disk = (Disk) element; + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? disk.getServer().getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.DISK.ordinal() ? disk.getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE.ordinal() ? NumberUtil.formatNumber(disk.getSpace()) + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE_USED.ordinal() ? NumberUtil.formatNumber(disk.getSpaceInUse()) + : "Invalid"); + } + }; + } + + private void createPage(List<Disk> disks) { + setupPageLayout(); + + filterText = guiHelper.createFilterText(this); + new Label(this, SWT.NONE); + + createDualTableViewer(disks); + createFilter(filterText, false); // attach filter text to the dual table viewer for auto-filtering + + Composite buttonContainer = new Composite(this, SWT.NONE); + buttonContainer.setLayout(new GridLayout(1, false)); + GridData buttonContainerData = new GridData(SWT.FILL, SWT.CENTER, true, true); + buttonContainerData.minimumWidth = 40; + buttonContainer.setLayoutData(buttonContainerData); + + Button btnUp = new Button(buttonContainer, SWT.TOGGLE); + GridData btnUpData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); + btnUpData.minimumWidth = 30; + btnUp.setLayoutData(btnUpData); + btnUp.setImage(guiHelper.getImage(IImageKeys.ARROW_UP)); + + Button btnDown = new Button(buttonContainer, SWT.TOGGLE); + btnDown.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); + btnDown.setImage(guiHelper.getImage(IImageKeys.ARROW_DOWN)); + } + + private void createFilter(final Text filterText, boolean caseSensitive) { + final String initialFilterString = filterText.getText(); + + final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); + // On every keystroke inside the text field, update the filter string + filterText.addKeyListener(new KeyAdapter() { + private String filterString = initialFilterString; + + @Override + public void keyReleased(KeyEvent e) { + String enteredString = filterText.getText(); + if (enteredString.equals(filterString)) { + // Filter string has not changed. don't do anything + return; + } + + // Update filter string + filterString = enteredString; + filter.setFilterString(filterString); + + // Refresh viewer with newly filtered content + dualTableViewer.refreshAvailableViewer(); + dualTableViewer.refreshChosenViewer(); + } + }); + + dualTableViewer.setAvailableViewerFilter(filter); + dualTableViewer.setChosenViewerFilter(filter); + } + + private void createDualTableViewer(List<Disk> disks) { + TableColumnData[] columnData = createColumnData(); + ITableLabelProvider diskLabelProvider = getDiskLabelProvider(); + + dualTableViewer = new CustomTableDualListComposite<Disk>(this, SWT.NONE, + columnData, columnData); + + dualTableViewer.setViewerLabels("Available:", "Chosen:"); + + dualTableViewer.setAvailableTableLinesVisible(false); + dualTableViewer.setAvailableTableHeaderVisible(true); + dualTableViewer.setAvailableContentProvider(new RemovableContentProvider<Disk>()); + dualTableViewer.setAvailableLabelProvider(diskLabelProvider); + + dualTableViewer.setChosenTableLinesVisible(true); + dualTableViewer.setChosenTableHeaderVisible(true); + dualTableViewer.setChosenContentProvider(new RemovableContentProvider<Disk>(disks)); + dualTableViewer.setChosenLabelProvider(diskLabelProvider); + } + + private TableColumnData[] createColumnData() { + DISK_TABLE_COLUMN_INDICES[] columns = DISK_TABLE_COLUMN_INDICES.values(); + TableColumnData[] columnData = new TableColumnData[columns.length]; + + for (DISK_TABLE_COLUMN_INDICES column : columns) { + int columnNum = column.ordinal(); + columnData[columnNum] = new TableColumnData(columnNum, DISK_TABLE_COLUMNS_NAMES[columnNum], 100); + } + return columnData; + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + + setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java new file mode 100644 index 00000000..21edd368 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java @@ -0,0 +1,131 @@ +package com.gluster.storage.management.gui.dialogs; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; + +public class CreateVolumePage1 extends WizardPage { + private static final String PAGE_NAME = "create.volume.page.1"; + private Text txtName; + private Text txtAccessControl; + + /** + * Create the wizard. + */ + public CreateVolumePage1() { + super(PAGE_NAME); + setTitle("Create Volume"); + setDescription("Create a new Volume by choosing disks from the cluster servers and configuring the volume properties."); + } + + /** + * Create contents of the wizard. + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + + setControl(container); + GridLayout gl_container = new GridLayout(2, false); + gl_container.verticalSpacing = 10; + gl_container.marginHeight = 10; + gl_container.marginLeft = 20; + gl_container.horizontalSpacing = 10; + container.setLayout(gl_container); + + new Label(container, SWT.NONE); + new Label(container, SWT.NONE); + + Label lblName = new Label(container, SWT.NONE); + lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblName.setText("Name: "); + + txtName = new Text(container, SWT.BORDER); + GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + txtNameData.widthHint = 300; + txtName.setLayoutData(txtNameData); + + Label lblType = new Label(container, SWT.NONE); + lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblType.setText("Type: "); + + ComboViewer typeComboViewer = new ComboViewer(container, SWT.READ_ONLY); + Combo typeCombo = typeComboViewer.getCombo(); + GridData typeComboData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + typeCombo.setLayoutData(typeComboData); + typeComboViewer.setContentProvider(new ArrayContentProvider()); + typeComboViewer.setInput(Volume.VOLUME_TYPE.values()); + typeCombo.select(VOLUME_TYPE.PLAIN_DISTRIBUTE.ordinal()); // default type = Plain Distribute + typeComboViewer.setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + VOLUME_TYPE volumeType = (VOLUME_TYPE)element; + return Volume.getVolumeTypeStr(volumeType); + } + }); + + Label lblTransportType = new Label(container, SWT.NONE); + lblTransportType.setText("Transport Type: "); + + Label lblEthernet = new Label(container, SWT.NONE); + lblEthernet.setText("Ethernet"); + + Label lblDisks = new Label(container, SWT.RIGHT); + lblDisks.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblDisks.setText("Disks: "); + + Link linkCustomize = new Link(container, SWT.UNDERLINE_LINK); + linkCustomize.setText("All Disks (<A>customize</A>)"); + linkCustomize.addListener (SWT.Selection, new Listener () { + public void handleEvent(Event event) { + SelectDisksDialog dialog = new SelectDisksDialog(getShell()); + dialog.create(); + dialog.open(); + } + }); + + Label lblNasProtocol = new Label(container, SWT.RIGHT); + lblNasProtocol.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblNasProtocol.setText("NAS Protocol: "); + + Button btnGluster = new Button(container, SWT.CHECK); + btnGluster.setEnabled(false); + btnGluster.setSelection(true); + btnGluster.setText("Gluster"); + new Label(container, SWT.NONE); + + Button btnNfs = new Button(container, SWT.CHECK); + btnNfs.setSelection(true); + btnNfs.setText("NFS"); + + Label lblAccessControl = new Label(container, SWT.NONE); + lblAccessControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblAccessControl.setText("Access Control: "); + + txtAccessControl = new Text(container, SWT.BORDER); + txtAccessControl.setText("*"); + GridData accessControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + accessControlData.widthHint = 300; + txtAccessControl.setLayoutData(accessControlData); + + new Label(container, SWT.NONE); + Label lblAccessControlInfo = new Label(container, SWT.TOP); + lblAccessControlInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblAccessControlInfo.setText("(Comma separated list of IP addresses)"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java new file mode 100644 index 00000000..1b22cc77 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java @@ -0,0 +1,23 @@ +package com.gluster.storage.management.gui.dialogs; + +import org.eclipse.jface.wizard.Wizard; + +public class CreateVolumeWizard extends Wizard { + + public CreateVolumeWizard() { + setWindowTitle("Gluster Management Console - Create Volume"); + setHelpAvailable(false); // TODO: Introduce wizard help + } + + @Override + public void addPages() { + addPage(new CreateVolumePage1()); + } + + @Override + public boolean performFinish() { + System.out.println("Finishing volume creation!"); + // TODO: Add code to create volume + return true; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskPage1.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskPage1.java new file mode 100644 index 00000000..47b43090 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskPage1.java @@ -0,0 +1,185 @@ +package com.gluster.storage.management.gui.dialogs; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.GlusterDummyModel; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.TableLabelProviderAdapter; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class MigrateDiskPage1 extends WizardPage { + private static final String PAGE_NAME = "migrate.disk.page.1"; + private enum DISK_TABLE_COLUMN_INDICES { + SERVER, DISK, SPACE, SPACE_IN_USE + } + private static final String[] DISK_TABLE_COLUMN_NAMES = { "Server", "Disk", "Space (GB)", "Used Space (GB)" }; + + private Volume volume; + private Disk fromDisk; + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private ITableLabelProvider getDiskLabelProvider() { + return new TableLabelProviderAdapter() { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Disk)) { + return null; + } + + Disk disk = (Disk) element; + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? disk.getServer().getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.DISK.ordinal() ? disk.getName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE.ordinal() ? NumberUtil.formatNumber(disk.getSpace()) + : columnIndex == DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal() ? NumberUtil.formatNumber(disk.getSpaceInUse()) + : "Invalid"); + } + }; + } + + private void setupDiskTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, DISK_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SERVER, SWT.CENTER, 100); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.DISK, SWT.CENTER, 100); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SPACE, SWT.CENTER, 90); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE, SWT.CENTER, 90); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, DISK_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + + /** + * Create the wizard. + */ + public MigrateDiskPage1(Volume volume, Disk disk) { + super(PAGE_NAME); + this.volume = volume; + this.fromDisk = disk; + setTitle("Migrate Disk [" + volume.getName() + "]"); +// setDescription("Migrate data from one disk to another for the chosen Volume. " + +// "This will copy all data present in the \"from disk\" of the volume " + +// "to \"to disk\", remove \"from disk\" from the volume, and " + +// "add \"to disk\" to the volume"); + setDescription("Migrate volume data from \"From Disk\" to \"To Disk\""); + } + + private void setupPageLayout(Composite container) { + final GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.horizontalSpacing = 10; + layout.marginTop = 10; + layout.marginLeft = 10; + layout.marginRight = 10; + container.setLayout(layout); + } + + private Composite createTableViewerComposite(Composite parent) { + Composite tableViewerComposite = new Composite(parent, SWT.NONE); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + setControl(container); + + setupPageLayout(container); + + GridData labelLayoutData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); + labelLayoutData.minimumWidth = 100; + labelLayoutData.verticalAlignment = SWT.BOTTOM; + //labelLayoutData.verticalIndent = 10; + + Label lblFromDisk = new Label(container, SWT.NONE); + lblFromDisk.setText("From Disk:"); + lblFromDisk.setLayoutData(labelLayoutData); + Label lblToDisk = new Label(container, SWT.NONE); + lblToDisk.setText("To Disk:"); + lblToDisk.setLayoutData(labelLayoutData); + + Text txtFilterFrom = guiHelper.createFilterText(container); + Text txtFilterTo = guiHelper.createFilterText(container); + + ITableLabelProvider diskLabelProvider = getDiskLabelProvider(); + + GlusterDummyModel glusterDummyModel = GlusterDummyModel.getInstance(); + List<Disk> fromDisks = glusterDummyModel.getReadyDisksOfVolume(volume); + List<Disk> toDisks = glusterDummyModel.getReadyDisksOfAllServersExcluding(volume.getDisks()); + + TableViewer tableViewerFrom = createTableViewer(container, diskLabelProvider, fromDisks, txtFilterFrom); + if(fromDisk != null) { + setFromDisk(tableViewerFrom, fromDisk); + } + + createTableViewer(container, diskLabelProvider, toDisks, txtFilterTo); + } + + private void setFromDisk(TableViewer tableViewer, Disk diskToSelect) { + Table table = tableViewer.getTable(); + for(int i = 0 ; i < table.getItemCount(); i++) { + TableItem item = table.getItem(i); + if(item.getData() == diskToSelect) { + table.select(i); + return; + } + } + } + + private TableViewer createTableViewer(Composite container, ITableLabelProvider diskLabelProvider, List<Disk> fromDisks, Text txtFilterText) { + Composite tableViewerComposite = createTableViewerComposite(container); + + TableViewer tableViewer = new TableViewer(tableViewerComposite, SWT.SINGLE); + tableViewer.setContentProvider(new ArrayContentProvider()); + tableViewer.setLabelProvider(diskLabelProvider); + + setupDiskTable(tableViewerComposite, tableViewer.getTable()); + guiHelper.createFilter(tableViewer, txtFilterText, false); + + tableViewer.setInput(fromDisks.toArray()); + return tableViewer; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskWizard.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskWizard.java new file mode 100644 index 00000000..f9416c9f --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateDiskWizard.java @@ -0,0 +1,30 @@ +package com.gluster.storage.management.gui.dialogs; + +import org.eclipse.jface.wizard.Wizard; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Volume; + +public class MigrateDiskWizard extends Wizard { + private Volume volume; + private Disk disk; + + public MigrateDiskWizard(Volume volume, Disk disk) { + setWindowTitle("Gluster Management Console - Migrate Disk [" + volume.getName() + "]"); + this.volume = volume; + this.disk = disk; + setHelpAvailable(false); // TODO: Introduce wizard help + } + + @Override + public void addPages() { + addPage(new MigrateDiskPage1(volume, disk)); + } + + @Override + public boolean performFinish() { + System.out.println("Triggered Disk Migration!"); + // TODO: Add code to migrate disk + return true; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/SelectDisksDialog.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/SelectDisksDialog.java new file mode 100644 index 00000000..57caa8e4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/SelectDisksDialog.java @@ -0,0 +1,77 @@ +package com.gluster.storage.management.gui.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import com.gluster.storage.management.core.model.GlusterDummyModel; + +public class SelectDisksDialog extends Dialog { + + /** + * Create the dialog. + * + * @param parentShell + */ + public SelectDisksDialog(Shell parentShell) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); + } + + /** + * Create contents of the dialog. + * + * @param parent + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout containerLayout = new GridLayout(2, false); + container.setLayout(containerLayout); + GridData containerLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + container.setLayoutData(containerLayoutData); + + getShell().setText("Create Volume - Select Disks"); + CreateVolumeDisksPage disksPage = new CreateVolumeDisksPage(container, SWT.NONE, GlusterDummyModel + .getInstance().getReadyDisksOfAllServers()); + + return container; + } + + /** + * Create contents of the button bar. + * + * @param parent + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + /** + * Return the initial size of the dialog. + */ + @Override + protected Point getInitialSize() { + return new Point(1024, 600); + } + + @Override + protected void cancelPressed() { + // TODO Auto-generated method stub + super.cancelPressed(); + } + + @Override + protected void okPressed() { + // TODO Auto-generated method stub + super.okPressed(); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/Messages.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/Messages.java new file mode 100644 index 00000000..57293228 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/Messages.java @@ -0,0 +1,23 @@ +package com.gluster.storage.management.gui.editor;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "com.gluster.storage.management.gui.editor.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage.java new file mode 100644 index 00000000..7b87aba4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage.java @@ -0,0 +1,158 @@ +package com.gluster.storage.management.gui.editor; + +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.bindings.keys.ParseException; +import org.eclipse.jface.fieldassist.ComboContentAdapter; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.forms.editor.FormPage; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ColumnLayout; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.Section; + +import com.swtdesigner.SWTResourceManager; + +public class SettingsPage extends FormPage { + + public static final String ID = "com.gluster.storage.management.gui.editor.ClusterSummaryPage"; + + /** + * Create the form page. + * + * @param id + * @param title + */ + public SettingsPage(String title) { + super(ID, title); + } + + /** + * Create the form page. + * + * @param editor + * @param id + * @param title + * @wbp.parser.constructor + * @wbp.eval.method.parameter title "Some title" + */ + public SettingsPage(FormEditor editor, String title) { + super(editor, ID, title); + } + + private void setupForm(FormToolkit toolkit, final ScrolledForm form) { + form.setText("Settings"); + toolkit.decorateFormHeading(form.getForm()); + + ColumnLayout layout = new ColumnLayout(); + + // layout.topMargin = 0; + // layout.bottomMargin = 5; + // layout.leftMargin = 10; + // layout.rightMargin = 10; + // layout.horizontalSpacing = 10; + // layout.verticalSpacing = 10; + // layout.maxNumColumns = 4; + // layout.minNumColumns = 1; + + form.getBody().setLayout(layout); + } + + /** + * Create contents of the form. + * + * @param managedForm + */ + @Override + protected void createFormContent(IManagedForm managedForm) { + FormToolkit toolkit = managedForm.getToolkit(); + final ScrolledForm form = managedForm.getForm(); + + setupForm(toolkit, form); + createClusterSettingsSection(toolkit, form); + } + + private Composite createSection(final ScrolledForm form, + FormToolkit toolkit, String title, String desc, int numColumns, + boolean collapsible) { + int style = Section.TITLE_BAR | Section.EXPANDED; + if (desc != null && !desc.isEmpty()) { + style |= Section.DESCRIPTION; + } + if (collapsible) { + style |= Section.TWISTIE; + } + + Section section = toolkit.createSection(form.getBody(), style); + section.setText(title); + section.setDescription(desc); + + // toolkit.createCompositeSeparator(section); + Composite client = toolkit.createComposite(section); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 0; + layout.numColumns = numColumns; + client.setLayout(layout); + section.setClient(client); + new Label(client, SWT.NONE); + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(false); + } + }); + return client; + } + + private void createClusterSettingsSection(FormToolkit toolkit, + final ScrolledForm form) { + Composite sectionClient = createSection(form, toolkit, "Volumes", null, + 2, false); + + Label lblNumberOfVolumes = toolkit.createLabel(sectionClient, + "Number of Volumes: ", SWT.NONE); + Label lblVolumeCount = toolkit.createLabel(sectionClient, "12", + SWT.NONE); + Label lblOnline = toolkit.createLabel(sectionClient, "Online: ", + SWT.NONE); + Label labelOnlineCount = toolkit.createLabel(sectionClient, "9", + SWT.NONE); + labelOnlineCount.setForeground(SWTResourceManager + .getColor(SWT.COLOR_DARK_GREEN)); + Label lblOffline = toolkit.createLabel(sectionClient, "Offline: ", + SWT.NONE); + Label lblOfflineCount = toolkit.createLabel(sectionClient, "3", + SWT.NONE); + lblOfflineCount.setForeground(SWTResourceManager + .getColor(SWT.COLOR_RED)); + /*CCombo cboTimeZone = new CCombo(sectionClient, SWT.FLAT); + cboTimeZone.setData(FormToolkit.KEY_DRAW_BORDER, + FormToolkit.TEXT_BORDER);*/ + /*toolkit.paintBordersFor(sectionClient); + + cboTimeZone.add("Asia/Calcutta"); + try { + ContentProposalAdapter proposalAdapter = new ContentProposalAdapter( + cboTimeZone, new ComboContentAdapter(), + new SimpleContentProposalProvider( + new String[] { "Asia/Calcutta" }), + KeyStroke.getInstance("Ctrl+Space"), null); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + + /*Label lblTimeServer = toolkit.createLabel(sectionClient, "Network Time GlusterServer", + SWT.NONE);*/ + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage1.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage1.java new file mode 100644 index 00000000..146e2fa4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/SettingsPage1.java @@ -0,0 +1,173 @@ +package com.gluster.storage.management.gui.editor; + +import org.eclipse.jface.fieldassist.ComboContentAdapter; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.forms.editor.FormPage; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ColumnLayout; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.Section; + +public class SettingsPage1 extends FormPage { + + public static final String ID = "com.gluster.storage.management.gui.editor.ClusterSummaryPage"; + + /** + * Create the form page. + * + * @param id + * @param title + */ + public SettingsPage1(String title) { + super(ID, title); + } + + /** + * Create the form page. + * + * @param editor + * @param id + * @param title + * @wbp.parser.constructor + * @wbp.eval.method.parameter title "Some title" + */ + public SettingsPage1(FormEditor editor, String title) { + super(editor, ID, title); + } + + private void setupForm(FormToolkit toolkit, final ScrolledForm form) { + form.setText("Settings"); + toolkit.decorateFormHeading(form.getForm()); + + ColumnLayout layout = new ColumnLayout(); + + // layout.topMargin = 0; + // layout.bottomMargin = 5; + // layout.leftMargin = 10; + // layout.rightMargin = 10; + // layout.horizontalSpacing = 10; + // layout.verticalSpacing = 10; + // layout.maxNumColumns = 4; + // layout.minNumColumns = 1; + + form.getBody().setLayout(layout); + } + + /** + * Create contents of the form. + * + * @param managedForm + */ + @Override + protected void createFormContent(IManagedForm managedForm) { + FormToolkit toolkit = managedForm.getToolkit(); + final ScrolledForm form = managedForm.getForm(); + + setupForm(toolkit, form); + createClusterSettingsSection(toolkit, form); + createAppSettingsSection(toolkit, form); + } + + private Composite createSection(final ScrolledForm form, + FormToolkit toolkit, String title, String desc, int numColumns, + boolean collapsible) { + int style = Section.TITLE_BAR | Section.EXPANDED; + if (desc != null && !desc.isEmpty()) { + style |= Section.DESCRIPTION; + } + if (collapsible) { + style |= Section.TWISTIE; + } + + Section section = toolkit.createSection(form.getBody(), style); + section.setText(title); + section.setDescription(desc); + + //toolkit.createCompositeSeparator(section); + Composite client = toolkit.createComposite(section); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 10; + layout.numColumns = numColumns; + layout.verticalSpacing = 20; + client.setLayout(layout); + section.setClient(client); + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(false); + } + }); + return client; + } + + private void createAppSettingsSection(FormToolkit toolkit, + final ScrolledForm form) { + GridData layoutData = createDefaultLayoutData(); + + Composite sectionClient = createSection(form, toolkit, "Application Settings", null, + 2, false); + + toolkit.createButton(sectionClient, "Enable Remote CLI?", SWT.CHECK | SWT.FLAT); + toolkit.paintBordersFor(sectionClient); + } + + private void createClusterSettingsSection(FormToolkit toolkit, + final ScrolledForm form) { + GridData layoutData = createDefaultLayoutData(); + + Composite sectionClient = createSection(form, toolkit, "Cluster Settings", null, + 2, false); + + Label lblTimeZone = toolkit.createLabel(sectionClient, + "Time Zone: ", SWT.NONE); + Combo cboTimeZone = createTimeZoneCombo(sectionClient, layoutData); + + Label lblTimeServer = toolkit.createLabel(sectionClient, + "Network Time GlusterServer: ", SWT.NONE); + Text txtTimeServer = toolkit.createText(sectionClient, "pool.ntp.org", SWT.BORDER_SOLID); + txtTimeServer.setLayoutData(layoutData); + + toolkit.paintBordersFor(sectionClient); + } + + private GridData createDefaultLayoutData() { + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace=true; + layoutData.minimumWidth=200; + return layoutData; + } + + private Combo createTimeZoneCombo(Composite sectionClient, GridData layoutData) { + Combo cboTimeZone = new Combo(sectionClient, SWT.FLAT); + cboTimeZone.setData(FormToolkit.KEY_DRAW_BORDER, + FormToolkit.TEXT_BORDER); + cboTimeZone.setLayoutData(layoutData); + + for(String timeZone : TimeZones.timeZones) { + cboTimeZone.add(timeZone); + } + cboTimeZone.setText("Asia/Calcutta"); + + SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider( + TimeZones.timeZones); + proposalProvider.setFiltering(true); + ContentProposalAdapter proposalAdapter = new ContentProposalAdapter( + cboTimeZone, new ComboContentAdapter(), proposalProvider, null, + null); + proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); + + return cboTimeZone; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/ThirdPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/ThirdPage.java new file mode 100644 index 00000000..921624ec --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/ThirdPage.java @@ -0,0 +1,147 @@ +/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.gluster.storage.management.gui.editor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ColumnLayout;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+/**
+ * @author dejan
+ *
+ * To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Generation - Code and Comments
+ */
+public class ThirdPage extends FormPage {
+ /**
+ * @param id
+ * @param title
+ */
+ public ThirdPage(FormEditor editor) {
+ super(editor, "third", Messages.getString("ThirdPage.label")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ //FormToolkit toolkit = managedForm.getToolkit();
+ form.setText(Messages.getString("ThirdPage.title")); //$NON-NLS-1$
+ ColumnLayout layout = new ColumnLayout();
+ layout.topMargin = 0;
+ layout.bottomMargin = 5;
+ layout.leftMargin = 10;
+ layout.rightMargin = 10;
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 10;
+ layout.maxNumColumns = 4;
+ layout.minNumColumns = 1;
+ form.getBody().setLayout(layout);
+ //form.getBody().setBackground(
+ // form.getBody().getDisplay().getSystemColor(SWT.COLOR_GREEN));
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.ls1.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ls1.desc"), 2); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.ls2.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ls2.desc"), 2); //$NON-NLS-1$
+ createMixedSection(managedForm, Messages.getString("ThirdPage.ms1.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ms1.desc")); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.ls3.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ls3.desc"), 4); //$NON-NLS-1$
+ createSectionWithControls(managedForm, Messages.getString("ThirdPage.cs1.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.cs1.desc")); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.ls4.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ls4.desc"), 3); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.ls5.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ls5.desc"), 5); //$NON-NLS-1$
+ createMixedSection(managedForm, Messages.getString("ThirdPage.ms2.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.ms2.desc")); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.l6.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.l6.desc"), 2); //$NON-NLS-1$
+ createSectionWithControls(managedForm, Messages.getString("ThirdPage.cs2.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.cs2.desc")); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.l7.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.l7.desc"), 4); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.l8.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.l8.desc"), 2); //$NON-NLS-1$
+ createMixedSection(managedForm, Messages.getString("ThirdPage.m3.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.m3.desc")); //$NON-NLS-1$
+ createSectionWithLinks(managedForm, Messages.getString("ThirdPage.l9.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.l9.desc"), 2); //$NON-NLS-1$
+ createSectionWithControls(managedForm, Messages.getString("ThirdPage.c3.name"), //$NON-NLS-1$
+ Messages.getString("ThirdPage.c3.desc")); //$NON-NLS-1$
+ }
+ private void createSectionWithLinks(IManagedForm mform, String title,
+ String desc, int nlinks) {
+ Composite client = createSection(mform, title, desc, 1);
+ FormToolkit toolkit = mform.getToolkit();
+ for (int i = 1; i <= nlinks; i++)
+ toolkit.createHyperlink(client, Messages.getString("ThirdPage.link") + i, SWT.WRAP); //$NON-NLS-1$
+ }
+ private void createSectionWithControls(IManagedForm mform, String title,
+ String desc) {
+ Composite client = createSection(mform, title, desc, 1);
+ FormToolkit toolkit = mform.getToolkit();
+ toolkit.createButton(client, Messages.getString("ThirdPage.button1"), SWT.RADIO); //$NON-NLS-1$
+ toolkit.createButton(client, Messages.getString("ThirdPage.button2"), SWT.RADIO); //$NON-NLS-1$
+ toolkit.createButton(client, Messages.getString("ThirdPage.button3"), //$NON-NLS-1$
+ SWT.RADIO);
+ toolkit.createButton(client, Messages.getString("ThirdPage.checkbox"), SWT.CHECK); //$NON-NLS-1$
+ }
+ private void createMixedSection(IManagedForm mform, String title, String desc) {
+ Composite client = createSection(mform, title, desc, 2);
+ FormToolkit toolkit = mform.getToolkit();
+ Hyperlink link = toolkit.createHyperlink(client,
+ Messages.getString("ThirdPage.longlink"), SWT.WRAP); //$NON-NLS-1$
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ link.setLayoutData(gd);
+ link = toolkit.createHyperlink(client, Messages.getString("ThirdPage.link2"), //$NON-NLS-1$
+ SWT.WRAP);
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ link.setLayoutData(gd);
+ toolkit.createLabel(client, Messages.getString("ThirdPage.textLabel")); //$NON-NLS-1$
+ Text text = toolkit.createText(client, "", SWT.SINGLE); //$NON-NLS-1$
+ gd = new GridData();
+ gd.widthHint = 150;
+ text.setLayoutData(gd);
+ //toolkit.paintBordersFor(client);
+ }
+ private Composite createSection(IManagedForm mform, String title,
+ String desc, int numColumns) {
+ final ScrolledForm form = mform.getForm();
+ FormToolkit toolkit = mform.getToolkit();
+ Section section = toolkit.createSection(form.getBody(), Section.TWISTIE
+ | Section.TITLE_BAR | Section.DESCRIPTION | Section.EXPANDED);
+ section.setText(title);
+ section.setDescription(desc);
+ //toolkit.createCompositeSeparator(section);
+ Composite client = toolkit.createComposite(section);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ layout.numColumns = numColumns;
+ client.setLayout(layout);
+ section.setClient(client);
+ section.addExpansionListener(new ExpansionAdapter() {
+ public void expansionStateChanged(ExpansionEvent e) {
+ form.reflow(false);
+ }
+ });
+ return client;
+ }
+}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/TimeZones.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/TimeZones.java new file mode 100644 index 00000000..278c0830 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/TimeZones.java @@ -0,0 +1,161 @@ +package com.gluster.storage.management.gui.editor; + +public interface TimeZones { + public String[] timeZones = { "Africa/Abidjan", "Africa/Accra", + "Africa/Addis_Ababa", "Africa/Algiers", "Africa/Asmara", + "Africa/Asmera", "Africa/Bamako", "Africa/Bangui", "Africa/Banjul", + "Africa/Bissau", "Africa/Blantyre", "Africa/Brazzaville", + "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", + "Africa/Ceuta", "Africa/Conakry", "Africa/Dakar", + "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Douala", + "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone", + "Africa/Harare", "Africa/Johannesburg", "Africa/Kampala", + "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", + "Africa/Lagos", "Africa/Libreville", "Africa/Lome", + "Africa/Luanda", "Africa/Lubumbashi", "Africa/Lusaka", + "Africa/Malabo", "Africa/Maputo", "Africa/Maseru", + "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", + "Africa/Nairobi", "Africa/Ndjamena", "Africa/Niamey", + "Africa/Nouakchott", "Africa/Ouagadougou", "Africa/Porto-Novo", + "Africa/Sao_Tome", "Africa/Timbuktu", "Africa/Tripoli", + "Africa/Tunis", "Africa/Windhoek", "America/Adak", + "America/Anchorage", "America/Anguilla", "America/Antigua", + "America/Araguaina", "America/Argentina/Buenos_Aires", + "America/Argentina/Catamarca", "America/Argentina/ComodRivadavia", + "America/Argentina/Cordoba", "America/Argentina/Jujuy", + "America/Argentina/La_Rioja", "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", "America/Argentina/Salta", + "America/Argentina/San_Juan", "America/Argentina/San_Luis", + "America/Argentina/Tucuman", "America/Argentina/Ushuaia", + "America/Aruba", "America/Asuncion", "America/Atikokan", + "America/Atka", "America/Bahia", "America/Barbados", + "America/Belem", "America/Belize", "America/Blanc-Sablon", + "America/Boa_Vista", "America/Bogota", "America/Boise", + "America/Buenos_Aires", "America/Cambridge_Bay", + "America/Campo_Grande", "America/Cancun", "America/Caracas", + "America/Catamarca", "America/Cayenne", "America/Cayman", + "America/Chicago", "America/Chihuahua", "America/Coral_Harbour", + "America/Cordoba", "America/Costa_Rica", "America/Cuiaba", + "America/Curacao", "America/Danmarkshavn", "America/Dawson", + "America/Dawson_Creek", "America/Denver", "America/Detroit", + "America/Dominica", "America/Edmonton", "America/Eirunepe", + "America/El_Salvador", "America/Ensenada", "America/Fortaleza", + "America/Fort_Wayne", "America/Glace_Bay", "America/Godthab", + "America/Goose_Bay", "America/Grand_Turk", "America/Grenada", + "America/Guadeloupe", "America/Guatemala", "America/Guayaquil", + "America/Guyana", "America/Halifax", "America/Havana", + "America/Hermosillo", "America/Indianapolis", + "America/Indiana/Indianapolis", "America/Indiana/Knox", + "America/Indiana/Marengo", "America/Indiana/Petersburg", + "America/Indiana/Tell_City", "America/Indiana/Vevay", + "America/Indiana/Vincennes", "America/Indiana/Winamac", + "America/Inuvik", "America/Iqaluit", "America/Jamaica", + "America/Jujuy", "America/Juneau", "America/Kentucky/Louisville", + "America/Kentucky/Monticello", "America/Knox_IN", "America/La_Paz", + "America/Lima", "America/Los_Angeles", "America/Louisville", + "America/Maceio", "America/Managua", "America/Manaus", + "America/Marigot", "America/Martinique", "America/Mazatlan", + "America/Mendoza", "America/Menominee", "America/Merida", + "America/Mexico_City", "America/Miquelon", "America/Moncton", + "America/Monterrey", "America/Montevideo", "America/Montreal", + "America/Montserrat", "America/Nassau", "America/New_York", + "America/Nipigon", "America/Nome", "America/Noronha", + "America/North_Dakota/Center", "America/North_Dakota/New_Salem", + "America/Panama", "America/Pangnirtung", "America/Paramaribo", + "America/Phoenix", "America/Porto_Acre", "America/Porto_Velho", + "America/Port-au-Prince", "America/Port_of_Spain", + "America/Puerto_Rico", "America/Rainy_River", + "America/Rankin_Inlet", "America/Recife", "America/Regina", + "America/Resolute", "America/Rio_Branco", "America/Rosario", + "America/Santarem", "America/Santiago", "America/Santo_Domingo", + "America/Sao_Paulo", "America/Scoresbysund", "America/Shiprock", + "America/St_Barthelemy", "America/St_Johns", "America/St_Kitts", + "America/St_Lucia", "America/St_Thomas", "America/St_Vincent", + "America/Swift_Current", "America/Tegucigalpa", "America/Thule", + "America/Thunder_Bay", "America/Tijuana", "America/Toronto", + "America/Tortola", "America/Vancouver", "America/Virgin", + "America/Whitehorse", "America/Winnipeg", "America/Yakutat", + "America/Yellowknife", "Antarctica/Casey", "Antarctica/Davis", + "Antarctica/DumontDUrville", "Antarctica/Mawson", + "Antarctica/McMurdo", "Antarctica/Palmer", "Antarctica/Rothera", + "Antarctica/South_Pole", "Antarctica/Syowa", "Antarctica/Vostok", + + "Arctic/Longyearbyen", + + "Asia/Aden", "Asia/Almaty", "Asia/Amman", "Asia/Anadyr", + "Asia/Aqtau", "Asia/Aqtobe", "Asia/Ashgabat", "Asia/Ashkhabad", + "Asia/Baghdad", "Asia/Bahrain", "Asia/Baku", "Asia/Bangkok", + "Asia/Beirut", "Asia/Bishkek", "Asia/Brunei", "Asia/Calcutta", + "Asia/Choibalsan", "Asia/Chongqing", "Asia/Chungking", + "Asia/Colombo", "Asia/Dacca", "Asia/Damascus", "Asia/Dhaka", + "Asia/Dili", "Asia/Dubai", "Asia/Dushanbe", "Asia/Gaza", + "Asia/Harbin", "Asia/Hong_Kong", "Asia/Hovd", "Asia/Ho_Chi_Minh", + "Asia/Irkutsk", "Asia/Istanbul", "Asia/Jakarta", "Asia/Jayapura", + "Asia/Jerusalem", "Asia/Kabul", "Asia/Kamchatka", "Asia/Karachi", + "Asia/Kashgar", "Asia/Kathmandu", "Asia/Katmandu", "Asia/Kolkata", + "Asia/Krasnoyarsk", "Asia/Kuala_Lumpur", "Asia/Kuching", + "Asia/Kuwait", "Asia/Macao", "Asia/Macau", "Asia/Magadan", + "Asia/Makassar", "Asia/Manila", "Asia/Muscat", "Asia/Nicosia", + "Asia/Novokuznetsk", "Asia/Novosibirsk", "Asia/Omsk", "Asia/Oral", + "Asia/Phnom_Penh", "Asia/Pontianak", "Asia/Pyongyang", + "Asia/Qatar", "Asia/Qyzylorda", "Asia/Rangoon", "Asia/Riyadh", + "Asia/Riyadh87", "Asia/Riyadh88", "Asia/Riyadh89", "Asia/Saigon", + "Asia/Sakhalin", "Asia/Samarkand", "Asia/Seoul", "Asia/Shanghai", + "Asia/Singapore", "Asia/Taipei", "Asia/Tashkent", "Asia/Tbilisi", + "Asia/Tehran", "Asia/Tel_Aviv", "Asia/Thimbu", "Asia/Thimphu", + "Asia/Tokyo", "Asia/Ujung_Pandang", "Asia/Ulaanbaatar", + "Asia/Ulan_Bator", "Asia/Urumqi", "Asia/Vientiane", + "Asia/Vladivostok", "Asia/Yakutsk", "Asia/Yekaterinburg", + "Asia/Yerevan", + + "Atlantic/Azores", "Atlantic/Bermuda", "Atlantic/Canary", + "Atlantic/Cape_Verde", "Atlantic/Faeroe", "Atlantic/Faroe", + "Atlantic/Jan_Mayen", "Atlantic/Madeira", "Atlantic/Reykjavik", + "Atlantic/South_Georgia", "Atlantic/Stanley", "Atlantic/St_Helena", + "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", + "Australia/Broken_Hill", "Australia/Canberra", "Australia/Currie", + "Australia/Darwin", "Australia/Eucla", "Australia/Hobart", + "Australia/LHI", "Australia/Lindeman", "Australia/Lord_Howe", + "Australia/Melbourne", "Australia/NSW", "Australia/North", + "Australia/Perth", "Australia/Queensland", "Australia/South", + "Australia/Sydney", "Australia/Tasmania", "Australia/Victoria", + "Australia/West", "Australia/Yancowinna", + + "Europe/Amsterdam", "Europe/Andorra", "Europe/Athens", + "Europe/Belfast", "Europe/Belgrade", "Europe/Berlin", + "Europe/Bratislava", "Europe/Brussels", "Europe/Bucharest", + "Europe/Budapest", "Europe/Chisinau", "Europe/Copenhagen", + "Europe/Dublin", "Europe/Gibraltar", "Europe/Guernsey", + "Europe/Helsinki", "Europe/Isle_of_Man", "Europe/Istanbul", + "Europe/Jersey", "Europe/Kaliningrad", "Europe/Kiev", + "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", + "Europe/Luxembourg", "Europe/Madrid", "Europe/Malta", + "Europe/Mariehamn", "Europe/Minsk", "Europe/Monaco", + "Europe/Moscow", "Europe/Nicosia", "Europe/Oslo", "Europe/Paris", + "Europe/Podgorica", "Europe/Prague", "Europe/Riga", "Europe/Rome", + "Europe/Samara", "Europe/San_Marino", "Europe/Sarajevo", + "Europe/Simferopol", "Europe/Skopje", "Europe/Sofia", + "Europe/Stockholm", "Europe/Tallinn", "Europe/Tirane", + "Europe/Tiraspol", "Europe/Uzhgorod", "Europe/Vaduz", + "Europe/Vatican", "Europe/Vienna", "Europe/Vilnius", + "Europe/Volgograd", "Europe/Warsaw", "Europe/Zagreb", + "Europe/Zaporozhye", "Europe/Zurich", + + "Indian/Antananarivo", "Indian/Chagos", "Indian/Christmas", + "Indian/Cocos", "Indian/Comoro", "Indian/Kerguelen", "Indian/Mahe", + "Indian/Maldives", "Indian/Mauritius", "Indian/Mayotte", + "Indian/Reunion", "Pacific/Apia", "Pacific/Auckland", + "Pacific/Chatham", "Pacific/Easter", "Pacific/Efate", + "Pacific/Enderbury", "Pacific/Fakaofo", "Pacific/Fiji", + "Pacific/Funafuti", "Pacific/Galapagos", "Pacific/Gambier", + "Pacific/Guadalcanal", "Pacific/Guam", "Pacific/Honolulu", + "Pacific/Johnston", "Pacific/Kiritimati", "Pacific/Kosrae", + "Pacific/Kwajalein", "Pacific/Majuro", "Pacific/Marquesas", + "Pacific/Midway", "Pacific/Nauru", "Pacific/Niue", + "Pacific/Norfolk", "Pacific/Noumea", "Pacific/Pago_Pago", + "Pacific/Palau", "Pacific/Pitcairn", "Pacific/Ponape", + "Pacific/Port_Moresby", "Pacific/Rarotonga", "Pacific/Saipan", + "Pacific/Samoa", "Pacific/Tahiti", "Pacific/Tarawa", + "Pacific/Tongatapu", "Pacific/Truk", "Pacific/Wake", + "Pacific/Wallis", "Pacific/Yap", "UTC" }; +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/messages_en_IN.properties b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/messages_en_IN.properties new file mode 100644 index 00000000..e0ff7a02 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/editor/messages_en_IN.properties @@ -0,0 +1,96 @@ +FreeFormPage.label=First Page
+FreeFormPage.title=Free-form text with links
+FreeFormPage.link=Sample hyperlink with longer text.
+FreeFormPage.button=Button
+FreeFormPage.sectionTitle1=Expandable Section with a longer title
+FreeFormPage.sectionTitle2=Section title
+FreeFormPage.sectionDescription=This is a section description that should be rendered below the separator.
+FreeFormPage.mtitle=Eclipse Forms
+FreeFormPage.mtext=Link activated: href=
+SecondPage.label=Section Page
+SecondPage.title=Title for the second page
+SecondPage.firstSection=First Table Section
+SecondPage.secondSection=Second Table Section
+SecondPage.add=Add...
+SecondPage.desc=This section has a tree and a button.
+ScrolledPropertiesBlock.sname=Model Objects
+ScrolledPropertiesBlock.sdesc=The list contains objects from the model whose details are editable on the right
+ScrolledPropertiesBlock.add=Add...
+ScrolledPropertiesBlock.horizontal=Horizontal orientation
+ScrolledPropertiesBlock.vertical=Vertical orientation
+TypeOneDetailsPage.name=Set the properties of the selected TypeOne object.
+TypeTwoDetailsPage.name=Type Two Details
+TypeTwoDetailsPage.desc=Set the properties of the selected TypeTwo object.
+TypeOneDetailsPage.check=Value of the flag property
+TypeOneDetailsPage.label=Text property:
+TypeTwoDetailsPage.flag1=Value of the flag1 property
+TypeTwoDetailsPage.flag2=Value of the flag2 property
+OpenSimpleFormEditorAction.name=Simple Editor
+SimpleModel.t1_i1=TypeOne instance 1
+SimpleModel.text1=Some text
+SimpleModel.t1_i2=TypeOne instance 2
+SimpleModel.text2=Different text
+SimpleModel.t1_i3=TypeOne instance 3
+SimpleModel.text3=Text
+SimpleModel.t1_i4=TypeOne instance 4
+SimpleModel.text4=Longer text
+SimpleModel.t1_i5=TypeOne instance 5
+SimpleModel.text5=Sample
+SimpleModel.t2_i1=TypeTwo instance 1
+SimpleModel.t2_i2=TypeTwo instance 2
+MasterDetailsPage.label=Master Details
+MasterDetailsPage.title=Form with scrolled sections
+ThirdPage.label=Flow Page
+ThirdPage.title=Form with wrapped controls
+ThirdPage.ls1.name=Link Section
+ThirdPage.ls1.desc=An example of a section with links
+ThirdPage.ls2.name=Link Section
+ThirdPage.ls2.desc=An example of a section with links
+ThirdPage.ms1.name=Mixed Section
+ThirdPage.ms1.desc=An example of a section with both links and form controls
+ThirdPage.ls3.name=Link Section
+ThirdPage.ls3.desc=An example of a section with links
+ThirdPage.cs1.name=Control Section
+ThirdPage.cs1.desc=An example of a section with form controls
+ThirdPage.ls4.name=Sample Section
+ThirdPage.ls4.desc=An example of a section with links
+ThirdPage.ls5.name=Sample Section
+ThirdPage.ls5.desc=An example of a section with links
+ThirdPage.ms2.name=Mixed Section
+ThirdPage.ms2.desc=An example of a section with both links and form controls
+ThirdPage.l6.name=Sample Section
+ThirdPage.l6.desc=An example of a section with links
+ThirdPage.cs2.name=Control Section
+ThirdPage.cs2.desc=An example of a section with links
+ThirdPage.l7.name=Sample Section
+ThirdPage.l7.desc=An example of a section with links
+ThirdPage.l8.name=Sample Section
+ThirdPage.l8.desc=An example of a section with links
+ThirdPage.m3.name=Mixed Section
+ThirdPage.m3.desc=An example of a section with both links and form controls
+ThirdPage.l9.name=Sample Section
+ThirdPage.l9.desc=An example of a section with links
+ThirdPage.c3.name=Control Section
+ThirdPage.c3.desc=An example of a section with form controls
+ThirdPage.link=Hyperlink text
+ThirdPage.button1=A radio button 1
+ThirdPage.button2=A radio button 2
+ThirdPage.button3=A radio button with a longer text
+ThirdPage.checkbox=A checkbox button
+ThirdPage.longlink=A longer hyperlink text example
+ThirdPage.link2=Another hyperlink text
+ThirdPage.textLabel=A text label:
+PageWithSubPages.label=Composite Page
+PageWithSubPages.title=Form with subpages
+PageWithSubPages.copyright.tab=Copyright
+PageWithSubPages.copyright.text=Copyright 2004 IBM and others.
+PageWithSubPages.license.tab=License Agreement
+PageWithSubPages.license.text=LICENSE AGREEMENT\n\nUse this feature any way you want.
+PageWithSubPages.desc.tab=Description
+PageWithSubPages.desc.text=A simple description of the feature
+PageWithSubPages.apply=Apply
+PageWithSubPages.reset=Reset
+TypeOne.c1=Choice 1
+TypeOne.c2=Choice 2
+TypeOne.c3=Choice 3
+TypeOne.c4=Choice 4
diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java new file mode 100644 index 00000000..7614a06d --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java @@ -0,0 +1,66 @@ +package com.gluster.storage.management.gui.jobs; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ui.progress.IProgressConstants; +import org.eclipse.ui.progress.IProgressConstants2; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Disk.DISK_STATUS; +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class InitializeDiskJob extends Job { + private Disk disk; + private Application app = Application.getApplication(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + public InitializeDiskJob(Disk disk) { + super("Initialize Disk [" + disk.getQualifiedName() + "]"); + this.disk = disk; + setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE); + setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); + setProperty(IProgressConstants.ICON_PROPERTY, guiHelper.getImageDescriptor(IImageKeys.WORK_IN_PROGRESS)); + } + + private void updateStatus(final DISK_STATUS status) { + disk.setStatus(status); + disk.setSpaceInUse(0d); + app.entityChanged(disk, new String[] { "status", "spaceInUse" }); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + monitor.beginTask("Formatting the disk...", 100); + boolean cancelRequested = false; + String msgPrefix = ""; + try { + for (int i = 1; i <= 5; i++) { + if (!cancelRequested && monitor.isCanceled()) { + cancelRequested = true; // come only once here + + msgPrefix = "This task cannot be cancelled! "; + monitor.setTaskName(msgPrefix); +// setProperty(IProgressConstants.ICON_PROPERTY, guiHelper.getImageDescriptor(IImageKeys.STATUS_CANCELLED)); +// +// updateStatus(DISK_STATUS.UNINITIALIZED); +// return new Status(Status.CANCEL, Application.PLUGIN_ID, "Cancelled"); + } + Thread.sleep(2000); + monitor.worked(20); + monitor.setTaskName(msgPrefix + "[" + 20 * i + "%] completed"); + } + monitor.done(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + updateStatus(DISK_STATUS.READY); + setProperty(IProgressConstants.ICON_PROPERTY, guiHelper.getImageDescriptor(IImageKeys.STATUS_SUCCESS)); + + return new Status(Status.OK, Application.PLUGIN_ID, "Task Completed!"); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java new file mode 100644 index 00000000..230832e1 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java @@ -0,0 +1,192 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005 Jean-Michel Lemieux, Jeff McAffer and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Hyperbola is an RCP application developed for the book + * Eclipse Rich Client Platform - + * Designing, Coding, and Packaging Java Applications + * Addison-Wesley, Summer 2005 + * + * Contributors: + * Jean-Michel Lemieux and Jeff McAffer - initial implementation + * Nick Edgar and Pascal Rapicault - additional work for EclipseCon 2005 tutorial + * http://www.eclipsecon.org/presentations/EclipseCon2005_Tutorial26.pdf + *******************************************************************************/ +package com.gluster.storage.management.gui.login; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +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.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.gluster.storage.management.client.AuthManager; +import com.gluster.storage.management.core.model.ConnectionDetails; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.validators.StringRequiredValidator; + +/** + * Login dialog, which prompts for the user's account info, and has Login and Cancel buttons. + */ +public class LoginDialog extends Dialog { + + private Text userIdText = null; + private Text passwordText = null; + private Button okButton; + + private final ConnectionDetails connectionDetails = new ConnectionDetails("", "gluster", ""); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Composite composite; + + public LoginDialog(Shell parentShell) { + super(parentShell); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + private void createUserIdLabel(Composite composite) { + Label userIdLabel = new Label(composite, SWT.NONE); + userIdLabel.setText("&User ID:"); + userIdLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createUserIdText(Composite composite) { + userIdText = new Text(composite, SWT.BORDER); + userIdText.setText("gluster"); + userIdText.setEnabled(false); + + GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); + ; + layoutData.widthHint = convertWidthInCharsToPixels(32); + userIdText.setLayoutData(layoutData); + } + + private void createPasswordLabel(Composite composite) { + Label passwordLabel = new Label(composite, SWT.NONE); + passwordLabel.setText("&Password:"); + passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createPasswordText(Composite composite) { + passwordText = new Text(composite, SWT.BORDER | SWT.PASSWORD); + + GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); + ; + layoutData.widthHint = convertWidthInCharsToPixels(32); + passwordText.setLayoutData(layoutData); + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 2; + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 20; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 20; + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + guiHelper.centerShellInScreen(getShell()); + } + + @Override + protected Control createDialogArea(Composite parent) { + parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); + parent.setBackgroundMode(SWT.INHERIT_FORCE); // Makes sure that child composites inherit the same background + + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + + createUserIdLabel(composite); + createUserIdText(composite); + + createPasswordLabel(composite); + createPasswordText(composite); + + return composite; + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + okButton = createButton(parent, IDialogConstants.OK_ID, "&Login", true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + + setupDataBinding(); + } + + /** + * Sets up data binding between the text fields and the connection details object. Also attaches a "string required" + * validator to the "password" text field. This validator is configured to do the following on validation failure<br> + * <li>show an ERROR decorator</li><li>disable the "Login" button + */ + private void setupDataBinding() { + DataBindingContext dataBindingContext = new DataBindingContext(SWTObservables.getRealm(Display.getCurrent())); + UpdateValueStrategy passwordBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + + // The Validator shows error decoration and disables OK button on validation failure + passwordBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter password!", guiHelper + .createErrorDecoration(passwordText), okButton)); + + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(passwordText), + PojoProperties.value("password").observe(connectionDetails), passwordBindingStrategy, + passwordBindingStrategy); + + UpdateValueStrategy userIdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + dataBindingContext + .bindValue(WidgetProperties.text(SWT.Modify).observe(userIdText), PojoProperties.value("userId") + .observe(connectionDetails), userIdBindingStrategy, userIdBindingStrategy); + } + + protected void okPressed() { + if (new AuthManager().authenticate(connectionDetails)) { + super.okPressed(); + } else { + MessageDialog.openError(getShell(), "Authentication Failed", "Invalid User ID or password"); + return; + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ClusterPreferencePage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ClusterPreferencePage.java new file mode 100644 index 00000000..afec45b9 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ClusterPreferencePage.java @@ -0,0 +1,65 @@ +package com.gluster.storage.management.gui.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; + +import com.gluster.storage.management.gui.Activator; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class ClusterPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public ClusterPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH, + "&Directory preference:", getFieldEditorParent())); + addField( + new BooleanFieldEditor( + PreferenceConstants.P_BOOLEAN, + "&An example of a boolean preference", + getFieldEditorParent())); + + addField(new RadioGroupFieldEditor( + PreferenceConstants.P_CHOICE, + "An example of a multiple-choice preference", + 1, + new String[][] { { "&Choice 1", "choice1" }, { + "C&hoice 2", "choice2" } + }, getFieldEditorParent())); + addField( + new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ConsolePreferencePage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ConsolePreferencePage.java new file mode 100644 index 00000000..c06d385a --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ConsolePreferencePage.java @@ -0,0 +1,65 @@ +package com.gluster.storage.management.gui.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; + +import com.gluster.storage.management.gui.Activator; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class ConsolePreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public ConsolePreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH, + "&Directory preference:", getFieldEditorParent())); + addField( + new BooleanFieldEditor( + PreferenceConstants.P_BOOLEAN, + "&An example of a boolean preference", + getFieldEditorParent())); + + addField(new RadioGroupFieldEditor( + PreferenceConstants.P_CHOICE, + "An example of a multiple-choice preference", + 1, + new String[][] { { "&Choice 1", "choice1" }, { + "C&hoice 2", "choice2" } + }, getFieldEditorParent())); + addField( + new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java new file mode 100644 index 00000000..3d25e992 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java @@ -0,0 +1,65 @@ +package com.gluster.storage.management.gui.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; + +import com.gluster.storage.management.gui.Activator; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class GlusterPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public GlusterPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("A demonstration of a preference page implementation"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH, + "&Directory preference:", getFieldEditorParent())); + addField( + new BooleanFieldEditor( + PreferenceConstants.P_BOOLEAN, + "&An example of a boolean preference", + getFieldEditorParent())); + + addField(new RadioGroupFieldEditor( + PreferenceConstants.P_CHOICE, + "An example of a multiple-choice preference", + 1, + new String[][] { { "&Choice 1", "choice1" }, { + "C&hoice 2", "choice2" } + }, getFieldEditorParent())); + addField( + new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceConstants.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceConstants.java new file mode 100644 index 00000000..3903eb6e --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceConstants.java @@ -0,0 +1,16 @@ +package com.gluster.storage.management.gui.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_PATH = "pathPreference"; + + public static final String P_BOOLEAN = "booleanPreference"; + + public static final String P_CHOICE = "choicePreference"; + + public static final String P_STRING = "stringPreference"; + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceInitializer.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceInitializer.java new file mode 100644 index 00000000..5263a5a1 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/PreferenceInitializer.java @@ -0,0 +1,26 @@ +package com.gluster.storage.management.gui.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import com.gluster.storage.management.gui.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/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/IToolbarManager.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/IToolbarManager.java new file mode 100644 index 00000000..93319be4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/IToolbarManager.java @@ -0,0 +1,17 @@ +package com.gluster.storage.management.gui.toolbar; + +import com.gluster.storage.management.core.model.Entity; + +/** + * Whenever the current selection/action demands changes to the toolbar, the toolbar manager is used to update the + * toolbar. + */ +public interface IToolbarManager { + /** + * Updates the toolbar for given entity. This typically means that user is working with the given entity, and hence + * the toolbar actions related to that entity should be made visible, and other un-related actions should be hidden. + * + * @param entity + */ + public void updateToolbar(Entity entity); +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/ToolbarManager.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/ToolbarManager.java new file mode 100644 index 00000000..56831267 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/toolbar/ToolbarManager.java @@ -0,0 +1,84 @@ +package com.gluster.storage.management.gui.toolbar; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; + +import com.gluster.storage.management.core.model.Cluster; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.actions.IActionSetIDs; + +public class ToolbarManager implements IToolbarManager { + private enum ENTITY_TYPE { + CLUSTER, VOLUMES, VOLUME, GLUSTER_SERVERS, GLUSTER_SERVER, DISCOVERED_SERVERS, DISCOVERED_SERVER + }; + + private IWorkbenchWindow window; + private final Map<Class<? extends Entity>, ENTITY_TYPE> entityTypeMap = createEntityTypeMap(); + private final Map<ENTITY_TYPE, String> actionSetMap = createActionSetMap(); + + private Map<Class<? extends Entity>, ENTITY_TYPE> createEntityTypeMap() { + Map<Class<? extends Entity>, ENTITY_TYPE> entityTypeMap = new HashMap<Class<? extends Entity>, ToolbarManager.ENTITY_TYPE>(); + entityTypeMap.put(Cluster.class, ENTITY_TYPE.CLUSTER); + entityTypeMap.put(Volume.class, ENTITY_TYPE.VOLUME); + entityTypeMap.put(Server.class, ENTITY_TYPE.DISCOVERED_SERVER); + entityTypeMap.put(GlusterServer.class, ENTITY_TYPE.GLUSTER_SERVER); + + return entityTypeMap; + } + + private Map<ENTITY_TYPE, String> createActionSetMap() { + Map<ENTITY_TYPE, String> actionSetMap = new HashMap<ToolbarManager.ENTITY_TYPE, String>(); + actionSetMap.put(ENTITY_TYPE.CLUSTER, IActionSetIDs.ACTION_SET_CLUSTER); + actionSetMap.put(ENTITY_TYPE.VOLUMES, IActionSetIDs.ACTION_SET_VOLUMES); + actionSetMap.put(ENTITY_TYPE.VOLUME, IActionSetIDs.ACTION_SET_VOLUME); + actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVERS, IActionSetIDs.ACTION_SET_GLUSTER_SERVERS); + actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVER, IActionSetIDs.ACTION_SET_GLUSTER_SERVER); + actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVERS, IActionSetIDs.ACTION_SET_DISCOVERED_SERVERS); + actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVER, IActionSetIDs.ACTION_SET_DISCOVERED_SERVER); + + return actionSetMap; + } + + public ToolbarManager(IWorkbenchWindow window) { + this.window = window; + } + + @SuppressWarnings("rawtypes") + private ENTITY_TYPE getEntityType(Entity entity) { + if (entity instanceof EntityGroup) { + EntityGroup entityGroup = (EntityGroup) entity; + if (entityGroup.getEntityType() == Volume.class) { + return ENTITY_TYPE.VOLUMES; + } else if (entityGroup.getEntityType() == GlusterServer.class) { + return ENTITY_TYPE.GLUSTER_SERVERS; + } else { + return ENTITY_TYPE.DISCOVERED_SERVERS; + } + } + + return entityTypeMap.get(entity.getClass()); + } + + @Override + public void updateToolbar(Entity entity) { + ENTITY_TYPE entityType = getEntityType(entity); + IWorkbenchPage page = window.getActivePage(); + + for (ENTITY_TYPE targetEntityType : actionSetMap.keySet()) { + String actionSetId = actionSetMap.get(targetEntityType); + if (entityType == targetEntityType) { + // show only the action set mapped to given entity + page.showActionSet(actionSetId); + } else { + page.hideActionSet(actionSetId); + } + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePicker.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePicker.java new file mode 100644 index 00000000..77ec58f7 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePicker.java @@ -0,0 +1,513 @@ +package com.gluster.storage.management.gui.utils;
+
+import java.text.DateFormatSymbols;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TypedListener;
+
+/**
+ * The date picker panel
+ *
+ * changes by sebthom
+ * ~ setDate will fire the Selection event
+ * + you can use setDate(null) to clear the selection,
+ * the calendar will display the current date, but
+ * getDate will return null until the user explicitely
+ * selects a date from the control
+ *
+ * @author <a href="mailto:andy@tiff.ru">Andrey Onistchuk</a>
+ */
+public class DatePicker extends Composite {
+
+ //~ Inner Classes
+ // ----------------------------------------------------------
+ private class DatePanel extends Canvas {
+ //~ Instance fields
+ // ----------------------------------------------------
+ private int colSize;
+ private Display display = Display.getCurrent();
+ private int rowSize;
+ private Calendar temp = Calendar.getInstance();
+
+ //~ Constructors
+ // -------------------------------------------------------
+ public DatePanel(Composite parent, int style) {
+ super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
+
+ GC gc = new GC(this);
+ Point p = gc.stringExtent("Q");
+ gc.dispose();
+ colSize = p.x * 3;
+ rowSize = (int) (p.y * 1.2);
+
+ addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ onPaint(event);
+ }
+ });
+ addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ redraw();
+ }
+ });
+ addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ onKeyDown(e);
+ }
+ });
+ addMouseListener(new MouseAdapter() {
+ public void mouseDoubleClick(MouseEvent e) {
+ doubleClick();
+ }
+ public void mouseDown(MouseEvent e) {
+ onMouseDown(e);
+ }
+ });
+ addMouseMoveListener(new MouseMoveListener() {
+ public void mouseMove(MouseEvent e) {
+ onMouseMove(e);
+ }
+ });
+ }
+
+ //~ Methods
+ // ------------------------------------------------------------
+ private int computeOffset(int day) {
+ switch (day) {
+ case Calendar.MONDAY :
+ return 1;
+ case Calendar.TUESDAY :
+ return 2;
+ case Calendar.WEDNESDAY :
+ return 3;
+ case Calendar.THURSDAY :
+ return 4;
+ case Calendar.FRIDAY :
+ return 5;
+ case Calendar.SATURDAY :
+ return 6;
+ case Calendar.SUNDAY :
+ return 7;
+ }
+ return -1;
+ }
+
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ return new Point(colSize * 7, rowSize * 7);
+ }
+
+ /**
+ * Method drawTextImage.
+ *
+ * @param gc
+ * @param string
+ * @param object
+ * @param i
+ * @param i1
+ * @param i2
+ * @param colSize
+ * @param rowSize
+ */
+ private void drawTextImage(GC gc, String string, int x, int y,
+ int colSize, int rowSize) {
+ gc.fillRectangle(x, y, colSize, rowSize);
+ gc.drawString(string, x, y, true);
+ }
+
+ private int getDayFromPoint(int x, int y) {
+ int result = -1;
+
+ for (int i = 1; i <= 31; i++) {
+ Point p = getDayPoint(i);
+ Rectangle r = new Rectangle(p.x, p.y, colSize, rowSize);
+ if (r.contains(x, y)) {
+ result = i;
+ break;
+ }
+ }
+ return result;
+ }
+
+ private String getDayName(int day) {
+ return dateSymbols.getShortWeekdays()[day];
+ }
+
+ private Point getDayPoint(int day) {
+ syncTime();
+ temp.set(Calendar.DAY_OF_MONTH, 1);
+
+ int firstDayOffset = computeOffset(temp.get(Calendar.DAY_OF_WEEK))
+ - 1;
+ temp.set(Calendar.DAY_OF_MONTH, day);
+ int dayOffset = computeOffset(temp.get(Calendar.DAY_OF_WEEK));
+ int x = (dayOffset - 1) * colSize;
+ int y = (1 + (((firstDayOffset + day) - 1) / 7)) * rowSize;
+
+ return new Point(x, y);
+ }
+
+ private int getMaxDay() {
+ syncTime();
+
+ int day = 28;
+
+ for (int i = 0; i < 10; i++) {
+ temp.set(Calendar.DAY_OF_MONTH, day);
+
+ if (temp.get(Calendar.MONTH) != cal.get(Calendar.MONTH)) {
+ return day - 1;
+ }
+ day++;
+ }
+ return -1;
+ }
+
+ private void onKeyDown(KeyEvent e) {
+ if (e.character == SWT.ESC) {
+ dateSelected(false);
+ return;
+ }
+
+ if ((e.character == ' ') || (e.character == '\r')) {
+ dateSelected(true);
+ return;
+ }
+
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+ int month = cal.get(Calendar.MONTH);
+ int oldDay = day;
+ int oldMonth = month;
+
+ if (e.keyCode == SWT.ARROW_LEFT) {
+ day--;
+ }
+
+ if (e.keyCode == SWT.ARROW_RIGHT) {
+ day++;
+ }
+
+ if (e.keyCode == SWT.ARROW_UP) {
+ day = ((day - 7) < 1 ? oldDay : day - 7);
+ }
+
+ if (e.keyCode == SWT.ARROW_DOWN) {
+ day = ((day + 7) > getMaxDay() ? oldDay : day + 7);
+ }
+
+ if (e.keyCode == SWT.PAGE_UP) {
+ month--;
+ }
+
+ if (e.keyCode == SWT.PAGE_DOWN) {
+ month++;
+ }
+
+ cal.set(Calendar.MONTH, month);
+ cal.set(Calendar.DAY_OF_MONTH, day);
+
+ if ((day != oldDay) || (month != oldMonth)) {
+ redraw();
+
+ if (month != oldMonth) {
+ updateMonthLabel();
+ }
+ }
+ }
+
+ private void onMouseDown(MouseEvent e) {
+ int day = getDayFromPoint(e.x, e.y);
+
+ if (day > 0) {
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ dateSelected(true);
+ updateDate();
+ }
+ }
+
+ private void onMouseMove(MouseEvent e) {
+ int day = getDayFromPoint(e.x, e.y);
+ selection = day;
+ updateDate();
+ }
+
+ private void onPaint(PaintEvent event) {
+ Rectangle rect = getClientArea();
+ GC gc0 = event.gc;
+ Image image = new Image(display, rect.width, rect.height);
+ GC gc = new GC(image);
+ gc.setBackground(display
+ .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ gc.fillRectangle(rect);
+
+ int x = 0;
+ int y = 0;
+
+ for (int i = 0; i < 7; i++) {
+ if (i == 6) {
+ gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ }
+ drawTextImage(gc, getDayName(1 + i), x, 0, colSize, rowSize);
+ x += colSize;
+ }
+
+ gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ y += rowSize;
+ gc.drawLine(0, 0, rect.width, 0);
+ gc.drawLine(0, y - 1, rect.width, y - 1);
+
+ syncTime();
+
+ int day = 1;
+
+ while (true) {
+ temp.set(Calendar.DAY_OF_MONTH, day);
+
+ if (temp.get(Calendar.MONTH) != cal.get(Calendar.MONTH)) {
+ break;
+ }
+
+ int dayOffset = computeOffset(temp.get(Calendar.DAY_OF_WEEK));
+ Point p = getDayPoint(day);
+
+ if (day == cal.get(Calendar.DAY_OF_MONTH)) {
+ gc.setForeground(display.getSystemColor(
+ SWT.COLOR_LIST_SELECTION_TEXT));
+ gc.setBackground(display.getSystemColor(
+ SWT.COLOR_LIST_SELECTION));
+ } else if (day == selection) {
+ gc.setForeground(display.getSystemColor(
+ SWT.COLOR_LIST_SELECTION_TEXT));
+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+ } else {
+ gc.setBackground(display.getSystemColor(
+ SWT.COLOR_WIDGET_BACKGROUND));
+ gc.setForeground(display.getSystemColor(dayOffset == 7
+ ? SWT.COLOR_RED
+ : SWT.COLOR_BLACK));
+ }
+
+ drawTextImage(gc, "" + day, p.x, p.y, colSize, rowSize);
+ day++;
+ }
+
+ gc0.drawImage(image, 0, 0);
+ gc.dispose();
+ image.dispose();
+ }
+
+ private void syncTime() {
+ temp.setTimeInMillis(cal.getTimeInMillis());
+ }
+ }
+
+ //~ Instance fields
+ // --------------------------------------------------------
+ private Calendar cal = Calendar.getInstance();
+
+ // sebthom
+ private Date selectedDate;
+
+ private DatePanel datePanel;
+ private DateFormatSymbols dateSymbols = new DateFormatSymbols();
+ private Label monthLabel;
+ private int selection = -1;
+
+ //~ Constructors
+ // -----------------------------------------------------------
+ public DatePicker(Composite parent, int style) {
+ super(parent, style);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 5;
+ gridLayout.verticalSpacing = gridLayout.horizontalSpacing = 0;
+ gridLayout.marginHeight = gridLayout.marginWidth = 0;
+ setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_CYAN));
+ setLayout(gridLayout);
+
+ GridData gridData;
+
+ // previous year
+ Button prevYear = new Button(this, SWT.FLAT);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.heightHint = gridData.widthHint = 20;
+ prevYear.setLayoutData(gridData);
+ prevYear.setText("<<");
+ prevYear.setSelection(false);
+ prevYear.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ cal.roll(Calendar.YEAR, -1);
+ updateDate();
+ }
+ });
+
+ // previous month
+ Button prevMonth = new Button(this, SWT.FLAT);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.heightHint = gridData.widthHint = 20;
+ prevMonth.setLayoutData(gridData);
+ prevMonth.setText("<");
+ prevMonth.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ cal.roll(Calendar.MONTH, -1);
+ updateDate();
+ }
+ });
+
+ // current month
+ monthLabel = new Label(this, SWT.CENTER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.CENTER);
+ gridData.heightHint = prevYear.computeSize(20, 20).y;
+ gridData.grabExcessHorizontalSpace = true;
+ monthLabel.setLayoutData(gridData);
+
+ // next month
+ Button nextMonth = new Button(this, SWT.FLAT);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gridData.heightHint = gridData.widthHint = 20;
+ nextMonth.setLayoutData(gridData);
+ nextMonth.setText(">");
+ nextMonth.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ cal.roll(Calendar.MONTH, 1);
+ updateDate();
+ }
+ });
+
+ // next year
+ Button nextYear = new Button(this, SWT.FLAT);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gridData.heightHint = gridData.widthHint = 20;
+ nextYear.setLayoutData(gridData);
+ nextYear.setText(">>");
+ nextYear.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ cal.roll(Calendar.YEAR, 1);
+ updateDate();
+ }
+ });
+
+ // a panel
+ datePanel = new DatePanel(this, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 5;
+ datePanel.setLayoutData(gridData);
+
+ updateDate();
+ }
+
+ //~ Methods
+ // ----------------------------------------------------------------
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+ }
+
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ Point pSize = datePanel.computeSize(wHint, hHint, changed);
+ Point labelSize = monthLabel.computeSize(wHint, hHint, changed);
+
+ int x = (pSize.x < (labelSize.x + 80) ? labelSize.x + 80 : pSize.x);
+ int y = (pSize.y < (labelSize.y + 20) ? labelSize.y + 20 : pSize.y);
+ return new Point(x, y);
+ }
+
+ private void dateSelected(boolean good) {
+ // sebthom
+ if (good)
+ selectedDate = cal.getTime();
+
+ Event event = new Event();
+ event.doit = good;
+ notifyListeners(SWT.Selection, event);
+ }
+
+ private void doubleClick() {
+ Event event = new Event();
+ event.doit = true;
+ notifyListeners(SWT.MouseDoubleClick, event);
+ }
+
+ private String getCurrentMonthName() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getMonthName(cal.get(Calendar.MONTH)));
+ sb.append(", ");
+ sb.append(cal.get(Calendar.YEAR));
+ return sb.toString();
+ }
+
+ public Date getDate() {
+ // sebthom
+ //return cal.getTime();
+ return selectedDate;
+ }
+
+ private String getMonthName(int month) {
+ return dateSymbols.getMonths()[month];
+ }
+
+ public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+ }
+
+ public void reset() {
+ cal = Calendar.getInstance();
+ updateDate();
+ }
+
+ public void setDate(Date date) {
+ // sebthom
+ //cal.setTime(date);
+ selectedDate = date;
+ cal.setTime(selectedDate == null ? new Date() : date);
+
+ updateMonthLabel();
+ redraw();
+ }
+
+ private void updateDate() {
+ datePanel.redraw();
+ updateMonthLabel();
+ }
+
+ private void updateMonthLabel() {
+ monthLabel.setText(getCurrentMonthName());
+ }
+}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePickerCombo.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePickerCombo.java new file mode 100644 index 00000000..2f57f792 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DatePickerCombo.java @@ -0,0 +1,1124 @@ +package com.gluster.storage.management.gui.utils;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.ACC;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TypedListener;
+
+/**
+ * The combo widget with drop-down date-picker panel.
+ *
+ * changes by sebthom
+ * ~ declared package accessible methods as private
+ * ~ declared getEditable() as public
+ * + added useSingleMouseClickToCommit behaviour
+ * + manually modifying the date in the text field is reflected in the date picker
+ * + setDate(null) clears the date.
+ * + added getText & setText()
+ *
+ * @author <a href="mailto:andy@tiff.ru">Andrey Onistchuk</a>
+ *
+ */
+public final class DatePickerCombo extends Composite
+{
+ //~ Static Methods ---------------------------------------------------------
+ public static int checkStyle(int style)
+ {
+ int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT;
+
+ return style & mask;
+ }
+
+ //~ Instance fields --------------------------------------------------------
+ private Button arrow;
+ private DatePicker dp;
+ private boolean hasFocus;
+
+ /**
+ * @author sebthom
+ */
+ private boolean isClosePopupWithSingleMouseClick = false;
+ private Shell popup;
+ private Text text;
+
+ //~ Constructors -----------------------------------------------------------
+ public DatePickerCombo(Composite parent, int style)
+ {
+ super(parent, checkStyle(style));
+
+ style = getStyle();
+
+ int textStyle = SWT.SINGLE;
+
+ if ((style & SWT.READ_ONLY) != 0)
+ {
+ textStyle |= SWT.READ_ONLY;
+ }
+
+ if ((style & SWT.FLAT) != 0)
+ {
+ textStyle |= SWT.FLAT;
+ }
+
+ text = new Text(this, textStyle);
+
+ popup = new Shell(getShell(), SWT.NO_TRIM);
+
+ int pickerStyle = SWT.SINGLE;
+
+ if ((style & SWT.FLAT) != 0)
+ {
+ pickerStyle |= SWT.FLAT;
+ }
+
+ dp = new DatePicker(popup, pickerStyle);
+
+ int arrowStyle = SWT.ARROW | SWT.DOWN;
+
+ if ((style & SWT.FLAT) != 0)
+ {
+ arrowStyle |= SWT.FLAT;
+ }
+
+ arrow = new Button(this, arrowStyle);
+
+ Listener listener = new Listener()
+ {
+ public void handleEvent(Event event)
+ {
+ if (popup == event.widget)
+ {
+ popupEvent(event);
+ return;
+ }
+
+ if (text == event.widget)
+ {
+ textEvent(event);
+ return;
+ }
+
+ if (dp == event.widget)
+ {
+ dpEvent(event);
+ return;
+ }
+
+ if (arrow == event.widget)
+ {
+ arrowEvent(event);
+ return;
+ }
+
+ if (DatePickerCombo.this == event.widget)
+ {
+ comboEvent(event);
+ return;
+ }
+ }
+ };
+
+ int[] comboEvents = { SWT.Dispose, SWT.Move, SWT.Resize };
+
+ for (int i = 0; i < comboEvents.length; i++)
+ this.addListener(comboEvents[i], listener);
+
+ int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
+
+ for (int i = 0; i < popupEvents.length; i++)
+ popup.addListener(popupEvents[i], listener);
+
+ int[] textEvents =
+ { SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut };
+
+ for (int i = 0; i < textEvents.length; i++)
+ text.addListener(textEvents[i], listener);
+
+ int[] dpEvents =
+ {
+ SWT.MouseUp,
+ SWT.MouseDoubleClick,
+ SWT.Selection,
+ SWT.Traverse,
+ SWT.KeyDown,
+ SWT.KeyUp,
+ SWT.FocusIn,
+ SWT.FocusOut };
+
+ for (int i = 0; i < dpEvents.length; i++)
+ dp.addListener(dpEvents[i], listener);
+
+ int[] arrowEvents = { SWT.Selection, SWT.FocusIn, SWT.FocusOut };
+
+ for (int i = 0; i < arrowEvents.length; i++)
+ arrow.addListener(arrowEvents[i], listener);
+
+ initAccessible();
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * Adds the listener to receive events.
+ *
+ * @param listener
+ * the listener
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_NULL_ARGUMENT)
+ * when listener is null
+ */
+ public void addModifyListener(ModifyListener listener)
+ {
+ checkWidget();
+
+ if (listener == null)
+ {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Modify, typedListener);
+ }
+
+ /**
+ * Adds the listener to receive events.
+ *
+ * @param listener
+ * the listener
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_NULL_ARGUMENT)
+ * when listener is null
+ */
+ public void addSelectionListener(SelectionListener listener)
+ {
+ checkWidget();
+
+ if (listener == null)
+ {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+ }
+
+ private void arrowEvent(Event event)
+ {
+ switch (event.type)
+ {
+ case SWT.FocusIn :
+ {
+ if (hasFocus)
+ {
+ return;
+ }
+
+ hasFocus = true;
+
+ if (getEditable())
+ {
+ text.selectAll();
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+
+ case SWT.FocusOut :
+ {
+ Control focusControl = getDisplay().getFocusControl();
+
+ if ((focusControl == dp) || (focusControl == text))
+ {
+ return;
+ }
+
+ hasFocus = false;
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+
+ case SWT.Selection :
+ {
+ dropDown(!isDropped());
+ break;
+ }
+ }
+ }
+
+ /**
+ * Clears the current selection.
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+ public void clearSelection()
+ {
+ checkWidget();
+ text.clearSelection();
+ dp.reset();
+ }
+
+ private void comboEvent(Event event)
+ {
+ switch (event.type)
+ {
+ case SWT.Dispose :
+
+ if ((popup != null) && !popup.isDisposed())
+ {
+ popup.dispose();
+ }
+
+ popup = null;
+ text = null;
+ dp = null;
+ arrow = null;
+ break;
+
+ case SWT.Move :
+ dropDown(false);
+ break;
+
+ case SWT.Resize :
+ internalLayout();
+ break;
+ }
+ }
+
+ public Point computeSize(int wHint, int hHint, boolean changed)
+ {
+ checkWidget();
+
+ int width = 0;
+ int height = 0;
+ Point textSize = text.computeSize(wHint, SWT.DEFAULT, changed);
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point listSize = dp.computeSize(wHint, SWT.DEFAULT, changed);
+ int borderWidth = getBorderWidth();
+
+ height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + (2 * borderWidth));
+ width = Math.max(wHint, Math.max(textSize.x + arrowSize.x + (2 * borderWidth), listSize.x + 2));
+
+ return new Point(width, height);
+ }
+
+ private void dpEvent(Event event)
+ {
+ switch (event.type)
+ {
+ case SWT.FocusIn :
+ {
+ if (hasFocus)
+ {
+ return;
+ }
+
+ hasFocus = true;
+
+ if (getEditable())
+ {
+ text.selectAll();
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+
+ case SWT.FocusOut :
+ {
+ Control focusControl = getDisplay().getFocusControl();
+
+ if ((focusControl == text) || (focusControl == arrow))
+ {
+ return;
+ }
+
+ hasFocus = false;
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+
+ case SWT.MouseDown :
+ {
+ if (event.button != 1)
+ {
+ return;
+ }
+
+ dropDown(false);
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.DefaultSelection, e);
+ break;
+ }
+
+ case SWT.Selection :
+ {
+ // sebthom
+ if (!isClosePopupWithSingleMouseClick)
+ {
+ Date date = dp.getDate();
+ text.setText(DateFormat.getDateInstance().format(date));
+ text.selectAll();
+
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+
+ break;
+ }
+ // otherwise perform the code of SWT.MouseDoubleClick
+ }
+
+ case SWT.MouseDoubleClick :
+ {
+ dropDown(false);
+
+ Date date = dp.getDate();
+
+ // sebthom
+ if (date == null)
+ {
+ text.setText("");
+ }
+ else
+ {
+ text.setText(DateFormat.getDateInstance().format(date));
+ text.selectAll();
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+ break;
+ }
+
+ case SWT.Traverse :
+ {
+ switch (event.detail)
+ {
+ case SWT.TRAVERSE_TAB_NEXT :
+ case SWT.TRAVERSE_RETURN :
+ case SWT.TRAVERSE_ESCAPE :
+ case SWT.TRAVERSE_ARROW_PREVIOUS :
+ case SWT.TRAVERSE_ARROW_NEXT :
+ event.doit = false;
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ break;
+ }
+
+ case SWT.KeyUp :
+ {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+
+ case SWT.KeyDown :
+ {
+ if (event.character == SWT.ESC)
+ {
+ // escape key cancels popup dp
+ dropDown(false);
+ }
+
+ if ((event.character == SWT.CR) || (event.character == '\t'))
+ {
+ // Enter and Tab cause default selection
+ dropDown(false);
+
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ {
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+ }
+ }
+ }
+
+ private void dropDown(boolean drop)
+ {
+ if (drop == isDropped())
+ {
+ return;
+ }
+
+ if (!drop)
+ {
+ popup.setVisible(false);
+ text.setFocus();
+ return;
+ }
+
+ Rectangle listRect = dp.getBounds();
+ Point point = getParent().toDisplay(getLocation());
+ Point comboSize = getSize();
+ int width = Math.max(comboSize.x, listRect.width + 2);
+ popup.setBounds(point.x, point.y + comboSize.y, width, listRect.height + 2);
+ popup.setVisible(true);
+ dp.setFocus();
+ }
+
+ public Control[] getChildren()
+ {
+ checkWidget();
+
+ return new Control[0];
+ }
+
+ public Date getDate()
+ {
+ checkWidget();
+
+ return dp.getDate();
+ }
+
+ public boolean getEditable()
+ {
+ return text.getEditable();
+ }
+
+ /**
+ * @author sebthom
+ */
+ public String getText()
+ {
+ return text.getText();
+ }
+
+ public void setText(String txt)
+ {
+ text.setText(txt);
+ }
+
+ public int getTextHeight()
+ {
+ checkWidget();
+ return text.getLineHeight();
+ }
+
+ private void initAccessible()
+ {
+ getAccessible().addAccessibleListener(new AccessibleAdapter()
+ {
+ public void getHelp(AccessibleEvent e)
+ {
+ e.result = getToolTipText();
+ }
+ });
+
+ getAccessible().addAccessibleControlListener(new AccessibleControlAdapter()
+ {
+ public void getChildAtPoint(AccessibleControlEvent e)
+ {
+ Point testPoint = toControl(new Point(e.x, e.y));
+
+ if (getBounds().contains(testPoint))
+ {
+ e.childID = ACC.CHILDID_SELF;
+ }
+ }
+
+ public void getChildCount(AccessibleControlEvent e)
+ {
+ e.detail = 0;
+ }
+
+ public void getLocation(AccessibleControlEvent e)
+ {
+ Rectangle location = getBounds();
+ Point pt = toDisplay(new Point(location.x, location.y));
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+
+ public void getRole(AccessibleControlEvent e)
+ {
+ e.detail = ACC.ROLE_COMBOBOX;
+ }
+
+ public void getState(AccessibleControlEvent e)
+ {
+ e.detail = ACC.STATE_NORMAL;
+ }
+
+ public void getValue(AccessibleControlEvent e)
+ {
+ e.result = text.getText();
+ }
+ });
+ }
+
+ private void internalLayout()
+ {
+ if (isDropped())
+ {
+ dropDown(false);
+ }
+
+ Rectangle rect = getClientArea();
+ int width = rect.width;
+ int height = rect.height;
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, height);
+ text.setBounds(0, 0, width - arrowSize.x, height);
+ arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+
+ Point size = getSize();
+ int itemHeight = dp.getBounds().height;
+ Point listSize = dp.computeSize(SWT.DEFAULT, itemHeight);
+ dp.setBounds(1, 1, Math.max(size.x - 2, listSize.x), listSize.y);
+ }
+
+ /**
+ * determines if you need to double click a date in the expanded calender control to hide it
+ * default is false meaning you have to double click a date
+ *
+ * @author sebthom
+ *
+ * @param useSingleMouseClickToCommit
+ */
+ public boolean isClosePopupWithSingleMouseClick()
+ {
+ return isClosePopupWithSingleMouseClick;
+ }
+
+ private boolean isDropped()
+ {
+ return popup.getVisible();
+ }
+
+ public boolean isFocusControl()
+ {
+ checkWidget();
+
+ if (text.isFocusControl() || arrow.isFocusControl() || dp.isFocusControl() || popup.isFocusControl())
+ {
+ return true;
+ }
+ else
+ {
+ return super.isFocusControl();
+ }
+ }
+
+ private void popupEvent(Event event)
+ {
+ switch (event.type)
+ {
+ case SWT.Paint :
+
+ // draw black rectangle around dp
+ Rectangle listRect = dp.getBounds();
+ Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ event.gc.setForeground(black);
+ event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
+ break;
+
+ case SWT.Close :
+ event.doit = false;
+ dropDown(false);
+ break;
+
+ case SWT.Deactivate :
+ dropDown(false);
+ break;
+ }
+ }
+
+ public void redraw(int x, int y, int width, int height, boolean all)
+ {
+ checkWidget();
+
+ if (!all)
+ {
+ return;
+ }
+
+ Point location = text.getLocation();
+ text.redraw(x - location.x, y - location.y, width, height, all);
+ location = dp.getLocation();
+ dp.redraw(x - location.x, y - location.y, width, height, all);
+
+ if (arrow != null)
+ {
+ location = arrow.getLocation();
+ arrow.redraw(x - location.x, y - location.y, width, height, all);
+ }
+ }
+
+ /**
+ * Removes the listener.
+ *
+ * @param listener
+ * the listener
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_NULL_ARGUMENT)
+ * when listener is null
+ */
+ public void removeModifyListener(ModifyListener listener)
+ {
+ checkWidget();
+
+ if (listener == null)
+ {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ removeListener(SWT.Modify, listener);
+ }
+
+ /**
+ * Removes the listener.
+ *
+ * @param listener
+ * the listener
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_NULL_ARGUMENT)
+ * when listener is null
+ */
+ public void removeSelectionListener(SelectionListener listener)
+ {
+ checkWidget();
+
+ if (listener == null)
+ {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+ }
+
+ public void setBackground(Color color)
+ {
+ super.setBackground(color);
+
+ if (text != null)
+ {
+ text.setBackground(color);
+ }
+
+ if (dp != null)
+ {
+ dp.setBackground(color);
+ }
+
+ if (arrow != null)
+ {
+ arrow.setBackground(color);
+ }
+ }
+
+ /**
+ * set if you need to double click a date in the expanded calender control to hide it
+ * default is false meaning you have to double click a date
+ *
+ * @author sebthom
+ *
+ * @param useSingleMouseClickToCommit
+ */
+ public void setClosePopupWithSingleMouseClick(boolean isClosePopupWithSingleMouseClick)
+ {
+ this.isClosePopupWithSingleMouseClick = isClosePopupWithSingleMouseClick;
+ }
+
+ /**
+ * Selects an item.
+ * <p>
+ * If the item at an index is not selected, it is selected. Indices that
+ * are out of range are ignored. Indexing is zero based.
+ *
+ * @param index
+ * the index of the item
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+ public void setDate(Date date)
+ {
+ checkWidget();
+
+ //sebthom
+ if (date != null)
+ {
+ text.setText(DateFormat.getDateInstance().format(date));
+ text.selectAll();
+ }
+ else
+ {
+ text.setText("");
+ }
+
+ dp.setDate(date);
+ }
+
+ public boolean setFocus()
+ {
+ checkWidget();
+ return text.setFocus();
+ }
+
+ public void setFont(Font font)
+ {
+ super.setFont(font);
+ text.setFont(font);
+ dp.setFont(font);
+ internalLayout();
+ }
+
+ public void setForeground(Color color)
+ {
+ super.setForeground(color);
+
+ if (text != null)
+ {
+ text.setForeground(color);
+ }
+
+ if (dp != null)
+ {
+ dp.setForeground(color);
+ }
+
+ if (arrow != null)
+ {
+ arrow.setForeground(color);
+ }
+ }
+
+ /**
+ * Sets the new selection.
+ *
+ * @param selection
+ * point representing the start and the end of the new selection
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_NULL_ARGUMENT)
+ * when selection is null
+ */
+ public void setSelection(Point selection)
+ {
+ checkWidget();
+
+ if (selection == null)
+ {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ text.setSelection(selection.x, selection.y);
+ }
+
+ /**
+ * Sets the text limit
+ *
+ * @param limit
+ * new text limit
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ * @exception SWTError(ERROR_CANNOT_BE_ZERO)
+ * when limit is 0
+ */
+ public void setTextLimit(int limit)
+ {
+ checkWidget();
+ text.setTextLimit(limit);
+ }
+
+ public void setToolTipText(String string)
+ {
+ checkWidget();
+ super.setToolTipText(string);
+ arrow.setToolTipText(string);
+ text.setToolTipText(string);
+ }
+
+ public void setVisible(boolean visible)
+ {
+ super.setVisible(visible);
+
+ if (!visible)
+ {
+ popup.setVisible(false);
+ }
+ }
+
+ private void textEvent(Event event)
+ {
+ switch (event.type)
+ {
+ case SWT.FocusIn :
+ {
+ if (hasFocus)
+ {
+ return;
+ }
+
+ hasFocus = true;
+
+ if (getEditable())
+ {
+ text.selectAll();
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+
+ case SWT.FocusOut :
+ {
+ Control focusControl = getDisplay().getFocusControl();
+
+ if ((focusControl == dp) || (focusControl == arrow))
+ {
+ return;
+ }
+
+ hasFocus = false;
+
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+
+ case SWT.KeyDown :
+ {
+ if (event.character == SWT.ESC)
+ {
+ // escape key cancels popup dp
+ dropDown(false);
+ }
+
+ if (event.character == SWT.CR)
+ {
+ dropDown(false);
+
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ {
+ break;
+ }
+
+ if ((event.keyCode == SWT.ARROW_UP) || (event.keyCode == SWT.ARROW_DOWN))
+ {
+ //Date oldDate = getDate();
+
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ {
+ break;
+ }
+ }
+
+ // Further work : Need to add support for incremental
+ // search in
+ // pop up dp as characters typed in text widget
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+ }
+
+ case SWT.KeyUp :
+ {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+
+ case SWT.Modify :
+ {
+ // sebthom
+ if (!popup.isVisible())
+ {
+ if (text.getText().length() == 0)
+ {
+ dp.setDate(null);
+ }
+ else
+ {
+ try
+ {
+ dp.setDate(SimpleDateFormat.getDateInstance().parse(text.getText()));
+ }
+ catch (ParseException pe)
+ {
+ dp.setDate(null);
+ }
+ }
+ }
+ // dp.deselectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.Modify, e);
+ break;
+ }
+
+ case SWT.MouseDown :
+ {
+ if (event.button != 1 || text.getEditable())
+ {
+ return;
+ }
+
+ boolean dropped = isDropped();
+ text.selectAll();
+
+ if (!dropped)
+ {
+ setFocus();
+ }
+ dropDown(!dropped);
+
+ break;
+ }
+
+ case SWT.MouseUp :
+ {
+ if (event.button != 1 || text.getEditable())
+ {
+ return;
+ }
+ text.selectAll();
+ break;
+ }
+
+ case SWT.Traverse :
+ {
+ switch (event.detail)
+ {
+ case SWT.TRAVERSE_RETURN :
+ case SWT.TRAVERSE_ARROW_PREVIOUS :
+ case SWT.TRAVERSE_ARROW_NEXT :
+ // The enter causes default selection and
+ // the arrow keys are used to manipulate the dp
+ // contents so do not use them for traversal.
+ event.doit = false;
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DiskViewerEditingSupport.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DiskViewerEditingSupport.java new file mode 100644 index 00000000..85f6edce --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/DiskViewerEditingSupport.java @@ -0,0 +1,39 @@ +package com.gluster.storage.management.gui.utils; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.Disk; + +public class DiskViewerEditingSupport extends EditingSupport { + private FormToolkit toolkit; + + public DiskViewerEditingSupport(FormToolkit toolkit, TableViewer viewer) { + super(viewer); + this.toolkit = toolkit; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return new HyperlinkCellEditor(toolkit, (TableViewer)getViewer(), (Disk) element); + } + + @Override + protected boolean canEdit(Object element) { + Disk disk = (Disk) element; + return (disk.isUninitialized()); + } + + @Override + protected Object getValue(Object element) { + return ((Disk) element).getStatus(); + } + + @Override + protected void setValue(Object element, Object value) { + getViewer().update(element, new String[] { "status" }); + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/EntityViewerFilter.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/EntityViewerFilter.java new file mode 100644 index 00000000..c4774f34 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/EntityViewerFilter.java @@ -0,0 +1,60 @@ +package com.gluster.storage.management.gui.utils; + +import java.util.Map.Entry; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +import com.gluster.storage.management.core.model.Filterable; +import com.gluster.storage.management.core.utils.StringUtils; + +public class EntityViewerFilter extends ViewerFilter { + + private String filterString; + private boolean caseSensitive = false; + + public EntityViewerFilter(String filterString, boolean caseSensitive) { + this.filterString = filterString; + this.caseSensitive = caseSensitive; + } + + public boolean isCaseSensitive() { + return caseSensitive; + } + + public void setCaseSensitive(boolean caseSensitive) { + this.caseSensitive = caseSensitive; + } + + public String getFilterString() { + return filterString; + } + + public void setFilterString(String filterString) { + this.filterString = filterString; + } + + @SuppressWarnings("unchecked") + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + if (filterString == null || filterString.isEmpty()) { + // No filter string. select everything + return true; + } + + if (element instanceof Filterable) { + return ((Filterable) element).filter(filterString, caseSensitive); + } + + if(element instanceof Entry) { + Entry<String, String> entry = (Entry<String, String>)element; + return StringUtils.filterString(entry.getKey() + entry.getValue(), filterString, caseSensitive); + } + + if(element instanceof String) { + return StringUtils.filterString((String)element, filterString, caseSensitive); + } + + return false; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java new file mode 100644 index 00000000..1d4a2a00 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java @@ -0,0 +1,313 @@ +package com.gluster.storage.management.gui.utils; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ColumnLayoutData; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ColumnLayout; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IImageKeys; + +public class GUIHelper { + private static final GUIHelper instance = new GUIHelper(); + + private GUIHelper() { + + } + + public static GUIHelper getInstance() { + return instance; + } + + public ScrolledForm setupForm(Composite parent, FormToolkit toolkit, final String formName) { + return setupForm(toolkit, formName, toolkit.createScrolledForm(parent)); + } + + public ScrolledForm setupForm(FormToolkit toolkit, final String formName, ScrolledForm form) { + form.setText(formName); + toolkit.decorateFormHeading(form.getForm()); + + ColumnLayout layout = new ColumnLayout(); + + // layout.topMargin = 0; + // layout.bottomMargin = 5; + // layout.leftMargin = 10; + // layout.rightMargin = 10; + // layout.horizontalSpacing = 10; + // layout.verticalSpacing = 10; + // layout.maxNumColumns = 4; + // layout.minNumColumns = 1; + + form.getBody().setLayout(layout); + return form; + } + + public Composite createSection(final ScrolledForm form, FormToolkit toolkit, String title, String desc, + int numColumns, boolean collapsible) { + int style = Section.TITLE_BAR | Section.EXPANDED; + if (desc != null && !desc.isEmpty()) { + style |= Section.DESCRIPTION; + } + if (collapsible) { + style |= Section.TWISTIE; + } + + Section section = toolkit.createSection(form.getBody(), style); + section.setText(title); + section.setDescription(desc); + + // toolkit.createCompositeSeparator(section); + Composite client = toolkit.createComposite(section); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 0; + layout.numColumns = numColumns; + layout.verticalSpacing = 15; + layout.marginBottom = 20; + layout.marginTop = 5; + + client.setLayout(layout); + section.setClient(client); + + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(false); + } + }); + return client; + } + + public Composite createTab(TabFolder tabFolder, String title, String imageKey) { + TabItem item = new TabItem(tabFolder, SWT.NONE); + item.setText(title); + item.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, imageKey).createImage()); + + Composite composite = new Composite(tabFolder, SWT.NONE); + composite.setLayout(new FillLayout()); + + item.setControl(composite); + + return composite; + } + + public ImageDescriptor getImageDescriptor(String imagePath) { + return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, imagePath); + } + + public Image getImage(String imagePath) { + return getImageDescriptor(imagePath).createImage(); + } + + public Action createPullDownMenu(String menuName, String iconPath, final MenuManager menuManager) { + Action action = new Action(menuName, IAction.AS_DROP_DOWN_MENU) { + public void run() { + } + }; + action.setMenuCreator(new IMenuCreator() { + + @Override + public Menu getMenu(Menu menu) { + return null; + } + + @Override + public Menu getMenu(Control control) { + return menuManager.createContextMenu(control); + } + + @Override + public void dispose() { + } + }); + action.setImageDescriptor(getImageDescriptor(iconPath)); + return action; + } + + public TableColumnLayout createTableColumnLayout(Table table, String[] columns) { + TableColumnLayout tableColumnLayout = new TableColumnLayout(); + ColumnLayoutData defaultColumnLayoutData = new ColumnWeightData(100); + + for (String columnName : columns) { + TableColumn column = new TableColumn(table, SWT.LEFT); + column.setText(columnName); + + tableColumnLayout.setColumnData(column, defaultColumnLayoutData); + } + + return tableColumnLayout; + } + + /** + * Creates a filter for given structured viewer that will filter the contents of the viewer based on the current + * text of the text field + * + * @param viewer + * Structured viewer for which the filter is to be created + * @param filterText + * The text field whose contents are to be used for filtering + * @param caseSensitive + * Flag indicating whether the filtering should be case sensitive + * @return The newly created filter + */ + public EntityViewerFilter createFilter(final StructuredViewer viewer, final Text filterText, boolean caseSensitive) { + final String initialFilterString = filterText.getText(); + + final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); + // On every keystroke inside the text field, update the filter string + filterText.addKeyListener(new KeyAdapter() { + private String filterString = initialFilterString; + + @Override + public void keyReleased(KeyEvent e) { + String enteredString = filterText.getText(); + if (enteredString.equals(filterString)) { + // Filter string has not changed. don't do anything + return; + } + + // Update filter string + filterString = enteredString; + filter.setFilterString(filterString); + + // Refresh viewer with newly filtered content + viewer.refresh(true); + } + }); + + viewer.addFilter(filter); + return filter; + } + + public IViewPart getView(String viewId) { + IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + .getViewReferences(); + for (IViewReference view : views) { + if (view.getId().equals(viewId)) { + return view.getView(false); + } + } + return null; + } + + public ControlDecoration createErrorDecoration(Control control) { + ControlDecoration passwordErrorDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP); + passwordErrorDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); + return passwordErrorDecoration; + } + + public void centerShellInScreen(Shell shell) { + Rectangle monitorBounds = shell.getMonitor().getBounds(); + Rectangle myBounds = shell.getBounds(); + + int x = monitorBounds.x + (monitorBounds.width - myBounds.width) / 2; + int y = monitorBounds.y + (monitorBounds.height - myBounds.height) / 2; + shell.setLocation(x, y); + } + + public Text createFilterText(FormToolkit toolkit, Composite parent) { + final String tooltipMessage = "Start typing to filter table contents."; + final Text filterText = toolkit.createText(parent, "", SWT.FLAT); + + GridData data = new GridData(SWT.LEFT, SWT.CENTER, false, false); + data.widthHint = 300; + filterText.setLayoutData(data); + + ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.RIGHT); + searchDecoration.setImage(getImage(IImageKeys.SEARCH)); + searchDecoration.show(); + searchDecoration.setShowHover(true); + searchDecoration.setDescriptionText(tooltipMessage); + + filterText.setToolTipText(tooltipMessage); + return filterText; + } + + public Text createFilterText(Composite parent) { + final String tooltipMessage = "Start typing to filter table contents."; + final Text filterText = new Text(parent, SWT.FLAT); + + GridData data = new GridData(SWT.LEFT, SWT.CENTER, false, false); + data.widthHint = 300; + filterText.setLayoutData(data); + + ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.RIGHT); + searchDecoration.setImage(getImage(IImageKeys.SEARCH)); + searchDecoration.show(); + searchDecoration.setShowHover(true); + searchDecoration.setDescriptionText(tooltipMessage); + + filterText.setToolTipText(tooltipMessage); + return filterText; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, int columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + * + * @return The table viewer column created + */ + public TableViewerColumn setColumnProperties(TableViewer tableViewer, int columnIndex, int style, int weight) { + TableViewerColumn column = new TableViewerColumn(tableViewer, style, columnIndex); + TableColumnLayout tableColumnLayout = (TableColumnLayout)tableViewer.getTable().getParent().getLayout(); + tableColumnLayout.setColumnData(column.getColumn(), new ColumnWeightData(weight)); + column.setLabelProvider(new ColumnLabelProvider()); + return column; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/HyperlinkCellEditor.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/HyperlinkCellEditor.java new file mode 100644 index 00000000..48b7117d --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/HyperlinkCellEditor.java @@ -0,0 +1,50 @@ +package com.gluster.storage.management.gui.utils; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; + +import com.gluster.storage.management.core.model.Disk; + +public class HyperlinkCellEditor extends CellEditor { + private FormToolkit toolkit; + private Disk disk; + private ImageHyperlink link; + private TableViewer viewer; + + public HyperlinkCellEditor(FormToolkit toolkit, TableViewer viewer, Disk disk) { + this.toolkit = toolkit; + this.viewer = viewer; + this.disk = disk; + } + + @Override + protected Control createControl(Composite parent) { + link = toolkit.createImageHyperlink(viewer.getTable(), SWT.NONE); + // link.setImage(guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED)); + link.setText("Initialize"); + return link; + } + + @Override + protected Object doGetValue() { + return disk.getStatus(); + } + + @Override + protected void doSetFocus() { + link.setFocus(); + } + + @Override + protected void doSetValue(Object value) { + if(!disk.isUninitialized()) { + this.deactivate(); + this.dispose(); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/validators/StringRequiredValidator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/validators/StringRequiredValidator.java new file mode 100644 index 00000000..cbe352c3 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/validators/StringRequiredValidator.java @@ -0,0 +1,41 @@ +package com.gluster.storage.management.gui.validators; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.swt.widgets.Control; + +public class StringRequiredValidator implements IValidator { + private final String errorText; + private final ControlDecoration controlDecoration; + private final Control linkedControl; + + public StringRequiredValidator(String errorText, ControlDecoration controlDecoration, Control linkedControl) { + super(); + this.errorText = errorText; + this.controlDecoration = controlDecoration; + this.linkedControl = linkedControl; + } + + public StringRequiredValidator(String errorText, ControlDecoration controlDecoration) { + this(errorText, controlDecoration, null); + } + + public IStatus validate(Object value) { + if (value instanceof String) { + if (((String) value).isEmpty()) { + controlDecoration.setDescriptionText(errorText); + controlDecoration.show(); + if (linkedControl != null) { + linkedControl.setEnabled(false); + } + return ValidationStatus.error(errorText); + } + } + linkedControl.setEnabled(true); + controlDecoration.hide(); + return Status.OK_STATUS; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/AbstractDisksPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/AbstractDisksPage.java new file mode 100644 index 00000000..c76d8582 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/AbstractDisksPage.java @@ -0,0 +1,297 @@ +package com.gluster.storage.management.gui.views.details; + +import java.util.List; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.TableEditor; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; +import org.eclipse.ui.progress.IProgressConstants; + +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.Disk.DISK_STATUS; +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IEntityListener; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.jobs.InitializeDiskJob; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public abstract class AbstractDisksPage extends Composite implements IEntityListener { + protected final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + protected TableViewer tableViewer; + private IWorkbenchSite site; + protected static final GUIHelper guiHelper = GUIHelper.getInstance(); + + /** + * Setup properties of the table e.g. column headers, widths, etc. + * + * @param parent + * The parent composite. (TableColumnLayout has to be set on this) + * @param table + * The table to be set up + */ + protected abstract void setupDiskTable(Composite parent, Table table); + + /** + * @return The label provider to be used with the disk table viewer + */ + protected abstract ITableLabelProvider getTableLabelProvider(); + + /** + * @return Index of the "status" column in the table. Return -1 if status column is not displayed + */ + protected abstract int getStatusColumnIndex(); + + private void init(final Composite parent, IWorkbenchSite site, List<Disk> disks) { + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + this.site = site; + + setupPageLayout(); + Text filterText = guiHelper.createFilterText(toolkit, this); + setupDiskTableViewer(createTableViewerComposite(), filterText); + + tableViewer.setInput(disks); + setupStatusCellEditor(); // creates hyperlinks for "unitialized" disks + + site.setSelectionProvider(tableViewer); + Application.getApplication().addEntityListener(this); + + parent.layout(); // Important - this actually paints the table + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + } + + public AbstractDisksPage(final Composite parent, int style, IWorkbenchSite site, List<Disk> disks) { + super(parent, style); + init(parent, site, disks); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void createInitializeLink(final TableItem item, final int rowNum, final Disk disk) { + final Table table = tableViewer.getTable(); + final TableEditor editor = new TableEditor(table); + editor.grabHorizontal = true; + editor.horizontalAlignment = SWT.RIGHT; + + table.addPaintListener(new PaintListener() { + private TableItem myItem = item; + private int myRowNum = rowNum; + private ImageHyperlink myLink = null; + private TableEditor myEditor = null; + + private void createLinkFor(Disk disk1, TableItem item1, int rowNum1) { + myItem = item1; + myRowNum = rowNum1; + + myEditor = new TableEditor(table); + myEditor.grabHorizontal = true; + myEditor.horizontalAlignment = SWT.RIGHT; + + myLink = toolkit.createImageHyperlink(table, SWT.NONE); + // link.setImage(guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED)); + myLink.setText("Initialize"); + myLink.addHyperlinkListener(new StatusLinkListener(myLink, myEditor, myItem, tableViewer, disk1, site)); + + myEditor.setEditor(myLink, item1, getStatusColumnIndex()); + + myItem.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + myLink.dispose(); + myEditor.dispose(); + } + }); + } + + @Override + public void paintControl(PaintEvent e) { + int itemCount = table.getItemCount(); + + // Find the table item corresponding to our disk + Disk disk1 = null; + int rowNum1 = -1; + TableItem item1 = null; + for (int i = 0; i < itemCount; i++) { + item1 = table.getItem(i); + disk1 = (Disk) item1.getData(); + if (disk1 != null && disk1 == disk) { + rowNum1 = i; + break; + } + } + + if (rowNum1 == -1) { + // item disposed and disk not visible. nothing to do. + return; + } + + if (myEditor == null || myItem.isDisposed()) { + // item visible, and + // either editor never created, OR + // old item disposed. create the link for it + createLinkFor(disk1, item1, rowNum1); + } + + if (rowNum1 != myRowNum) { + // disk visible, but at a different row num. re-create the link + myLink.dispose(); + myEditor.dispose(); + createLinkFor(disk1, item1, rowNum1); + } + + myEditor.layout(); // IMPORTANT. Without this, the link location goes for a toss on maximize + restore + } + }); + } + + private void setupStatusCellEditor() { + final TableViewer viewer = tableViewer; + final Table table = viewer.getTable(); + for (int i = 0; i < table.getItemCount(); i++) { + final TableItem item = table.getItem(i); + if (item.isDisposed() || item.getData() == null) { + continue; + } + final Disk disk = (Disk) item.getData(); + if (disk.isUninitialized()) { + createInitializeLink(item, i, disk); + } + } + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + private TableViewer createDiskTableViewer(Composite parent) { + tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + + tableViewer.setLabelProvider(getTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupDiskTable(parent, tableViewer.getTable()); + + return tableViewer; + } + + private void setupDiskTableViewer(Composite parent, final Text filterText) { + tableViewer = createDiskTableViewer(parent); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + private final class StatusLinkListener extends HyperlinkAdapter { + private final Disk disk; + private final TableEditor myEditor; + private final ImageHyperlink myLink; + private final TableViewer viewer; + private final IWorkbenchSite site; + + private StatusLinkListener(ImageHyperlink link, TableEditor editor, TableItem item, TableViewer viewer, + Disk disk, IWorkbenchSite site) { + this.disk = disk; + this.viewer = viewer; + this.myEditor = editor; + this.myLink = link; + this.site = site; + } + + private void updateStatus(final DISK_STATUS status, final boolean disposeEditor) { + if (disposeEditor) { + myLink.dispose(); + myEditor.dispose(); + } + disk.setStatus(status); + viewer.update(disk, new String[] { "status" }); + Application.getApplication().entityChanged(disk, new String[] { "status" }); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + updateStatus(DISK_STATUS.INITIALIZING, true); + + try { + site.getWorkbenchWindow().getActivePage().showView(IProgressConstants.PROGRESS_VIEW_ID); + } catch (PartInitException e1) { + e1.printStackTrace(); + throw new GlusterRuntimeException("Could not open the progress view!", e1); + } + + new InitializeDiskJob(disk).schedule(); + } + } + + @Override + public void entityChanged(final Entity entity, final String[] paremeters) { + if (!(entity instanceof Disk)) { + return; + } + final Disk disk = (Disk) entity; + + Display.getDefault().syncExec(new Runnable() { + public void run() { + tableViewer.update(disk, paremeters); + + if (disk.isUninitialized()) { + Table table = tableViewer.getTable(); + + for (int rowNum = 0; rowNum < table.getItemCount(); rowNum++) { + TableItem item = table.getItem(rowNum); + if (item.getData() == disk) { + createInitializeLink(item, rowNum, disk); + } + } + } + } + }); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DetailsView.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DetailsView.java new file mode 100644 index 00000000..ff40d1ea --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DetailsView.java @@ -0,0 +1,93 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.contexts.IContextService; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.part.ViewPart; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.toolbar.ToolbarManager; +import com.gluster.storage.management.gui.views.navigator.NavigationView; + +/** + * This view is displayed on the right hand side of the platform UI. It updates itself with appropriate tabs + * whenever selection changes on the navigation view (cluster tree) on the left hand side of the UI. + */ +public class DetailsView extends ViewPart implements ISelectionListener { + public static final String ID = "com.gluster.storage.management.gui.views.details"; + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TabFolder tabFolder; + private Entity entity; + private TabCreatorFactory tabCreatorFactory = new TabCreatorFactoryImpl(); + private ToolbarManager toolbarManager; + private IWorkbenchPartSite site; + + public DetailsView() { + super(); + } + + @Override + public void createPartControl(final Composite parent) { + parent.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + tabFolder = new TabFolder(parent, SWT.TOP); + + // listen to selection event on the navigation tree view + IWorkbenchWindow window = getViewSite().getWorkbenchWindow(); + window.getSelectionService().addSelectionListener(this); + + // Create the toolbar manager + toolbarManager = new ToolbarManager(window); + site = getSite(); + } + + @Override + public void setFocus() { + tabFolder.setFocus(); + } + + private void removeAllTabs() { + for (TabItem item : tabFolder.getItems()) { + item.getControl().dispose(); + item.dispose(); + } + } + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (part instanceof NavigationView && selection instanceof TreeSelection) { + Entity selectedEntity = (Entity) ((TreeSelection) selection).getFirstElement(); + + if (entity == selectedEntity || selectedEntity == null) { + // entity selection has not changed. do nothing. + return; + } + + entity = selectedEntity; + removeAllTabs(); + + // Create tabs for newly selected entity + tabCreatorFactory.getTabCreator(entity).createTabs(entity, tabFolder, toolkit, site); + + // update toolbar buttons visibility based on selected entity + toolbarManager.updateToolbar(entity); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DisksPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DisksPage.java new file mode 100644 index 00000000..cdd3ebb5 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/DisksPage.java @@ -0,0 +1,53 @@ +package com.gluster.storage.management.gui.views.details; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.IWorkbenchSite; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.gui.DiskTableLabelProvider; +import com.gluster.storage.management.gui.utils.DiskViewerEditingSupport; + +public class DisksPage extends AbstractDisksPage { + + public enum DISK_TABLE_COLUMN_INDICES { + SERVER, DISK, SPACE, SPACE_IN_USE, STATUS + }; + + private static final String[] DISK_TABLE_COLUMN_NAMES = new String[] { "Server", "Disk", "Space (GB)", + "Space in Use (GB)", "Status" }; + + public DisksPage(final Composite parent, int style, IWorkbenchSite site, List<Disk> disks) { + super(parent, style, site, disks); + } + + @Override + protected void setupDiskTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, DISK_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + guiHelper.setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SERVER.ordinal(), SWT.CENTER, 100); + guiHelper.setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.DISK.ordinal(), SWT.CENTER, 100); + guiHelper.setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SPACE.ordinal(), SWT.CENTER, 90); + guiHelper.setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal(), SWT.CENTER, 90); + } + + @Override + protected ITableLabelProvider getTableLabelProvider() { + return new DiskTableLabelProvider(); + } + + @Override + protected int getStatusColumnIndex() { + return DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); + } +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/GlusterServersPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/GlusterServersPage.java new file mode 100644 index 00000000..c4d03b7d --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/GlusterServersPage.java @@ -0,0 +1,146 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.gui.EntityGroupContentProvider; +import com.gluster.storage.management.gui.GlusterServerTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class GlusterServersPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TableViewer tableViewer; + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public enum GLUSTER_SERVER_TABLE_COLUMN_INDICES { + NAME, PREFERRED_NETWORK, IP_ADDRESSES, NUM_OF_CPUS, TOTAL_MEMORY, TOTAL_DISK_SPACE, STATUS + }; + + private static final String[] GLUSTER_SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "Preferred\nNetwork", + "IP Address(es)", "Number\nof CPUs", "Total\nMemory (GB)", "Total Disk\n Space (GB)", "Status" }; + + public GlusterServersPage(Composite parent, int style) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + Text filterText = guiHelper.createFilterText(toolkit, this); + setupServerTableViewer(filterText); + } + + public GlusterServersPage(final Composite parent, int style, EntityGroup<GlusterServer> servers) { + this(parent, style); + + tableViewer.setInput(servers); + parent.layout(); // Important - this actually paints the table + + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + } + + public void addDoubleClickListener(IDoubleClickListener listener) { + tableViewer.addDoubleClickListener(listener); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void setupServerTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, GLUSTER_SERVER_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 100); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS, SWT.CENTER, 70); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); + } + + private TableViewer createServerTableViewer(Composite parent) { + TableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + //TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new GlusterServerTableLabelProvider()); + tableViewer.setContentProvider(new EntityGroupContentProvider<GlusterServer>()); + + setupServerTable(parent, tableViewer.getTable()); + + return tableViewer; + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + private void setupServerTableViewer(final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + tableViewer = createServerTableViewer(tableViewerComposite); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, GLUSTER_SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerDisksPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerDisksPage.java new file mode 100644 index 00000000..f65ddc0c --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerDisksPage.java @@ -0,0 +1,50 @@ +package com.gluster.storage.management.gui.views.details; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.IWorkbenchSite; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.gui.ServerDiskTableLabelProvider; +import com.gluster.storage.management.gui.TableLabelProviderAdapter; + +public class ServerDisksPage extends AbstractDisksPage { + public ServerDisksPage(Composite parent, int style, IWorkbenchSite site, List<Disk> disks) { + super(parent, style, site, disks); + } + + public enum SERVER_DISK_TABLE_COLUMN_INDICES { + DISK, SPACE, SPACE_IN_USE, STATUS + }; + + private static final String[] SERVER_DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Space (GB)", + "Space in Use (GB)", "Status" }; + + @Override + protected void setupDiskTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, SERVER_DISK_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK.ordinal(), SWT.CENTER, 100); + guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.SPACE.ordinal(), SWT.CENTER, 90); + guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal(), SWT.CENTER, 90); + guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(), SWT.LEFT, 90); + } + + @Override + protected int getStatusColumnIndex() { + return SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); + } + + @Override + protected TableLabelProviderAdapter getTableLabelProvider() { + return new ServerDiskTableLabelProvider(); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerLogsPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerLogsPage.java new file mode 100644 index 00000000..4d867e58 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServerLogsPage.java @@ -0,0 +1,161 @@ +package com.gluster.storage.management.gui.views.details; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.layout.FillLayout; +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.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class ServerLogsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Text text; + private Table table; + + public enum LOG_TABLE_COLUMN_INDICES { + DATE, TIME, DISK, SEVERITY, MESSAGE + }; + + private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Disk", "Severity", "Message" }; + + /** + * Create the composite. + * + * @param parent + * @param style + */ + public ServerLogsPage(Composite parent, int style, GlusterServer server) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setLayout(new GridLayout(1, false)); + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + setLayoutData(layoutData); + + Composite composite = toolkit.createComposite(this, SWT.NONE); + toolkit.paintBordersFor(composite); + + Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); + lblScanLast.setBounds(0, 15, 80, 20); + + text = toolkit.createText(composite, "100", SWT.NONE); + text.setBounds(85, 15, 60, 20); + + Label lblMessagesAndFilter = toolkit.createLabel(composite, " messages from ", SWT.CENTER); + lblMessagesAndFilter.setBounds(160, 15, 110, 20); + + Combo combo = new Combo(composite, SWT.CENTER); + combo.setBounds(295, 15, 100, 20); + combo.setItems(new String[] { "syslog", "dmesg" }); + toolkit.adapt(combo); + toolkit.paintBordersFor(combo); + combo.select(0); + + Button btngo = toolkit.createButton(composite, "&Go", SWT.NONE); + btngo.setBounds(410, 13, 50, 30); + + Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); + separator.setBounds(0, 50, 500, 2); + + Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); + lblFilterString.setBounds(0, 65, 100, 20); + + text = guiHelper.createFilterText(toolkit, composite); + text.setBounds(105, 65, 250, 20); + + Composite logContentsComposite = createLogContentsComposite(toolkit); + // Text logContentsText = toolkit.createText(logContentsComposite, "", SWT.MULTI | SWT.FLAT | SWT.BORDER); + // logContentsText.setEditable(false); + // populateDummyLogContent(logContentsText); + + ListViewer logViewer = new ListViewer(logContentsComposite, SWT.BORDER | SWT.V_SCROLL | SWT.NO); + logViewer.setContentProvider(new ArrayContentProvider()); + guiHelper.createFilter(logViewer, text, false); + logViewer.setInput(getDummyLogContents()); + + // TODO: Link the filter string with the contents text + } + + private Composite createLogContentsComposite(FormToolkit toolkit) { + Composite tableViewerComposite = toolkit.createComposite(this, SWT.NONE); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData.verticalIndent = 10; + tableViewerComposite.setLayoutData(layoutData); + return tableViewerComposite; + } + + private String[] getDummyLogContents() { + + String[] logMessages = { + "Jan 19 13:43:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:44:08 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:44:47 shireesh-laptop dhclient: last message repeated 2 times", + "Jan 19 13:44:47 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", + "Jan 19 13:45:49 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:46:59 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:48:01 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:49:02 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:50:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:51:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:52:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:53:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:54:08 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:55:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:56:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:57:08 shireesh-laptop dhclient: last message repeated 3 times", + "Jan 19 13:58:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:59:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:59:40 shireesh-laptop dhclient: last message repeated 3 times", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> DHCP: device eth1 state changed bound -> expire", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> DHCP: device eth1 state changed expire -> preinit", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPOFFER of 192.168.1.174 from 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPACK of 192.168.1.174 from 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop dhclient: bound to 192.168.1.174 -- renewal in 3205 seconds.", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> DHCP: device eth1 state changed preinit -> bound", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> address 192.168.1.174", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> prefix 24 (255.255.255.0)", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> gateway 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> nameserver '192.168.1.1'", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: <info> domain name 'in.gluster.com'", + "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", + "Jan 19 14:05:09 shireesh-laptop avahi-daemon[1098]: last message repeated 8 times", + "Jan 19 14:12:48 shireesh-laptop NetworkManager: <debug> [1295426568.002642] periodic_update(): Roamed from BSSID E0:CB:4E:C0:0B:7F (glfs) to (none) ((none))", + "Jan 19 14:12:54 shireesh-laptop NetworkManager: <debug> [1295426574.002448] periodic_update(): Roamed from BSSID (none) ((none)) to E0:CB:4E:C0:0B:7F (glfs)", + "Jan 19 14:17:01 shireesh-laptop CRON[5321]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)" }; + + return logMessages; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServersPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServersPage.java new file mode 100644 index 00000000..43a64ffc --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/ServersPage.java @@ -0,0 +1,153 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.gui.EntityGroupContentProvider; +import com.gluster.storage.management.gui.ServerTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class ServersPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TableViewer tableViewer; + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public enum SERVER_TABLE_COLUMN_INDICES { + NAME, IP_ADDRESSES, NUM_OF_DISKS, TOTAL_DISK_SPACE + }; + + private static final String[] SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "IP Address(es)", "Number of Disks", "Total Disk Space (GB)" }; + + // public enum SERVER_DISK_TABLE_COLUMN_INDICES { + // NAME, NUM_OF_CPUS, CPU_USAGE, TOTAL_MEMORY, MEMORY_IN_USE, TOTAL_DISK_SPACE, DISK_SPACE_IN_USE + // }; + // + // private static final String[] SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", + // "Number\nof CPUs", "CPU\nUsage (%)", "Total\nMemory (GB)", "Memory\nIn Use (GB)", + // "Total Disk\n Space (GB)", "Disk Space\nin Use (GB)"}; + + public ServersPage(Composite parent, int style) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + Text filterText = guiHelper.createFilterText(toolkit, this); + setupServerTableViewer(filterText); + } + + public ServersPage(final Composite parent, int style, EntityGroup<Server> servers) { + this(parent, style); + + tableViewer.setInput(servers); + parent.layout(); // Important - this actually paints the table + + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + } + + public void addDoubleClickListener(IDoubleClickListener listener) { + tableViewer.addDoubleClickListener(listener); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void setupServerTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, SERVER_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 70); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES, SWT.CENTER, 100); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS, SWT.CENTER, 70); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 70); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); + } + + private TableViewer createServerTableViewer(Composite parent) { + TableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + // TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new ServerTableLabelProvider()); + tableViewer.setContentProvider(new EntityGroupContentProvider<Server>()); + + setupServerTable(parent, tableViewer.getTable()); + + return tableViewer; + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NONE); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + private void setupServerTableViewer(final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + tableViewer = createServerTableViewer(tableViewerComposite); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + private void setColumnProperties(Table table, SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/SmartControlAdapter.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/SmartControlAdapter.java new file mode 100644 index 00000000..0cf60af0 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/SmartControlAdapter.java @@ -0,0 +1,35 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * This is an extended version of the regular ControlAdapter. + * It is used to get only the real resize events and excludes all resize + * events of the text size determination. + * + */ +public abstract class SmartControlAdapter extends ControlAdapter { + + public void controlResized( ControlEvent e ) { + Shell shell = ( ( Control )e.widget ).getShell(); + Point shellSize = shell.getSize(); + Point previousSize = ( Point )e.widget.getData( "previousShellSize" + + this.hashCode() ); + e.widget.setData( "previousShellSize" + this.hashCode(), shellSize ); + if( previousSize != null ) { + int dx = Math.abs( Math.abs( shellSize.x - previousSize.x ) - 1000 ); + int dy = Math.abs( Math.abs( shellSize.y - previousSize.y ) - 1000 ); + if( ( dx <= 2 || dy <= 2 ) ) { + // This came from the TextSizeDetermination + return; + } + } + handleControlResized( e ); + } + + protected abstract void handleControlResized( ControlEvent e ); +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreator.java new file mode 100644 index 00000000..d6d9c77b --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreator.java @@ -0,0 +1,31 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.Entity; + +/** + * For every entity that can be selected from the navigation view (cluster tree), a set of tabs are created on the + * details view. Each entity has a corresponding tab creator that creates these tabs. These tab creators must implement + * this interface. + * <p> + * <b>Important:</b> Tab creators are cached for performance reasons. Hence they should not store any state information + * in class level variables. + */ +public interface TabCreator { + /** + * Creates tabs for the given entity + * + * @param entity + * Entity for which tabs are to be created + * @param tabFolder + * The tab folder in which the tabs are to be created + * @param toolkit + * The form toolkit that can be used for create components using Forms API + * @param site + * The workbench site that can be used to register as a selection provider + */ + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site); +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactory.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactory.java new file mode 100644 index 00000000..0bafdf1a --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactory.java @@ -0,0 +1,14 @@ +package com.gluster.storage.management.gui.views.details; + +import com.gluster.storage.management.core.model.Entity; + +/** + * Interface for tab creator factory. + */ +public interface TabCreatorFactory { + /** + * @param entity The entity for which tab creator factory is to be returned + * @return A tab creator factory for given entity + */ + public TabCreator getTabCreator(Entity entity); +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactoryImpl.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactoryImpl.java new file mode 100644 index 00000000..640d72e8 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TabCreatorFactoryImpl.java @@ -0,0 +1,53 @@ +package com.gluster.storage.management.gui.views.details; + +import java.util.HashMap; +import java.util.Map; + +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; + +public class TabCreatorFactoryImpl implements TabCreatorFactory { + + private Map<String, TabCreator> tabCreatorCache = new HashMap<String, TabCreator>(); + + /** + * Returns tab creator for given entity. The logic is as follows: <br> + * 1) Check if an tab creator is already created for the "class" of the entity. In case of {@link EntityGroup}, + * append the class name with entity type <br> + * 2) If the tab creator is found in the cache, return it <br> + * 3) If not found, create one by instantiating the class "<current package>.tabcreators.<class name>TabCreator". + * Again, "class name" includes "entity type" in case of {@link EntityGroup} <br> + * 4) Add the newly created tab creator to the cache and return it + */ + @Override + public TabCreator getTabCreator(Entity entity) { + Class entityClass = entity.getClass(); + String key = entityClass.getSimpleName(); + if (entityClass == EntityGroup.class) { + // If it's an entity group, add the entity type to the key + key += ((EntityGroup) entity).getEntityType().getSimpleName(); + } + + TabCreator tabCreator = tabCreatorCache.get(key); + if (tabCreator == null) { + // Not created yet. Create one and add to the cache + String className = getClass().getPackage().getName() + ".tabcreators." + key + "TabCreator"; + try { + Class<TabCreator> creatorFactoryClass = (Class<TabCreator>) Class.forName(className); + tabCreator = creatorFactoryClass.newInstance(); + tabCreatorCache.put(key, tabCreator); + } catch (ClassNotFoundException e) { + throw new GlusterRuntimeException("Could not load creator factory class [" + className + "]", e); + } catch (InstantiationException e) { + throw new GlusterRuntimeException("Could not create instance of creator factory class [" + className + + "]", e); + } catch (IllegalAccessException e) { + throw new GlusterRuntimeException("Could not create instance of creator factory class [" + className + + "]", e); + } + } + + return tabCreator; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TestComposite.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TestComposite.java new file mode 100644 index 00000000..e9cff399 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/TestComposite.java @@ -0,0 +1,67 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Table; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.jface.viewers.TableViewerColumn; +import com.swtdesigner.ResourceManager; + +public class TestComposite extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private Table table; + + /** + * Create the composite. + * @param parent + * @param style + */ + public TestComposite(Composite parent, int style) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + Composite composite = new Composite(this, SWT.NONE); + composite.setBounds(10, 10, 430, 280); + toolkit.adapt(composite); + toolkit.paintBordersFor(composite); + + TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); + table = tableViewer.getTable(); + table.setBounds(10, 10, 410, 260); + toolkit.paintBordersFor(table); + + TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn tableColumn = tableViewerColumn.getColumn(); + tableColumn.setImage(ResourceManager.getPluginImage("com.gluster.storage.management.gui", "icons/cluster.png")); + tableColumn.setWidth(100); + tableColumn.setText("New Column"); + + TableViewerColumn tableViewerColumn_3 = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn tableColumn_3 = tableViewerColumn_3.getColumn(); + tableColumn_3.setWidth(100); + tableColumn_3.setText("New Column"); + + TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn tableColumn_2 = tableViewerColumn_2.getColumn(); + tableColumn_2.setWidth(100); + tableColumn_2.setText("New Column"); + + TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn tableColumn_1 = tableViewerColumn_1.getColumn(); + tableColumn_1.setWidth(100); + tableColumn_1.setText("New Column"); + + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeLogsPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeLogsPage.java new file mode 100644 index 00000000..8aee564a --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeLogsPage.java @@ -0,0 +1,178 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.layout.FillLayout; +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.DateTime; +import org.eclipse.swt.widgets.Display; +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.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.GlusterDummyModel; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.VolumeLogTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class VolumeLogsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Text text; + public enum LOG_TABLE_COLUMN_INDICES { + DATE, TIME, DISK, SEVERITY, MESSAGE + }; + + private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Disk", "Severity", "Message" }; + + /** + * Create the composite. + * @param parent + * @param style + */ + public VolumeLogsPage(Composite parent, int style, Volume volume) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setLayout(new GridLayout(1, false)); + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + //layoutData.verticalIndent = 10; + setLayoutData(layoutData); + + Composite composite = toolkit.createComposite(this, SWT.NONE); + toolkit.paintBordersFor(composite); + + Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); + lblScanLast.setBounds(0, 15, 80, 20); + + text = toolkit.createText(composite, "100", SWT.NONE); + text.setBounds(85, 15, 60, 20); + + Label lblMessagesAndFilter = toolkit.createLabel(composite, "messages, and filter on disk", SWT.NONE); + lblMessagesAndFilter.setBounds(160, 15, 200, 20); + + Combo combo = new Combo(composite, SWT.NONE); + combo.setBounds(365, 15, 100, 20); + combo.setItems(new String[] {"ALL", "sda", "sdb", "sdc", "sdd"}); + toolkit.adapt(combo); + toolkit.paintBordersFor(combo); + combo.select(0); + + Label lblSeverity = toolkit.createLabel(composite, "Severity", SWT.NONE); + lblSeverity.setBounds(480, 15, 70, 20); + + Combo combo_1 = new Combo(composite, SWT.NONE); + combo_1.setBounds(555, 15, 110, 20); + combo_1.setItems(new String[] {"ALL", "SEVERE", "WARNING", "DEBUG", "INFO"}); + toolkit.adapt(combo_1); + toolkit.paintBordersFor(combo_1); + combo_1.select(1); + + Label lblFrom = toolkit.createLabel(composite, "from", SWT.NONE); + lblFrom.setBounds(0, 60, 40, 20); + + DateTime dateTime = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); + dateTime.setBounds(45, 60, 120, 20); + toolkit.adapt(dateTime); + toolkit.paintBordersFor(dateTime); + + DateTime dateTime_1 = new DateTime(composite, SWT.BORDER | SWT.TIME); + dateTime_1.setBounds(171, 60, 120, 20); + toolkit.adapt(dateTime_1); + toolkit.paintBordersFor(dateTime_1); + + Label lblTo = toolkit.createLabel(composite, "To", SWT.NONE); + lblTo.setBounds(329, 60, 26, 20); + + DateTime dateTime_2 = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); + dateTime_2.setBounds(355, 60, 120, 20); + toolkit.adapt(dateTime_2); + toolkit.paintBordersFor(dateTime_2); + + DateTime dateTime_3 = new DateTime(composite, SWT.BORDER | SWT.TIME); + dateTime_3.setBounds(480, 60, 120, 20); + toolkit.adapt(dateTime_3); + toolkit.paintBordersFor(dateTime_3); + + Button btngo = toolkit.createButton(composite, "&Go", SWT.NONE); + btngo.setBounds(605, 55, 60, 30); + + Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); + separator.setBounds(0, 95, 680, 2); + + Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); + lblFilterString.setBounds(0, 105, 85, 20); + + text = guiHelper.createFilterText(toolkit, composite); + text.setBounds(90, 105, 250, 20); + + Composite tableViewerComposite = createTableViewerComposite(); + + TableViewer tableViewer = new TableViewer(tableViewerComposite, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new VolumeLogTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupLogsTable(tableViewerComposite, tableViewer.getTable()); + guiHelper.createFilter(tableViewer, text, false); + tableViewer.setInput(GlusterDummyModel.getDummyLogMessages().toArray()); + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData.verticalIndent = 10; + tableViewerComposite.setLayoutData(layoutData); + return tableViewerComposite; + } + + private void setupLogsTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, LOG_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.DATE, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.TIME, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.DISK, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.SEVERITY, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.MESSAGE, SWT.LEFT, 100); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + private void setColumnProperties(Table table, LOG_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java new file mode 100644 index 00000000..be94b52e --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java @@ -0,0 +1,134 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.VolumeOptionsTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class VolumeOptionsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TableViewer tableViewer; + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public enum OPTIONS_TABLE_COLUMN_INDICES { + OPTION_KEY, OPTION_VALUE + }; + + private static final String[] OPTIONS_TABLE_COLUMN_NAMES = new String[] { "Option Key", "Option Value" }; + + public VolumeOptionsPage(Composite parent, int style) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + Text filterText = guiHelper.createFilterText(toolkit, this); + setupDiskTableViewer(filterText); + } + + public VolumeOptionsPage(final Composite parent, int style, Volume volume) { + this(parent, style); + + tableViewer.setInput(volume.getOptions().entrySet().toArray()); + + parent.layout(); // Important - this actually paints the table + + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void setupDiskTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, OPTIONS_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY, SWT.CENTER, 100); + setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE, SWT.CENTER, 100); + } + + private TableViewer createDiskTableViewer(Composite parent) { + TableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + // TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new VolumeOptionsTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupDiskTable(parent, tableViewer.getTable()); + + return tableViewer; + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + private void setupDiskTableViewer(final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + tableViewer = createDiskTableViewer(tableViewerComposite); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, OPTIONS_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumesPage.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumesPage.java new file mode 100644 index 00000000..c86d8a28 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumesPage.java @@ -0,0 +1,139 @@ +package com.gluster.storage.management.gui.views.details; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.EntityGroupContentProvider; +import com.gluster.storage.management.gui.VolumeTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; + +public class VolumesPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TableViewer tableViewer; + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public enum VOLUME_TABLE_COLUMN_INDICES { + NAME, VOLUME_TYPE, NUM_OF_DISKS, TRANSPORT_TYPE, VOLUME_STATUS + }; + + private static final String[] VOLUME_TABLE_COLUMN_NAMES = new String[] { "Name", + "Volume Type", "Number of\nDisks", "Transport Type", "Status" }; + + public VolumesPage(Composite parent, int style) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + Text filterText = guiHelper.createFilterText(toolkit, this); + setupVolumeTableViewer(filterText); + } + + public VolumesPage(final Composite parent, int style, EntityGroup<Volume> volumes) { + this(parent, style); + + tableViewer.setInput(volumes); + parent.layout(); // Important - this actually paints the table + + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + } + + public void addDoubleClickListener(IDoubleClickListener listener) { + tableViewer.addDoubleClickListener(listener); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void setupVolumeTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableColumnLayout columnLayout = guiHelper.createTableColumnLayout(table, VOLUME_TABLE_COLUMN_NAMES); + parent.setLayout(columnLayout); + + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS, SWT.CENTER, 50); + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.NUM_OF_DISKS, SWT.CENTER, 50); + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE, SWT.CENTER, 70); + } + + private TableViewer createVolumeTableViewer(Composite parent) { + TableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new VolumeTableLabelProvider()); + tableViewer.setContentProvider(new EntityGroupContentProvider<Volume>()); + + setupVolumeTable(parent, tableViewer.getTable()); + + return tableViewer; + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + private void setupVolumeTableViewer(final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + tableViewer = createVolumeTableViewer(tableViewerComposite); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, VOLUME_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ClusterTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ClusterTabCreator.java new file mode 100644 index 00000000..90c782eb --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ClusterTabCreator.java @@ -0,0 +1,190 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import org.eclipse.jface.fieldassist.ComboContentAdapter; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Cluster; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; +import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.editor.TimeZones; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.TabCreator; + +public class ClusterTabCreator implements TabCreator { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + private int getVolumeCountByStatus(Cluster cluster, VOLUME_STATUS status) { + int count = 0; + for (Volume volume : cluster.getVolumes()) { + if (volume.getStatus() == status) { + count++; + } + } + return count; + } + + private int getServerCountByStatus(Cluster cluster, SERVER_STATUS status) { + int count = 0; + for (GlusterServer server : cluster.getServers()) { + if (server.getStatus() == status) { + count++; + } + } + return count; + } + + private void createVolumesSection(Cluster cluster, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Volumes", null, 1, false); + + // toolkit.createLabel(sectionClient, "Number of Volumes: ", SWT.NONE); + // toolkit.createLabel(sectionClient, "12", SWT.NONE); + // + // toolkit.createLabel(sectionClient, "Online: ", SWT.NONE); + // Label labelOnlineCount = toolkit.createLabel(sectionClient, "9", SWT.NONE); + // labelOnlineCount.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN)); + // + // toolkit.createLabel(sectionClient, "Offline: ", SWT.NONE); + // Label lblOfflineCount = toolkit.createLabel(sectionClient, "3", SWT.NONE); + // lblOfflineCount.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED)); + + Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(cluster, VOLUME_STATUS.ONLINE)), + Double.valueOf(getVolumeCountByStatus(cluster, VOLUME_STATUS.OFFLINE)) }; + createStatusChart(toolkit, section, values); + } + + private void createServersSection(Cluster cluster, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Servers", null, 1, false); + +// toolkit.createLabel(sectionClient, "Number of Servers: ", SWT.NONE); +// toolkit.createLabel(sectionClient, "7", SWT.NONE); +// +// toolkit.createLabel(sectionClient, "Online: ", SWT.NONE); +// Label labelOnlineCount = toolkit.createLabel(sectionClient, "6", SWT.NONE); +// labelOnlineCount.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN)); +// +// toolkit.createLabel(sectionClient, "Offline: ", SWT.NONE); +// Label lblOfflineCount = toolkit.createLabel(sectionClient, "1", SWT.NONE); +// lblOfflineCount.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED)); + + Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(cluster, SERVER_STATUS.ONLINE)), + Double.valueOf(getServerCountByStatus(cluster, SERVER_STATUS.OFFLINE)) }; + + createStatusChart(toolkit, section, values); + } + + private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { + String[] categories = new String[] { "Online", "Offline" }; + PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite(section, SWT.NONE, categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 250; + data.heightHint = 250; + chartViewerComposite.setLayoutData(data); + } + + private void createAppSettingsSection(FormToolkit toolkit, final ScrolledForm form) { + Composite sectionClient = guiHelper.createSection(form, toolkit, "Application Settings", null, 2, false); + toolkit.createButton(sectionClient, "Enable Remote CLI?", SWT.CHECK | SWT.FLAT); + } + + private Combo createTimeZoneCombo(Composite sectionClient, GridData layoutData) { + Combo cboTimeZone = new Combo(sectionClient, SWT.FLAT); + cboTimeZone.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + cboTimeZone.setLayoutData(layoutData); + + for (String timeZone : TimeZones.timeZones) { + cboTimeZone.add(timeZone); + } + cboTimeZone.setText("Asia/Calcutta"); + + SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(TimeZones.timeZones); + proposalProvider.setFiltering(true); + ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(cboTimeZone, new ComboContentAdapter(), + proposalProvider, null, null); + proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); + + return cboTimeZone; + } + + private GridData createDefaultLayoutData() { + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.minimumWidth = 200; + return layoutData; + } + + private void createClusterSettingsSection(final FormToolkit toolkit, final ScrolledForm form) { + GridData layoutData = createDefaultLayoutData(); + + Composite section = guiHelper.createSection(form, toolkit, "Cluster Settings", null, 2, false); + + toolkit.createLabel(section, "Time Zone: ", SWT.NONE); + createTimeZoneCombo(section, layoutData); + + toolkit.createLabel(section, "Network Time GlusterServer: ", SWT.NONE); + Text txtTimeServer = toolkit.createText(section, "pool.ntp.org", SWT.BORDER_SOLID); + txtTimeServer.setLayoutData(layoutData); + } + + private void createActionsSection(final Cluster cluster, final FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Actions", null, 1, false); + + ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); + imageHyperlink.setText("Create Volume"); + imageHyperlink.setImage(guiHelper.getImage(IImageKeys.CREATE_VOLUME_BIG)); + imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + // TODO: Override appropriate method and handle hyperlink event + }); + + imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); + imageHyperlink.setText("Add Server(s)"); + imageHyperlink.setImage(guiHelper.getImage(IImageKeys.ADD_SERVER_BIG)); + imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + // TODO: Override appropriate method and handle hyperlink event + }); + } + + private void createClusterSummaryTab(final Cluster cluster, final TabFolder tabFolder, final FormToolkit toolkit) { + Composite summaryTab = guiHelper.createTab(tabFolder, cluster.getName(), IImageKeys.CLUSTER); + + final ScrolledForm form = guiHelper.setupForm(summaryTab, toolkit, "Cluster Summary"); + createVolumesSection(cluster, toolkit, form); + createServersSection(cluster, toolkit, form); + createActionsSection(cluster, toolkit, form); + + summaryTab.layout(); // IMP: lays out the form properly + } + + private void createSettingsTab(final Cluster cluster, final TabFolder tabFolder, final FormToolkit toolkit) { + Composite settingsTab = guiHelper.createTab(tabFolder, "Settings", IImageKeys.SETTINGS); + + final ScrolledForm form = guiHelper.setupForm(settingsTab, toolkit, "Settings"); + createClusterSettingsSection(toolkit, form); + createAppSettingsSection(toolkit, form); + + settingsTab.layout(); // IMP: lays out the form properly + } + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createClusterSummaryTab((Cluster) entity, tabFolder, toolkit); + //createSettingsTab((Cluster) entity, tabFolder, toolkit); + } + +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupGlusterServerTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupGlusterServerTabCreator.java new file mode 100644 index 00000000..493e17d2 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupGlusterServerTabCreator.java @@ -0,0 +1,118 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Disk; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.DisksPage; +import com.gluster.storage.management.gui.views.details.GlusterServersPage; +import com.gluster.storage.management.gui.views.details.TabCreator; +import com.gluster.storage.management.gui.views.navigator.NavigationView; + +public class EntityGroupGlusterServerTabCreator implements TabCreator, IDoubleClickListener { + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private int getServerCountByStatus(EntityGroup<GlusterServer> servers, SERVER_STATUS status) { + int count = 0; + for (GlusterServer server : (List<GlusterServer>)servers.getEntities()) { + if (server.getStatus() == status) { + count++; + } + } + return count; + } + + private void createAlertsSection(final EntityGroup<GlusterServer> servers, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 2, false); + + toolkit.createLabel(section, "Any alerts related to servers\nwill be displayed here."); + } + + private void createRunningTasksSection(final EntityGroup<GlusterServer> servers, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Running Tasks", null, 2, false); + + toolkit.createLabel(section, "List of running tasks related to\nservers will be displayed here."); + } + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createSummaryTab((EntityGroup<GlusterServer>)entity, tabFolder, toolkit); + createServersTab((EntityGroup<GlusterServer>)entity, tabFolder, toolkit); + createDisksTab((EntityGroup<GlusterServer>)entity, tabFolder, toolkit, site); + } + + private void createServersTab(EntityGroup<GlusterServer> servers, TabFolder tabFolder, FormToolkit toolkit) { + Composite serversTab = guiHelper.createTab(tabFolder, "Servers", IImageKeys.SERVERS); + GlusterServersPage page = new GlusterServersPage(serversTab, SWT.NONE, servers); + page.addDoubleClickListener(this); + } + + private void createSummaryTab(EntityGroup<GlusterServer> servers, TabFolder tabFolder, FormToolkit toolkit) { + Composite summaryTab = guiHelper.createTab(tabFolder, "Summary", IImageKeys.SERVERS); + final ScrolledForm form = guiHelper.setupForm(summaryTab, toolkit, "Servers - Summary"); + createSummarySection(servers, toolkit, form); + createRunningTasksSection(servers, toolkit, form); + createAlertsSection(servers, toolkit, form); + + summaryTab.layout(); // IMP: lays out the form properly + } + + private void createSummarySection(final EntityGroup<GlusterServer> servers, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Availability", null, 2, false); + + Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.ONLINE)), + Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.OFFLINE)) }; + createStatusChart(toolkit, section, values); + } + + private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { + String[] categories = new String[] { "Online", "Offline" }; + PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite(section, SWT.NONE, categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 250; + data.heightHint = 250; + chartViewerComposite.setLayoutData(data); + } + + + private void createDisksTab(EntityGroup<GlusterServer> servers, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + Composite disksTab = guiHelper.createTab(tabFolder, "Disks", IImageKeys.SERVERS); + DisksPage page = new DisksPage(disksTab, SWT.NONE, site, getAllDisks(servers)); + + disksTab.layout(); // IMP: lays out the form properly + } + + private List<Disk> getAllDisks(EntityGroup<GlusterServer> servers) { + List<Disk> disks = new ArrayList<Disk>(); + for(GlusterServer server : (List<GlusterServer>)servers.getEntities()) { + disks.addAll(server.getDisks()); + } + return disks; + } + + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupServerTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupServerTabCreator.java new file mode 100644 index 00000000..92ac6bb4 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupServerTabCreator.java @@ -0,0 +1,42 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.ServersPage; +import com.gluster.storage.management.gui.views.details.TabCreator; +import com.gluster.storage.management.gui.views.navigator.NavigationView; + +public class EntityGroupServerTabCreator implements TabCreator, IDoubleClickListener { + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createServersTab((EntityGroup<Server>) entity, tabFolder); + } + + private void createServersTab(EntityGroup<Server> servers, TabFolder tabFolder) { + Composite serversTab = guiHelper.createTab(tabFolder, "Discovered Servers", IImageKeys.SERVERS); + ServersPage page = new ServersPage(serversTab, SWT.NONE, servers); + page.addDoubleClickListener(this); + } + + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupVolumeTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupVolumeTabCreator.java new file mode 100644 index 00000000..377e781b --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/EntityGroupVolumeTabCreator.java @@ -0,0 +1,99 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import java.util.List; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.TabCreator; +import com.gluster.storage.management.gui.views.details.VolumesPage; +import com.gluster.storage.management.gui.views.navigator.NavigationView; + +public class EntityGroupVolumeTabCreator implements TabCreator, IDoubleClickListener { + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createSummaryTab((EntityGroup<Volume>) entity, tabFolder, toolkit); + createVolumesTab((EntityGroup<Volume>) entity, tabFolder, toolkit); + } + + private int getVolumeCountByStatus(EntityGroup<Volume> volumes, VOLUME_STATUS status) { + int count = 0; + for (Volume volume : (List<Volume>) volumes.getEntities()) { + if (volume.getStatus() == status) { + count++; + } + } + return count; + } + + private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { + String[] categories = new String[] { "Online", "Offline" }; + PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite(section, SWT.NONE, categories, + values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 250; + data.heightHint = 250; + chartViewerComposite.setLayoutData(data); + } + + private void createAlertsSection(final EntityGroup<Volume> volumes, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 2, false); + + toolkit.createLabel(section, "Any alerts related to volumes\nwill be displayed here."); + } + + private void createRunningTasksSection(final EntityGroup<Volume> volumes, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Running Tasks", null, 2, false); + + toolkit.createLabel(section, "List of running tasks related to\nvolumes will be displayed here."); + } + + private void createSummarySection(final EntityGroup<Volume> volumes, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Availability", null, 2, false); + + Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)), + Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) }; + createStatusChart(toolkit, section, values); + } + + private void createSummaryTab(final EntityGroup<Volume> volumes, TabFolder tabFolder, FormToolkit toolkit) { + Composite summaryTab = guiHelper.createTab(tabFolder, "Summary", IImageKeys.VOLUMES); + final ScrolledForm form = guiHelper.setupForm(summaryTab, toolkit, "Volumes - Summary"); + createSummarySection(volumes, toolkit, form); + createRunningTasksSection(volumes, toolkit, form); + createAlertsSection(volumes, toolkit, form); + + summaryTab.layout(); // IMP: lays out the form properly + } + + private void createVolumesTab(EntityGroup<Volume> volumes, TabFolder tabFolder, FormToolkit toolkit) { + Composite volumesTab = guiHelper.createTab(tabFolder, "Volumes", IImageKeys.VOLUMES); + VolumesPage page = new VolumesPage(volumesTab, SWT.NONE, volumes); + page.addDoubleClickListener(this); + } + + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/GlusterServerTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/GlusterServerTabCreator.java new file mode 100644 index 00000000..3e92d9c9 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/GlusterServerTabCreator.java @@ -0,0 +1,243 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.ProgressBar; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.NetworkInterfaceTableLabelProvider; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.ServerDisksPage; +import com.gluster.storage.management.gui.views.details.ServerLogsPage; +import com.gluster.storage.management.gui.views.details.TabCreator; +import com.richclientgui.toolbox.gauges.CoolGauge; + +public class GlusterServerTabCreator implements TabCreator { + public enum NETWORK_INTERFACE_TABLE_COLUMN_INDICES { + INTERFACE, IP_ADDRESS, NETMASK, GATEWAY, PREFERRED + }; + + private static final String[] NETWORK_INTERFACE_TABLE_COLUMN_NAMES = { "Interface", "IP Address", "Netmask", + "Gateway", "Preferred?" }; + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private void createServerSummarySection(GlusterServer server, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); + + toolkit.createLabel(section, "Preferred Network: ", SWT.NONE); + toolkit.createLabel(section, server.getPreferredNetworkInterface().getName(), SWT.NONE); + + boolean online = server.getStatus() == SERVER_STATUS.ONLINE; + + if (online) { + toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); + toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); + + // toolkit.createLabel(section, "CPU Usage (%): ", SWT.NONE); + // toolkit.createLabel(section, online ? "" + server.getCpuUsage() : "NA", SWT.NONE); + + toolkit.createLabel(section, "% CPU Usage (avg): ", SWT.NONE); + CoolGauge gauge = new CoolGauge(section, guiHelper.getImage(IImageKeys.GAUGE_SMALL)); + gauge.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); + gauge.setGaugeNeedleColour(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + gauge.setGaugeNeedleWidth(2); + gauge.setGaugeNeedlePivot(new Point(66, 65)); + + gauge.setPoints(getPnts()); + gauge.setLevel(server.getCpuUsage() / 100); + gauge.setToolTipText(server.getCpuUsage() + "%"); + + toolkit.createLabel(section, "Memory Usage: ", SWT.NONE); + ProgressBar memoryUsageBar = new ProgressBar(section, SWT.SMOOTH); + memoryUsageBar.setMinimum(0); + memoryUsageBar.setMaximum((int) Math.round(server.getTotalMemory())); + memoryUsageBar.setSelection((int) Math.round(server.getMemoryInUse())); + memoryUsageBar.setToolTipText("Total: " + server.getTotalMemory() + "GB, In Use: " + + server.getMemoryInUse() + "GB"); + + // toolkit.createLabel(section, "Memory Usage: ", SWT.NONE); + // final CoolProgressBar bar = new CoolProgressBar(section,SWT.HORIZONTAL, + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_LEFT), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_FILLED), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_EMPTY), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_RIGHT)); + // bar.updateProgress(server.getMemoryInUse() / server.getTotalMemory()); + + // toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + // toolkit.createLabel(section, online ? "" + server.getTotalDiskSpace() : "NA", SWT.NONE); + // + // toolkit.createLabel(section, "Disk Space in Use (GB): ", SWT.NONE); + // toolkit.createLabel(section, online ? "" + server.getDiskSpaceInUse() : "NA", SWT.NONE); + + toolkit.createLabel(section, "Disk Usage: ", SWT.NONE); + ProgressBar diskUsageBar = new ProgressBar(section, SWT.SMOOTH); + diskUsageBar.setMinimum(0); + diskUsageBar.setMaximum((int) Math.round(server.getTotalDiskSpace())); + diskUsageBar.setSelection((int) Math.round(server.getDiskSpaceInUse())); + diskUsageBar.setToolTipText("Total: " + NumberUtil.formatNumber(server.getTotalDiskSpace()) + + "GB, In Use: " + NumberUtil.formatNumber(server.getDiskSpaceInUse()) + "GB"); + } + + toolkit.createLabel(section, "Status: ", SWT.NONE); + CLabel lblStatusValue = new CLabel(section, SWT.NONE); + lblStatusValue.setText(server.getStatusStr()); + lblStatusValue.setImage(server.getStatus() == GlusterServer.SERVER_STATUS.ONLINE ? guiHelper + .getImage(IImageKeys.STATUS_ONLINE) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE)); + toolkit.adapt(lblStatusValue, true, true); + } + + private List<Point> getPnts() { + final List<Point> pnts = new ArrayList<Point>(); + pnts.add(new Point(47, 98)); + pnts.add(new Point(34, 84)); + pnts.add(new Point(29, 65)); + pnts.add(new Point(33, 48)); + pnts.add(new Point(48, 33)); + pnts.add(new Point(66, 28)); + pnts.add(new Point(83, 32)); + pnts.add(new Point(98, 47)); + pnts.add(new Point(103, 65)); + pnts.add(new Point(98, 83)); + pnts.add(new Point(84, 98)); + return pnts; + } + + private void createServerSummaryTab(GlusterServer server, TabFolder tabFolder, FormToolkit toolkit) { + String serverName = server.getName(); + Composite serverSummaryTab = guiHelper.createTab(tabFolder, serverName, IImageKeys.SERVER); + final ScrolledForm form = guiHelper.setupForm(serverSummaryTab, toolkit, "Server Summary [" + serverName + "]"); + createServerSummarySection(server, toolkit, form); + + if (server.getStatus() == SERVER_STATUS.ONLINE) { + Composite section = createNetworkInterfacesSection(server, toolkit, form); + } + + serverSummaryTab.layout(); // IMP: lays out the form properly + } + + private void setupNetworkInterfaceTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, + NETWORK_INTERFACE_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS, SWT.CENTER, 100); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.PREFERRED, SWT.CENTER, 70); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES columnIndex, int alignment, + int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + private TableViewer createNetworkInterfacesTableViewer(final Composite parent, GlusterServer server) { + TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + // TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new NetworkInterfaceTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupNetworkInterfaceTable(parent, tableViewer.getTable()); + tableViewer.setInput(server.getNetworkInterfaces().toArray()); + + return tableViewer; + } + + private Composite createTableViewerComposite(Composite parent) { + Composite tableViewerComposite = new Composite(parent, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false); + tableLayoutData.widthHint = 400; + tableLayoutData.minimumWidth = 400; + // tableLayoutData.grabExcessHorizontalSpace = true; + tableViewerComposite.setLayoutData(tableLayoutData); + return tableViewerComposite; + } + + private Composite createNetworkInterfacesSection(GlusterServer server, FormToolkit toolkit, ScrolledForm form) { + final Composite section = guiHelper.createSection(form, toolkit, "Network Interfaces", null, 1, false); + createNetworkInterfacesTableViewer(createTableViewerComposite(section), server); + Hyperlink changePreferredNetworkLink = toolkit.createHyperlink(section, "Change Preferred Network", SWT.NONE); + changePreferredNetworkLink.addHyperlinkListener(new HyperlinkAdapter() { + + @Override + public void linkActivated(HyperlinkEvent e) { + new MessageDialog( + section.getShell(), + "Gluster Storage Platform", + guiHelper.getImage(IImageKeys.SERVER), + "This will show additional controls to help user choose a new network interface. TO BE IMPLEMENTED.", + MessageDialog.INFORMATION, new String[] { "OK" }, 0).open(); + } + }); + return section; + } + + private void createServerLogsTab(GlusterServer server, TabFolder tabFolder, FormToolkit toolkit) { + String serverName = server.getName(); + Composite serverLogsTab = guiHelper.createTab(tabFolder, "Logs", IImageKeys.SERVER); + ServerLogsPage logsPage = new ServerLogsPage(serverLogsTab, SWT.NONE, server); + + serverLogsTab.layout(); // IMP: lays out the form properly + } + + private void createServerDisksTab(GlusterServer server, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + Composite serverDisksTab = guiHelper.createTab(tabFolder, "Disks", IImageKeys.SERVER); + ServerDisksPage page = new ServerDisksPage(serverDisksTab, SWT.NONE, site, server.getDisks()); + + serverDisksTab.layout(); // IMP: lays out the form properly + } + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + GlusterServer server = (GlusterServer) entity; + + createServerSummaryTab(server, tabFolder, toolkit); + if (server.getStatus() == SERVER_STATUS.ONLINE) { + createServerDisksTab(server, tabFolder, toolkit, site); + createServerLogsTab(server, tabFolder, toolkit); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/PieChartViewerComposite.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/PieChartViewerComposite.java new file mode 100644 index 00000000..9ed179c6 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/PieChartViewerComposite.java @@ -0,0 +1,258 @@ +/*********************************************************************** + * Copyright (c) 2004, 2007 Actuate Corporation. + * 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: + * Actuate Corporation - initial API and implementation + ***********************************************************************/ + +package com.gluster.storage.management.gui.views.details.tabcreators; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.birt.chart.api.ChartEngine; +import org.eclipse.birt.chart.device.IDeviceRenderer; +import org.eclipse.birt.chart.device.IUpdateNotifier; +import org.eclipse.birt.chart.exception.ChartException; +import org.eclipse.birt.chart.factory.GeneratedChartState; +import org.eclipse.birt.chart.factory.Generator; +import org.eclipse.birt.chart.model.Chart; +import org.eclipse.birt.chart.model.ChartWithoutAxes; +import org.eclipse.birt.chart.model.attribute.Bounds; +import org.eclipse.birt.chart.model.attribute.ChartDimension; +import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; +import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; +import org.eclipse.birt.chart.model.component.Series; +import org.eclipse.birt.chart.model.component.impl.SeriesImpl; +import org.eclipse.birt.chart.model.data.NumberDataSet; +import org.eclipse.birt.chart.model.data.SeriesDefinition; +import org.eclipse.birt.chart.model.data.TextDataSet; +import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; +import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; +import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; +import org.eclipse.birt.chart.model.layout.Legend; +import org.eclipse.birt.chart.model.layout.Plot; +import org.eclipse.birt.chart.model.type.PieSeries; +import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; +import org.eclipse.birt.core.framework.PlatformConfig; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * + */ +public final class PieChartViewerComposite extends Composite implements PaintListener, IUpdateNotifier { + + private IDeviceRenderer idr = null; + private Chart cm = null; + private GeneratedChartState gcs = null; + private boolean bNeedsGeneration = true; + + private static Logger logger = Logger.getLogger(PieChartViewerComposite.class.getName()); + + public static void main(String[] args) { + Display display = Display.getDefault(); + Shell shell = new Shell(display); + shell.setSize(800, 600); + shell.setLayout(new GridLayout()); + + // Data Set + String[] categories = new String[] { "New York", "Boston", "Chicago", "San Francisco", "Dallas" };//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + Double[] values = new Double[] { 54.65, 21d, 75.95, 91.28, 37.43 }; + + PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite(shell, SWT.NO_BACKGROUND, + categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 250; + data.heightHint = 250; + chartViewerComposite.setLayoutData(data); + + shell.setText(chartViewerComposite.getClass().getName() + " [device=" //$NON-NLS-1$ + + chartViewerComposite.idr.getClass().getName() + "]");//$NON-NLS-1$ + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + display.dispose(); + } + + /** + * Get the connection with SWT device to render the graphics. + */ + PieChartViewerComposite(Composite parent, int style, String[] categories, Double[] values) { + super(parent, style); + try { + PlatformConfig config = new PlatformConfig(); + config.setBIRTHome(Platform.getInstallLocation().getURL().getPath()); + idr = ChartEngine.instance(config).getRenderer("dv.SWT");//$NON-NLS-1$ + } catch (ChartException ex) { + logger.log(Level.SEVERE, "Could not create Chart Renderer for SWT", ex); + } + addControlListener(new ControlListener() { + + public void controlMoved(ControlEvent e) { + bNeedsGeneration = true; + } + + public void controlResized(ControlEvent e) { + bNeedsGeneration = true; + } + }); + cm = createPieChart(categories, values); + addPaintListener(this); + } + + /** + * Creates a pie chart model as a reference implementation + * + * @return An instance of the simulated runtime chart model (containing filled datasets) + */ + public static final Chart createPieChart(String[] categories, Double[] values) { + ChartWithoutAxes pieChart = ChartWithoutAxesImpl.create(); + + // Plot + pieChart.setSeriesThickness(2); + pieChart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL); + pieChart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + Plot p = pieChart.getPlot(); + p.getClientArea().setBackground(null); + p.getClientArea().getOutline().setVisible(false); + p.getOutline().setVisible(false); + + // Legend + Legend lg = pieChart.getLegend(); + lg.getText().getFont().setSize(8); + lg.setBackground(null); + lg.getOutline().setVisible(false); + lg.setVisible(true); + + // Title + pieChart.getTitle().getLabel().getCaption().setValue("Pie Chart");//$NON-NLS-1$ + pieChart.getTitle().getOutline().setVisible(false); + pieChart.getTitle().setVisible(false); + + TextDataSet categoryValues = TextDataSetImpl.create(categories); + NumberDataSet seriesOneValues = NumberDataSetImpl.create(values); + + // Base Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + + SeriesDefinition sd = SeriesDefinitionImpl.create(); + pieChart.getSeriesDefinitions().add(sd); + sd.getSeriesPalette().shift(0); + sd.getSeries().add(seCategory); + + // Orthogonal Series + PieSeries sePie = (PieSeries) PieSeriesImpl.create(); + sePie.setDataSet(seriesOneValues); + sePie.setSeriesIdentifier("Cities");//$NON-NLS-1$ + sePie.getTitle().setVisible(false); + sePie.setExplosion(2); + + SeriesDefinition seriesDefinition = SeriesDefinitionImpl.create(); + seriesDefinition.getQuery().setDefinition("query.definition");//$NON-NLS-1$ + sd.getSeriesDefinitions().add(seriesDefinition); + seriesDefinition.getSeries().add(sePie); + + return pieChart; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent) + */ + public final void paintControl(PaintEvent e) { + Rectangle d = ((Composite) e.getSource()).getBounds(); + Image imgChart = new Image(this.getDisplay(), d); + GC gcImage = new GC(imgChart); + idr.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage); + idr.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this); + + Bounds bo = BoundsImpl.create(0, 0, d.width, d.height); + bo.scale(58d / idr.getDisplayServer().getDpiResolution()); + + Generator gr = Generator.instance(); + if (bNeedsGeneration) { + bNeedsGeneration = false; + try { + gcs = gr.build(idr.getDisplayServer(), cm, bo, null, null, null); + } catch (ChartException ce) { + ce.printStackTrace(); + } + } + + try { + gr.render(idr, gcs); + GC gc = e.gc; + gc.drawImage(imgChart, d.x, d.y); + } catch (ChartException gex) { + logger.log(Level.SEVERE, "Exception while rendering pie chart [" + gex.getMessage() + "]", gex); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#getDesignTimeModel() + */ + public Chart getDesignTimeModel() { + return cm; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#getRunTimeModel() + */ + public Chart getRunTimeModel() { + return gcs.getChartModel(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#peerInstance() + */ + public Object peerInstance() { + return this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#regenerateChart() + */ + public void regenerateChart() { + redraw(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#repaintChart() + */ + public void repaintChart() { + redraw(); + } +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ServerTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ServerTabCreator.java new file mode 100644 index 00000000..c630a964 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/ServerTabCreator.java @@ -0,0 +1,55 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.TabCreator; + +public class ServerTabCreator implements TabCreator { + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private void createServerSummarySection(Server server, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); + + toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); + toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); + +// toolkit.createLabel(section, "CPU Usage (%): ", SWT.NONE); +// toolkit.createLabel(section, "" + server.getCpuUsage(), SWT.NONE); + + toolkit.createLabel(section, "Total Memory (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + server.getTotalMemory(), SWT.NONE); + +// toolkit.createLabel(section, "Memory in Use (GB): ", SWT.NONE); +// toolkit.createLabel(section, "" + server.getMemoryInUse(), SWT.NONE); + + toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + NumberUtil.formatNumber(server.getTotalDiskSpace()), SWT.NONE); + +// toolkit.createLabel(section, "Disk Space in Use (GB): ", SWT.NONE); +// toolkit.createLabel(section, "" + server.getDiskSpaceInUse(), SWT.NONE); + } + + private void createServerSummaryTab(Server server, TabFolder tabFolder, FormToolkit toolkit) { + String serverName = server.getName(); + Composite serverSummaryTab = guiHelper.createTab(tabFolder, serverName, IImageKeys.SERVER); + final ScrolledForm form = guiHelper.setupForm(serverSummaryTab, toolkit, "Discovered Server Summary [" + serverName + "]"); + createServerSummarySection(server, toolkit, form); + + serverSummaryTab.layout(); // IMP: lays out the form properly + } + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createServerSummaryTab((Server) entity, tabFolder, toolkit); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java new file mode 100644 index 00000000..cba58703 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java @@ -0,0 +1,251 @@ +package com.gluster.storage.management.gui.views.details.tabcreators; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; +import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import com.gluster.storage.management.core.utils.NumberUtil; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; +import com.gluster.storage.management.gui.views.details.DisksPage; +import com.gluster.storage.management.gui.views.details.TabCreator; +import com.gluster.storage.management.gui.views.details.VolumeLogsPage; +import com.gluster.storage.management.gui.views.details.VolumeOptionsPage; + +public class VolumeTabCreator implements TabCreator { + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private void createVolumePropertiesSection(final Volume volume, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Properties", null, 3, false); + + createVolumeTypeField(volume, toolkit, section); + + VOLUME_TYPE volumeType = volume.getVolumeType(); + if (volumeType == VOLUME_TYPE.DISTRIBUTED_MIRROR) { + createReplicaCountField(volume, toolkit, section); + } + + if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + createStripeCountField(volume, toolkit, section); + } + + createNumOfDisksField(volume, toolkit, section); + createDiskSpaceField(volume, toolkit, section); + createTransportTypeField(volume, toolkit, section); + createNASProtocolField(volume, toolkit, section); + createAccessControlField(volume, toolkit, section); + createStatusField(volume, toolkit, section); + } + + private void createDiskSpaceField(final Volume volume, FormToolkit toolkit, Composite section) { + Label diskSpaceLabel = toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + diskSpaceLabel.setToolTipText("<b>bold</b>normal"); + toolkit.createLabel(section, "" + NumberUtil.formatNumber(volume.getTotalDiskSpace()), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createStatusField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Status: ", SWT.NONE); + + CLabel lblStatusValue = new CLabel(section, SWT.NONE); + lblStatusValue.setText(volume.getStatusStr()); + lblStatusValue.setImage(volume.getStatus() == Volume.VOLUME_STATUS.ONLINE ? guiHelper + .getImage(IImageKeys.STATUS_ONLINE) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE)); + + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createTransportTypeField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Transport Type: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getTransportTypeStr(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createNumOfDisksField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Number of Disks: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getNumOfDisks(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createStripeCountField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Stripe Count: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getStripeCount(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createReplicaCountField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Replica Count: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getReplicaCount(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createVolumeTypeField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Volume Type: ", SWT.NONE); + toolkit.createLabel(section, volume.getVolumeTypeStr(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); + } + + private void createVolumeAlertsSection(final Volume volume, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 3, false); + toolkit.createLabel(section, "Volume related alerts will be displayed here"); + } + + private void createVolumeMountingInfoSection(final Volume volume, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 3, false); + toolkit.createLabel(section, "Information about mounting the\nvolume will be printed here"); + } + + private GridData createDefaultLayoutData() { + GridData layoutData = new GridData(); + layoutData.minimumWidth = 150; + layoutData.widthHint = 150; + return layoutData; + } + + private void createAccessControlField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "Access Control: ", SWT.NONE); + Text accessControlText = toolkit.createText(section, volume.getAccessControlList()); + accessControlText.setLayoutData(createDefaultLayoutData()); + accessControlText.setEnabled(false); + createChangeLinkForAccessControl(volume, toolkit, section, accessControlText); + } + + private void createChangeLinkForAccessControl(final Volume volume, FormToolkit toolkit, Composite section, + final Text accessControlText) { + final Hyperlink changeLink = toolkit.createHyperlink(section, "change", SWT.NONE); + changeLink.addHyperlinkListener(new HyperlinkAdapter() { + + private void finishEdit() { + // TODO: Update value to back-end + // TODO: Validation of entered text + volume.setAccessControlList(accessControlText.getText()); + accessControlText.setEnabled(false); + changeLink.setText("change"); + } + + private void startEdit() { + accessControlText.setEnabled(true); + changeLink.setText("update"); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + if (accessControlText.isEnabled()) { + // we were already in edit mode. + finishEdit(); + } else { + // Get in to edit mode + startEdit(); + } + } + }); + } + + private void createNASProtocolField(final Volume volume, FormToolkit toolkit, Composite section) { + toolkit.createLabel(section, "NAS Protocols: ", SWT.NONE); + + Composite nasProtocolsComposite = toolkit.createComposite(section); + nasProtocolsComposite.setLayout(new FillLayout()); + + createCheckbox(toolkit, nasProtocolsComposite, "Gluster", true); + final Button nfsCheckBox = createCheckbox(toolkit, nasProtocolsComposite, "NFS", volume.getNASProtocols().contains(NAS_PROTOCOL.NFS)); + + createChangeLinkForNASProtocol(volume, toolkit, section, nfsCheckBox); + } + + private void createChangeLinkForNASProtocol(final Volume volume, FormToolkit toolkit, Composite section, + final Button nfsCheckBox) { + final Hyperlink changeLink = toolkit.createHyperlink(section, "change", SWT.NONE); + changeLink.addHyperlinkListener(new HyperlinkAdapter() { + + private void finishEdit() { + // TODO: Update value to back-end + if (nfsCheckBox.getSelection()) { + volume.enableNFS(); + } else { + volume.disableNFS(); + } + nfsCheckBox.setEnabled(false); + changeLink.setText("change"); + } + + private void startEdit() { + nfsCheckBox.setEnabled(true); + changeLink.setText("update"); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + if (nfsCheckBox.isEnabled()) { + // we were already in edit mode. + finishEdit(); + } else { + // Get in to edit mode + startEdit(); + } + } + }); + } + + private Button createCheckbox(FormToolkit toolkit, Composite parent, String label, boolean selected) { + final Button checkBox = toolkit.createButton(parent, label, SWT.CHECK); + checkBox.setEnabled(false); + checkBox.setSelection(selected); + return checkBox; + } + + private void createVolumePropertiesTab(Volume volume, TabFolder tabFolder, FormToolkit toolkit) { + Composite volumeTab = guiHelper.createTab(tabFolder, volume.getName() + " - Properties", IImageKeys.VOLUME); + final ScrolledForm form = guiHelper.setupForm(volumeTab, toolkit, "Volume Properties [" + volume.getName() + "]"); + createVolumePropertiesSection(volume, toolkit, form); + createVolumeMountingInfoSection(volume, toolkit, form); + createVolumeAlertsSection(volume, toolkit, form); + + volumeTab.layout(); // IMP: lays out the form properly + } + + private void createVolumeLogsTab(Volume volume, TabFolder tabFolder, FormToolkit toolkit) { + Composite volumeTab = guiHelper.createTab(tabFolder, "Logs", IImageKeys.VOLUME); + VolumeLogsPage logsPage = new VolumeLogsPage(volumeTab, SWT.NONE, volume); + + volumeTab.layout(); // IMP: lays out the form properly + } + + private void createVolumeDisksTab(Volume volume, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + Composite volumeDisksTab = guiHelper.createTab(tabFolder, "Disks", IImageKeys.VOLUME); + DisksPage page = new DisksPage(volumeDisksTab, SWT.NONE, site, volume.getDisks()); + + volumeDisksTab.layout(); // IMP: lays out the form properly + } + + private void createVolumeOptionsTab(Volume volume, TabFolder tabFolder, FormToolkit toolkit) { + Composite volumeTab = guiHelper.createTab(tabFolder, "Options", IImageKeys.VOLUME); + VolumeOptionsPage page = new VolumeOptionsPage(volumeTab, SWT.NONE, volume); + + volumeTab.layout(); // IMP: lays out the form properly + } + + @Override + public void createTabs(Entity entity, TabFolder tabFolder, FormToolkit toolkit, IWorkbenchSite site) { + createVolumePropertiesTab((Volume) entity, tabFolder, toolkit); + createVolumeDisksTab((Volume) entity, tabFolder, toolkit, site); + createVolumeOptionsTab((Volume) entity, tabFolder, toolkit); + createVolumeLogsTab((Volume) entity, tabFolder, toolkit); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/ClusterAdapterFactory.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/ClusterAdapterFactory.java new file mode 100644 index 00000000..53a9ba3d --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/ClusterAdapterFactory.java @@ -0,0 +1,80 @@ +package com.gluster.storage.management.gui.views.navigator; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.gluster.storage.management.core.model.Cluster; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.GlusterDataModel; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IImageKeys; + +public class ClusterAdapterFactory implements IAdapterFactory { + private IWorkbenchAdapter entityAdapter = new IWorkbenchAdapter() { + + @Override + public Object getParent(Object o) { + return ((Entity) o).getParent(); + } + + @Override + public String getLabel(Object o) { + return ((Entity)o).getName(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + String iconPath = null; + + if(object instanceof GlusterDataModel || object instanceof Cluster) { + iconPath = IImageKeys.CLUSTER; + } + + if(object instanceof EntityGroup) { + Class<? extends Entity> entityType = ((EntityGroup) object).getEntityType(); + if(entityType == Volume.class) { + iconPath = IImageKeys.VOLUMES; + } else { + iconPath = IImageKeys.SERVERS; + } + } + + if(object instanceof Volume) { + iconPath = IImageKeys.VOLUME; + } + + if(object instanceof Server || object instanceof GlusterServer) { + iconPath = IImageKeys.SERVER; + } + + return AbstractUIPlugin.imageDescriptorFromPlugin( + Application.PLUGIN_ID, iconPath); + } + + @Override + public Object[] getChildren(Object o) { + return ((Entity)o).getChildren().toArray(); + } + }; + + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adapterType == IWorkbenchAdapter.class) { + if (adaptableObject instanceof Entity) { + return entityAdapter; + } + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[] { IWorkbenchAdapter.class }; + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationTreeLabelDecorator.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationTreeLabelDecorator.java new file mode 100644 index 00000000..607cb3af --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationTreeLabelDecorator.java @@ -0,0 +1,68 @@ +package com.gluster.storage.management.gui.views.navigator; + +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.gluster.storage.management.core.model.EntityGroup; +import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IImageKeys; + +public class NavigationTreeLabelDecorator implements ILightweightLabelDecorator { + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @Override + public void decorate(Object element, IDecoration decoration) { + if (element instanceof Volume) { + Volume volume = (Volume) element; + if (volume.getStatus() == Volume.VOLUME_STATUS.OFFLINE) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_OFFLINE)); + } else { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_ONLINE)); + } + } + + if (element instanceof GlusterServer) { + GlusterServer server = (GlusterServer) element; + if (server.getStatus() == GlusterServer.SERVER_STATUS.OFFLINE) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_OFFLINE)); + } else { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_ONLINE)); + } + } + + if (element instanceof Server) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_STAR)); + } + + if(element instanceof EntityGroup && ((EntityGroup)element).getEntityType() == Server.class) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_STAR)); + } + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationView.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationView.java new file mode 100644 index 00000000..5d8efae0 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/NavigationView.java @@ -0,0 +1,61 @@ +package com.gluster.storage.management.gui.views.navigator; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.part.ViewPart; + +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.GlusterDataModel; +import com.gluster.storage.management.core.model.GlusterDummyModel; + +public class NavigationView extends ViewPart { + public static final String ID = "com.gluster.storage.management.gui.views.navigator"; + private GlusterDataModel model; + private TreeViewer treeViewer; + private IAdapterFactory adapterFactory = new ClusterAdapterFactory(); + + public NavigationView() { + super(); + } + + @Override + public void createPartControl(Composite parent) { + model = GlusterDummyModel.getInstance().getModel(); + + treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + getSite().setSelectionProvider(treeViewer); + Platform.getAdapterManager().registerAdapters(adapterFactory, Entity.class); + treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); + treeViewer.setContentProvider(new BaseWorkbenchContentProvider()); + treeViewer.setInput(model); + treeViewer.expandAll(); + // select the first element by default + treeViewer.setSelection(new StructuredSelection(model.getChildren().get(0))); + + MenuManager menuManager = new MenuManager("&Gluster", "gluster.context.menu"); + Menu contextMenu = menuManager.createContextMenu(treeViewer.getControl()); + treeViewer.getTree().setMenu(contextMenu); + + getSite().registerContextMenu(menuManager, treeViewer); + } + + public void selectEntity(Entity entity) { + treeViewer.setSelection(new StructuredSelection(entity)); + treeViewer.reveal(entity); + setFocus(); // this ensures that the "selection changed" event gets fired + } + + + @Override + public void setFocus() { + treeViewer.getControl().setFocus(); + } +} diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/RootAdapter.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/RootAdapter.java new file mode 100644 index 00000000..ff4840ff --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/navigator/RootAdapter.java @@ -0,0 +1,103 @@ +package com.gluster.storage.management.gui.views.navigator; + +import java.util.List; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import com.gluster.storage.management.core.model.Cluster; +import com.gluster.storage.management.core.model.Entity; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.gui.Application; +import com.gluster.storage.management.gui.IImageKeys; + +public class RootAdapter implements IWorkbenchAdapter { + public enum NODE_TYPE { + CLUSTER, SERVERS, VOLUMES, GSN + }; + + private Cluster cluster; + private static final String LABEL_SERVERS = "Servers"; + private static final String LABEL_VOLUMES = "Volumes"; + private static final String LABEL_GSN = "GSN"; + + public RootAdapter(Cluster cluster) { + this.cluster = cluster; + } + + @Override + public Object getParent(Object o) { + return cluster; + } + + @Override + public String getLabel(Object o) { + switch (getNodeType(o)) { + case CLUSTER: + return cluster.getName(); + case VOLUMES: + return LABEL_VOLUMES; + case SERVERS: + return LABEL_SERVERS; + case GSN: + return LABEL_GSN; + default: + return null; + } + } + + private NODE_TYPE getNodeType(Object obj) { + if(obj instanceof Cluster) { + return NODE_TYPE.CLUSTER; + } + + if (obj instanceof String) { + return NODE_TYPE.GSN; + } + + if (obj instanceof List) { + List<? extends Entity> list = (List<? extends Entity>) obj; + if (list.size() == 0) { + return null; + } + Entity firstEntity = list.get(0); + return ((firstEntity instanceof Volume) ? NODE_TYPE.VOLUMES + : NODE_TYPE.SERVERS); + } + + return null; + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + String iconPath = null; + switch (getNodeType(object)) { + case CLUSTER: + iconPath = IImageKeys.CLUSTER; + case VOLUMES: + iconPath = IImageKeys.VOLUMES; + case SERVERS: + iconPath = IImageKeys.SERVERS; + case GSN: + iconPath = IImageKeys.GSN; + } + return AbstractUIPlugin.imageDescriptorFromPlugin( + Application.PLUGIN_ID, iconPath); + } + + @Override + public Object[] getChildren(Object o) { + /*switch (getNodeType(o)) { + case CLUSTER: + return new Object[] {cluster.getVolumes(), cluster.getServers(), "GSN"}; + case VOLUMES: + return cluster.getVolumes().toArray(); + case GLUSTER_SERVERS: + return cluster.getServers().toArray(); + default: + return null; + }*/ + return null; + } +} diff --git a/com.gluster.storage.management.gui/src/com/swtdesigner/ResourceManager.java b/com.gluster.storage.management.gui/src/com/swtdesigner/ResourceManager.java new file mode 100644 index 00000000..e171da70 --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/swtdesigner/ResourceManager.java @@ -0,0 +1,405 @@ +package com.swtdesigner; + +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.CompositeImageDescriptor; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.osgi.framework.Bundle; + +/** + * Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images, + * etc. + * + * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the + * operating system resources managed by cached objects when those objects and OS resources are no longer + * needed (e.g. on application shutdown) + * + * This class may be freely distributed as part of any application or plugin. + * <p> + * + * @author scheglov_ke + * @author Dan Rubel + */ +public class ResourceManager extends SWTResourceManager { + //////////////////////////////////////////////////////////////////////////// + // + // Image + // + //////////////////////////////////////////////////////////////////////////// + private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>(); + /** + * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified + * class. + * + * @param clazz + * the {@link Class} relative to which to find the image descriptor. + * @param path + * the path to the image file. + * @return the {@link ImageDescriptor} stored in the file at the specified path. + */ + public static ImageDescriptor getImageDescriptor(Class<?> clazz, String path) { + return ImageDescriptor.createFromFile(clazz, path); + } + /** + * Returns an {@link ImageDescriptor} stored in the file at the specified path. + * + * @param path + * the path to the image file. + * @return the {@link ImageDescriptor} stored in the file at the specified path. + */ + public static ImageDescriptor getImageDescriptor(String path) { + try { + return ImageDescriptor.createFromURL(new File(path).toURI().toURL()); + } catch (MalformedURLException e) { + return null; + } + } + /** + * Returns an {@link Image} based on the specified {@link ImageDescriptor}. + * + * @param descriptor + * the {@link ImageDescriptor} for the {@link Image}. + * @return the {@link Image} based on the specified {@link ImageDescriptor}. + */ + public static Image getImage(ImageDescriptor descriptor) { + if (descriptor == null) { + return null; + } + Image image = m_descriptorImageMap.get(descriptor); + if (image == null) { + image = descriptor.createImage(); + m_descriptorImageMap.put(descriptor, image); + } + return image; + } + /** + * Maps images to decorated images. + */ + @SuppressWarnings("unchecked") + private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated. + * @param decorator + * the {@link Image} to decorate the base image. + * @return {@link Image} The resulting decorated image. + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated. + * @param decorator + * the {@link Image} to decorate the base image. + * @param corner + * the corner to place decorator image. + * @return the resulting decorated {@link Image}. + */ + public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap<Image, Image>(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + // + Image result = decoratedMap.get(decorator); + if (result == null) { + final Rectangle bib = baseImage.getBounds(); + final Rectangle dib = decorator.getBounds(); + final Point baseImageSize = new Point(bib.width, bib.height); + CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() { + @Override + protected void drawCompositeImage(int width, int height) { + drawImage(baseImage.getImageData(), 0, 0); + if (corner == TOP_LEFT) { + drawImage(decorator.getImageData(), 0, 0); + } else if (corner == TOP_RIGHT) { + drawImage(decorator.getImageData(), bib.width - dib.width, 0); + } else if (corner == BOTTOM_LEFT) { + drawImage(decorator.getImageData(), 0, bib.height - dib.height); + } else if (corner == BOTTOM_RIGHT) { + drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height); + } + } + @Override + protected Point getSize() { + return baseImageSize; + } + }; + // + result = compositImageDesc.createImage(); + decoratedMap.put(decorator, result); + } + return result; + } + /** + * Dispose all of the cached images. + */ + public static void disposeImages() { + SWTResourceManager.disposeImages(); + // dispose ImageDescriptor images + { + for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) { + I.next().dispose(); + } + m_descriptorImageMap.clear(); + } + // dispose decorated images + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + // dispose plugin images + { + for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) { + I.next().dispose(); + } + m_URLImageMap.clear(); + } + } + //////////////////////////////////////////////////////////////////////////// + // + // Plugin images support + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps URL to images. + */ + private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>(); + /** + * Provider for plugin resources, used by WindowBuilder at design time. + */ + public interface PluginResourceProvider { + URL getEntry(String symbolicName, String path); + } + /** + * Instance of {@link PluginResourceProvider}, used by WindowBuilder at design time. + */ + private static PluginResourceProvider m_designTimePluginResourceProvider = null; + /** + * Returns an {@link Image} based on a plugin and file path. + * + * @param plugin + * the plugin {@link Object} containing the image + * @param name + * the path to the image within the plugin + * @return the {@link Image} stored in the file at the specified path + * + * @deprecated Use {@link #getPluginImage(String, String)} instead. + */ + @Deprecated + public static Image getPluginImage(Object plugin, String name) { + try { + URL url = getPluginImageURL(plugin, name); + if (url != null) { + return getPluginImageFromUrl(url); + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + } + /** + * Returns an {@link Image} based on a {@link Bundle} and resource entry path. + * + * @param symbolicName + * the symbolic name of the {@link Bundle}. + * @param path + * the path of the resource entry. + * @return the {@link Image} stored in the file at the specified path. + */ + public static Image getPluginImage(String symbolicName, String path) { + try { + URL url = getPluginImageURL(symbolicName, path); + if (url != null) { + return getPluginImageFromUrl(url); + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + } + /** + * Returns an {@link Image} based on given {@link URL}. + */ + private static Image getPluginImageFromUrl(URL url) { + try { + try { + String key = url.toExternalForm(); + Image image = m_URLImageMap.get(key); + if (image == null) { + InputStream stream = url.openStream(); + try { + image = getImage(stream); + m_URLImageMap.put(key, image); + } finally { + stream.close(); + } + } + return image; + } catch (Throwable e) { + // Ignore any exceptions + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + } + /** + * Returns an {@link ImageDescriptor} based on a plugin and file path. + * + * @param plugin + * the plugin {@link Object} containing the image. + * @param name + * the path to th eimage within the plugin. + * @return the {@link ImageDescriptor} stored in the file at the specified path. + * + * @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead. + */ + @Deprecated + public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) { + try { + try { + URL url = getPluginImageURL(plugin, name); + return ImageDescriptor.createFromURL(url); + } catch (Throwable e) { + // Ignore any exceptions + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + } + /** + * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. + * + * @param symbolicName + * the symbolic name of the {@link Bundle}. + * @param path + * the path of the resource entry. + * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. + */ + public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) { + try { + URL url = getPluginImageURL(symbolicName, path); + if (url != null) { + return ImageDescriptor.createFromURL(url); + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + } + /** + * Returns an {@link URL} based on a {@link Bundle} and resource entry path. + */ + private static URL getPluginImageURL(String symbolicName, String path) { + // try runtime plugins + { + Bundle bundle = Platform.getBundle(symbolicName); + if (bundle != null) { + return bundle.getEntry(path); + } + } + // try design time provider + if (m_designTimePluginResourceProvider != null) { + return m_designTimePluginResourceProvider.getEntry(symbolicName, path); + } + // no such resource + return null; + } + /** + * Returns an {@link URL} based on a plugin and file path. + * + * @param plugin + * the plugin {@link Object} containing the file path. + * @param name + * the file path. + * @return the {@link URL} representing the file at the specified path. + * @throws Exception + */ + private static URL getPluginImageURL(Object plugin, String name) throws Exception { + // try to work with 'plugin' as with OSGI BundleContext + try { + Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$ + Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$ + if (BundleContextClass.isAssignableFrom(plugin.getClass())) { + Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$ + Object bundle = getBundleMethod.invoke(plugin, new Object[0]); + // + Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ + Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class}); + Object path = pathConstructor.newInstance(new Object[]{name}); + // + Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ + Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ + Method findMethod = PlatformClass.getMethod("find", new Class[]{BundleClass, IPathClass}); //$NON-NLS-1$ + return (URL) findMethod.invoke(null, new Object[]{bundle, path}); + } + } catch (Throwable e) { + // Ignore any exceptions + } + // else work with 'plugin' as with usual Eclipse plugin + { + Class<?> PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$ + if (PluginClass.isAssignableFrom(plugin.getClass())) { + // + Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ + Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class}); + Object path = pathConstructor.newInstance(new Object[]{name}); + // + Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ + Method findMethod = PluginClass.getMethod("find", new Class[]{IPathClass}); //$NON-NLS-1$ + return (URL) findMethod.invoke(plugin, new Object[]{path}); + } + } + return null; + } + //////////////////////////////////////////////////////////////////////////// + // + // General + // + //////////////////////////////////////////////////////////////////////////// + /** + * Dispose of cached objects and their underlying OS resources. This should only be called when the cached + * objects are no longer needed (e.g. on application shutdown). + */ + public static void dispose() { + disposeColors(); + disposeFonts(); + disposeImages(); + } +}
\ No newline at end of file diff --git a/com.gluster.storage.management.gui/src/com/swtdesigner/SWTResourceManager.java b/com.gluster.storage.management.gui/src/com/swtdesigner/SWTResourceManager.java new file mode 100644 index 00000000..ef062c0b --- /dev/null +++ b/com.gluster.storage.management.gui/src/com/swtdesigner/SWTResourceManager.java @@ -0,0 +1,437 @@ +package com.swtdesigner; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; + +/** + * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. + * <p> + * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the + * operating system resources managed by cached objects when those objects and OS resources are no longer + * needed (e.g. on application shutdown) + * <p> + * This class may be freely distributed as part of any application or plugin. + * <p> + * @author scheglov_ke + * @author Dan Rubel + */ +public class SWTResourceManager { + //////////////////////////////////////////////////////////////////////////// + // + // Color + // + //////////////////////////////////////////////////////////////////////////// + private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>(); + /** + * Returns the system {@link Color} matching the specific ID. + * + * @param systemColorID + * the ID value for the color + * @return the system {@link Color} matching the specific ID + */ + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + /** + * Returns a {@link Color} given its red, green and blue component values. + * + * @param r + * the red component of the color + * @param g + * the green component of the color + * @param b + * the blue component of the color + * @return the {@link Color} matching the given red, green and blue component values + */ + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + /** + * Returns a {@link Color} given its RGB value. + * + * @param rgb + * the {@link RGB} value of the color + * @return the {@link Color} matching the RGB value + */ + public static Color getColor(RGB rgb) { + Color color = m_colorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_colorMap.put(rgb, color); + } + return color; + } + /** + * Dispose of all the cached {@link Color}'s. + */ + public static void disposeColors() { + for (Color color : m_colorMap.values()) { + color.dispose(); + } + m_colorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Image + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps image paths to images. + */ + private static Map<String, Image> m_imageMap = new HashMap<String, Image>(); + /** + * Returns an {@link Image} encoded by the specified {@link InputStream}. + * + * @param stream + * the {@link InputStream} encoding the image data + * @return the {@link Image} encoded by the specified input stream + */ + protected static Image getImage(InputStream stream) throws IOException { + try { + Display display = Display.getCurrent(); + ImageData data = new ImageData(stream); + if (data.transparentPixel > 0) { + return new Image(display, data, data.getTransparencyMask()); + } + return new Image(display, data); + } finally { + stream.close(); + } + } + /** + * Returns an {@link Image} stored in the file at the specified path. + * + * @param path + * the path to the image file + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(String path) { + Image image = m_imageMap.get(path); + if (image == null) { + try { + image = getImage(new FileInputStream(path)); + m_imageMap.put(path, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(path, image); + } + } + return image; + } + /** + * Returns an {@link Image} stored in the file at the specified path relative to the specified class. + * + * @param clazz + * the {@link Class} relative to which to find the image + * @param path + * the path to the image file, if starts with <code>'/'</code> + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(Class<?> clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = m_imageMap.get(key); + if (image == null) { + try { + image = getImage(clazz.getResourceAsStream(path)); + m_imageMap.put(key, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(key, image); + } + } + return image; + } + private static final int MISSING_IMAGE_SIZE = 10; + /** + * @return the small {@link Image} that can be used as placeholder for missing image. + */ + private static Image getMissingImage() { + Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + // + GC gc = new GC(image); + gc.setBackground(getColor(SWT.COLOR_RED)); + gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + gc.dispose(); + // + return image; + } + /** + * Style constant for placing decorator image in top left corner of base image. + */ + public static final int TOP_LEFT = 1; + /** + * Style constant for placing decorator image in top right corner of base image. + */ + public static final int TOP_RIGHT = 2; + /** + * Style constant for placing decorator image in bottom left corner of base image. + */ + public static final int BOTTOM_LEFT = 3; + /** + * Style constant for placing decorator image in bottom right corner of base image. + */ + public static final int BOTTOM_RIGHT = 4; + /** + * Internal value. + */ + protected static final int LAST_CORNER_KEY = 5; + /** + * Maps images to decorated images. + */ + @SuppressWarnings("unchecked") + private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @return {@link Image} The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @param corner + * the corner to place decorator image + * @return the resulting decorated {@link Image} + */ + public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap<Image, Image>(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + // + Image result = decoratedMap.get(decorator); + if (result == null) { + Rectangle bib = baseImage.getBounds(); + Rectangle dib = decorator.getBounds(); + // + result = new Image(Display.getCurrent(), bib.width, bib.height); + // + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + if (corner == TOP_LEFT) { + gc.drawImage(decorator, 0, 0); + } else if (corner == TOP_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, 0); + } else if (corner == BOTTOM_LEFT) { + gc.drawImage(decorator, 0, bib.height - dib.height); + } else if (corner == BOTTOM_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); + } + gc.dispose(); + // + decoratedMap.put(decorator, result); + } + return result; + } + /** + * Dispose all of the cached {@link Image}'s. + */ + public static void disposeImages() { + // dispose loaded images + { + for (Image image : m_imageMap.values()) { + image.dispose(); + } + m_imageMap.clear(); + } + // dispose decorated images + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + } + //////////////////////////////////////////////////////////////////////////// + // + // Font + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps font names to fonts. + */ + private static Map<String, Font> m_fontMap = new HashMap<String, Font>(); + /** + * Maps fonts to their bold versions. + */ + private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>(); + /** + * Returns a {@link Font} based on its name, height and style. + * + * @param name + * the name of the font + * @param height + * the height of the font + * @param style + * the style of the font + * @return {@link Font} The font matching the name, height and style + */ + public static Font getFont(String name, int height, int style) { + return getFont(name, height, style, false, false); + } + /** + * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline + * flags are also supported. + * + * @param name + * the name of the font + * @param size + * the size of the font + * @param style + * the style of the font + * @param strikeout + * the strikeout flag (warning: Windows only) + * @param underline + * the underline flag (warning: Windows only) + * @return {@link Font} The font matching the name, height, style, strikeout and underline + */ + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; + Font font = m_fontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ + Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + } + } catch (Throwable e) { + System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + font = new Font(Display.getCurrent(), fontData); + m_fontMap.put(fontName, font); + } + return font; + } + /** + * Returns a bold version of the given {@link Font}. + * + * @param baseFont + * the {@link Font} for which a bold version is desired + * @return the bold version of the given {@link Font} + */ + public static Font getBoldFont(Font baseFont) { + Font font = m_fontToBoldFontMap.get(baseFont); + if (font == null) { + FontData fontDatas[] = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); + m_fontToBoldFontMap.put(baseFont, font); + } + return font; + } + /** + * Dispose all of the cached {@link Font}'s. + */ + public static void disposeFonts() { + // clear fonts + for (Font font : m_fontMap.values()) { + font.dispose(); + } + m_fontMap.clear(); + // clear bold fonts + for (Font font : m_fontToBoldFontMap.values()) { + font.dispose(); + } + m_fontToBoldFontMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Cursor + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps IDs to cursors. + */ + private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>(); + /** + * Returns the system cursor matching the specific ID. + * + * @param id + * int The ID value for the cursor + * @return Cursor The system cursor matching the specific ID + */ + public static Cursor getCursor(int id) { + Integer key = Integer.valueOf(id); + Cursor cursor = m_idToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_idToCursorMap.put(key, cursor); + } + return cursor; + } + /** + * Dispose all of the cached cursors. + */ + public static void disposeCursors() { + for (Cursor cursor : m_idToCursorMap.values()) { + cursor.dispose(); + } + m_idToCursorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // General + // + //////////////////////////////////////////////////////////////////////////// + /** + * Dispose of cached objects and their underlying OS resources. This should only be called when the cached + * objects are no longer needed (e.g. on application shutdown). + */ + public static void dispose() { + disposeColors(); + disposeImages(); + disposeFonts(); + disposeCursors(); + } +}
\ No newline at end of file |
