📄 resourcepropertiestaghandler.java
字号:
/*************************************************************************** * * * 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.parser;import java.util.ArrayList;import java.util.GregorianCalendar;import java.util.List;import net.sourceforge.ganttproject.GanttCalendar;import net.sourceforge.ganttproject.ResourceTreeTable;import net.sourceforge.ganttproject.ResourceTreeTableModel;import net.sourceforge.ganttproject.Mediator;import net.sourceforge.ganttproject.resource.ResourceColumn;import org.w3c.util.DateParser;import org.w3c.util.InvalidDateException;import org.xml.sax.Attributes;/** * This class parses the properties of a resource and initializes the resources' * table and the ResourceManager */public class ResourcePropertiesTagHandler implements TagHandler, ParsingListener { private List columns = null; private ResourceTreeTable treeTable = null; public ResourcePropertiesTagHandler(ResourceTreeTable resTreeTable) { treeTable = resTreeTable; columns = new ArrayList(); } /** * @see net.sourceforge.ganttproject.parser.TagHandler#startElement(String, * String, String, Attributes) */ public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) { if (qName.equals("resproperty")) loadTaskProperty(attrs); } /** * @see net.sourceforge.ganttproject.parser.TagHandler#endElement(String, * String, String) */ public void endElement(String namespaceURI, String sName, String qName) { } private void loadTaskProperty(Attributes atts) { String name = atts.getValue("name"); String type = atts.getValue("valueType"); if (atts.getValue("type").equals("custom")) { ResourceColumn rc; String valueStr = atts.getValue("defaultValue"); Object defValue = null; Class clType = null; if (type.equals("text")) { clType = String.class; defValue = valueStr.toString(); } else if (type.equals("boolean")) { clType = Boolean.class; defValue = Boolean.valueOf(valueStr); } else if (type.equals("int")) { clType = Integer.class; defValue = Integer.valueOf(valueStr); } else if (type.equals("double")) { clType = Double.class; defValue = Double.valueOf(valueStr); } else if (type.equals("date")) { clType = GregorianCalendar.class; try { defValue = new GanttCalendar(DateParser.parse(valueStr)); } catch (InvalidDateException e) { e.printStackTrace(); } } else { clType = String.class; // TODO remove if(...text) defValue = ""; } /* TODO check index */ int index = ((ResourceTreeTableModel) treeTable.getTreeTableModel()) .useNextIndex(); rc = new ResourceColumn(name, index, clType); rc.setDefaultVal(defValue); treeTable.addCustomColumn(rc); } } /** * @see net.sourceforge.ganttproject.parser.ParsingListener#parsingStarted() */ public void parsingStarted() { // nothing to do. } /* * (non-Javadoc) * * @see net.sourceforge.ganttproject.parser.ParsingListener#parsingFinished() */ public void parsingFinished() { // this.treeTable.setDisplayedColumns(columns); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -