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

📄 ganttoptions.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*************************************************************************** GanttOptions.java  -  description ------------------- begin                : mar 2003 copyright            : (C) 2003 by Thomas Alexandre email                : alexthomas(at)ganttproject.org ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/package net.sourceforge.ganttproject;import java.awt.Color;import java.awt.Font;import java.awt.print.*;import java.io.File;import java.net.MalformedURLException;import java.net.URL;import java.security.AccessControlException;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Locale;import java.util.Map;import java.util.Map.Entry;import javax.swing.JToolBar;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;import javax.xml.transform.OutputKeys;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerConfigurationException;import javax.xml.transform.TransformerFactoryConfigurationError;import javax.xml.transform.sax.SAXTransformerFactory;import javax.xml.transform.sax.TransformerHandler;import javax.xml.transform.stream.StreamResult;import net.sourceforge.ganttproject.document.Document;import net.sourceforge.ganttproject.document.DocumentCreator;import net.sourceforge.ganttproject.document.DocumentManager;import net.sourceforge.ganttproject.document.DocumentsMRU;import net.sourceforge.ganttproject.gui.GanttLookAndFeelInfo;import net.sourceforge.ganttproject.gui.GanttLookAndFeels;import net.sourceforge.ganttproject.gui.UIConfiguration;import net.sourceforge.ganttproject.gui.options.model.GP1XOptionConverter;import net.sourceforge.ganttproject.gui.options.model.GPOption;import net.sourceforge.ganttproject.gui.options.model.GPOptionGroup;import net.sourceforge.ganttproject.io.CSVOptions;import net.sourceforge.ganttproject.io.GanttXMLOpen;import net.sourceforge.ganttproject.language.GanttLanguage;import net.sourceforge.ganttproject.parser.IconPositionTagHandler;import net.sourceforge.ganttproject.parser.RoleTagHandler;import net.sourceforge.ganttproject.roles.Role;import net.sourceforge.ganttproject.roles.RoleManager;import net.sourceforge.ganttproject.roles.RoleSet;import net.sourceforge.ganttproject.util.ColorConvertion;import org.xml.sax.Attributes;import org.xml.sax.SAXException;import org.xml.sax.helpers.AttributesImpl;import org.xml.sax.helpers.DefaultHandler;/** * The class aible to load and save options on the file */public class GanttOptions {    private GanttLanguage language = GanttLanguage.getInstance();    // private Color color;    private int x = 0, y = 0, width = 800, height = 600;    private String styleClass = "", styleName = "";    private GanttLookAndFeelInfo lookAndFeel;    private boolean isloaded;    private boolean automatic;    // private boolean dragTime;    private boolean openTips;    private boolean redline;    private int lockDAVMinutes;    private int undoNumber;    private String xslDir;    private String xslFo;    private String workingDir = "";    private final RoleManager myRoleManager;    private DocumentsMRU documentsMRU;    private UIConfiguration myUIConfig;    private Font myChartMainFont;    private String sTaskNamePrefix;    private int toolBarPosition;    private boolean bShowStatusBar;    private String iconSize;    public static final int ICONS = 0;    public static final int ICONS_TEXT = 1;    public static final int TEXT = 2;    private int buttonsshow;    /** FTP options */    private String FTPUrl = "";    private String FTPDirectory = "";    private String FTPUser = "";    private String FTPPwd = "";    /** Export options. */    private boolean bExportName;    private boolean bExportComplete;    private boolean bExportRelations;    private boolean bExport3DBorders;    /** Print settings. */    private PageFormat pageFormat;        /** CVS export options. */    private CSVOptions csvOptions;    private int[] iconListAsIntArray;    private int[] deletedIconListAsIntArray;    private String iconListAsString;    private String deletedIconListAsString;    private boolean isOnlyViewer;    public static final int SEPARATOR = 0;    public static final int EXIT = 1;    public static final int NEW = 2;    public static final int OPEN = 3;    public static final int SAVE = 4;    public static final int SAVEAS = 5;    public static final int IMPORT = 6;    public static final int EXPORT = 7;    public static final int PRINT = 8;    public static final int CUT = 9;    public static final int COPY = 10;    public static final int PASTE = 11;    public static final int NEWTASK = 12;    public static final int DELETE = 13;    public static final int PROPERTIES = 14;    public static final int UNLINK = 15;    public static final int LINK = 16;    public static final int IND = 17;    public static final int UNIND = 18;    public static final int UP = 19;    public static final int DOWN = 20;    public static final int PREV = 21;    public static final int CENTER = 22;    public static final int NEXT = 23;    public static final int ZOOMOUT = 24;    public static final int ZOOMIN = 25;    public static final int UNDO = 26;    public static final int REDO = 27;    public static final int CRITICAL = 28;    public static final int ABOUT = 29;    public static final int SAVECURRENT = 30;    public static final int COMPAREPREV = 31;    public static final int REFRESH = 32;    public static final int PREVIEWPRINT = 33;    private Map/*<String,GPOption>*/ myGPOptions = new LinkedHashMap();    private Map/*<String,GP1XOptionConverter>*/ myTagDotAttribute_Converter = new HashMap();	private final DocumentManager myDocumentManager;    /** Default constructor. */    public GanttOptions(RoleManager roleManager, DocumentManager documentManager, boolean isOnlyViewer) {    	myDocumentManager = documentManager;        myRoleManager = roleManager;        this.isOnlyViewer = isOnlyViewer;        initByDefault();        try {            this.workingDir = System.getProperty("user.home");        } catch (AccessControlException e) {            // This can happen when running in a sandbox (Java WebStart)            System.err.println(e + ": " + e.getMessage());        }    }    /** Init the options by default. */    public void initByDefault() {        automatic = false;        // dragTime = true;        openTips = true;        redline = false;        lockDAVMinutes = 240;        undoNumber = 50;        xslDir = GanttOptions.class.getResource("/xslt").toString();        xslFo = GanttOptions.class.getResource("/xslfo/ganttproject.xsl")                .toString();        sTaskNamePrefix = "";        toolBarPosition = JToolBar.HORIZONTAL;        bShowStatusBar = true;        iconSize = "16"; // must be 16 small, 24 for big (32 for extra big        // not directly include on UI)        buttonsshow = GanttOptions.ICONS;        /** Export options. */        bExportName = true;        bExportComplete = true;        bExportRelations = true;        bExport3DBorders = false;        /** CVS export options. */        csvOptions = new CSVOptions();        // Icon status bar        iconListAsString = getDefaultIconListAsString();        iconListAsIntArray = getDefaultIconListIntArray();        deletedIconListAsString = getDefaultDeletedIconListAsString();        deletedIconListAsIntArray = getDefaultDeletedIconListIntArray();                /** Print settings */        PrinterJob print_job = PrinterJob.getPrinterJob();        this.pageFormat = print_job.defaultPage();        this.pageFormat.setOrientation(PageFormat.LANDSCAPE);    }    // iconListAsIntArray = initIconList ();    /**     * Constructor. public GanttOptions(Color c, int x, int y, int width, int     * height, GanttLookAndFeelInfo lookAndFeel, boolean automatic, boolean     * dragTime, String xslDir, String xslFo,String workingDir, boolean tips,     * boolean redline, int lockDAVMinutes, DocumentsMRU documentsMRU,     * UIConfiguration uiConfiguration, RoleManager roleManager) { myRoleManager =     * roleManager; color = c; this.x = x; this.y = y; this.width = width;     * this.height = height; this.lookAndFeel = lookAndFeel;     * this.automatic=automatic; this.dragTime=dragTime; this.openTips=tips;     * this.redline=redline; this.lockDAVMinutes=lockDAVMinutes; this.myUIConfig =     * uiConfiguration; if(xslFo!=null) this.xslFo=xslFo; if (xslDir != null)     * this.xslDir = xslDir; try { this.workingDir =     * System.getProperty("user.home"); } catch (AccessControlException e) { //     * This can happen when running in a sandbox (Java WebStart)     * System.err.println (e + ": " + e.getMessage()); } if (workingDir != null &&     * new File(workingDir).exists()) this.workingDir = workingDir;     * this.documentsMRU = documentsMRU; }     */    private void startElement(String name, Attributes attrs,            TransformerHandler handler) throws SAXException {        handler.startElement("", name, name, attrs);    }    private void endElement(String name, TransformerHandler handler)            throws SAXException {        handler.endElement("", name, name);    }    private void addAttribute(String name, String value, AttributesImpl attrs) {        if (value != null) {            attrs.addAttribute("", name, name, "CDATA", value);        } else {            System.err.println("[GanttOptions] attribute '" + name                    + "' is null");        }    }    private void emptyElement(String name, AttributesImpl attrs,            TransformerHandler handler) throws SAXException {        startElement(name, attrs, handler);        endElement(name, handler);        attrs.clear();    }    /**     * Save the options file     */    public void save() {        try {            String sFileName = ".ganttproject";            /*             * if(System.getProperty("os.name").startsWith("Windows") ||             * System.getProperty("os.name").startsWith("Mac")) sFileName =             * "ganttproject.ini";             */            File file = new File(System.getProperty("user.home")                    + System.getProperty("file.separator") + sFileName);            // DataOutputStream fout = new DataOutputStream(new            // FileOutputStream(file));            TransformerHandler handler = ((SAXTransformerFactory) SAXTransformerFactory                    .newInstance()).newTransformerHandler();            Transformer serializer = handler.getTransformer();            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");            serializer.setOutputProperty(OutputKeys.INDENT, "yes");            serializer.setOutputProperty(                    "{http://xml.apache.org/xslt}indent-amount", "4");            handler.setResult(new StreamResult(file));            handler.startDocument();            // handler.startDTD("ganttproject.sourceforge.net",            // "-//GanttProject.org//DTD GanttProject-1.x//EN",            // "http://ganttproject.sourceforge.net/dtd/ganttproject.dtd");            // handler.endDTD();            //            AttributesImpl attrs = new AttributesImpl();            handler.startElement("", "ganttproject-options",                    "ganttproject-options", attrs);            //            attrs.addAttribute("", "selection", "selection", "CDATA", language                    .getText("shortLanguage"));            handler.startElement("", "language", "language", attrs);            handler.endElement("", "language", "language");            attrs.clear();            // write the task Color            /*             * Color color = getUIConfiguration().getTaskColor();             * attrs.addAttribute("", "red", "red", "CDATA", ""+color.getRed());             * attrs.addAttribute("", "green", "green", "CDATA",             * ""+color.getGreen()); attrs.addAttribute("", "blue", "blue",             * "CDATA", ""+color.getBlue()); handler.startElement("",             * "task-color", "task-color", attrs); handler.endElement("",             * "task-color", "task-color"); attrs.clear();             */            Color resourceColor = myUIConfig.getResourceColor();

⌨️ 快捷键说明

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