Author: dgolovin
Date: 2007-10-24 20:18:07 -0400 (Wed, 24 Oct 2007)
New Revision: 4485
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1094
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2007-10-24
23:58:21 UTC (rev 4484)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2007-10-25
00:18:07 UTC (rev 4485)
@@ -66,7 +66,7 @@
import org.osgi.service.prefs.BackingStoreException;
// TODO: why not just *one* global filter set to avoid any missing names ? (assert for it
in our unittests!
-public class Seam2FacetInstallDelegate extends Object implements
IDelegate,ISeamFacetDataModelProperties {
+public class Seam2FacetInstallDelegate extends SeamFacetAbstractInstallDelegate{
public static String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
public static String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
@@ -194,7 +194,7 @@
public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
- public void execute(final IProject project, IProjectFacetVersion fv,
+ public void doExecute(final IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
final IDataModel model = (IDataModel)config;
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2007-10-25
00:18:07 UTC (rev 4485)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.seam.core.SeamCoreMessages;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+/**
+ *
+ * @author eskimo
+ *
+ */
+public abstract class SeamFacetAbstractInstallDelegate implements ILogListener,
+ IDelegate,ISeamFacetDataModelProperties {
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject,
org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object,
org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ try {
+ // TODO find a better way to handle exceptions for creating seam projects
+ // now here is the simple way that allows keep most of seam classes
+ // untouched, this abstract class just listen to eclipse log and show an
+ // error dialog if there were records logged from seam.core plugin
+ startListening();
+ doExecute(project,fv,config,monitor);
+ } finally {
+ stopListening();
+ }
+ if(errorOccurs) {
+ Display.getDefault().syncExec(
+ new Runnable() {
+ public void run() {
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ SeamCoreMessages.SEAM_FACET_INSTALL_ABSTRACT_DELEGATE_ERROR,
+ SeamCoreMessages.SEAM_FACET_INSTALL_ABSTRACT_DELEGATE_CHECK_ERROR_LOG_VIEW,
+ new Status(IStatus.ERROR,SeamCorePlugin.PLUGIN_ID,
+ SeamCoreMessages.SEAM_FACET_INSTALL_ABSTRACT_DELEGATE_ERRORS_OCCURED));
+ }
+ });
+ }
+ }
+
+ /**
+ *
+ * @param project
+ * @param fv
+ * @param config
+ * @param monitor
+ * @throws CoreException
+ */
+ protected abstract void doExecute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException;
+
+
+ /**
+ *
+ */
+ private void stopListening() {
+ SeamCorePlugin.getDefault().getLog().removeLogListener(this);
+ }
+
+ /**
+ *
+ */
+ private void startListening() {
+ SeamCorePlugin.getDefault().getLog().addLogListener(this);
+ }
+
+ private boolean errorOccurs = false;
+
+ private boolean hasErrors() {
+ return errorOccurs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.project.facet.core.IActionConfigFactory#create()
+ */
+ public Object create() throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void logging(IStatus status, String plugin) {
+ if(status.getPlugin().equals(SeamCorePlugin.PLUGIN_ID)) {
+ errorOccurs = true;
+ }
+ }
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2007-10-24
23:58:21 UTC (rev 4484)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2007-10-25
00:18:07 UTC (rev 4485)
@@ -61,7 +61,7 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.osgi.service.prefs.BackingStoreException;
-public class SeamFacetInstallDelegate extends Object implements
IDelegate,ISeamFacetDataModelProperties {
+public class SeamFacetInstallDelegate extends SeamFacetAbstractInstallDelegate {
public static String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
public static String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
@@ -188,7 +188,7 @@
public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
- public void execute(final IProject project, IProjectFacetVersion fv,
+ public void doExecute(final IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
final IDataModel model = (IDataModel)config;
@@ -662,12 +662,4 @@
SeamCorePlugin.getPluginLog().logError(e);
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.project.facet.core.IActionConfigFactory#create()
- */
- public Object create() throws CoreException {
- // TODO Auto-generated method stub
- return null;
- }
}