⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scripttaskflowleteditpart.java

📁 一个java写的business process management系统
💻 JAVA
字号:
/*
 * Copyright (c) 2003-2004, Alexander Greif
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the Flow4J-Eclipse project nor the names of its
 *       contributors may be used to endorse or promote products derived from
 *       this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

package net.orthanc.flow4j.designer.editparts;

import net.orthanc.flow4j.designer.core.Flow4JPlugin;
import net.orthanc.flow4j.designer.editparts.policies.TaskFlowletDirectEditPolicy;
import net.orthanc.flow4j.designer.figures.Flow4FigureFactory;
import net.orthanc.flow4j.designer.model.ScriptTaskFlowletModelPart;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;

/**
 * @author greifa
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class ScriptTaskFlowletEditPart extends FlowletWithLabelEditPart {

	/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
	 */
	protected void createEditPolicies() {
		super.createEditPolicies();
		installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new TaskFlowletDirectEditPolicy());
	}


	/**
	 * Creates the task flowlet figure and sets it's tool tip figure
	 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
	 */
	protected IFigure createFigure() {
		if (getModel() == null)
			return null;
		IFigure figure = Flow4FigureFactory.createScriptTaskFlowletFigure();
//		figure.setToolTip(toolTip);
		
		return figure;
	}

	/**
	 * Returns the model of this as a ScriptTaskFlowletModelPart.
	 * @return  Model of this as a ScriptTaskFlowletModelPart.
	 */
	protected ScriptTaskFlowletModelPart getScriptTaskFlowlet() {
		return (ScriptTaskFlowletModelPart)getModel();
	}



	/**
	 * Performs a direct edit on the Task Flowlet.
	 * Searches for the class's java source and opens it.
	 * If the java source is in a jar or zip archive,
	 * then its currently not handled.
	 */
	private void performDirectEdit() {
		String scriptPath = getScriptTaskFlowlet().getFlowletLabel().getText();
		try {
			IPath[] srcContainers = Flow4JPlugin.getClasspathSourceContainers(Flow4JPlugin.getActiveProject());
			for (int i = 0; i < srcContainers.length; i++) {
				IPath path = srcContainers[i];
				path = path.append(scriptPath);
				if (Flow4JPlugin.getWorkspaceRoot().exists(path)) {
					IWorkbenchPage page = Flow4JPlugin.getActivePage();
					if (page != null)
						try {
							IPath projectLocation = Flow4JPlugin.getJavaProject(path.segment(0)).getProject().getLocation();
							IPath location = projectLocation.append(path.removeFirstSegments(1));
							IFile file = Flow4JPlugin.getWorkspaceRoot().getFileForLocation(location);
							page.openEditor(file, Flow4JPlugin.getEditorID(scriptPath), true);
						} catch (PartInitException e) {
							Flow4JPlugin.log("Exception while opening script source: " + e.getMessage());
							//Flow4JPlugin.getActiveFlowEditor().getStatusLineManager().setErrorMessage("hallo");
						}
					break;
				}
			}
		} catch (JavaModelException e1) {
			Flow4JPlugin.log("Exception while getting project source folders: " + e1.getMessage());
		}
	}


	/**
	 * @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request)
	 */
	public void performRequest(Request request) {
		if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
			performDirectEdit();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -