[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-cvs-commits
Subject:    [jboss-cvs] contrib/jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui
From:       Laurent Etiemble <letiemble () users ! sourceforge ! net>
Date:       2003-07-31 21:47:46
[Download RAW message or body]

  User: letiemble
  Date: 03/07/31 14:47:46

  Added:       jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui/actions
  AbstractDeployAction.java DeployAction.java
                        RedeployAction.java UndeployAction.java
  Log:
  First iteration for the Deployer Plugin
  I18N to be done
  Javadoc to be completed
  Need for more tests
  
  Revision  Changes    Path
  1.1                  \
contrib/jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui/actions/AbstractDeployAction.java
  
  Index: AbstractDeployAction.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at www.gnu.org.
   */
  package org.jboss.ide.eclipse.deployer.ui.actions;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  
  import org.eclipse.core.resources.IResource;
  import org.eclipse.jface.action.IAction;
  import org.eclipse.jface.viewers.ISelection;
  import org.eclipse.jface.viewers.ISelectionProvider;
  import org.eclipse.jface.viewers.StructuredSelection;
  import org.eclipse.ui.IObjectActionDelegate;
  import org.eclipse.ui.IWorkbenchPart;
  import org.eclipse.ui.actions.ActionDelegate;
  import org.jboss.ide.eclipse.deployer.core.target.ITarget;
  import org.jboss.ide.eclipse.deployer.ui.decorators.DeployedDecorator;
  
  /**
   * @author    Laurent Etiemble
   * @created   24 mars 2003
   * @version   $Revision: 1.1 $
   */
  public abstract class AbstractDeployAction extends ActionDelegate implements \
IObjectActionDelegate  {
     /** Description of the Field */
     protected IWorkbenchPart part = null;
  
  
     /**Constructor for the XDocletRunAction object */
     public AbstractDeployAction()
     {
        super();
     }
  
  
     /**
      * Main processing method for the XDocletRunAction object
      *
      * @param action  Description of the Parameter
      */
     public void run(IAction action)
     {
        // Gets the selection provider and extract what we need
        ISelectionProvider provider = this.part.getSite().getSelectionProvider();
        StructuredSelection selection = (StructuredSelection) \
provider.getSelection();  Collection resources = new ArrayList();
        Iterator it = selection.iterator();
        while (it.hasNext())
        {
           Object o = it.next();
  
           // For each resource
           if (o instanceof IResource)
           {
              resources.add(o);
           }
        }
        this.process(resources);
     }
  
  
     /**
      * Description of the Method
      *
      * @param action     Description of the Parameter
      * @param selection  Description of the Parameter
      */
     public void selectionChanged(IAction action, ISelection selection)
     {
     }
  
  
     /**
      * @param action      The new ActivePart value
      * @param targetPart  The new ActivePart value
      * @see               \
                org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, \
                IWorkbenchPart)
      */
     public void setActivePart(IAction action, IWorkbenchPart targetPart)
     {
        this.part = targetPart;
     }
  
  
     /**
      * Gets the deploymentTarget attribute of the AbstractDeployAction object
      *
      * @param resource  Description of the Parameter
      * @return          The deploymentTarget value
      */
     protected abstract ITarget getDeploymentTarget(IResource resource);
  
  
     /**
      * Description of the Method
      *
      * @param resources  Description of the Parameter
      */
     protected void process(Collection resources)
     {
        Iterator it = resources.iterator();
        while (it.hasNext())
        {
           IResource resource = (IResource) it.next();
           ITarget target = this.getDeploymentTarget(resource);
           if (target != null)
           {
              this.process(target, resource);
              this.refresh(resource);
           }
        }
     }
  
  
     /**
      * Description of the Method
      *
      * @param target    Description of the Parameter
      * @param resource  Description of the Parameter
      */
     protected abstract void process(ITarget target, IResource resource);
  
  
     /**
      * Description of the Method
      *
      * @param resource  Description of the Parameter
      */
     protected void refresh(IResource resource)
     {
        DeployedDecorator decorator = DeployedDecorator.getDemoDecorator();
        if (decorator != null)
        {
           decorator.refresh(resource);
        }
     }
  }
  
  
  
  1.1                  \
contrib/jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui/actions/DeployAction.java
  
  Index: DeployAction.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at www.gnu.org.
   */
  package org.jboss.ide.eclipse.deployer.ui.actions;
  
  import java.util.ArrayList;
  import java.util.Collection;
  
  import org.eclipse.core.resources.IResource;
  import org.eclipse.jface.dialogs.IDialogConstants;
  import org.jboss.ide.eclipse.deployer.core.DeployerCorePlugin;
  import org.jboss.ide.eclipse.deployer.core.target.DeploymentException;
  import org.jboss.ide.eclipse.deployer.core.target.ITarget;
  import org.jboss.ide.eclipse.deployer.ui.DeployerUIPlugin;
  import org.jboss.ide.eclipse.deployer.ui.dialogs.TargetChoiceDialog;
  import org.jboss.ide.eclipse.deployer.ui.util.DeployedResourceUtil;
  
  /**
   * @author    Laurent Etiemble
   * @created   24 mars 2003
   * @version   $Revision: 1.1 $
   */
  public class DeployAction extends AbstractDeployAction
  {
     /**Constructor for the XDocletRunAction object */
     public DeployAction()
     {
        super();
     }
  
  
     /**
      * Gets the deploymentTarget attribute of the DeployAction object
      *
      * @param resource  Description of the Parameter
      * @return          The deploymentTarget value
      */
     protected ITarget getDeploymentTarget(IResource resource)
     {
        ITarget target = null;
  
        DeployerCorePlugin.getDefault().refreshDebugTargets();
        DeployerCorePlugin.getDefault().refreshTargets();
  
        Collection choices = new ArrayList();
        choices.addAll(DeployerCorePlugin.getDefault().getDebugTargets());
        choices.addAll(DeployerCorePlugin.getDefault().getTargets());
  
        TargetChoiceDialog dialog = new \
TargetChoiceDialog(DeployerUIPlugin.getShell(), choices);  if (dialog.open() == \
IDialogConstants.OK_ID)  {
           target = dialog.getTarget();
        }
  
        return target;
     }
  
  
     /**
      * Description of the Method
      *
      * @param target    Description of the Parameter
      * @param resource  Description of the Parameter
      */
     protected void process(ITarget target, IResource resource)
     {
        try
        {
           target.deploy(resource);
  		DeployedResourceUtil.linkTarget(resource, target);
           DeployerUIPlugin.getDefault().showInfoMessage("Deployment was \
successfull");  }
        catch (DeploymentException de)
        {
           DeployerUIPlugin.getDefault().showErrorMessage("The deployment failed with \
the following message :\n" + de.getMessage());  }
     }
  }
  
  
  
  1.1                  \
contrib/jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui/actions/RedeployAction.java
  
  Index: RedeployAction.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at www.gnu.org.
   */
  package org.jboss.ide.eclipse.deployer.ui.actions;
  
  import java.util.ArrayList;
  import java.util.Collection;
  
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.runtime.CoreException;
  import org.eclipse.jface.dialogs.IDialogConstants;
  import org.jboss.ide.eclipse.deployer.core.DeployerCorePlugin;
  import org.jboss.ide.eclipse.deployer.core.target.DeploymentException;
  import org.jboss.ide.eclipse.deployer.core.target.ITarget;
  import org.jboss.ide.eclipse.deployer.ui.DeployerUIPlugin;
  import org.jboss.ide.eclipse.deployer.ui.IDeployerUIConstants;
  import org.jboss.ide.eclipse.deployer.ui.dialogs.TargetChoiceDialog;
  import org.jboss.ide.eclipse.deployer.ui.util.DeployedResourceUtil;
  
  /**
   * @author    Laurent Etiemble
   * @created   24 mars 2003
   * @version   $Revision: 1.1 $
   */
  public class RedeployAction extends AbstractDeployAction
  {
     /**Constructor for the XDocletRunAction object */
     public RedeployAction()
     {
        super();
     }
  
  
     /**
      * Gets the deploymentTarget attribute of the DeployAction object
      *
      * @param resource  Description of the Parameter
      * @return          The deploymentTarget value
      */
     protected ITarget getDeploymentTarget(IResource resource)
     {
        ITarget target = null;
  
        try
        {
           DeployerCorePlugin.getDefault().refreshDebugTargets();
           DeployerCorePlugin.getDefault().refreshTargets();
  
           Collection choices = new ArrayList();
           choices.addAll(DeployerCorePlugin.getDefault().getDebugTargets());
           choices.addAll(DeployerCorePlugin.getDefault().getTargets());
  
           target = (ITarget) \
resource.getSessionProperty(IDeployerUIConstants.QNAME_TARGET);  if \
(!choices.contains(target))  {
              TargetChoiceDialog dialog = new \
TargetChoiceDialog(DeployerUIPlugin.getShell(), choices);  if (dialog.open() == \
IDialogConstants.OK_ID)  {
                 target = dialog.getTarget();
              }
           }
        }
        catch (CoreException ce)
        {
           DeployerUIPlugin.logError("Unable to set session property with target", \
ce);  }
  
        return target;
     }
  
  
     /**
      * Description of the Method
      *
      * @param target    Description of the Parameter
      * @param resource  Description of the Parameter
      */
     protected void process(ITarget target, IResource resource)
     {
        try
        {
           target.redeploy(resource);
  		DeployedResourceUtil.linkTarget(resource, target);
           DeployerUIPlugin.getDefault().showInfoMessage("Redeployment was \
successfull");  }
        catch (DeploymentException de)
        {
           DeployerUIPlugin.getDefault().showErrorMessage("The redeployment failed \
with the following message :\n" + de.getMessage());  }
     }
  }
  
  
  
  1.1                  \
contrib/jbosside/org.jboss.ide.eclipse.deployer.ui/src/org/jboss/ide/eclipse/deployer/ui/actions/UndeployAction.java
  
  Index: UndeployAction.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at www.gnu.org.
   */
  package org.jboss.ide.eclipse.deployer.ui.actions;
  
  import java.util.ArrayList;
  import java.util.Collection;
  
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.runtime.CoreException;
  import org.jboss.ide.eclipse.deployer.core.DeployerCorePlugin;
  import org.jboss.ide.eclipse.deployer.core.target.DeploymentException;
  import org.jboss.ide.eclipse.deployer.core.target.ITarget;
  import org.jboss.ide.eclipse.deployer.ui.DeployerUIPlugin;
  import org.jboss.ide.eclipse.deployer.ui.IDeployerUIConstants;
  import org.jboss.ide.eclipse.deployer.ui.util.DeployedResourceUtil;
  
  /**
   * @author    Laurent Etiemble
   * @created   24 mars 2003
   * @version   $Revision: 1.1 $
   */
  public class UndeployAction extends AbstractDeployAction
  {
     /**Constructor for the XDocletRunAction object */
     public UndeployAction()
     {
        super();
     }
  
  
     /**
      * Gets the deploymentTarget attribute of the DeployAction object
      *
      * @param resource  Description of the Parameter
      * @return          The deploymentTarget value
      */
     protected ITarget getDeploymentTarget(IResource resource)
     {
        ITarget target = null;
  
        try
        {
           DeployerCorePlugin.getDefault().refreshDebugTargets();
           DeployerCorePlugin.getDefault().refreshTargets();
  
           Collection choices = new ArrayList();
           choices.addAll(DeployerCorePlugin.getDefault().getDebugTargets());
           choices.addAll(DeployerCorePlugin.getDefault().getTargets());
  
           target = (ITarget) \
resource.getSessionProperty(IDeployerUIConstants.QNAME_TARGET);  if (target == null)
           {
              DeployerUIPlugin.getDefault().showWarningMessage("Cannot undeploy a \
non-deployed resource");  }
        }
        catch (CoreException ce)
        {
           DeployerUIPlugin.logError("Unable to set session property with target", \
ce);  }
  
        return target;
     }
  
  
     /**
      * Description of the Method
      *
      * @param target    Description of the Parameter
      * @param resource  Description of the Parameter
      */
     protected void process(ITarget target, IResource resource)
     {
        try
        {
           target.undeploy(resource);
           DeployedResourceUtil.unlinkTarget(resource);
           DeployerUIPlugin.getDefault().showInfoMessage("Undeployment was \
successfull");  }
        catch (DeploymentException de)
        {
           DeployerUIPlugin.getDefault().showErrorMessage("The undeployment failed \
with the following message :\n" + de.getMessage());  }
     }
  }
  
  
  


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic