Author: vyemialyanchyk
Date: 2011-02-08 10:19:40 -0500 (Tue, 08 Feb 2011)
New Revision: 29061
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizard.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizardPage.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
Log:
https://issues.jboss.org/browse/JBIDE-6098 - fixed - add import hibernate jars wizard
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.properties 2011-02-08
11:18:18 UTC (rev 29060)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.properties 2011-02-08
15:19:40 UTC (rev 29061)
@@ -11,3 +11,5 @@
#NavigatorContent_HibernateKnownConfigs=Hibernate Known Configurations
exportHibernateAntCodeGenerationWizardName=Ant Code Generation
exportHibernateAntCodeGenerationWizardDescription=Export Hibernate Code Generation
Configuration to Ant Code Generation script
+importHibernateLibsWizardName=Hibernate Jars
+importHibernateLibsWizardDescription=Import Hibernate Jars into project
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2011-02-08
11:18:18 UTC (rev 29060)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2011-02-08
15:19:40 UTC (rev 29061)
@@ -787,6 +787,23 @@
name="Hibernate">
</category>
</extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <wizard
+ category="org.hibernate.eclipse.console.HibernateToolsImport"
+ class="org.hibernate.eclipse.libsimport.ImportHibernateJarsWizard"
+ icon="icons/images/ant_codegen_export.gif"
+ id="org.hibernate.eclipse.libsimport.ImportHibernateJarsWizard"
+ name="%importHibernateLibsWizardName">
+ <description>
+ %importHibernateLibsWizardDescription
+ </description>
+ </wizard>
+ <category
+ id="org.hibernate.eclipse.console.HibernateToolsImport"
+ name="Hibernate">
+ </category>
+ </extension>
<!-- <extension
point="org.eclipse.ui.themes">
<themeElementCategory
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2011-02-08
11:18:18 UTC (rev 29060)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2011-02-08
15:19:40 UTC (rev 29061)
@@ -528,6 +528,11 @@
public static String
ExportAntCodeGenWizardPage_error_in_hibernate_code_generation_configuration;
public static String ExportAntCodeGenWizardPage_warning;
+ public static String ImportHibernateJarsWizard_title;
+ public static String ImportHibernateJarsWizardPage_title;
+ public static String ImportHibernateJarsWizardPage_description;
+ public static String ImportHibernateJarsWizardPage_error_message;
+
public static String QueryParametersPage_add_query_parameter_tooltip;
public static String QueryParametersPage_remove_query_parameter_tooltip;
public static String QueryParametersPage_enable_disable_parameters_tooltip;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-02-08
11:18:18 UTC (rev 29060)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-02-08
15:19:40 UTC (rev 29061)
@@ -528,6 +528,11 @@
ExportAntCodeGenWizardPage_error_in_hibernate_code_generation_configuration=Error in
Hibernate Code Generation Configuration: ''{0}''
ExportAntCodeGenWizardPage_warning=Warning: ''{0}'' already exists.
+ImportHibernateJarsWizard_title=Import Hibernate Jars
+ImportHibernateJarsWizardPage_title=Hibernate Jars
+ImportHibernateJarsWizardPage_description=Import Hibernate Jars from Hibernate Tools
plugin.
+ImportHibernateJarsWizardPage_error_message=Hibernate Jars folder does not exist.
+
QueryParametersPage_add_query_parameter_tooltip=Add Query Parameter
QueryParametersPage_remove_query_parameter_tooltip=Remove Query Parameter
QueryParametersPage_enable_disable_parameters_tooltip=Enable/Disable Parameters
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizard.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizard.java 2011-02-08
15:19:40 UTC (rev 29061)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.libsimport;
+
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.ide.IDE;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+
+/**
+ * Import Hibernate jars wizard responsible to import Hibernate jars
+ * from Hibernate Tools internal libs into user specified place.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ImportHibernateJarsWizard extends Wizard implements IImportWizard {
+ private IWorkbench workbench;
+
+ private IStructuredSelection selection;
+
+ private ImportHibernateJarsWizardPage mainPage;
+
+ /**
+ * Creates a wizard for importing Hibernate jars into the workspace from
+ * the file system.
+ */
+ public ImportHibernateJarsWizard() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void addPages() {
+ super.addPages();
+ mainPage = new ImportHibernateJarsWizardPage(workbench, selection);
+ addPage(mainPage);
+ }
+
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWizard.
+ */
+ @SuppressWarnings("rawtypes")
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ this.workbench = workbench;
+ this.selection = currentSelection;
+
+ List selectedResources = IDE.computeSelectedResources(currentSelection);
+ if (!selectedResources.isEmpty()) {
+ this.selection = new StructuredSelection(selectedResources);
+ }
+
+ setWindowTitle(HibernateConsoleMessages.ImportHibernateJarsWizard_title);
+ ImageDescriptor descriptor =
HibernateConsolePlugin.getImageDescriptor("icons/images/newhibernate_wiz.gif");
//$NON-NLS-1$
+ setDefaultPageImageDescriptor(descriptor);
+ setNeedsProgressMonitor(true);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ @SuppressWarnings("restriction")
+ public boolean performFinish() {
+ return mainPage.finish();
+ }
+}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizardPage.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/libsimport/ImportHibernateJarsWizardPage.java 2011-02-08
15:19:40 UTC (rev 29061)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.libsimport;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1;
+import org.hibernate.eclipse.HibernatePlugin;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+@SuppressWarnings("restriction")
+public class ImportHibernateJarsWizardPage extends WizardFileSystemResourceImportPage1 {
+
+ public static final String HIBERNATE_PLUGIN_LIB_PATH = "lib";
//$NON-NLS-1$
+
+ protected String errorMessage = null;
+
+ public ImportHibernateJarsWizardPage(IWorkbench aWorkbench, IStructuredSelection
selection) {
+ super(aWorkbench, selection);
+ setTitle(HibernateConsoleMessages.ImportHibernateJarsWizardPage_title);
+
setDescription(HibernateConsoleMessages.ImportHibernateJarsWizardPage_description);
+ }
+
+ protected void createRootDirectoryGroup(Composite parent) {
+ super.createRootDirectoryGroup(parent);
+ //
+ sourceBrowseButton.setEnabled(false);
+ String libsPath = ""; //$NON-NLS-1$
+ errorMessage = null;
+ try {
+ File libFolderHibernatePlugin = getHibernatePluginFolder(HIBERNATE_PLUGIN_LIB_PATH);
+ if (libFolderHibernatePlugin.exists()) {
+ libsPath = libFolderHibernatePlugin.getAbsolutePath();
+ } else {
+ errorMessage = HibernateConsoleMessages.ImportHibernateJarsWizardPage_error_message;
+ }
+ } catch (IOException e) {
+ errorMessage = "IOException: " + e.getMessage(); //$NON-NLS-1$
+ }
+ if (libsPath.length() > 0 && !libsPath.endsWith(File.separator)) {
+ libsPath += File.separator;
+ }
+ sourceNameField.setText(libsPath);
+ sourceNameField.setEnabled(false);
+ }
+
+ protected File getHibernatePluginFolder(String path) throws IOException {
+ URL entry = HibernatePlugin.getDefault().getBundle().getEntry(path);
+ URL resProject = FileLocator.resolve(entry);
+ String resolvePath = FileLocator.resolve(resProject).getFile();
+ File folder = new File(resolvePath);
+ return folder;
+ }
+
+ protected boolean ensureSourceIsValid() {
+ boolean res = true;
+ if (errorMessage != null) {
+ setErrorMessage(errorMessage);
+ res = false;
+ }
+ if (res) {
+ res = super.ensureSourceIsValid();
+ }
+ return res;
+ }
+
+}