📄 ganttoptions.java
字号:
if (resourceColor != null) attrs.addAttribute("", "resources", "resources", "CDATA", "" + ColorConvertion.getColor(resourceColor)); Color resourceOverloadColor = myUIConfig.getResourceOverloadColor(); if (resourceOverloadColor != null) attrs.addAttribute("", "resourcesOverload", "resourcesOverload", "CDATA", "" + ColorConvertion .getColor(resourceOverloadColor)); Color resourceUnderloadColor = myUIConfig .getResourceUnderloadColor(); if (resourceUnderloadColor != null) attrs.addAttribute("", "resourcesUnderload", "resourcesUnderload", "CDATA", "" + ColorConvertion .getColor(resourceUnderloadColor)); Color weekEndColor = myUIConfig.getWeekEndColor(); if (weekEndColor != null) attrs.addAttribute("", "weekEnd", "weekEnd", "CDATA", "" + ColorConvertion.getColor(weekEndColor)); Color daysOffColor = myUIConfig.getDayOffColor(); if (daysOffColor != null) attrs.addAttribute("", "daysOff", "daysOff", "CDATA", "" + ColorConvertion.getColor(daysOffColor)); handler.startElement("", "colors", "colors", attrs); handler.endElement("", "colors", "colors"); attrs.clear(); // Geometry of the window addAttribute("x", "" + x, attrs); addAttribute("y", "" + y, attrs); addAttribute("width", "" + width, attrs); addAttribute("height", "" + height, attrs); emptyElement("geometry", attrs, handler); // look'n'feel addAttribute("name", lookAndFeel.getName(), attrs); addAttribute("class", lookAndFeel.getClassName(), attrs); emptyElement("looknfeel", attrs, handler); // ToolBar position addAttribute("position", "" + toolBarPosition, attrs); addAttribute("icon-size", "" + iconSize, attrs); addAttribute("show", "" + buttonsshow, attrs); emptyElement("toolBar", attrs, handler); addAttribute("show", "" + bShowStatusBar, attrs); emptyElement("statusBar", attrs, handler); // Export options addAttribute("name", "" + bExportName, attrs); addAttribute("complete", "" + bExportComplete, attrs); addAttribute("border3d", "" + bExport3DBorders, attrs); addAttribute("relations", "" + bExportRelations, attrs); emptyElement("export", attrs, handler); // csv export options startElement("csv-export", attrs, handler); addAttribute("fixed", "" + csvOptions.bFixedSize, attrs); addAttribute("separatedChar", "" + csvOptions.sSeparatedChar, attrs); addAttribute("separatedTextChar", "" + csvOptions.sSeparatedTextChar, attrs); emptyElement("csv-general", attrs, handler); addAttribute("id", "" + csvOptions.bExportTaskID, attrs); addAttribute("name", "" + csvOptions.bExportTaskName, attrs); addAttribute("start-date", "" + csvOptions.bExportTaskStartDate, attrs); addAttribute("end-date", "" + csvOptions.bExportTaskEndDate, attrs); addAttribute("percent", "" + csvOptions.bExportTaskPercent, attrs); addAttribute("duration", "" + csvOptions.bExportTaskDuration, attrs); addAttribute("webLink", "" + csvOptions.bExportTaskWebLink, attrs); addAttribute("resources", "" + csvOptions.bExportTaskResources, attrs); addAttribute("notes", "" + csvOptions.bExportTaskNotes, attrs); emptyElement("csv-tasks", attrs, handler); addAttribute("id", "" + csvOptions.bExportResourceID, attrs); addAttribute("name", "" + csvOptions.bExportResourceName, attrs); addAttribute("mail", "" + csvOptions.bExportResourceMail, attrs); addAttribute("phone", "" + csvOptions.bExportResourcePhone, attrs); addAttribute("role", "" + csvOptions.bExportResourceRole, attrs); emptyElement("csv-resources", attrs, handler); endElement("csv-export", handler); // automatic popup launch addAttribute("value", "" + automatic, attrs); emptyElement("automatic-launch", attrs, handler); // automaticdrag time on the chart // addAttribute("value", ""+dragTime, attrs); emptyElement("dragTime", attrs, handler); // automatic tips of the day launch addAttribute("value", "" + openTips, attrs); emptyElement("tips-on-startup", attrs, handler); // Should WebDAV resources be locked, when opening them? addAttribute("value", "" + lockDAVMinutes, attrs); emptyElement("lockdavminutes", attrs, handler); // write the xsl directory addAttribute("dir", xslDir, attrs); emptyElement("xsl-dir", attrs, handler); // write the xslfo directory addAttribute("file", xslFo, attrs); emptyElement("xsl-fo", attrs, handler); // write the working directory directory addAttribute("dir", workingDir, attrs); emptyElement("working-dir", attrs, handler); // write the task name prefix addAttribute("prefix", sTaskNamePrefix, attrs); emptyElement("task-name", attrs, handler); // The last opened files { startElement("files", attrs, handler); for (Iterator iterator = documentsMRU.iterator(); iterator .hasNext();) { Document document = (Document) iterator.next(); addAttribute("path", document.getPath(), attrs); emptyElement("file", attrs, handler); } endElement("files", handler); } addAttribute("category", "menu", attrs); addAttribute("spec", getFontSpec(getUIConfiguration().getMenuFont()), attrs); emptyElement("font", attrs, handler); // addAttribute("category", "chart-main", attrs); addAttribute("spec", getFontSpec(getUIConfiguration() .getChartMainFont()), attrs); emptyElement("font", attrs, handler); // saveIconPositions(handler); saveRoleSets(handler); for (Iterator options = myGPOptions.entrySet().iterator(); options.hasNext();) { Map.Entry nextEntry = (Entry) options.next(); GPOption nextOption = (GPOption)nextEntry.getValue(); if (nextOption.getPersistentValue()!=null) { addAttribute("id", nextEntry.getKey().toString(), attrs); addAttribute("value", nextOption.getPersistentValue(), attrs); emptyElement("option", attrs, handler); } } endElement("ganttproject-options", handler); // System.err.println("[GanttOptions] save(): finished!!"); handler.endDocument(); } catch (Exception e) { e.printStackTrace(); } } private String getFontSpec(Font font) { return font.getFamily() + "-" + getFontStyle(font) + "-" + font.getSize(); } private String getFontStyle(Font font) { String result; final int BOLDITALIC = Font.BOLD + Font.ITALIC; switch (font.getStyle()) { case Font.PLAIN: { result = "plain"; break; } case Font.BOLD: { result = "bold"; break; } case Font.ITALIC: { result = "italic"; break; } case BOLDITALIC: { result = "bolditalic"; break; } default: { throw new RuntimeException("Illegal value of font style. style=" + font.getStyle() + " font=" + font); } } return result; } public String correct(String s) { String res; res = s.replaceAll("&", "&"); res = res.replaceAll("<", "<"); res = res.replaceAll(">", ">"); res = res.replaceAll("/", "/"); res = res.replaceAll("\"", """); return res; } /** Load the options file */ public boolean load() { // Use an instance of ourselves as the SAX event handler DefaultHandler handler = new GanttXMLOptionsParser(); // Use the default (non-validating) parser SAXParserFactory factory = SAXParserFactory.newInstance(); 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); if (!file.exists()) { return false; } documentsMRU.clear(); // Parse the input SAXParser saxParser = factory.newSAXParser(); saxParser.parse(file, handler); GanttLookAndFeelInfo info = GanttLookAndFeels .getGanttLookAndFeels().getInfoByClass(styleClass); if (null == info) info = GanttLookAndFeels.getGanttLookAndFeels().getInfoByName( styleName); if (null != info) lookAndFeel = info; if (null == lookAndFeel) lookAndFeel = GanttLookAndFeels.getGanttLookAndFeels() .getDefaultInfo(); loadRoleSets(file); } catch (Exception e) { e.printStackTrace(); return false; } isloaded = true; return true; } private void loadRoleSets(File optionsFile) { GanttXMLOpen loader = new GanttXMLOpen(null); IconPositionTagHandler iconHandler = new IconPositionTagHandler(); loader.addTagHandler(iconHandler); loader.addTagHandler(new RoleTagHandler(getRoleManager())); loader.load(optionsFile); if (iconHandler.getList() != null) { iconListAsIntArray = iconHandler.getList(); iconListAsString = iconHandler.getPositions(); } if (iconHandler.getDeletedList() != null) { deletedIconListAsIntArray = iconHandler.getDeletedList(); deletedIconListAsString = iconHandler.getDeletedPositions(); } } private void saveRoleSets(TransformerHandler handler) throws TransformerConfigurationException, TransformerFactoryConfigurationError, SAXException { RoleSet[] roleSets = getRoleManager().getRoleSets(); for (int i = 0; i < roleSets.length; i++) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "roleset-name", "roleset-name", "CDATA", roleSets[i].getName()); handler.startElement("", "roles", "roles", attrs); saveRoles(roleSets[i], handler); handler.endElement("", "roles", "roles"); } } private void saveRoles(RoleSet roleSet, TransformerHandler handler) throws SAXException { Role[] roles = roleSet.getRoles(); AttributesImpl attrs = new AttributesImpl(); for (int i = 0; i < roles.length; i++) { Role next = roles[i]; addAttribute("id", "" + next.getID(), attrs); addAttribute("name", next.getName(), attrs); emptyElement("role", attrs, handler); } } private void saveIconPositions(TransformerHandler handler) throws TransformerConfigurationException, TransformerFactoryConfigurationError, SAXException { AttributesImpl attrs = new AttributesImpl(); addAttribute("icons-list", iconListAsString, attrs); addAttribute("deletedIcons-list", deletedIconListAsString, attrs); emptyElement("positions", attrs, handler); } public UIConfiguration getUIConfiguration() { if (myUIConfig == null) { myUIConfig = new UIConfiguration(null, null, new Color(140, 182, 206), redline) { public Font getMenuFont() { return myMenuFont == null ? super.getMenuFont() : myMenuFont; } public Font getChartMainFont() { return myChartMainFont == null ? super.getChartMainFont() : myChartMainFont; } }; // Color.black } return myUIConfig; } private RoleManager getRoleManager() { return myRoleManager; } private Font myMenuFont; /** Class to parse the xml option file */ class GanttXMLOptionsParser extends DefaultHandler { public void startElement(String namespaceURI, String sName, // simple // name String qName, // qualified name Attributes attrs) throws SAXException { int r = 0, g = 0, b = 0; if ("option".equals(qName)) { GPOption option = (GPOption) myGPOptions.get(attrs.getValue("id")); if (option!=null) { option.lock(); option.loadPersistentValue(attrs.getValue("value")); option.commit(); } return; } if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String aName = attrs.getQName(i); // Attr name String value = attrs.getValue(i); String tagDotAttribute = qName+"."+aName; GP1XOptionConverter converter = (GP1XOptionConverter) myTagDotAttribute_Converter.get(tagDotAttribute); if (converter!=null) { converter.loadValue(value); continue; } if (qName.equals("language")) { if (aName == "selection") { if (value.equals("English") || value.equals("en")) { language.setLocale(Locale.US); } else if (value.equals("English (UK)") || value.equals("en_GB")) { language.setLocale(Locale.UK); } else if (value.equals("Fran\u00e7ais") || value.equals("fr")) { language.setLocale(Locale.FRANCE); } else if (value.equals("Espa\u00f1ol") || value.equals("es")) { language.setLocale(new Locale("es", "ES")); } else if (value.equals("Portugues") || value.equals("pt")) { language.setLocale(new Locale("pt", "PT")); } else if (value.equals("Portugu\u00eas do Brasil") || value.equals("pt_BR")) { language.setLocale(new Locale("pt", "BR")); } else if (value.equals("Deutsch") || value.equals("de")) { language.setLocale(Locale.GERMANY); } else if (value.equals("Norsk") || value.equals("no")) { language.setLocale(new Locale("no", "NO"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -