Commit d49da95c authored by 王业明's avatar 王业明
Browse files

初始化 BAPIDE 1.5.0

parent 646dac8e
javacDefaultEncoding.. = UTF-8
source.. = src/
output.. = bin/
bin.includes = .,\
META-INF/,\
plugin.xml,\
xml/,\
icons/
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
class="cn.com.bankit.ide.bap.business.workflow.editor.BapEditor"
contributorClass="cn.com.bankit.ide.bap.business.workflow.action.BapActionBarContributor"
extensions="bapwf"
icon="icons/workflow.png"
id="cn.com.bankit.ide.bap.business.workflow.editor.BapEditor"
name="BapEditor">
</editor>
</extension>
<extension
id="branchesMarker"
name="workflow error marker"
point="org.eclipse.core.resources.markers">
<persistent
value="true">
</persistent>
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
<attribute
name="nodeID">
</attribute>
</extension>
<extension
id="parameterMarker"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
<persistent
value="true">
</persistent>
<attribute
name="nodeID">
</attribute>
</extension>
<extension
id="valueMarker"
point="org.eclipse.core.resources.markers">
<persistent
value="true">
</persistent>
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
<attribute
name="nodeID">
</attribute>
</extension>
<extension
id="deleteMarker"
point="org.eclipse.core.resources.markers">
<attribute
name="nodeID">
</attribute>
<persistent
value="true">
</persistent>
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
</extension>
</plugin>
package cn.com.bankit.ide.bap.business.workflow;
import java.util.Collections;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import cn.com.bankit.ide.bap.business.workflow.model.AbstractModel;
import cn.com.bankit.ide.bap.business.workflow.model.RootModel;
import cn.com.bankit.ide.bap.business.workflow.model.StepNodeModel;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.util.BapSysResManager;
import cn.com.bankit.ide.common.diagram.model.CommonNodeModel;
/**
* The activator class controls the plug-in life cycle
*/
public class BapWorkflowActivator extends AbstractUIPlugin
{
// The plug-in ID
public static final String PLUGIN_ID = "cn.com.bankit.ide.bap.business.workflow"; //$NON-NLS-1$
// The shared instance
private static BapWorkflowActivator plugin;
/**
* The constructor
*/
public BapWorkflowActivator()
{
}
/*
* (non-Javadoc)
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception
{
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception
{
plugin = null;
BapSysResManager.getInstance().dispose();
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static BapWorkflowActivator getDefault()
{
return plugin;
}
//如下方法已经转移到util下面的BapUtil里面
//
// //模板目录
// public static IContainer getTemplateFolder(IProject project)
// {
//
// IContainer template = project.getWorkspace().getRoot().getProject(NavigatorConstants.NV_NODE_PUBRES);
//
// if (template.exists())
// {
// template = (IContainer) template.findMember(NavigatorConstants.NV_NODE_PUBTMP);
// if (null != template && template.exists())
// {
// return template;
// }
// }
// return null;
// }
// //业务组件目录
// public static IContainer getBizCmpFolder(IProject project)
// {
//
// IContainer bizcmp = project.getWorkspace().getRoot().getProject(NavigatorConstants.NV_NODE_PUBRES);
//
// if (bizcmp.exists())
// {
// bizcmp = (IContainer) bizcmp.findMember(NavigatorConstants.NV_NODE_CMPRES + File.separator
// + NavigatorConstants.NV_NODE_BIZCMP);
// if (null != bizcmp && bizcmp.exists())
// {
// return bizcmp;
// }
// }
// return null;
// }
public static void refactoryNodeID(RootModel rm)
{
if (BapPreActivator.getDefault().getPreferenceStore()
.getBoolean(IBapConstants.BAP_PREF_R_NODE_ID))
{
//steps
AbstractModel cnm = (AbstractModel) rm.getChildren().get(0);
refactoryStepNodeId(cnm);
}
}
/**
* 重构step node‘s ID
* @param cnm
* steps
*/
public static void refactoryStepNodeId(AbstractModel cnm)
{
List children = cnm.getChildren();
Collections.sort(children);
int index = 1;
List<AbstractModel> tempchildren = children;
for (AbstractModel child : tempchildren)
{
child.setIndex(index + "");
index++;
refactoryWorkflowNodeId(child);
}
//恢复为最大值
cnm.setNodeIndex(index);
}
/**
* 重构workflow 's ID
* @param cnm
* step
*/
public static void refactoryWorkflowNodeId(CommonNodeModel cnm)
{
StepNodeModel snm = (StepNodeModel) cnm;
if (snm.getWorkflowsModel() != null)
{
List children = snm.getWorkflowsModel().getChildren();
Collections.sort(children);
int index = 1;
List<AbstractModel> tempchildren = children;
for (AbstractModel child : tempchildren)
{
child.setIndex(index + "");
index++;
}
//恢复为最大值
snm.getWorkflowsModel().setNodeIndex(index);
}
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path)
{
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
/**
* Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company.
*
* 特别声明:本技术材料受《中华人民共和国着作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明!
*
* Copyright(C) 2012 Bankit Tech, All rights reserved.
*/
package cn.com.bankit.ide.bap.business.workflow.action;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import cn.com.bankit.ide.bap.business.workflow.layout.BAPNodeVisitor;
import cn.com.bankit.ide.bap.business.workflow.model.StepNodeModel;
import cn.com.bankit.ide.bap.business.workflow.part.RootEditPart;
import cn.com.bankit.ide.common.auto.layout.model.AbstractTreeNode;
import cn.com.bankit.ide.common.diagram.command.ChangeBoundsCommand;
import cn.com.bankit.ide.common.diagram.model.CommonNodeModel;
/**
* @author 朱克平
* @author 浙江宇信班克信息技术有限公司
* 2012-5-17 上午9:29:37
*/
public class AutoLayoutAction extends BapSelectionAction
{
public static final String ID = "bap.auto.layout";
BAPNodeVisitor visitor = new BAPNodeVisitor();
public AutoLayoutAction(IWorkbenchPart part)
{
super(part);
}
protected void init()
{
super.init();
setId(ID);
ISharedImages sharedImages = PlatformUI.getWorkbench()
.getSharedImages();
setImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
setDisabledImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED_DISABLED));
setText("自动布局");
}
@SuppressWarnings("rawtypes")
@Override
protected boolean calculateEnabled()
{
List result = getSelectedObjects();
if (result.size() == 1)
{
Object obj = result.get(0);
return (obj instanceof RootEditPart);
}
return false;
}
@SuppressWarnings("rawtypes")
public void run()
{
List result = getSelectedObjects();
if (result.size() == 1)
{
Object obj = result.get(0);
if (obj instanceof RootEditPart)
{
RootEditPart objTemp = (RootEditPart) obj;
CommonNodeModel cnm = (CommonNodeModel) objTemp.getModel();
cnm = cnm.getChildren().get(0);
for (CommonNodeModel model : cnm.getChildren())
{
StepNodeModel am = (StepNodeModel) model;
if (am.getWorkflowsModel() != null
&& am.getWorkflowsModel().isVisible()
&& am.getWorkflowsModel().getChildren().size() > 0)
{
AbstractTreeNode root = visitor.visitor(
am.getWorkflowsModel(), false);
Rectangle rect = root.getRegion();
Map<CommonNodeModel, Rectangle> r = new HashMap<CommonNodeModel, Rectangle>();
CommonNodeModel rm = am.getWorkflowsModel();
Rectangle rectTemp = getRectangle(objTemp, rm);
root.setRegion(new Rectangle(rectTemp.x, 50,
rect.width, rect.height), r);
Iterator<CommonNodeModel> it = r.keySet().iterator();
CompoundCommand cc=null;
while (it.hasNext())
{
if(cc==null)cc=new CompoundCommand();
CommonNodeModel temp = it.next();
ChangeBoundsCommand command=new ChangeBoundsCommand();
command.setModel(temp);
command.setNewBounds(r.get(temp));
cc.add(command);
}
if(cc!=null)this.getCommandStack().execute(cc);
}
}
}
}
}
@SuppressWarnings("unchecked")
private Rectangle getRectangle(RootEditPart ep, CommonNodeModel model)
{
List<EditPart> epl = ep.getChildren();
for (EditPart ept : epl)
{
if (ept.getModel() == model)
{
return ((GraphicalEditPart) ept).getFigure().getBounds()
.getCopy();
}
}
return null;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment