jadex.bpmn.editor.BpmnEditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-editor-bpmn Show documentation
Show all versions of jadex-editor-bpmn Show documentation
Editor for Business Process Model and Notation (BPMN).
package jadex.bpmn.editor;
import java.awt.EventQueue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import com.mxgraph.view.mxStylesheet;
import jadex.bpmn.editor.gui.BpmnEditorWindow;
import jadex.bpmn.editor.gui.stylesheets.BpmnStylesheetColor;
import jadex.bpmn.editor.gui.stylesheets.BpmnStylesheetColorGradient;
import jadex.bpmn.editor.gui.stylesheets.BpmnStylesheetComplexGrayscale;
import jadex.bpmn.editor.gui.stylesheets.BpmnStylesheetSimpleGrayscale;
import jadex.bpmn.task.info.TaskMetaInfo;
import jadex.commons.SUtil;
import jadex.commons.Tuple2;
import jadex.commons.transformation.binaryserializer.BinarySerializer;
/**
* Class for starting the BPMN editor.
*/
public class BpmnEditor
{
/** Current version. */
public static final int BUILD = 86;
/** Console logging flag. */
public static final boolean CONSOLE_LOGGING = false;
/** The name of the application. */
public static final String APP_NAME = "Jadex BPMN Editor";
/** The settings directory name. */
public static String HOME_DIR = System.getProperty("user.home") + File.separator + ".jadex-bpmn-editor";
/** The settings directory name for windows. */
public static final String WINDOWS_HOME_DIR = System.getProperty("user.dir") + File.separator + "config";
/** The image cache file. */
// public static final String IMAGE_CACHE = HOME_DIR + File.separator + "imagecache.dat";
/** Log level for status area. */
public static final Level STATUS_AREA_LOG_LEVEL = Level.INFO;
/** Main Logger. */
public static final Logger LOGGER = Logger.getLogger(APP_NAME);
static
{
// Avoids a GUI bug on modern Linux systems.
System.setProperty("sun.java2d.xrender", "true");
}
/** The style sheets. */
@SuppressWarnings("unchecked")
// Hack!!! generics expression doesn't compile on build servers (JDK 1.6/1.7/1.8 ???)
// public static List> STYLE_SHEETS = new ArrayList>((Collection extends Tuple2>) Arrays.asList(new Tuple2[]
public static List> STYLE_SHEETS = new ArrayList(Arrays.asList(new Tuple2[]
{
new Tuple2("Color Gradient", new BpmnStylesheetColorGradient()),
new Tuple2("Color", new BpmnStylesheetColor()),
new Tuple2("Simple Grayscale", new BpmnStylesheetSimpleGrayscale()),
new Tuple2("Complex Grayscale", new BpmnStylesheetComplexGrayscale())
}));
/** Standard task classes. */
protected static final String[] FALLBACK_TASK_NAMES = { "jadex.bpmn.runtime.task.PrintTask",
"jadex.bpmn.runtime.task.InvokeMethodTask",
"jadex.bpmn.runtime.task.CreateComponentTask",
"jadex.bpmn.runtime.task.DestroyComponentTask",
"jadex.bpmn.runtime.task.StoreResultsTask",
"jadex.bpmn.runtime.task.UserInteractionTask",
"jadex.bdibpmn.task.DispatchGoalTask",
"jadex.bdibpmn.task.WaitForGoalTask",
"jadex.bdibpmn.task.DispatchInternalEventTask",
"jadex.bdibpmn.task.WriteBeliefTask",
"jadex.bdibpmn.task.WriteParameterTask",
"jadex.bdibpmn.task.CreateSpaceObjectTaskTask",
"jadex.bdibpmn.task.WaitForSpaceObjectTaskTask",
"jadex.bdibpmn.task.RemoveSpaceObjectTaskTask",
"jadex.wfms.client.task.WorkitemTask"
};
/** Available look and feels. */
public static final Map LOOK_AND_FEELS = new HashMap();
/** Task informations. */
public static Map TASK_INFOS;
public static Map STRINGS;
static
{
try
{
String res = BpmnEditor.class.getPackage().getName().replaceAll("\\.", "/") + "/strings_USA_eng.properties";
InputStream sis = BpmnEditor.class.getClassLoader().getResourceAsStream(res);
Properties strings = new Properties();
strings.load(sis);
sis.close();
STRINGS = propertiesToMap(strings);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Starts the BPMN editor.
*
* @param args The arguments.
*/
public static void main(String[] args)
{
LOGGER.setUseParentHandlers(CONSOLE_LOGGING);
LOGGER.setLevel(Level.ALL);
String osname = System.getProperty("os.name");
if (osname != null && osname.toLowerCase().contains("win"))
{
HOME_DIR = WINDOWS_HOME_DIR;
}
// try
// {
// String country = Locale.getDefault().getISO3Country();
// String lang = Locale.getDefault().getISO3Language();
// InputStream sis = BpmnEditor.class.getClassLoader().getResourceAsStream(BpmnEditor.class.getPackage().getName().replaceAll("\\.", "/") + "/strings_" + country + "_" + lang + ".properties");
// Properties strings = new Properties();
// strings.load(sis);
// sis.close();
// STRINGS = propertiesToMap(strings);
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
try
{
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
{
LOOK_AND_FEELS.put(info.getName(), info);
// if ("Nimbus".equals(info.getName()))
// {
// UIManager.setLookAndFeel(info.getClassName());
// break;
// }
}
}
catch (Exception e)
{
}
EventQueue.invokeLater(new Runnable()
{
public void run()
{
// Enumeration