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

   .getFeatureID(PageflowPackage.class);
      if (PageflowNodeEditPart.access$2(this$0, featureId)) {
        this$0.validate();
      }
      if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
        this$0.refreshVisuals();
      } else {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            this$0.refreshVisuals();
          }
        });
      }
      break;
    }
  }
}

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

import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;

class PageflowNodeEditPart$2
  implements Runnable
{
  PageflowNodeEditPart$2(PageflowNodeEditPart paramPageflowNodeEditPart, Annotation paramAnnotation) {}
  
  public void run()
  {
    this$0.getPageflowNodeFigure().setImage(
      PageflowNodeEditPart.access$3(this$0, (PageflowElement)this$0.getModel()));
    this$0.getPageflowNodeFigure().setToolTipText(val$annotation.getText());
  }
}

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

import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;

class PageflowNodeEditPart$3
  implements Runnable
{
  PageflowNodeEditPart$3(PageflowNodeEditPart paramPageflowNodeEditPart) {}
  
  public void run()
  {
    this$0.getPageflowNodeFigure().setImage(
      this$0.getImage((PageflowElement)this$0.getModel()));
    this$0.getPageflowNodeFigure().setToolTipText(null);
  }
}

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

import org.eclipse.jdt.ui.JavaElementImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.ILabelDecorator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

class PageflowNodeEditPart$ImageDecorator
  implements ILabelDecorator
{
  private Image decrateImage = null;
  
  private PageflowNodeEditPart$ImageDecorator(PageflowNodeEditPart paramPageflowNodeEditPart) {}
  
  public Image decorateImage(Image image, Object element)
  {
    dispose();
    int adornmentFlags = computeAdornmentFlags(element);
    if (adornmentFlags != 0)
    {
      ImageDescriptor baseImage = ImageDescriptor.createFromImage(image);
      Rectangle bounds = image.getBounds();
      decrateImage = new JavaElementImageDescriptor(baseImage, 
        adornmentFlags, new Point(
        width, height)).createImage();
      return decrateImage;
    }
    return image;
  }
  
  protected int computeAdornmentFlags(Object obj)
  {
    return 32;
  }
  
  public void dispose()
  {
    if (decrateImage != null) {
      decrateImage.dispose();
    }
  }
  
  public String decorateText(String text, Object element)
  {
    return null;
  }
}

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

import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.Label;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.NodeEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.DropRequest;
import org.eclipse.gef.tools.DirectEditManager;
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OpenEditorCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowElementEditPolicy;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowNodeDirectEditPolicy;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowNodeEditPolicy;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.ILabelDecorator;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;
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.model.PageflowPackage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class PageflowNodeEditPart
  extends PageflowElementEditPart
  implements NodeEditPart, INodePreference, PFValidator
{
  protected DirectEditManager editManager;
  
  private class ImageDecorator
    implements ILabelDecorator
  {
    private Image decrateImage = null;
    
    private ImageDecorator() {}
    
    public Image decorateImage(Image image, Object element)
    {
      dispose();
      int adornmentFlags = computeAdornmentFlags(element);
      if (adornmentFlags != 0)
      {
        ImageDescriptor baseImage = ImageDescriptor.createFromImage(image);
        Rectangle bounds = image.getBounds();
        decrateImage = new JavaElementImageDescriptor(baseImage, 
          adornmentFlags, new org.eclipse.swt.graphics.Point(
          width, height)).createImage();
        return decrateImage;
      }
      return image;
    }
    
    protected int computeAdornmentFlags(Object obj)
    {
      return 32;
    }
    
    public void dispose()
    {
      if (decrateImage != null) {
        decrateImage.dispose();
      }
    }
    
    public String decorateText(String text, Object element)
    {
      return null;
    }
  }
  
  public void dispose()
  {
    if (imageDecorator != null) {
      imageDecorator.dispose();
    }
  }
  
  private ImageDecorator imageDecorator = null;
  
  public PageflowNodeEditPart(PageflowNode element)
  {
    super(element);
  }
  
  public PageflowNode getPageflowNode()
  {
    return (PageflowNode)getModel();
  }
  
  protected List getModelSourceConnections()
  {
    return getPageflowNode().getOutlinks();
  }
  
  protected List getModelTargetConnections()
  {
    return getPageflowNode().getInlinks();
  }
  
  protected PageflowNodeFigure getPageflowNodeFigure()
  {
    return (PageflowNodeFigure)getFigure();
  }
  
  public Adapter createEMFAdapter()
  {
    new PFBatchAdapter()
    {
      public void doNotifyChanged(Notification notification)
      {
        int type = notification.getEventType();
        switch (type)
        {
        case 3: 
        case 4: 
        case 5: 
        case 6: 
          if ((notification.getNewValue() instanceof PageflowLink)) {
            if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
            {
              refreshTargetConnections();
              refreshSourceConnections();
              validate();
            }
            else
            {
              PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
              {
                public void run()
                {
                  refreshTargetConnections();
                  refreshSourceConnections();
                  validate();
                }
              });
            }
          }
          break;
        case 1: 
          int featureId = notification
            .getFeatureID(PageflowPackage.class);
          if (PageflowNodeEditPart.this.needValidation(featureId)) {
            validate();
          }
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
            refreshVisuals();
          } else {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                refreshVisuals();
              }
            });
          }
          break;
        }
      }
    };
  }
  
  private boolean needValidation(int featureId)
  {
    if (((getModel() instanceof PageflowPage)) && 
      (featureId == 11)) {
      return true;
    }
    return false;
  }
  
  public void validate()
  {
    if ((getModel() instanceof PageflowPage)) {
      PageflowAnnotationUtil.validatePage(this);
    }
  }
  
  protected void createEditPolicies()
  {
    installEditPolicy("GraphicalNodeEditPolicy", 
      new PageflowNodeEditPolicy());
    
    installEditPolicy("ComponentEditPolicy", 
      new PageflowElementEditPolicy());
    
    installEditPolicy("DirectEditPolicy", 
      new PageflowNodeDirectEditPolicy());
  }
  
  public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection)
  {
    PageflowLink link = (PageflowLink)connection.getModel();
    return getPageflowNodeFigure().getSourceConnectionAnchorAt(
      new org.eclipse.draw2d.geometry.Point(link.getSource().getX(), link.getSource().getY()));
  }
  
  public ConnectionAnchor getSourceConnectionAnchor(Request request)
  {
    org.eclipse.draw2d.geometry.Point pt = new org.eclipse.draw2d.geometry.Point(((DropRequest)request).getLocation());
    return getPageflowNodeFigure().getSourceConnectionAnchorAt(pt);
  }
  
  public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection)
  {
    PageflowLink link = (PageflowLink)connection.getModel();
    return getPageflowNodeFigure().getTargetConnectionAnchorAt(
      new org.eclipse.draw2d.geometry.Point(link.getTarget().getX(), link.getTarget().getY()));
  }
  
  public ConnectionAnchor getTargetConnectionAnchor(Request request)
  {
    org.eclipse.draw2d.geometry.Point pt = new org.eclipse.draw2d.geometry.Point(((DropRequest)request).getLocation());
    return getPageflowNodeFigure().getTargetConnectionAnchorAt(pt);
  }
  
  protected void refreshVisuals()
  {
    super.refreshVisuals();
    
    getPageflowNodeFigure().setText(getPageflowNode().getName());
  }
  
  public void activate()
  {
    super.activate();
    
    Iterator it = getPageflowNode().getInlinks().iterator();
    while (it.hasNext())
    {
      PageflowLink link = (PageflowLink)it.next();
      
      hookIntoPageflowElement(link);
    }
    it = getPageflowNode().getOutlinks().iterator();
    while (it.hasNext())
    {
      PageflowLink link = (PageflowLink)it.next();
      
      hookIntoPageflowElement(link);
    }
  }
  
  public void deactivate()
  {
    super.deactivate();
    dispose();
    
    Iterator it = getPageflowNode().getInlinks().iterator();
    while (it.hasNext())
    {
      PageflowLink link = (PageflowLink)it.next();
      
      unhookFromPageflowElement(link);
    }
    it = getPageflowNode().getOutlinks().iterator();
    while (it.hasNext())
    {
      PageflowLink link = (PageflowLink)it.next();
      
      unhookFromPageflowElement(link);
    }
  }
  
  protected void performDirectEdit()
  {
    if (editManager == null)
    {
      Label l = ((PageflowNodeFigure)getFigure()).getLabel();
      editManager = new PageflowDirectEditManager(this, 
        TextCellEditor.class, new DirectEditCellEditorLocator(l), l);
    }
    editManager.show();
  }
  
  protected void performOpen()
  {
    if ((getModel() instanceof PageflowPage))
    {
      Command command = new OpenEditorCommand(this);
      if ((command != null) && (command.canExecute())) {
        command.execute();
      }
    }
  }
  
  public void setForegroundColor(Color c)
  {
    getPageflowNodeFigure().setForegroundColor(c);
  }
  
  public void setBackgroundColor(Color c)
  {
    getPageflowNodeFigure().setBackgroundColor(c);
  }
  
  public void setFont(Font f)
  {
    getPageflowNodeFigure().setFont(f);
  }
  
  public void setTextPlacement(int where)
  {
    getPageflowNodeFigure().setTextPlacement(where);
  }
  
  public void addAnnotation(final Annotation annotation)
  {
    getViewer().getControl().getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        getPageflowNodeFigure().setImage(
          PageflowNodeEditPart.this.getDecoratedImage((PageflowElement)getModel()));
        getPageflowNodeFigure().setToolTipText(annotation.getText());
      }
    });
  }
  
  public void removeAnnotation()
  {
    getViewer().getControl().getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        getPageflowNodeFigure().setImage(
          getImage((PageflowElement)getModel()));
        getPageflowNodeFigure().setToolTipText(null);
      }
    });
  }
  
  private Image getDecoratedImage(PageflowElement element)
  {
    Image decoratedImage = getImage(element);
    
    decoratedImage = getImageDecorator().decorateImage(getImage(element), 
      null);
    
    return decoratedImage;
  }
  
  private ImageDecorator getImageDecorator()
  {
    if (imageDecorator == null) {
      imageDecorator = new ImageDecorator(null);
    }
    return imageDecorator;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;

class PageflowTreeEditPart
  extends PageflowElementTreeEditPart
{
  public PageflowTreeEditPart(Pageflow pageflow)
  {
    super(pageflow);
  }
  
  protected List getModelChildren()
  {
    List children_ = getPageflow().getNodes();
    
    return new ArrayList(children_);
  }
  
  public Pageflow getPageflow()
  {
    return (Pageflow)getModel();
  }
}

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

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;

public class PageflowTreePartFactory
  implements EditPartFactory
{
  public EditPart createEditPart(EditPart context, Object model)
  {
    if ((model instanceof Pageflow)) {
      return new PageflowTreeEditPart((Pageflow)model);
    }
    if ((model instanceof PageflowElement)) {
      return new PageflowElementTreeEditPart((PageflowElement)model);
    }
    return null;
  }
}

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

import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.BendpointEditPolicy;
import org.eclipse.gef.requests.BendpointRequest;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateBendpointCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteBendpointCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.MoveBendpointCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;

public class PFLinkBendpointEditPolicy
  extends BendpointEditPolicy
{
  protected Command getCreateBendpointCommand(BendpointRequest request)
  {
    CreateBendpointCommand createCmd = new CreateBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();
    
    conn.translateToRelative(p);
    
    createCmd.setLocation(p);
    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
    
    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);
    
    createCmd.setRelativeDimensions(p.getDifference(ref1), p
      .getDifference(ref2));
    createCmd.setPFLink((PageflowLink)request.getSource().getModel());
    createCmd.setIndex(request.getIndex());
    return createCmd;
  }
  
  protected Command getDeleteBendpointCommand(BendpointRequest request)
  {
    DeleteBendpointCommand deleteCom = new DeleteBendpointCommand();
    Point p = request.getLocation();
    deleteCom.setLocation(p);
    deleteCom.setPFLink((PageflowLink)request.getSource().getModel());
    deleteCom.setIndex(request.getIndex());
    return deleteCom;
  }
  
  protected Command getMoveBendpointCommand(BendpointRequest request)
  {
    MoveBendpointCommand moveCmd = new MoveBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();
    
    conn.translateToRelative(p);
    
    moveCmd.setLocation(p);
    
    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
    
    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);
    
    moveCmd.setRelativeDimensions(p.getDifference(ref1), p
      .getDifference(ref2));
    moveCmd.setPFLink((PageflowLink)request.getSource().getModel());
    moveCmd.setIndex(request.getIndex());
    return moveCmd;
  }
}

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

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteConnectionCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;

public class PFLinkEditPolicy
  extends ConnectionEditPolicy
{
  protected Command getDeleteCommand(GroupRequest request)
  {
    ConnectionCommand c = new DeleteConnectionCommand();
    c.setPFLink((PageflowLink)getHost().getModel());
    return c;
  }
}

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

import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;

public class PFLinkEndpointEditPolicy
  extends ConnectionEndpointEditPolicy
{
  protected void addSelectionHandles()
  {
    super.addSelectionHandles();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    int connectionWidth = store.getInt("LineWidth");
    getConnectionFigure().setLineWidth(connectionWidth + 1);
  }
  
  private PolylineConnection getConnectionFigure()
  {
    return (PolylineConnection)((GraphicalEditPart)getHost()).getFigure();
  }
  
  protected void removeSelectionHandles()
  {
    super.removeSelectionHandles();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    int connectionWidth = store.getInt("LineWidth");
    getConnectionFigure().setLineWidth(connectionWidth);
  }
}

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

import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editpolicies.ContainerEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.GroupRequest;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OrphanChildCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class PageflowContainerEditPolicy
  extends ContainerEditPolicy
{
  protected Command getCreateCommand(CreateRequest request)
  {
    return null;
  }
  
  public Command getOrphanChildrenCommand(GroupRequest request)
  {
    List parts = request.getEditParts();
    CompoundCommand result = new CompoundCommand("orphanchildcommand");
    for (int i = 0; i < parts.size(); i++)
    {
      OrphanChildCommand orphan = new OrphanChildCommand();
      orphan
        .setChild((PageflowNode)((EditPart)parts.get(i))
        .getModel());
      orphan.setParent((Pageflow)getHost().getModel());
      orphan.setLabel(PageflowMessages.PageflowContainerEditPolicy_OrphanLabel);
      result.add(orphan);
    }
    return result.unwrap();
  }
}

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

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteNodeCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class PageflowElementEditPolicy
  extends ComponentEditPolicy
{
  protected Command createDeleteCommand(GroupRequest request)
  {
    Object parent = getHost().getParent().getModel();
    DeleteNodeCommand deleteCmd = new DeleteNodeCommand((Pageflow)parent);
    deleteCmd.setParent((Pageflow)parent);
    deleteCmd.setChild((PageflowNode)getHost().getModel());
    return deleteCmd;
  }
}

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

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.DirectEditPolicy;
import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.RenameNodeCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class PageflowNodeDirectEditPolicy
  extends DirectEditPolicy
{
  protected Command getDirectEditCommand(DirectEditRequest request)
  {
    RenameNodeCommand cmd = new RenameNodeCommand();
    cmd.setSource((PageflowNode)getHost().getModel());
    cmd.setOldName(((PageflowNode)getHost().getModel()).getName());
    cmd.setName((String)request.getCellEditor().getValue());
    return cmd;
  }
  
  protected void showCurrentEditValue(DirectEditRequest request) {}
}

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

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.gef.ConnectionEditPart;
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.editpolicies.GraphicalNodeEditPolicy;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.OpenEditorAction;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommandFactory;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OpenEditorCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class PageflowNodeEditPolicy
  extends GraphicalNodeEditPolicy
{
  protected Connection createDummyConnection(Request req)
  {
    PolylineConnection conn = new PolylineConnection();
    conn.setLineWidth(getLineWidth());
    conn.setForegroundColor(ColorConstants.black);
    
    return conn;
  }
  
  private int getLineWidth()
  {
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    int lineWidth = store.getInt("LineWidth");
    return lineWidth;
  }
  
  protected Command getConnectionCompleteCommand(CreateConnectionRequest request)
  {
    ConnectionCommand command = (ConnectionCommand)request
      .getStartCommand();
    
    command.setTarget(getPageflowNode());
    
    return command;
  }
  
  protected Command getConnectionCreateCommand(CreateConnectionRequest request)
  {
    ConnectionCommand command = 
      ConnectionCommandFactory.createCommand(request);
    command.setPFLink((PageflowLink)request.getNewObject());
    PageflowNode flowObject = getPageflowNode();
    command.setSource(flowObject);
    request.setStartCommand(command);
    return command;
  }
  
  protected PageflowNodeEditPart getPageflowNodeEditPart()
  {
    return (PageflowNodeEditPart)getHost();
  }
  
  protected PageflowNode getPageflowNode()
  {
    return (PageflowNode)getHost().getModel();
  }
  
  protected Command getReconnectTargetCommand(ReconnectRequest request)
  {
    ConnectionCommand cmd = ConnectionCommandFactory.createCommand(request);
    cmd
      .setPFLink((PageflowLink)request.getConnectionEditPart()
      .getModel());
    cmd.setTarget(getPageflowNode());
    return cmd;
  }
  
  protected Command getReconnectSourceCommand(ReconnectRequest request)
  {
    ConnectionCommand cmd = ConnectionCommandFactory.createCommand(request);
    cmd
      .setPFLink((PageflowLink)request.getConnectionEditPart()
      .getModel());
    cmd.setSource(getPageflowNode());
    return cmd;
  }
  
  public Command getCommand(Request request)
  {
    if (OpenEditorAction.OPEN_EDITOR_REQUEST.equals(request.getType())) {
      return new OpenEditorCommand(getHost());
    }
    return super.getCommand(request);
  }
  
  protected PageflowNodeFigure getPageflowNodeFigure()
  {
    return (PageflowNodeFigure)((GraphicalEditPart)getHost()).getFigure();
  }
}

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

