org.eclipse.jst.jsf.facesconfig.ui_1.2.2.v201103292152

iewer();
    Object editpart = viewer.getEditPartRegistry().get(model);
    if ((editpart instanceof EditPart))
    {
      viewer.flush();
      viewer.select((EditPart)editpart);
      
      PlatformUI.getWorkbench().getActiveWorkbenchWindow()
        .getActivePage().activate(editor);
    }
  }
  
  protected void updateTargetRequest()
  {
    CreateRequest request = getCreateRequest();
    request.setLocation(getDropLocation());
  }
  
  private boolean isValidJSFFile(Object resource)
  {
    if ((resource == null) || (!(resource instanceof IResource))) {
      return false;
    }
    if (((IResource)resource).getProject() == 
      ((FileEditorInput)editor.getEditorInput()).getFile().getProject()) {
      if (WebrootUtil.getWebPath(((IResource)resource).getFullPath()).length() > 0) {
        return true;
      }
    }
    return false;
  }
  
  public boolean isEnabled(DropTargetEvent dropTargetEvent)
  {
    if (super.isEnabled(dropTargetEvent))
    {
      if (data != null)
      {
        IResource[] resources = (IResource[])data;
        if (isValidJSFFile(resources[0])) {
          return true;
        }
        return false;
      }
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.ResourceTransferDropTargetListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.AlignmentRequest;
import org.eclipse.gef.tools.ToolUtilities;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public final class AlignmentAction
  extends SelectionAction
{
  public static final String ID_ALIGN_BOTTOM = "org.eclipse.gef.align_bottom";
  public static final String ID_ALIGN_CENTER = "org.eclipse.gef.align_center";
  public static final String ID_ALIGN_LEFT = "org.eclipse.gef.align_left";
  public static final String ID_ALIGN_MIDDLE = "org.eclipse.gef.align_middle";
  public static final String ID_ALIGN_RIGHT = "org.eclipse.gef.align_right";
  public static final String ID_ALIGN_TOP = "org.eclipse.gef.align_top";
  private int alignment;
  private List operationSet;
  
  /**
   * @deprecated
   */
  public AlignmentAction(IEditorPart editor, int align)
  {
    this(editor, align);
  }
  
  public AlignmentAction(IWorkbenchPart part, int align)
  {
    super(part);
    alignment = align;
    initUI();
  }
  
  protected Rectangle calculateAlignmentRectangle(Request request)
  {
    List editparts = getOperationSet(request);
    if ((editparts == null) || (editparts.isEmpty())) {
      return null;
    }
    GraphicalEditPart part = null;
    if ((alignment == 16) || 
      (alignment == 2)) {
      part = (GraphicalEditPart)editparts.get(editparts.size() - 1);
    } else {
      part = getFitnessPart(editparts);
    }
    Rectangle rect = new PrecisionRectangle(part.getFigure().getBounds());
    part.getFigure().translateToAbsolute(rect);
    return rect;
  }
  
  private GraphicalEditPart getFitnessPart(List editparts)
  {
    if ((alignment == 16) || 
      (alignment == 2)) {
      return null;
    }
    int positionComparor = Integer.MAX_VALUE;
    if ((alignment == 1) || 
      (alignment == 8)) {
      positionComparor = Integer.MAX_VALUE;
    } else if ((alignment == 4) || 
      (alignment == 32)) {
      positionComparor = Integer.MIN_VALUE;
    }
    GraphicalEditPart fitnessPart = null;
    for (Iterator iter = editparts.iterator(); iter.hasNext();)
    {
      GraphicalEditPart part = (GraphicalEditPart)iter.next();
      Rectangle rectPart = part.getFigure().getBounds();
      switch (alignment)
      {
      case 1: 
        if (getLeftx < positionComparor)
        {
          fitnessPart = part;
          positionComparor = getLeftx;
        }
        break;
      case 4: 
        if (getRightx > positionComparor)
        {
          fitnessPart = part;
          positionComparor = getRightx;
        }
        break;
      case 8: 
        if (getTopy < positionComparor)
        {
          fitnessPart = part;
          positionComparor = getTopy;
        }
        break;
      case 32: 
        if (getBottomy > positionComparor)
        {
          fitnessPart = part;
          positionComparor = getBottomy;
        }
        break;
      }
    }
    return fitnessPart;
  }
  
  protected boolean calculateEnabled()
  {
    operationSet = null;
    Command cmd = createAlignmentCommand();
    if (cmd == null) {
      return false;
    }
    return cmd.canExecute();
  }
  
  private Command createAlignmentCommand()
  {
    AlignmentRequest request = new AlignmentRequest(
      "align");
    request.setAlignmentRectangle(calculateAlignmentRectangle(request));
    request.setAlignment(alignment);
    List editparts = getOperationSet(request);
    if (editparts.size() < 2) {
      return null;
    }
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel(getText());
    for (int i = 0; i < editparts.size(); i++)
    {
      EditPart editpart = (EditPart)editparts.get(i);
      command.add(editpart.getCommand(request));
    }
    return command;
  }
  
  public void dispose()
  {
    operationSet = Collections.EMPTY_LIST;
    super.dispose();
  }
  
  protected List getOperationSet(Request request)
  {
    if (operationSet != null) {
      return operationSet;
    }
    List editparts = new ArrayList(getSelectedObjects());
    if ((editparts.isEmpty()) || 
      (!(editparts.get(0) instanceof GraphicalEditPart))) {
      return Collections.EMPTY_LIST;
    }
    Object primary = editparts.get(editparts.size() - 1);
    editparts = ToolUtilities.getSelectionWithoutDependants(editparts);
    ToolUtilities.filterEditPartsUnderstanding(editparts, request);
    if ((editparts.size() < 2) || (!editparts.contains(primary))) {
      return Collections.EMPTY_LIST;
    }
    EditPart parent = ((EditPart)editparts.get(0)).getParent();
    for (int i = 1; i < editparts.size(); i++)
    {
      EditPart part = (EditPart)editparts.get(i);
      if (part.getParent() != parent) {
        return Collections.EMPTY_LIST;
      }
    }
    return editparts;
  }
  
  protected void initUI()
  {
    switch (alignment)
    {
    case 1: 
      setId("org.eclipse.gef.align_left");
      setText(EditorMessages.AlignmentAction_AlignLeftAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignLeftAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_LEFT);
      setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_LEFT_DIS);
      break;
    case 4: 
      setId("org.eclipse.gef.align_right");
      setText(EditorMessages.AlignmentAction_AlignRightAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignRightAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_RIGHT);
      setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_RIGHT_DIS);
      break;
    case 8: 
      setId("org.eclipse.gef.align_top");
      setText(EditorMessages.AlignmentAction_AlignTopAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignTopAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_VERT_ALIGN_TOP);
      setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_TOP_DIS);
      break;
    case 32: 
      setId("org.eclipse.gef.align_bottom");
      setText(EditorMessages.AlignmentAction_AlignBottomAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignBottomAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_VERT_ALIGN_BOTTOM);
      setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_BOTTOM_DIS);
      break;
    case 2: 
      setId("org.eclipse.gef.align_center");
      setText(EditorMessages.AlignmentAction_AlignCenterAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignCenterAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_CENTER);
      setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_CENTER_DIS);
      break;
    case 16: 
      setId("org.eclipse.gef.align_middle");
      setText(EditorMessages.AlignmentAction_AlignMiddleAction_Label);
      setToolTipText(EditorMessages.AlignmentAction_AlignMiddleAction_Tooltip);
      setImageDescriptor(InternalImages.DESC_VERT_ALIGN_MIDDLE);
      setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_MIDDLE_DIS);
    }
  }
  
  public void run()
  {
    operationSet = null;
    execute(createAlignmentCommand());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.AlignmentAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action;

import org.eclipse.jface.resource.ImageDescriptor;

public class InternalImages
{
  public static final ImageDescriptor DESC_HORZ_ALIGN_CENTER;
  public static final ImageDescriptor DESC_HORZ_ALIGN_LEFT;
  public static final ImageDescriptor DESC_HORZ_ALIGN_RIGHT;
  public static final ImageDescriptor DESC_VERT_ALIGN_MIDDLE;
  public static final ImageDescriptor DESC_VERT_ALIGN_TOP;
  public static final ImageDescriptor DESC_VERT_ALIGN_BOTTOM = createDescriptor("icons/alignbottom.gif");
  public static final ImageDescriptor DESC_HORZ_ALIGN_CENTER_DIS;
  public static final ImageDescriptor DESC_HORZ_ALIGN_LEFT_DIS;
  
  static
  {
    DESC_HORZ_ALIGN_CENTER = createDescriptor("icons/aligncenter.gif");
    DESC_HORZ_ALIGN_LEFT = createDescriptor("icons/alignleft.gif");
    DESC_VERT_ALIGN_MIDDLE = createDescriptor("icons/alignmid.gif");
    DESC_HORZ_ALIGN_RIGHT = createDescriptor("icons/alignright.gif");
    DESC_VERT_ALIGN_TOP = createDescriptor("icons/aligntop.gif");
    DESC_VERT_ALIGN_BOTTOM_DIS = createDescriptor("icons/alignbottom_d.gif");
    DESC_HORZ_ALIGN_CENTER_DIS = createDescriptor("icons/aligncenter_d.gif");
    DESC_HORZ_ALIGN_LEFT_DIS = createDescriptor("icons/alignleft_d.gif");
    DESC_VERT_ALIGN_MIDDLE_DIS = createDescriptor("icons/alignmid_d.gif");
  }
  
  public static final ImageDescriptor DESC_HORZ_ALIGN_RIGHT_DIS = createDescriptor("icons/alignright_d.gif");
  public static final ImageDescriptor DESC_VERT_ALIGN_MIDDLE_DIS;
  public static final ImageDescriptor DESC_VERT_ALIGN_TOP_DIS = createDescriptor("icons/aligntop_d.gif");
  public static final ImageDescriptor DESC_VERT_ALIGN_BOTTOM_DIS;
  
  private static ImageDescriptor createDescriptor(String filename)
  {
    return ImageDescriptor.createFromFile(InternalImages.class, filename);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.InternalImages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action;

import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;
import org.eclipse.ui.IWorkbenchPart;

public class OpenEditorAction
  extends SelectionAction
{
  public static final String OPEN_EDITOR_REQUEST = PageflowMessages.Pageflow_Commands_OpenEditorCommand_Label;
  Request request;
  
  public OpenEditorAction(IWorkbenchPart part)
  {
    super(part);
    request = new Request(OPEN_EDITOR_REQUEST);
    
    setText(PageflowMessages.Pageflow_Action_OpenEditor_Label);
    setId("org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor");
    
    setToolTipText(PageflowMessages.Pageflow_Action_OpenEditor_ToolTip);
  }
  
  protected boolean calculateEnabled()
  {
    return canPerformAction();
  }
  
  private boolean canPerformAction()
  {
    if (getSelectedObjects().isEmpty()) {
      return false;
    }
    List parts = getSelectedObjects();
    for (int i = 0; i < parts.size(); i++)
    {
      Object o = parts.get(i);
      if (!(o instanceof EditPart)) {
        return false;
      }
      EditPart part = (EditPart)o;
      if (!(part.getModel() instanceof PageflowPage)) {
        return false;
      }
    }
    return true;
  }
  
  private Command getCommand()
  {
    List editparts = getSelectedObjects();
    CompoundCommand cc = new CompoundCommand();
    cc.setDebugLabel(OPEN_EDITOR_REQUEST);
    for (int i = 0; i < editparts.size(); i++)
    {
      EditPart part = (EditPart)editparts.get(i);
      cc.add(part.getCommand(request));
    }
    return cc;
  }
  
  public void run()
  {
    execute(getCommand());
  }
  
  protected void execute(Command command)
  {
    if ((command == null) || (!command.canExecute())) {
      return;
    }
    command.execute();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.OpenEditorAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action;

import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

public class ShowPropertyViewAction
  extends SelectionAction
{
  private static final Logger log = EditorPlugin.getLogger(ShowPropertyViewAction.class);
  public static final String SHOW_PROPERTY_VIEW = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction";
  
  public ShowPropertyViewAction(IWorkbenchPart part)
  {
    super(part);
    
    setText(PageflowMessages.Pageflow_Action_ShowPropertyView_Label);
    setId("org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction");
    
    setToolTipText(PageflowMessages.Pageflow_Action_ShowPropertyView_ToolTip);
  }
  
  protected boolean calculateEnabled()
  {
    return canPerformAction();
  }
  
  private boolean canPerformAction()
  {
    if (getSelectedObjects().isEmpty()) {
      return false;
    }
    List parts = getSelectedObjects();
    for (int i = 0; i < parts.size(); i++)
    {
      Object o = parts.get(i);
      if (!(o instanceof EditPart)) {
        return false;
      }
      EditPart part = (EditPart)o;
      if (!(part.getModel() instanceof PageflowElement)) {
        return false;
      }
    }
    return true;
  }
  
  public void run()
  {
    List editparts = getSelectedObjects();
    if (editparts.size() > 0)
    {
      EditPart part = (EditPart)editparts.get(0);
      if ((part.getModel() instanceof PageflowElement))
      {
        IWorkbenchWindow dw = PlatformUI.getWorkbench()
          .getActiveWorkbenchWindow();
        IWorkbenchPage page = dw.getActivePage();
        if (page != null) {
          try
          {
            page.showView("org.eclipse.ui.views.PropertySheet");
          }
          catch (PartInitException e)
          {
            log.error(
              "Pageflow.PageflowEditor.Error.canNotShowPropertyView", 
              e);
          }
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.gef.commands.Command;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;

abstract class AbstractBatchEditCommand
  extends Command
{
  Pageflow pageflow;
  
  public AbstractBatchEditCommand(Pageflow pageflow)
  {
    this(pageflow, null);
  }
  
  public AbstractBatchEditCommand(Pageflow pageflow, String label)
  {
    super(label);
    this.pageflow = pageflow;
  }
  
  public Pageflow getPageflow()
  {
    return pageflow;
  }
  
  public final void execute()
  {
    preExecute();
    doExecute();
    postExecute();
  }
  
  public final void redo()
  {
    doRedo();
  }
  
  public final void undo()
  {
    preExecute();
    doUndo();
    postExecute();
  }
  
  public abstract void doExecute();
  
  public void doRedo()
  {
    execute();
  }
  
  abstract void doUndo();
  
  final void preExecute()
  {
    getPageflow().eNotify(
      new ENotificationImpl((InternalEObject)getPageflow(), 
      11, 
      0, null, null));
  }
  
  protected final void postExecute()
  {
    getPageflow().eNotify(
      new ENotificationImpl((InternalEObject)getPageflow(), 
      12, 
      0, null, null));
    notifyPageflow(getPageflow());
  }
  
  protected void notifyPageflow(Pageflow pageflow_)
  {
    pageflow_.notifyModelChanged(new ENotificationImpl(
      (InternalEObject)pageflow_, 3, 
      0, null, null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.AbstractBatchEditCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.layout.PageflowLayoutManager;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation;

public class AddConnectionCommand
  extends ConnectionCommand
{
  public boolean canExecute()
  {
    if (link == null) {
      return false;
    }
    if ((oldSource == null) && (oldTarget == null))
    {
      if ((source == null) || (target == null)) {
        return false;
      }
      if (!PageflowValidation.getInstance().isValidLinkForCreation(
        source, target)) {
        return false;
      }
    }
    return true;
  }
  
  public void doExecute()
  {
    if ((canExecute()) && (oldSource == null) && (oldTarget == null))
    {
      Pageflow pageflow = null;
      if (source != null) {
        pageflow = source.getPageflow();
      } else if (target != null) {
        pageflow = target.getPageflow();
      }
      pageflow.connect(source, target, link);
      if (source == target) {
        PageflowLayoutManager.updateSelfLoopLink(link);
      }
    }
  }
  
  public void redo()
  {
    super.redo();
  }
  
  public void undo()
  {
    if (canExecute()) {
      if ((oldSource == null) && (oldTarget == null))
      {
        Pageflow pageflow = null;
        if (source != null) {
          pageflow = source.getPageflow();
        } else if (target != null) {
          pageflow = target.getPageflow();
        }
        link.setSource(null);
        link.setTarget(null);
        
        pageflow.getLinks().remove(link);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.AddConnectionCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.commands.Command;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class AddNodeCommand
  extends Command
{
  private PageflowNode child;
  private Pageflow parent;
  private int index = -1;
  
  public AddNodeCommand()
  {
    super(PageflowMessages.Pageflow_Commands_AddNodeCommand_Label);
  }
  
  public void execute()
  {
    if (index < 0) {
      parent.getNodes().add(child);
    } else {
      parent.getNodes().add(index, child);
    }
  }
  
  public void redo()
  {
    if (index < 0) {
      parent.getNodes().add(child);
    } else {
      parent.getNodes().add(index, child);
    }
  }
  
  public void undo()
  {
    parent.getNodes().remove(child);
  }
  
  public Pageflow getParent()
  {
    return parent;
  }
  
  public void setChild(PageflowNode subpart)
  {
    child = subpart;
  }
  
  public void setIndex(int i)
  {
    index = i;
  }
  
  public void setParent(Pageflow newParent)
  {
    parent = newParent;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.AddNodeCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.commands.Command;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;

abstract class BendpointCommand
  extends Command
{
  protected int index;
  protected Point location;
  protected PageflowLink link;
  private Dimension dimStart;
  private Dimension dimEnd;
  
  public BendpointCommand(String label)
  {
    super(label);
  }
  
  protected Dimension getFirstRelativeDimension()
  {
    return dimStart;
  }
  
  protected Dimension getSecondRelativeDimension()
  {
    return dimEnd;
  }
  
  protected int getIndex()
  {
    return index;
  }
  
  protected Point getLocation()
  {
    return location;
  }
  
  protected PageflowLink getPFLink()
  {
    return link;
  }
  
  public void redo()
  {
    execute();
  }
  
  public void setRelativeDimensions(Dimension dim1, Dimension dim2)
  {
    dimStart = dim1;
    dimEnd = dim2;
  }
  
  public void setIndex(int i)
  {
    index = i;
  }
  
  public void setLocation(Point p)
  {
    location = p;
  }
  
  public void setPFLink(PageflowLink newLink)
  {
    link = newLink;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.BendpointCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.gef.commands.Command;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil;

public abstract class ConnectionCommand
  extends Command
{
  protected PageflowNode oldSource;
  protected PageflowNode oldTarget;
  protected PageflowNode source;
  protected PageflowNode target;
  protected PageflowLink link;
  
  public ConnectionCommand()
  {
    super(PageflowMessages.Pageflow_Commands_ConnectionCommand_Label);
  }
  
  public boolean canExecute()
  {
    return TransformUtil.isValidPageflowElement(link);
  }
  
  protected void doExecute() {}
  
  public final void execute()
  {
    if (canExecute()) {
      doExecute();
    } else {
      link = null;
    }
  }
  
  public void redo()
  {
    execute();
  }
  
  public void undo() {}
  
  public PageflowNode getSource()
  {
    return source;
  }
  
  public PageflowNode getTarget()
  {
    return target;
  }
  
  public PageflowLink getPFLink()
  {
    return link;
  }
  
  public void setSource(PageflowNode newSource)
  {
    source = newSource;
  }
  
  public void setTarget(PageflowNode newTarget)
  {
    target = newTarget;
  }
  
  public void setPFLink(PageflowLink link)
  {
    this.link = link;
    oldSource = link.getSource();
    oldTarget = link.getTarget();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.gef.Request;

public class ConnectionCommandFactory
{
  public static ConnectionCommand createCommand(Request request)
  {
    ConnectionCommand command = null;
    if ((request.getType() == "connection start") || 
      (request.getType() == "connection end")) {
      command = new AddConnectionCommand();
    } else if ((request.getType() == "Reconnection source") || 
      (request.getType() == "Reconnection target")) {
      command = new ReconnectConnectionCommand();
    } else if (request.getType() == "delete") {
      command = new DeleteConnectionCommand();
    }
    return command;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommandFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import java.util.Map;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage;

public class CreateBendpointCommand
  extends BendpointCommand
{
  public CreateBendpointCommand()
  {
    super(PageflowMessages.Pageflow_Commands_CreateBendpointCommand_Label);
  }
  
  public void execute()
  {
    Map registry = EPackage.Registry.INSTANCE;
    String pageflowURI = "http://www.sybase.com/suade/pageflow";
    PageflowPackage pageflowPackage = 
      (PageflowPackage)registry.get(pageflowURI);
    PageflowFactory factory = pageflowPackage.getPageflowFactory();
    PageflowLinkBendpoint _newBendpoint = factory.createPFLinkBendpoint();
    
    _newBendpoint.setRelativeDimensions(getFirstRelativeDimension(), 
      getSecondRelativeDimension());
    getPFLink().insertBendpoint(getIndex(), _newBendpoint);
    super.execute();
  }
  
  public void undo()
  {
    super.undo();
    getPFLink().removeBendpoint(getIndex());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateBendpointCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.commands.Command;
import org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog;
import org.eclipse.jst.jsf.common.ui.internal.guiutils.Alerts;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation;
import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;

public class CreateNodeCommand
  extends Command
  implements IPreExecuteCommand
{
  private static final String UNNAMED_NODE = "unnamed";
  private PageflowNode child;
  private Rectangle rect;
  private Pageflow parent;
  
  public CreateNodeCommand()
  {
    super(PageflowMessages.Pageflow_Commands_CreateNodeCommand_Label);
  }
  
  public boolean canExecute()
  {
    return (child != null) && (parent != null);
  }
  
  public void execute()
  {
    if (rect != null)
    {
      child.setX(rect.x);
      child.setY(rect.y);
      if (!rect.isEmpty())
      {
        child.setHeight(rect.getSize().height);
        child.setWidth(rect.getSize().width);
      }
    }
    if (child.getName() == "unnamed") {
      child.setName(parent.getDefaultNodeName(child.getClass()));
    }
    parent.getNodes().add(child);
  }
  
  public void redo()
  {
    if (rect != null)
    {
      child.setX(rect.x);
      child.setY(rect.y);
      if (!rect.isEmpty())
      {
        child.setHeight(rect.getSize().height);
        child.setWidth(rect.getSize().width);
      }
    }
    parent.getNodes().add(child);
  }
  
  public void undo()
  {
    parent.getNodes().remove(child);
  }
  
  private boolean selectJSPPage()
  {
    Shell shell = null;
    IWorkbenchWindow workbenchWindow = 
      EditorPlugin.getActiveWorkbenchWindow();
    if (workbenchWindow.getShell() != null) {
      shell = workbenchWindow.getShell();
    } else {
      shell = new Shell();
    }
    IProject project = WebrootUtil.getProject(getParent());
    
    CommonResourceDialog dialog = new CommonResourceDialog(shell, project, 
      0);
    
    dialog
      .setTitle(PageflowMessages.Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Title);
    
    dialog.setSuffixs(null);
    dialog
      .setResourceDescription(PageflowMessages.Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Description);
    if (dialog.open() == 0)
    {
      Object[] result = dialog.getResult();
      if (result != null)
      {
        IFile jspFile = (IFile)result[0];
        if (jspFile != null)
        {
          String jsfSelection = WebrootUtil.getWebPath(jspFile
            .getFullPath());
          if ((jsfSelection != null) && (jsfSelection.length() > 0))
          {
            if (PageflowValidation.getInstance().isExistedPage(
              parent, jsfSelection))
            {
              EditorPlugin.getAlerts().error(
                "Pageflow.PageflowEditor.Alert.DNDResourceTitle", 
                "Pageflow.PageflowEditor.Alert.ExistingPage", 
                jsfSelection);
              return false;
            }
            ((PageflowPage)child).setPath(jsfSelection);
            ((PageflowPage)child).setName(
              WebrootUtil.getPageNameFromWebPath(jsfSelection));
          }
          return true;
        }
      }
    }
    return false;
  }
  
  public Pageflow getParent()
  {
    return parent;
  }
  
  public void setChild(PageflowNode subpart)
  {
    child = subpart;
  }
  
  public void setLocation(Rectangle r)
  {
    rect = r;
  }
  
  public void setParent(Pageflow newParent)
  {
    parent = newParent;
  }
  
  public boolean preExecute()
  {
    if ((child instanceof PageflowPage)) {
      if (((PageflowPage)child).getPath() != null)
      {
        if (PageflowValidation.getInstance().isExistedPage(parent, 
          (PageflowPage)child))
        {
          EditorPlugin.getAlerts().error(
            "Pageflow.PageflowEditor.Alert.DNDResourceTitle", 
            "Pageflow.PageflowEditor.Alert.ExistingPage", 
            ((PageflowPage)child).getPath());
          return false;
        }
      }
      else {
        return selectJSPPage();
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateNodeCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import java.util.EventObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.commands.CommandStackListener;
import org.eclipse.gef.commands.UnexecutableCommand;

public class DelegatingCommandStack
  extends CommandStack
  implements CommandStackListener
{
  private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
  private CommandStack currentCommandStack = null;
  
  public CommandStack getCurrentCommandStack()
  {
    return currentCommandStack;
  }
  
  public void setCurrentCommandStack(CommandStack stack)
  {
    if (currentCommandStack == stack) {
      return;
    }
    if (currentCommandStack != null) {
      currentCommandStack.removeCommandStackListener(this);
    }
    currentCommandStack = stack;
    if (currentCommandStack != null)
    {
      currentCommandStack.addCommandStackListener(this);
      
      notifyListeners();
    }
  }
  
  public boolean canRedo()
  {
    if (currentCommandStack == null) {
      return false;
    }
    return currentCommandStack.canRedo();
  }
  
  public boolean canUndo()
  {
    if (currentCommandStack == null) {
      return false;
    }
    return currentCommandStack.canUndo();
  }
  
  public void dispose()
  {
    if (currentCommandStack != null) {
      currentCommandStack.dispose();
    }
  }
  
  public void execute(Command command)
  {
    if (currentCommandStack != null) {
      currentCommandStack.execute(command);
    }
  }
  
  public void flush()
  {
    if (currentCommandStack != null) {
      currentCommandStack.flush();
    }
  }
  
  public Object[] getCommands()
  {
    if (currentCommandStack == null) {
      return EMPTY_OBJECT_ARRAY;
    }
    return currentCommandStack.getCommands();
  }
  
  public Command getRedoCommand()
  {
    if (currentCommandStack == null) {
      return UnexecutableCommand.INSTANCE;
    }
    return currentCommandStack.getRedoCommand();
  }
  
  public Command getUndoCommand()
  {
    if (currentCommandStack == null) {
      return UnexecutableCommand.INSTANCE;
    }
    return currentCommandStack.getUndoCommand();
  }
  
  public int getUndoLimit()
  {
    if (currentCommandStack == null) {
      return -1;
    }
    return currentCommandStack.getUndoLimit();
  }
  
  public boolean isDirty()
  {
    if (currentCommandStack == null) {
      return false;
    }
    return currentCommandStack.isDirty();
  }
  
  public void markSaveLocation()
  {
    if (currentCommandStack != null) {
      currentCommandStack.markSaveLocation();
    }
  }
  
  public void redo()
  {
    if (currentCommandStack != null) {
      currentCommandStack.redo();
    }
  }
  
  public void setUndoLimit(int undoLimit)
  {
    if (currentCommandStack != null) {
      currentCommandStack.setUndoLimit(undoLimit);
    }
  }
  
  public void undo()
  {
    if (currentCommandStack != null) {
      currentCommandStack.undo();
    }
  }
  
  public String toString()
  {
    return "DelegatingCommandStack(" + currentCommandStack + ")";
  }
  
  public void commandStackChanged(EventObject event)
  {
    notifyListeners();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DelegatingCommandStack
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint;

public class DeleteBendpointCommand
  extends BendpointCommand
{
  private PageflowLinkBendpoint bendpoint;
  
  public DeleteBendpointCommand()
  {
    super(PageflowMessages.Pageflow_Commands_DeleteBendpointCommand_Label);
  }
  
  public void execute()
  {
    super.execute();
    bendpoint = ((PageflowLinkBendpoint)getPFLink().getBendPoints().get(
      getIndex()));
    getPFLink().removeBendpoint(getIndex());
  }
  
  public void undo()
  {
    super.undo();
    getPFLink().insertBendpoint(getIndex(), bendpoint);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteBendpointCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class DeleteConnectionCommand
  extends ConnectionCommand
{
  public boolean canExecute()
  {
    return link != null;
  }
  
  protected void doExecute()
  {
    if (link != null)
    {
      link.setSource(null);
      link.setTarget(null);
      oldSource.getPageflow().getLinks().remove(link);
      link.eAdapters().clear();
    }
  }
  
  public void undo()
  {
    if (canExecute())
    {
      link.setSource(oldSource);
      link.setTarget(oldTarget);
      oldSource.getPageflow().getLinks().add(link);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteConnectionCommand
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class DeleteNodeCommand
  extends AbstractBatchEditCommand
{
  private PageflowNode child;
  private Pageflow parent;
  private int index = -1;
  private List sourceConnections = new ArrayList();
  private List sourceConnectionSources = new ArrayList();
  private List sourceConnectionTargets = new ArrayList();
  private List targetConnections = new ArrayList();
  private List targetConnectionSources = new ArrayList();
  private List targetConnectionTargets = new ArrayList();
  
  public DeleteNodeCommand(Pageflow pageflow)
  {
    super(pageflow, PageflowMessages.Pageflow_Commands_DeleteNodeCommand_Label);
  }
  
  public void doExecute()
  {
    primExecute();
  }
  
  public void doRedo()
  {
    primExecute();
  }
  
  public void doUndo()
  {
    parent.getNodes().add(index, child);
    restoreConnections(child);
  }
  
  private void deleteConnections(PageflowNode node)
  {
    while (node.getOutlinks().size() > 0)
    {
      PageflowLink link = (PageflowLink)node.getOutlinks().get(0);
      sourceConnections.add(link);
      sourceConnectionSources.add(link.getSource());
      sourceConnectionTargets.add(link.getTarget());
      
      link.getTarget().getInlinks().remove(link);
      node.getOutlinks().remove(link);
      parent.getLinks().remove(link);
    }
    while (node.getInlinks().size() > 0)
    {
      PageflowLink link = (PageflowLink)node.getInlinks().get(0);
      targetConnections.add(link);
      targetConnectionSources.add(link.getSource());
      targetConnectionTargets.add(link.getTarget());
      
      link.getSource().getOutlinks().remove(link);
      node.getInlinks().remove(link);
      parent.getLinks().remove(link);
    }
  }
  
  protected void primExecute()
  {
    deleteConnections(child);
    index = parent.getNodes().indexOf(child);
    parent.getNodes().remove(child);
  }
  
  private void restoreConnections(PageflowNode node)
  {
    for (int i = 0; i < sourceConnections.size(); i++)
    {
      PageflowLink link = (PageflowLink)sourceConnections.get(i);
      PageflowNode source = (PageflowNode)sourceConnectionSources.get(i);
      PageflowNode target = (PageflowNode)sourceConnectionTargets.get(i);
      link.setSource(source);
      link.setTarget(target);
      
      parent.getLinks().add(link);
      node.getOutlinks().add(link);
      link.getTarget().getInlinks()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd