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

📄 palettehelper.java

📁 一个java写的business process management系统
💻 JAVA
字号:
/*
 * Copyright (c) 2003, 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.ui.editors;

import java.util.ArrayList;
import java.util.List;

import net.orthanc.flow4j.designer.core.Flow4JPlugin;
import net.orthanc.flow4j.designer.model.CallFlowletModelPart;
import net.orthanc.flow4j.designer.model.DecisionFlowletModelPart;
import net.orthanc.flow4j.designer.model.EndFlowletModelPart;
import net.orthanc.flow4j.designer.model.JavaTaskFlowletModelPart;
import net.orthanc.flow4j.designer.model.JoinFlowletModelPart;
import net.orthanc.flow4j.designer.model.JumpFlowletModelPart;
import net.orthanc.flow4j.designer.model.StartFlowletModelPart;
import net.orthanc.flow4j.designer.model.TemplateFlowletModelPart;

import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
import org.eclipse.gef.palette.MarqueeToolEntry;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.PaletteSeparator;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gef.requests.SimpleFactory;
import org.eclipse.jface.resource.ImageDescriptor;
/**
 * @author agreif
 *
 * TODO
 * 
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class PaletteHelper {

	/**
	 * Returns the newly created palette's root.
	 * @return the palette's root.
	 */
	static PaletteRoot createPalette() {
		PaletteRoot flowPalette = new PaletteRoot();
		flowPalette.addAll(createFlowPaletteCategories(flowPalette));

		return flowPalette;
	}

	/**
	 * TODO
	 * @param root
	 * @return
	 */
	static private List createFlowPaletteCategories(PaletteRoot root) {
		List categories = new ArrayList();

		categories.add(createControlGroup(root));
		categories.add(createFlowletsDrawer());

		return categories;
	}

	/**
	 * Creates the control tools.
	 * @param root
	 * @return the control group
	 */
	static private PaletteContainer createControlGroup(PaletteRoot root) {
		PaletteGroup controlGroup =
			new PaletteGroup(Flow4JPlugin.getResourceString("FlowEditor_Palette_Category_ControlGroup.label"));//$NON-NLS-1$

		List entries = new ArrayList();

		ToolEntry tool = new Flow4JSelectionToolEntry();
		entries.add(tool);
		root.setDefaultEntry(tool);

		tool = new MarqueeToolEntry();
		entries.add(tool);

		PaletteSeparator sep = new PaletteSeparator("net.orthanc.flow4j.designer.ui.editors.sep"); //$NON-NLS-1$
		sep.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
		entries.add(sep);

		tool = new Flow4JConnectionCreationToolEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_Connection.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_Connection.description"),//$NON-NLS-1$
			null, 
			ImageDescriptor.createFromFile(StartFlowletModelPart.class, "icons/connection16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(StartFlowletModelPart.class, "icons/connection24.gif")//$NON-NLS-1$
		);
		entries.add(tool);
		
		controlGroup.addAll(entries);
		return controlGroup;
	}





	/**
	 * Creates the Flowlets drawer in the palette
	 * @return the filled drawer container
	 */
	static private PaletteContainer createFlowletsDrawer(){
		PaletteDrawer drawer = new PaletteDrawer(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Category_Flowlets.label"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(StartFlowletModelPart.class, "icons/comp.gif"));//$NON-NLS-1$

		List entries = new ArrayList();
		CombinedTemplateCreationEntry combined;
		
		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_StartFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_StartFlowlet.description"),//$NON-NLS-1$
			StartFlowletModelPart.class,
			new SimpleFactory(StartFlowletModelPart.class),
			ImageDescriptor.createFromFile(StartFlowletModelPart.class, "icons/startflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(StartFlowletModelPart.class, "icons/startflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_TaskFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_TaskFlowlet.description"),//$NON-NLS-1$
			JavaTaskFlowletModelPart.class,
			new SimpleFactory(JavaTaskFlowletModelPart.class),
			ImageDescriptor.createFromFile(JavaTaskFlowletModelPart.class, "icons/taskflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(JavaTaskFlowletModelPart.class, "icons/taskflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_DecisionFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_DecisionFlowlet.description"),//$NON-NLS-1$
			DecisionFlowletModelPart.class,
			new SimpleFactory(DecisionFlowletModelPart.class),
			ImageDescriptor.createFromFile(DecisionFlowletModelPart.class, "icons/decisionflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(DecisionFlowletModelPart.class, "icons/decisionflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_JoinFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_JoinFlowlet.description"),//$NON-NLS-1$
			JoinFlowletModelPart.class,
			new SimpleFactory(JoinFlowletModelPart.class),
			ImageDescriptor.createFromFile(JoinFlowletModelPart.class, "icons/joinflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(JoinFlowletModelPart.class, "icons/joinflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_CallFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_CallFlowlet.description"),//$NON-NLS-1$
			CallFlowletModelPart.class,
			new SimpleFactory(CallFlowletModelPart.class),
			ImageDescriptor.createFromFile(CallFlowletModelPart.class, "icons/callflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(CallFlowletModelPart.class, "icons/callflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_JumpFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_JumpFlowlet.description"),//$NON-NLS-1$
			JumpFlowletModelPart.class,
			new SimpleFactory(JumpFlowletModelPart.class),
			ImageDescriptor.createFromFile(JumpFlowletModelPart.class, "icons/jumpflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(JumpFlowletModelPart.class, "icons/jumpflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_TemplateFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_TemplateFlowlet.description"),//$NON-NLS-1$
			TemplateFlowletModelPart.class,
			new SimpleFactory(TemplateFlowletModelPart.class),
			ImageDescriptor.createFromFile(TemplateFlowletModelPart.class, "icons/templateflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(TemplateFlowletModelPart.class, "icons/templateflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);

		combined = new CombinedTemplateCreationEntry(
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_EndFlowlet.label"),//$NON-NLS-1$
			Flow4JPlugin.getResourceString("FlowEditor_Palette_Tool_CreationTool_EndFlowlet.description"),//$NON-NLS-1$
			EndFlowletModelPart.class,
			new SimpleFactory(EndFlowletModelPart.class),
			ImageDescriptor.createFromFile(EndFlowletModelPart.class, "icons/endflowlet16.gif"),//$NON-NLS-1$
			ImageDescriptor.createFromFile(EndFlowletModelPart.class, "icons/endflowlet24.gif")//$NON-NLS-1$
		);
		entries.add(combined);






		entries.add(new PaletteSeparator());
		drawer.addAll(entries);
		
		return drawer;
	}







}

⌨️ 快捷键说明

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