import org.eclipse.gef.editpolicies.NonResizableEditPolicy;

public class PageflowNodeSelectionEditPolicy
  extends NonResizableEditPolicy
{
  protected void hideSelection()
  {
    super.hideSelection();
  }
  
  protected void showPrimarySelection()
  {
    super.showPrimarySelection();
  }
  
  protected void showSelection()
  {
    super.showSelection();
  }
}

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

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.AddNodeCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateNodeCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.SetConstraintCommand;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;

public class PageflowXYLayoutEditPolicy
  extends XYLayoutEditPolicy
{
  protected Command createAddCommand(EditPart childEditPart, Object constraint)
  {
    PageflowNode part = (PageflowNode)childEditPart.getModel();
    Rectangle rect = (Rectangle)constraint;
    
    AddNodeCommand add = new AddNodeCommand();
    add.setParent((Pageflow)getHost().getModel());
    add.setChild(part);
    add.setLabel(PageflowMessages.PageflowXYLayoutEditPolicy_Add);
    add.setDebugLabel("PageFlowXYEP add subpart");
    
    SetConstraintCommand setConstraint = new SetConstraintCommand();
    
    setConstraint.setLocation(rect);
    setConstraint.setPart(part);
    setConstraint.setLabel(PageflowMessages.PageflowXYLayoutEditPolicy_Add);
    setConstraint.setDebugLabel("PageFlowXYEP setConstraint");
    return add.chain(setConstraint);
  }
  
  protected Command createChangeConstraintCommand(EditPart child, Object constraint)
  {
    SetConstraintCommand locationCommand = new SetConstraintCommand();
    locationCommand.setPart((PageflowNode)child.getModel());
    locationCommand.setLocation((Rectangle)constraint);
    return locationCommand;
  }
  
  protected EditPolicy createChildEditPolicy(EditPart child)
  {
    if ((child instanceof PageflowNodeEditPart)) {
      return new PageflowNodeSelectionEditPolicy();
    }
    return new ResizableEditPolicy();
  }
  
  protected Command getCreateCommand(CreateRequest request)
  {
    CreateNodeCommand create = new CreateNodeCommand();
    create.setParent((Pageflow)getHost().getModel());
    create.setChild((PageflowNode)request.getNewObject());
    Rectangle constraint = (Rectangle)getConstraintFor(request);
    create.setLocation(constraint);
    create.setLabel(PageflowMessages.PageflowXYLayoutEditPolicy_Add);
    return create;
  }
  
  protected Command getDeleteDependantCommand(Request request)
  {
    return null;
  }
  
  protected Command getOrphanChildrenCommand(Request request)
  {
    return null;
  }
}

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

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

public class ConnectionLabel
  extends Label
{
  public ConnectionLabel()
  {
    this(null, null);
  }
  
  public ConnectionLabel(String s)
  {
    this(s, null);
  }
  
  public ConnectionLabel(Image i)
  {
    this(null, i);
  }
  
  public ConnectionLabel(String s, Image i)
  {
    super(s, i);
    
    setOpaque(true);
  }
  
  public void setBorderWidth(int w)
  {
    if (getBorder() != null) {
      ((LineBorder)getBorder()).setWidth(w);
    }
  }
  
  public void setBorderColor(Color c)
  {
    if (getBorder() != null) {
      ((LineBorder)getBorder()).setColor(c);
    }
  }
}

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

import org.eclipse.swt.graphics.Image;

public abstract interface ILabelDecorator
{
  public abstract Image decorateImage(Image paramImage, Object paramObject);
  
  public abstract String decorateText(String paramString, Object paramObject);
}

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

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.swt.graphics.Image;

public class NodeLabel
  extends Label
{
  public NodeLabel() {}
  
  public NodeLabel(String s)
  {
    super(s);
  }
  
  public NodeLabel(Image i)
  {
    super(i);
  }
  
  public NodeLabel(String s, Image i)
  {
    super(s, i);
  }
  
  public void setTextPlacement(int where)
  {
    super.setTextPlacement(where);
    layout();
    invalidate();
  }
  
  public void setToolTipText(String text)
  {
    Label toolTipLabel = null;
    if ((text != null) && (text.length() > 0))
    {
      toolTipLabel = new Label(text);
      toolTipLabel.setBorder(new MarginBorder(3));
    }
    super.setToolTip(toolTipLabel);
  }
  
  public String getToolTipText()
  {
    if (getToolTip() != null) {
      return ((Label)getToolTip()).getText();
    }
    return null;
  }
}

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

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.MidpointLocator;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;

