wizards and pref pages for ui plugin, exported necessary from core
plugin
diff --git a/org.apache.hdt.core/META-INF/MANIFEST.MF b/org.apache.hdt.core/META-INF/MANIFEST.MF
index de9d579..e491870 100644
--- a/org.apache.hdt.core/META-INF/MANIFEST.MF
+++ b/org.apache.hdt.core/META-INF/MANIFEST.MF
@@ -10,3 +10,5 @@
org.eclipse.jdt.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Export-Package: org.apache.hdt.core,
+ org.apache.hdt.core.natures
diff --git a/org.apache.hdt.ui/META-INF/MANIFEST.MF b/org.apache.hdt.ui/META-INF/MANIFEST.MF
index 4883ec0..759cd82 100644
--- a/org.apache.hdt.ui/META-INF/MANIFEST.MF
+++ b/org.apache.hdt.ui/META-INF/MANIFEST.MF
@@ -6,6 +6,11 @@
Bundle-Activator: org.apache.hdt.ui.Activator
Bundle-Vendor: Apache Foundation
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.apache.hdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.ui.ide
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/org.apache.hdt.ui/build.properties b/org.apache.hdt.ui/build.properties
index 34d2e4d..342f3ff 100644
--- a/org.apache.hdt.ui/build.properties
+++ b/org.apache.hdt.ui/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ resources/
diff --git a/org.apache.hdt.ui/resources/Components/Conf.png b/org.apache.hdt.ui/resources/Components/Conf.png
new file mode 100644
index 0000000..b23c4ec
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Conf.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/Export.png b/org.apache.hdt.ui/resources/Components/Export.png
new file mode 100644
index 0000000..acddba0
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Export.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/Import.png b/org.apache.hdt.ui/resources/Components/Import.png
new file mode 100644
index 0000000..4a2060a
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Import.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/New.png b/org.apache.hdt.ui/resources/Components/New.png
new file mode 100644
index 0000000..b098629
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/New.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/Reload.png b/org.apache.hdt.ui/resources/Components/Reload.png
new file mode 100644
index 0000000..aa19bf7
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Reload.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/Tool.png b/org.apache.hdt.ui/resources/Components/Tool.png
new file mode 100644
index 0000000..4993aab
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Tool.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Components/Tools.png b/org.apache.hdt.ui/resources/Components/Tools.png
new file mode 100644
index 0000000..0240ed2
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Components/Tools.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant-16x16.png b/org.apache.hdt.ui/resources/Elephant-16x16.png
new file mode 100644
index 0000000..5721a7a
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant-24x24.png b/org.apache.hdt.ui/resources/Elephant-24x24.png
new file mode 100644
index 0000000..0a48eaa
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant-24x24.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant-32x32.png b/org.apache.hdt.ui/resources/Elephant-32x32.png
new file mode 100644
index 0000000..82ef714
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant-32x32.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant-64x64.png b/org.apache.hdt.ui/resources/Elephant-64x64.png
new file mode 100644
index 0000000..7e26118
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant-64x64.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant-small-16x16.png b/org.apache.hdt.ui/resources/Elephant-small-16x16.png
new file mode 100644
index 0000000..0c349c7
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant-small-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant.jpg b/org.apache.hdt.ui/resources/Elephant.jpg
new file mode 100644
index 0000000..530baf9
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant.jpg
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant100x100.gif b/org.apache.hdt.ui/resources/Elephant100x100.gif
new file mode 100644
index 0000000..77e2e0d
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant100x100.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant16x16.gif b/org.apache.hdt.ui/resources/Elephant16x16.gif
new file mode 100644
index 0000000..80f650e
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2-136x136.png b/org.apache.hdt.ui/resources/Elephant2-136x136.png
new file mode 100644
index 0000000..2fa7f14
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2-136x136.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2-16x16.png b/org.apache.hdt.ui/resources/Elephant2-16x16.png
new file mode 100644
index 0000000..b12dd8a
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2-24x24.png b/org.apache.hdt.ui/resources/Elephant2-24x24.png
new file mode 100644
index 0000000..d1a105e
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2-24x24.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2-32x32.png b/org.apache.hdt.ui/resources/Elephant2-32x32.png
new file mode 100644
index 0000000..036469a
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2-32x32.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2-64x64.png b/org.apache.hdt.ui/resources/Elephant2-64x64.png
new file mode 100644
index 0000000..e9b5a30
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2-64x64.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant2.jpg b/org.apache.hdt.ui/resources/Elephant2.jpg
new file mode 100644
index 0000000..fdf8a41
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant2.jpg
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant3-122x122.png b/org.apache.hdt.ui/resources/Elephant3-122x122.png
new file mode 100644
index 0000000..9096b4c
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant3-122x122.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant3-16x16.png b/org.apache.hdt.ui/resources/Elephant3-16x16.png
new file mode 100644
index 0000000..8ec09d4
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant3-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/Elephant3-24x24.png b/org.apache.hdt.ui/resources/Elephant3-24x24.png
new file mode 100644
index 0000000..0d65327
--- /dev/null
+++ b/org.apache.hdt.ui/resources/Elephant3-24x24.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/MAP100x100.gif b/org.apache.hdt.ui/resources/MAP100x100.gif
new file mode 100644
index 0000000..71cb60d
--- /dev/null
+++ b/org.apache.hdt.ui/resources/MAP100x100.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/MAP16x15.gif b/org.apache.hdt.ui/resources/MAP16x15.gif
new file mode 100644
index 0000000..b2d3c04
--- /dev/null
+++ b/org.apache.hdt.ui/resources/MAP16x15.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/download.png b/org.apache.hdt.ui/resources/download.png
new file mode 100644
index 0000000..d9f1de8
--- /dev/null
+++ b/org.apache.hdt.ui/resources/download.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/drive100x100.gif b/org.apache.hdt.ui/resources/drive100x100.gif
new file mode 100644
index 0000000..1f36b54
--- /dev/null
+++ b/org.apache.hdt.ui/resources/drive100x100.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/drive16x16.gif b/org.apache.hdt.ui/resources/drive16x16.gif
new file mode 100644
index 0000000..15d5718
--- /dev/null
+++ b/org.apache.hdt.ui/resources/drive16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/driver.png b/org.apache.hdt.ui/resources/driver.png
new file mode 100644
index 0000000..ba270f4
--- /dev/null
+++ b/org.apache.hdt.ui/resources/driver.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/driverwiz.png b/org.apache.hdt.ui/resources/driverwiz.png
new file mode 100644
index 0000000..a70b1e4
--- /dev/null
+++ b/org.apache.hdt.ui/resources/driverwiz.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/elephantblue16x16.gif b/org.apache.hdt.ui/resources/elephantblue16x16.gif
new file mode 100644
index 0000000..0927b13
--- /dev/null
+++ b/org.apache.hdt.ui/resources/elephantblue16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/files.gif b/org.apache.hdt.ui/resources/files.gif
new file mode 100644
index 0000000..cc01595
--- /dev/null
+++ b/org.apache.hdt.ui/resources/files.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop-logo-16x16.png b/org.apache.hdt.ui/resources/hadoop-logo-16x16.png
new file mode 100644
index 0000000..4a87cdf
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop-logo-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop-logo-24x24.png b/org.apache.hdt.ui/resources/hadoop-logo-24x24.png
new file mode 100644
index 0000000..318a570
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop-logo-24x24.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop-logo-85x85.png b/org.apache.hdt.ui/resources/hadoop-logo-85x85.png
new file mode 100644
index 0000000..6fee03b
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop-logo-85x85.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop-logo.jpg b/org.apache.hdt.ui/resources/hadoop-logo.jpg
new file mode 100644
index 0000000..809525d
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop-logo.jpg
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop.gif b/org.apache.hdt.ui/resources/hadoop.gif
new file mode 100644
index 0000000..828c515
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/hadoop_small.gif b/org.apache.hdt.ui/resources/hadoop_small.gif
new file mode 100644
index 0000000..df609f3
--- /dev/null
+++ b/org.apache.hdt.ui/resources/hadoop_small.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/job.gif b/org.apache.hdt.ui/resources/job.gif
new file mode 100644
index 0000000..2bc247a
--- /dev/null
+++ b/org.apache.hdt.ui/resources/job.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/location-edit-16x16.png b/org.apache.hdt.ui/resources/location-edit-16x16.png
new file mode 100644
index 0000000..d563edb
--- /dev/null
+++ b/org.apache.hdt.ui/resources/location-edit-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/location-new-16x16.png b/org.apache.hdt.ui/resources/location-new-16x16.png
new file mode 100644
index 0000000..a7a072f
--- /dev/null
+++ b/org.apache.hdt.ui/resources/location-new-16x16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/map16x16.gif b/org.apache.hdt.ui/resources/map16x16.gif
new file mode 100644
index 0000000..2de5c5d
--- /dev/null
+++ b/org.apache.hdt.ui/resources/map16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/mapper16.png b/org.apache.hdt.ui/resources/mapper16.png
new file mode 100644
index 0000000..fe1d64e
--- /dev/null
+++ b/org.apache.hdt.ui/resources/mapper16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/mapwiz.png b/org.apache.hdt.ui/resources/mapwiz.png
new file mode 100644
index 0000000..54c4495
--- /dev/null
+++ b/org.apache.hdt.ui/resources/mapwiz.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/new-folder.png b/org.apache.hdt.ui/resources/new-folder.png
new file mode 100644
index 0000000..5fb0b28
--- /dev/null
+++ b/org.apache.hdt.ui/resources/new-folder.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/projwiz.png b/org.apache.hdt.ui/resources/projwiz.png
new file mode 100644
index 0000000..6efa859
--- /dev/null
+++ b/org.apache.hdt.ui/resources/projwiz.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/reduce100x100.gif b/org.apache.hdt.ui/resources/reduce100x100.gif
new file mode 100644
index 0000000..b30af6b
--- /dev/null
+++ b/org.apache.hdt.ui/resources/reduce100x100.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/reduce16x16.gif b/org.apache.hdt.ui/resources/reduce16x16.gif
new file mode 100644
index 0000000..288a5d4
--- /dev/null
+++ b/org.apache.hdt.ui/resources/reduce16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/reducer-16x16.gif b/org.apache.hdt.ui/resources/reducer-16x16.gif
new file mode 100644
index 0000000..74ee382
--- /dev/null
+++ b/org.apache.hdt.ui/resources/reducer-16x16.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/reducer16.png b/org.apache.hdt.ui/resources/reducer16.png
new file mode 100644
index 0000000..24fec89
--- /dev/null
+++ b/org.apache.hdt.ui/resources/reducer16.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/reducewiz.png b/org.apache.hdt.ui/resources/reducewiz.png
new file mode 100644
index 0000000..61b800d
--- /dev/null
+++ b/org.apache.hdt.ui/resources/reducewiz.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/refresh.png b/org.apache.hdt.ui/resources/refresh.png
new file mode 100644
index 0000000..ed961d2
--- /dev/null
+++ b/org.apache.hdt.ui/resources/refresh.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/spite_overcloud.png b/org.apache.hdt.ui/resources/spite_overcloud.png
new file mode 100644
index 0000000..e256a7e
--- /dev/null
+++ b/org.apache.hdt.ui/resources/spite_overcloud.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/spitesmall.gif b/org.apache.hdt.ui/resources/spitesmall.gif
new file mode 100644
index 0000000..5a1c095
--- /dev/null
+++ b/org.apache.hdt.ui/resources/spitesmall.gif
Binary files differ
diff --git a/org.apache.hdt.ui/resources/spitesmall.png b/org.apache.hdt.ui/resources/spitesmall.png
new file mode 100644
index 0000000..01c2b57
--- /dev/null
+++ b/org.apache.hdt.ui/resources/spitesmall.png
Binary files differ
diff --git a/org.apache.hdt.ui/resources/upload.png b/org.apache.hdt.ui/resources/upload.png
new file mode 100644
index 0000000..38cf1cc
--- /dev/null
+++ b/org.apache.hdt.ui/resources/upload.png
Binary files differ
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/ImageLibrary.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/ImageLibrary.java
new file mode 100644
index 0000000..09cd6e0
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/ImageLibrary.java
@@ -0,0 +1,252 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+
+/**
+ * Icons manager
+ */
+public class ImageLibrary {
+
+ private final Bundle bundle = Activator.getDefault().getBundle();
+
+ /**
+ * Singleton instance
+ */
+ private static volatile ImageLibrary instance = null;
+
+ private ISharedImages sharedImages =
+ PlatformUI.getWorkbench().getSharedImages();
+
+ /**
+ * Where resources (icons, images...) are available in the Bundle
+ */
+ private static final String RESOURCE_DIR = "resources/";
+
+ /**
+ * Public access to image descriptors
+ *
+ * @param name
+ * @return the image descriptor
+ */
+ public static ImageDescriptor get(String name) {
+ return getInstance().getImageDescriptorByName(name);
+ }
+
+ /**
+ * Public access to images
+ *
+ * @param name
+ * @return the image
+ */
+ public static Image getImage(String name) {
+ return getInstance().getImageByName(name);
+ }
+
+ /**
+ * Singleton access
+ *
+ * @return the Image library
+ */
+ public static ImageLibrary getInstance() {
+ if (instance == null) {
+ synchronized (ImageLibrary.class) {
+ if (instance == null)
+ instance = new ImageLibrary();
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Map of registered resources (ImageDescriptor and Image)
+ */
+ private Map<String, ImageDescriptor> descMap =
+ new HashMap<String, ImageDescriptor>();
+
+ private Map<String, Image> imageMap = new HashMap<String, Image>();
+
+ /**
+ * Image library constructor: put image definitions here.
+ */
+ private ImageLibrary() {
+ /*
+ * Servers view
+ */
+ newImage("server.view.location.entry", "Elephant-24x24.png");
+ newImage("server.view.job.entry", "job.gif");
+ newImage("server.view.action.location.new", "location-new-16x16.png");
+ newImage("server.view.action.location.edit", "location-edit-16x16.png");
+ newSharedImage("server.view.action.delete",
+ ISharedImages.IMG_TOOL_DELETE);
+
+ /*
+ * DFS Browser
+ */
+ newImage("dfs.browser.root.entry", "files.gif");
+ newImage("dfs.browser.location.entry", "Elephant-16x16.png");
+ newSharedImage("dfs.browser.folder.entry", ISharedImages.IMG_OBJ_FOLDER);
+ newSharedImage("dfs.browser.file.entry", ISharedImages.IMG_OBJ_FILE);
+ // DFS files in editor
+ newSharedImage("dfs.file.editor", ISharedImages.IMG_OBJ_FILE);
+ // Actions
+ newImage("dfs.browser.action.mkdir", "new-folder.png");
+ newImage("dfs.browser.action.download", "download.png");
+ newImage("dfs.browser.action.upload_files", "upload.png");
+ newImage("dfs.browser.action.upload_dir", "upload.png");
+ newSharedImage("dfs.browser.action.delete",
+ ISharedImages.IMG_TOOL_DELETE);
+ newImage("dfs.browser.action.refresh", "refresh.png");
+
+ /*
+ * Wizards
+ */
+ newImage("wizard.mapper.new", "mapwiz.png");
+ newImage("wizard.reducer.new", "reducewiz.png");
+ newImage("wizard.driver.new", "driverwiz.png");
+ newImage("wizard.mapreduce.project.new", "projwiz.png");
+ }
+
+ /**
+ * Accessor to images
+ *
+ * @param name
+ * @return
+ */
+ private ImageDescriptor getImageDescriptorByName(String name) {
+ return this.descMap.get(name);
+ }
+
+ /**
+ * Accessor to images
+ *
+ * @param name
+ * @return
+ */
+ private Image getImageByName(String name) {
+ return this.imageMap.get(name);
+ }
+
+ /**
+ * Access to platform shared images
+ *
+ * @param name
+ * @return
+ */
+ private ImageDescriptor getSharedByName(String name) {
+ return sharedImages.getImageDescriptor(name);
+ }
+
+ /**
+ * Load and register a new image. If the image resource does not exist or
+ * fails to load, a default "error" resource is supplied.
+ *
+ * @param name name of the image
+ * @param filename name of the file containing the image
+ * @return whether the image has correctly been loaded
+ */
+ private boolean newImage(String name, String filename) {
+ ImageDescriptor id;
+ boolean success;
+
+ try {
+ URL fileURL =
+ FileLocator.find(bundle, new Path(RESOURCE_DIR + filename), null);
+ id = ImageDescriptor.createFromURL(FileLocator.toFileURL(fileURL));
+ success = true;
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ id = ImageDescriptor.getMissingImageDescriptor();
+ // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
+ success = false;
+ }
+
+ descMap.put(name, id);
+ imageMap.put(name, id.createImage(true));
+
+ return success;
+ }
+
+ /**
+ * Register an image from the workspace shared image pool. If the image
+ * resource does not exist or fails to load, a default "error" resource is
+ * supplied.
+ *
+ * @param name name of the image
+ * @param sharedName name of the shared image ({@link ISharedImages})
+ * @return whether the image has correctly been loaded
+ */
+ private boolean newSharedImage(String name, String sharedName) {
+ boolean success = true;
+ ImageDescriptor id = getSharedByName(sharedName);
+
+ if (id == null) {
+ id = ImageDescriptor.getMissingImageDescriptor();
+ // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
+ success = false;
+ }
+
+ descMap.put(name, id);
+ imageMap.put(name, id.createImage(true));
+
+ return success;
+ }
+
+ /**
+ * Register an image from the workspace shared image pool. If the image
+ * resource does not exist or fails to load, a default "error" resource is
+ * supplied.
+ *
+ * @param name name of the image
+ * @param sharedName name of the shared image ({@link ISharedImages})
+ * @return whether the image has correctly been loaded
+ */
+ private boolean newPluginImage(String name, String pluginId,
+ String filename) {
+
+ boolean success = true;
+ ImageDescriptor id =
+ AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, filename);
+
+ if (id == null) {
+ id = ImageDescriptor.getMissingImageDescriptor();
+ // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
+ success = false;
+ }
+
+ descMap.put(name, id);
+ imageMap.put(name, id.createImage(true));
+
+ return success;
+ }
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/MapReducePreferencePage.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/MapReducePreferencePage.java
new file mode 100644
index 0000000..b653b10
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/MapReducePreferencePage.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hdt.ui.preferences;
+
+import org.apache.hdt.ui.Activator;
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * This class represents a preference page that is contributed to the
+ * Preferences dialog. By sub-classing <tt>FieldEditorPreferencePage</tt>,
+ * 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 MapReducePreferencePage extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public MapReducePreferencePage() {
+ super(GRID);
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ setTitle("Hadoop Map/Reduce Tools");
+ // setDescription("Hadoop Map/Reduce Preferences");
+ }
+
+ /**
+ * 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.
+ */
+ @Override
+ public void createFieldEditors() {
+ addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
+ "&Hadoop installation directory:", getFieldEditorParent()));
+
+ }
+
+ /* @inheritDoc */
+ public void init(IWorkbench workbench) {
+ }
+
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceConstants.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..4efcbdd
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceConstants.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.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/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceInitializer.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..c16168c
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/preferences/PreferenceInitializer.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /* @inheritDoc */
+ @Override
+ public void initializeDefaultPreferences() {
+ }
+
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizard.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizard.java
new file mode 100644
index 0000000..7b27fe9
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizard.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.wizards;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard for creating a new Driver class (a class that runs a MapReduce job).
+ *
+ */
+
+public class NewDriverWizard extends NewElementWizard implements INewWizard,
+ IRunnableWithProgress {
+ private NewDriverWizardPage page;
+
+ /*
+ * @Override public boolean performFinish() { }
+ */
+ public void run(IProgressMonitor monitor) {
+ try {
+ page.createType(monitor);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public NewDriverWizard() {
+ setWindowTitle("New MapReduce Driver");
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+
+ page = new NewDriverWizardPage();
+ addPage(page);
+ page.setSelection(selection);
+ }
+
+ @Override
+ /**
+ * Performs any actions appropriate in response to the user having pressed the
+ * Finish button, or refuse if finishing now is not permitted.
+ */
+ public boolean performFinish() {
+ if (super.performFinish()) {
+ if (getCreatedElement() != null) {
+ selectAndReveal(page.getModifiedResource());
+ openResource((IFile) page.getModifiedResource());
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ /**
+ *
+ */
+ protected void finishPage(IProgressMonitor monitor)
+ throws InterruptedException, CoreException {
+ this.run(monitor);
+ }
+
+ @Override
+ public IJavaElement getCreatedElement() {
+ return page.getCreatedType().getPrimaryElement();
+ }
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizardPage.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizardPage.java
new file mode 100644
index 0000000..99d0f99
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewDriverWizardPage.java
@@ -0,0 +1,264 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hdt.ui.wizards;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.hdt.ui.ImageLibrary;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+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.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+/**
+ * Pre-fills the new MapReduce driver class with a template.
+ *
+ */
+
+public class NewDriverWizardPage extends NewTypeWizardPage {
+ private Button isCreateMapMethod;
+
+ private Text reducerText;
+
+ private Text mapperText;
+
+ private final boolean showContainerSelector;
+
+ public NewDriverWizardPage() {
+ this(true);
+ }
+
+ public NewDriverWizardPage(boolean showContainerSelector) {
+ super(true, "MapReduce Driver");
+
+ this.showContainerSelector = showContainerSelector;
+ setTitle("MapReduce Driver");
+ setDescription("Create a new MapReduce driver.");
+ setImageDescriptor(ImageLibrary.get("wizard.driver.new"));
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ initContainerPage(getInitialJavaElement(selection));
+ initTypePage(getInitialJavaElement(selection));
+ }
+
+ @Override
+ /**
+ * Creates the new type using the entered field values.
+ */
+ public void createType(IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ super.createType(monitor);
+ }
+
+ @Override
+ protected void createTypeMembers(final IType newType, ImportsManager imports,
+ final IProgressMonitor monitor) throws CoreException {
+ super.createTypeMembers(newType, imports, monitor);
+ imports.addImport("org.apache.hadoop.fs.Path");
+ imports.addImport("org.apache.hadoop.io.Text");
+ imports.addImport("org.apache.hadoop.io.IntWritable");
+ imports.addImport("org.apache.hadoop.mapred.JobClient");
+ imports.addImport("org.apache.hadoop.mapred.JobConf");
+ imports.addImport("org.apache.hadoop.mapred.Reducer");
+ imports.addImport("org.apache.hadoop.mapred.Mapper");
+
+ /**
+ * TODO(jz) - move most code out of the runnable
+ */
+ getContainer().getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+
+ String method = "public static void main(String[] args) {\n JobClient client = new JobClient();";
+ method += "JobConf conf = new JobConf("
+ + newType.getFullyQualifiedName() + ".class);\n\n";
+
+ method += "// TODO: specify output types\nconf.setOutputKeyClass(Text.class);\nconf.setOutputValueClass(IntWritable.class);\n\n";
+
+ method += "// TODO: specify input and output DIRECTORIES (not files)\nconf.setInputPath(new Path(\"src\"));\nconf.setOutputPath(new Path(\"out\"));\n\n";
+
+ if (mapperText.getText().length() > 0) {
+ method += "conf.setMapperClass(" + mapperText.getText()
+ + ".class);\n\n";
+ } else {
+ method += "// TODO: specify a mapper\nconf.setMapperClass(org.apache.hadoop.mapred.lib.IdentityMapper.class);\n\n";
+ }
+ if (reducerText.getText().length() > 0) {
+ method += "conf.setReducerClass(" + reducerText.getText()
+ + ".class);\n\n";
+ } else {
+ method += "// TODO: specify a reducer\nconf.setReducerClass(org.apache.hadoop.mapred.lib.IdentityReducer.class);\n\n";
+ }
+
+ method += "client.setConf(conf);\n";
+ method += "try {\n\tJobClient.runJob(conf);\n} catch (Exception e) {\n"
+ + "\te.printStackTrace();\n}\n";
+ method += "}\n";
+
+ try {
+ newType.createMethod(method, null, false, monitor);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ public void createControl(Composite parent) {
+ // super.createControl(parent);
+
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ composite.setLayout(layout);
+
+ createContainerControls(composite, 4);
+
+ createPackageControls(composite, 4);
+ createSeparator(composite, 4);
+ createTypeNameControls(composite, 4);
+
+ createSuperClassControls(composite, 4);
+ createSuperInterfacesControls(composite, 4);
+ createSeparator(composite, 4);
+
+ createMapperControls(composite);
+ createReducerControls(composite);
+
+ if (!showContainerSelector) {
+ setPackageFragmentRoot(null, false);
+ setSuperClass("java.lang.Object", false);
+ setSuperInterfaces(new ArrayList(), false);
+ }
+
+ setControl(composite);
+
+ setFocus();
+ handleFieldChanged(CONTAINER);
+
+ // setSuperClass("org.apache.hadoop.mapred.MapReduceBase", true);
+ // setSuperInterfaces(Arrays.asList(new String[]{
+ // "org.apache.hadoop.mapred.Mapper" }), true);
+ }
+
+ @Override
+ protected void handleFieldChanged(String fieldName) {
+ super.handleFieldChanged(fieldName);
+
+ validate();
+ }
+
+ private void validate() {
+ if (showContainerSelector) {
+ updateStatus(new IStatus[] { fContainerStatus, fPackageStatus,
+ fTypeNameStatus, fSuperClassStatus, fSuperInterfacesStatus });
+ } else {
+ updateStatus(new IStatus[] { fTypeNameStatus, });
+ }
+ }
+
+ private void createMapperControls(Composite composite) {
+ this.mapperText = createBrowseClassControl(composite, "Ma&pper:",
+ "&Browse...", "org.apache.hadoop.mapred.Mapper", "Mapper Selection");
+ }
+
+ private void createReducerControls(Composite composite) {
+ this.reducerText = createBrowseClassControl(composite, "&Reducer:",
+ "Browse&...", "org.apache.hadoop.mapred.Reducer", "Reducer Selection");
+ }
+
+ private Text createBrowseClassControl(final Composite composite,
+ final String string, String browseButtonLabel,
+ final String baseClassName, final String dialogTitle) {
+ Label label = new Label(composite, SWT.NONE);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ label.setText(string);
+ label.setLayoutData(data);
+
+ final Text text = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
+ data2.horizontalSpan = 2;
+ text.setLayoutData(data2);
+
+ Button browse = new Button(composite, SWT.NONE);
+ browse.setText(browseButtonLabel);
+ GridData data3 = new GridData(GridData.FILL_HORIZONTAL);
+ browse.setLayoutData(data3);
+ browse.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ IType baseType;
+ try {
+ baseType = getPackageFragmentRoot().getJavaProject().findType(
+ baseClassName);
+
+ // edit this to limit the scope
+ SelectionDialog dialog = JavaUI.createTypeDialog(
+ composite.getShell(), new ProgressMonitorDialog(composite
+ .getShell()), SearchEngine.createHierarchyScope(baseType),
+ IJavaElementSearchConstants.CONSIDER_CLASSES, false);
+
+ dialog.setMessage("&Choose a type:");
+ dialog.setBlockOnOpen(true);
+ dialog.setTitle(dialogTitle);
+ dialog.open();
+
+ if ((dialog.getReturnCode() == Window.OK)
+ && (dialog.getResult().length > 0)) {
+ IType type = (IType) dialog.getResult()[0];
+ text.setText(type.getFullyQualifiedName());
+ }
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+
+ if (!showContainerSelector) {
+ label.setEnabled(false);
+ text.setEnabled(false);
+ browse.setEnabled(false);
+ }
+
+ return text;
+ }
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapReduceProjectWizard.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapReduceProjectWizard.java
new file mode 100644
index 0000000..3377731
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapReduceProjectWizard.java
@@ -0,0 +1,418 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.wizards;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.hdt.core.natures.MapReduceNature;
+import org.apache.hdt.ui.Activator;
+import org.apache.hdt.ui.ImageLibrary;
+import org.apache.hdt.ui.preferences.MapReducePreferencePage;
+import org.apache.hdt.ui.preferences.PreferenceConstants;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPage;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+
+/**
+ * Wizard for creating a new MapReduce Project
+ *
+ */
+
+public class NewMapReduceProjectWizard extends Wizard implements
+ IWorkbenchWizard, IExecutableExtension {
+ static Logger log = Logger.getLogger(NewMapReduceProjectWizard.class
+ .getName());
+
+ private HadoopFirstPage firstPage;
+
+ private NewJavaProjectWizardPage javaPage;
+
+ public NewDriverWizardPage newDriverPage;
+
+ private IConfigurationElement config;
+
+ public NewMapReduceProjectWizard() {
+ setWindowTitle("New MapReduce Project Wizard");
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+
+ }
+
+ @Override
+ public boolean canFinish() {
+ return firstPage.isPageComplete() && javaPage.isPageComplete()
+ // && ((!firstPage.generateDriver.getSelection())
+ // || newDriverPage.isPageComplete()
+ ;
+ }
+
+ @Override
+ public IWizardPage getNextPage(IWizardPage page) {
+ // if (page == firstPage
+ // && firstPage.generateDriver.getSelection()
+ // )
+ // {
+ // return newDriverPage; // if "generate mapper" checked, second page is
+ // new driver page
+ // }
+ // else
+ // {
+ IWizardPage answer = super.getNextPage(page);
+ if (answer == newDriverPage) {
+ return null; // dont flip to new driver page unless "generate
+ // driver" is checked
+ } else if (answer == javaPage) {
+ return answer;
+ } else {
+ return answer;
+ }
+ // }
+ }
+
+ @Override
+ public IWizardPage getPreviousPage(IWizardPage page) {
+ if (page == newDriverPage) {
+ return firstPage; // newDriverPage, if it appears, is the second
+ // page
+ } else {
+ return super.getPreviousPage(page);
+ }
+ }
+
+ static class HadoopFirstPage extends WizardNewProjectCreationPage implements
+ SelectionListener {
+ public HadoopFirstPage() {
+ super("New Hadoop Project");
+ setImageDescriptor(ImageLibrary.get("wizard.mapreduce.project.new"));
+ }
+
+ private Link openPreferences;
+
+ private Button workspaceHadoop;
+
+ private Button projectHadoop;
+
+ private Text location;
+
+ private Button browse;
+
+ private String path;
+
+ public String currentPath;
+
+ // private Button generateDriver;
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ setTitle("MapReduce Project");
+ setDescription("Create a MapReduce project.");
+
+ Group group = new Group((Composite) getControl(), SWT.NONE);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setText("Hadoop MapReduce Library Installation Path");
+ GridLayout layout = new GridLayout(3, true);
+ layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginRight = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginTop = convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginBottom = convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ group.setLayout(layout);
+
+ workspaceHadoop = new Button(group, SWT.RADIO);
+ GridData d = new GridData(GridData.BEGINNING, GridData.BEGINNING,
+ false, false);
+ d.horizontalSpan = 2;
+ workspaceHadoop.setLayoutData(d);
+ // workspaceHadoop.setText("Use default workbench Hadoop library
+ // location");
+ workspaceHadoop.setSelection(true);
+
+ updateHadoopDirLabelFromPreferences();
+
+ openPreferences = new Link(group, SWT.NONE);
+ openPreferences
+ .setText("<a>Configure Hadoop install directory...</a>");
+ openPreferences.setLayoutData(new GridData(GridData.END,
+ GridData.CENTER, false, false));
+ openPreferences.addSelectionListener(this);
+
+ projectHadoop = new Button(group, SWT.RADIO);
+ projectHadoop.setLayoutData(new GridData(GridData.BEGINNING,
+ GridData.CENTER, false, false));
+ projectHadoop.setText("Specify Hadoop library location");
+
+ location = new Text(group, SWT.SINGLE | SWT.BORDER);
+ location.setText("");
+ d = new GridData(GridData.END, GridData.CENTER, true, false);
+ d.horizontalSpan = 1;
+ d.widthHint = 250;
+ d.grabExcessHorizontalSpace = true;
+ location.setLayoutData(d);
+ location.setEnabled(false);
+
+ browse = new Button(group, SWT.NONE);
+ browse.setText("Browse...");
+ browse.setLayoutData(new GridData(GridData.BEGINNING,
+ GridData.CENTER, false, false));
+ browse.setEnabled(false);
+ browse.addSelectionListener(this);
+
+ projectHadoop.addSelectionListener(this);
+ workspaceHadoop.addSelectionListener(this);
+
+ // generateDriver = new Button((Composite) getControl(), SWT.CHECK);
+ // generateDriver.setText("Generate a MapReduce driver");
+ // generateDriver.addListener(SWT.Selection, new Listener()
+ // {
+ // public void handleEvent(Event event) {
+ // getContainer().updateButtons(); }
+ // });
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean validHadoop = validateHadoopLocation();
+
+ if (!validHadoop && isCurrentPage()) {
+ setErrorMessage("Invalid Hadoop Runtime specified; please click 'Configure Hadoop install directory' or fill in library location input field");
+ } else {
+ setErrorMessage(null);
+ }
+
+ return super.isPageComplete() && validHadoop;
+ }
+
+ private boolean validateHadoopLocation() {
+ FilenameFilter gotHadoopJar = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return (name.startsWith("hadoop") && name.endsWith(".jar")
+ && (name.indexOf("test") == -1) && (name
+ .indexOf("examples") == -1));
+ }
+ };
+
+ if (workspaceHadoop.getSelection()) {
+ this.currentPath = path;
+ return new Path(path).toFile().exists()
+ && (new Path(path).toFile().list(gotHadoopJar).length > 0);
+ } else {
+ this.currentPath = location.getText();
+ File file = new Path(location.getText()).toFile();
+ return file.exists()
+ && (new Path(location.getText()).toFile().list(
+ gotHadoopJar).length > 0);
+ }
+ }
+
+ private void updateHadoopDirLabelFromPreferences() {
+ path = Activator.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.P_PATH);
+
+ if ((path != null) && (path.length() > 0)) {
+ workspaceHadoop.setText("Use default Hadoop");
+ } else {
+ workspaceHadoop
+ .setText("Use default Hadoop (currently not set)");
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (e.getSource() == openPreferences) {
+ PreferenceManager manager = new PreferenceManager();
+ manager.addToRoot(new PreferenceNode(
+ "Hadoop Installation Directory",
+ new MapReducePreferencePage()));
+ PreferenceDialog dialog = new PreferenceDialog(this.getShell(),
+ manager);
+ dialog.create();
+ dialog.setMessage("Select Hadoop Installation Directory");
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ updateHadoopDirLabelFromPreferences();
+ } else if (e.getSource() == browse) {
+ DirectoryDialog dialog = new DirectoryDialog(this.getShell());
+ dialog.setMessage("Select a hadoop installation, containing hadoop-X-core.jar");
+ dialog.setText("Select Hadoop Installation Directory");
+ String directory = dialog.open();
+
+ if (directory != null) {
+ location.setText(directory);
+
+ if (!validateHadoopLocation()) {
+ setErrorMessage("No Hadoop jar found in specified directory");
+ } else {
+ setErrorMessage(null);
+ }
+ }
+ } else if (projectHadoop.getSelection()) {
+ location.setEnabled(true);
+ browse.setEnabled(true);
+ } else {
+ location.setEnabled(false);
+ browse.setEnabled(false);
+ }
+
+ getContainer().updateButtons();
+ }
+ }
+
+ @Override
+ public void addPages() {
+ /*
+ * firstPage = new HadoopFirstPage(); addPage(firstPage ); addPage( new
+ * JavaProjectWizardSecondPage(firstPage) );
+ */
+
+ firstPage = new HadoopFirstPage();
+ javaPage = new NewJavaProjectWizardPage(ResourcesPlugin.getWorkspace()
+ .getRoot(), firstPage);
+ // newDriverPage = new NewDriverWizardPage(false);
+ // newDriverPage.setPageComplete(false); // ensure finish button
+ // initially disabled
+ addPage(firstPage);
+ addPage(javaPage);
+
+ // addPage(newDriverPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ PlatformUI.getWorkbench().getProgressService()
+ .runInUI(this.getContainer(), new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Create Hadoop Project", 300);
+
+ javaPage.getRunnable().run(
+ new SubProgressMonitor(monitor, 100));
+
+ // if( firstPage.generateDriver.getSelection())
+ // {
+ // newDriverPage.setPackageFragmentRoot(javaPage.getNewJavaProject().getAllPackageFragmentRoots()[0],
+ // false);
+ // newDriverPage.getRunnable().run(new
+ // SubProgressMonitor(monitor,100));
+ // }
+
+ IProject project = javaPage.getNewJavaProject()
+ .getResource().getProject();
+ IProjectDescription description = project
+ .getDescription();
+ String[] existingNatures = description
+ .getNatureIds();
+ String[] natures = new String[existingNatures.length + 1];
+ for (int i = 0; i < existingNatures.length; i++) {
+ natures[i + 1] = existingNatures[i];
+ }
+
+ natures[0] = MapReduceNature.ID;
+ description.setNatureIds(natures);
+
+ project.setPersistentProperty(
+ new QualifiedName(Activator.PLUGIN_ID,
+ "hadoop.runtime.path"),
+ firstPage.currentPath);
+ project.setDescription(description,
+ new NullProgressMonitor());
+
+ String[] natureIds = project.getDescription()
+ .getNatureIds();
+ for (int i = 0; i < natureIds.length; i++) {
+ log.fine("Nature id # " + i + " > "
+ + natureIds[i]);
+ }
+
+ monitor.worked(100);
+ monitor.done();
+
+ BasicNewProjectResourceWizard
+ .updatePerspective(config);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ log.log(Level.SEVERE, "CoreException thrown.",
+ e);
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }, null);
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+ public void setInitializationData(IConfigurationElement config,
+ String propertyName, Object data) throws CoreException {
+ this.config = config;
+ }
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapperWizard.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapperWizard.java
new file mode 100644
index 0000000..710c915
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewMapperWizard.java
@@ -0,0 +1,182 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.wizards;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.hdt.ui.ImageLibrary;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard for creating a new Mapper class (a class that runs the Map portion
+ * of a MapReduce job). The class is pre-filled with a template.
+ *
+ */
+
+public class NewMapperWizard extends NewElementWizard implements INewWizard,
+ IRunnableWithProgress {
+ private Page page;
+
+ public NewMapperWizard() {
+ setWindowTitle("New Mapper");
+ }
+
+ public void run(IProgressMonitor monitor) {
+ try {
+ page.createType(monitor);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+
+ page = new Page();
+ addPage(page);
+ page.setSelection(selection);
+ }
+
+ public static class Page extends NewTypeWizardPage {
+ private Button isCreateMapMethod;
+
+ public Page() {
+ super(true, "Mapper");
+
+ setTitle("Mapper");
+ setDescription("Create a new Mapper implementation.");
+ setImageDescriptor(ImageLibrary.get("wizard.mapper.new"));
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ initContainerPage(getInitialJavaElement(selection));
+ initTypePage(getInitialJavaElement(selection));
+ }
+
+ @Override
+ public void createType(IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ super.createType(monitor);
+ }
+
+ @Override
+ protected void createTypeMembers(IType newType, ImportsManager imports,
+ IProgressMonitor monitor) throws CoreException {
+ super.createTypeMembers(newType, imports, monitor);
+ imports.addImport("java.io.IOException");
+ imports.addImport("org.apache.hadoop.io.WritableComparable");
+ imports.addImport("org.apache.hadoop.io.Writable");
+ imports.addImport("org.apache.hadoop.mapred.OutputCollector");
+ imports.addImport("org.apache.hadoop.mapred.Reporter");
+ newType
+ .createMethod(
+ "public void map(WritableComparable key, Writable values, OutputCollector output, Reporter reporter) throws IOException \n{\n}\n",
+ null, false, monitor);
+ }
+
+ public void createControl(Composite parent) {
+ // super.createControl(parent);
+
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ composite.setLayout(layout);
+
+ createContainerControls(composite, 4);
+ createPackageControls(composite, 4);
+ createSeparator(composite, 4);
+ createTypeNameControls(composite, 4);
+ createSuperClassControls(composite, 4);
+ createSuperInterfacesControls(composite, 4);
+ // createSeparator(composite, 4);
+
+ setControl(composite);
+
+ setSuperClass("org.apache.hadoop.mapred.MapReduceBase", true);
+ setSuperInterfaces(Arrays
+ .asList(new String[] { "org.apache.hadoop.mapred.Mapper" }), true);
+
+ setFocus();
+ validate();
+ }
+
+ @Override
+ protected void handleFieldChanged(String fieldName) {
+ super.handleFieldChanged(fieldName);
+
+ validate();
+ }
+
+ private void validate() {
+ updateStatus(new IStatus[] { fContainerStatus, fPackageStatus,
+ fTypeNameStatus, fSuperClassStatus, fSuperInterfacesStatus });
+ }
+ }
+
+ @Override
+ public boolean performFinish() {
+ if (super.performFinish()) {
+ if (getCreatedElement() != null) {
+ openResource((IFile) page.getModifiedResource());
+ selectAndReveal(page.getModifiedResource());
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ protected void finishPage(IProgressMonitor monitor)
+ throws InterruptedException, CoreException {
+ this.run(monitor);
+ }
+
+ @Override
+ public IJavaElement getCreatedElement() {
+ return page.getCreatedType().getPrimaryElement();
+ }
+
+}
diff --git a/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewReducerWizard.java b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewReducerWizard.java
new file mode 100644
index 0000000..5ea7bab
--- /dev/null
+++ b/org.apache.hdt.ui/src/org/apache/hdt/ui/wizards/NewReducerWizard.java
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hdt.ui.wizards;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.hdt.ui.ImageLibrary;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard for creating a new Reducer class (a class that runs the Reduce
+ * portion of a MapReduce job). The class is pre-filled with a template.
+ *
+ */
+
+public class NewReducerWizard extends NewElementWizard implements
+ INewWizard, IRunnableWithProgress {
+ private Page page;
+
+ public NewReducerWizard() {
+ setWindowTitle("New Reducer");
+ }
+
+ public void run(IProgressMonitor monitor) {
+ try {
+ page.createType(monitor);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+
+ page = new Page();
+ addPage(page);
+ page.setSelection(selection);
+ }
+
+ public static class Page extends NewTypeWizardPage {
+ public Page() {
+ super(true, "Reducer");
+
+ setTitle("Reducer");
+ setDescription("Create a new Reducer implementation.");
+ setImageDescriptor(ImageLibrary.get("wizard.reducer.new"));
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ initContainerPage(getInitialJavaElement(selection));
+ initTypePage(getInitialJavaElement(selection));
+ }
+
+ @Override
+ public void createType(IProgressMonitor monitor) throws CoreException,
+ InterruptedException {
+ super.createType(monitor);
+ }
+
+ @Override
+ protected void createTypeMembers(IType newType, ImportsManager imports,
+ IProgressMonitor monitor) throws CoreException {
+ super.createTypeMembers(newType, imports, monitor);
+ imports.addImport("java.io.IOException");
+ imports.addImport("org.apache.hadoop.io.WritableComparable");
+ imports.addImport("org.apache.hadoop.mapred.OutputCollector");
+ imports.addImport("org.apache.hadoop.mapred.Reporter");
+ imports.addImport("java.util.Iterator");
+ newType
+ .createMethod(
+ "public void reduce(WritableComparable _key, Iterator values, OutputCollector output, Reporter reporter) throws IOException \n{\n"
+ + "\t// replace KeyType with the real type of your key\n"
+ + "\tKeyType key = (KeyType) _key;\n\n"
+ + "\twhile (values.hasNext()) {\n"
+ + "\t\t// replace ValueType with the real type of your value\n"
+ + "\t\tValueType value = (ValueType) values.next();\n\n"
+ + "\t\t// process value\n" + "\t}\n" + "}\n", null, false,
+ monitor);
+ }
+
+ public void createControl(Composite parent) {
+ // super.createControl(parent);
+
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ composite.setLayout(layout);
+
+ createContainerControls(composite, 4);
+ createPackageControls(composite, 4);
+ createSeparator(composite, 4);
+ createTypeNameControls(composite, 4);
+ createSuperClassControls(composite, 4);
+ createSuperInterfacesControls(composite, 4);
+ // createSeparator(composite, 4);
+
+ setControl(composite);
+
+ setSuperClass("org.apache.hadoop.mapred.MapReduceBase", true);
+ setSuperInterfaces(Arrays
+ .asList(new String[] { "org.apache.hadoop.mapred.Reducer" }), true);
+
+ setFocus();
+ validate();
+ }
+
+ @Override
+ protected void handleFieldChanged(String fieldName) {
+ super.handleFieldChanged(fieldName);
+
+ validate();
+ }
+
+ private void validate() {
+ updateStatus(new IStatus[] { fContainerStatus, fPackageStatus,
+ fTypeNameStatus, fSuperClassStatus, fSuperInterfacesStatus });
+ }
+ }
+
+ @Override
+ public boolean performFinish() {
+ if (super.performFinish()) {
+ if (getCreatedElement() != null) {
+ selectAndReveal(page.getModifiedResource());
+ openResource((IFile) page.getModifiedResource());
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ protected void finishPage(IProgressMonitor monitor)
+ throws InterruptedException, CoreException {
+ this.run(monitor);
+ }
+
+ @Override
+ public IJavaElement getCreatedElement() {
+ return (page.getCreatedType() == null) ? null : page.getCreatedType()
+ .getPrimaryElement();
+ }
+}