public class PFLinkFigure
  extends PolylineConnection
{
  private ConnectionLabel textLabel = null;
  private Color labelBgColor;
  private Color labelFgColor;
  private boolean bLabelVisible = false;
  private int lineWidth = 0;
  private PolygonDecoration arrow;
  
  public PFLinkFigure()
  {
    arrow = new PolygonDecoration();
    arrow.setTemplate(PolygonDecoration.TRIANGLE_TIP);
    arrow.setScale(10.0D, getLineWidth() * 2);
    setTargetDecoration(arrow);
    setForegroundColor(getForegroundColor());
  }
  
  public void setLabel(String strLabel)
  {
    if (strLabel != null)
    {
      if (textLabel == null)
      {
        textLabel = new ConnectionLabel();
        textLabel.setFont(getLabelFont());
        textLabel.setBackgroundColor(getLabelBackgroundColor());
        textLabel.setForegroundColor(getLabelForegroundColor());
        setLineWidth(getLineWidth());
        setLabelVisible(getLabelVisible());
        setForegroundColor(getForegroundColor());
        add(textLabel, new MidpointLocator(this, 1));
      }
      textLabel.setText(strLabel);
    }
  }
  
  public void clearIcon()
  {
    setImage(null);
  }
  
  public void clearOutcome()
  {
    setLabel("");
  }
  
  public void setImage(Image image)
  {
    if (textLabel == null)
    {
      textLabel = new ConnectionLabel();
      textLabel.setFont(getLabelFont());
      textLabel.setBackgroundColor(getLabelBackgroundColor());
      textLabel.setForegroundColor(getLabelForegroundColor());
      setLineWidth(getLineWidth());
      setLabelVisible(getLabelVisible());
      setForegroundColor(getForegroundColor());
      add(textLabel, new MidpointLocator(this, 0));
    }
    textLabel.setIcon(image);
  }
  
  public void setActionImage()
  {
    ImageDescriptor imageDescriptor = PageflowElementEditPart.IMG_ACTION;
    Image image = EditorPlugin.getDefault().getImageRegistry().get(
      imageDescriptor.toString());
    if (image == null)
    {
      EditorPlugin.getDefault().getImageRegistry().put(
        imageDescriptor.toString(), imageDescriptor);
      image = EditorPlugin.getDefault().getImageRegistry().get(
        imageDescriptor.toString());
    }
    setImage(image);
  }
  
  public Image getImage()
  {
    if (textLabel != null) {
      return textLabel.getIcon();
    }
    return null;
  }
  
  public void setToolTipText(String text)
  {
    Label toolTipLabel = null;
    if ((text != null) && (text.length() > 0))
    {
      toolTipLabel = new Label(text);
      toolTipLabel.setBorder(new MarginBorder(3));
    }
    super.setToolTip(toolTipLabel);
  }
  
  public String getToolTipText()
  {
    if (getToolTip() != null) {
      return ((Label)getToolTip()).getText();
    }
    return null;
  }
  
  public void setFont(Font f)
  {
    if (textLabel != null) {
      textLabel.setFont(f);
    }
    super.setFont(f);
  }
  
  private Font getLabelFont()
  {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, 
      "LineLabelFont");
    if (!registry.get(fontData.toString()).equals(registry.defaultFont())) {
      return registry.get(fontData.toString());
    }
    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
  }
  
  public void setLineWidth(int w)
  {
    if (textLabel != null) {
      textLabel.setBorderWidth(w);
    }
    arrow.setScale(10.0D, getLineWidth() * 2);
    super.setLineWidth(w);
  }
  
  public int getLineWidth()
  {
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    lineWidth = store.getInt("LineWidth");
    return lineWidth;
  }
  
  public void setLabelVisible(boolean flag)
  {
    if (textLabel != null) {
      textLabel.setVisible(flag);
    }
  }
  
  private boolean getLabelVisible()
  {
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    bLabelVisible = store.getBoolean("ShowLineLabels");
    return bLabelVisible;
  }
  
  public void setLabelForegroundColor(Color c)
  {
    labelFgColor = c;
    if (textLabel != null) {
      textLabel.setForegroundColor(c);
    }
  }
  
  private Color getLabelForegroundColor()
  {
    if (labelFgColor == null)
    {
      IPreferenceStore store = EditorPlugin.getDefault()
      
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