You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
6.2 KiB
157 lines
6.2 KiB
2 years ago
|
package com.fr.plugin.xxgantt.ui;
|
||
|
|
||
|
import com.fr.chart.chartattr.Plot;
|
||
|
import com.fr.design.beans.BasicBeanPane;
|
||
|
import com.fr.design.gui.controlpane.NameObjectCreator;
|
||
|
import com.fr.design.gui.controlpane.NameableCreator;
|
||
|
import com.fr.design.gui.imenutable.UIMenuNameableCreator;
|
||
|
import com.fr.design.i18n.Toolkit;
|
||
|
import com.fr.general.NameObject;
|
||
|
import com.fr.json.JSONArray;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.plugin.xxgantt.xxGanttChart;
|
||
|
import com.fr.plugin.xxgantt.vo.*;
|
||
|
import com.fr.stable.ListMap;
|
||
|
import com.fr.stable.Nameable;
|
||
|
import com.fr.van.chart.designer.component.VanChartUIListControlPane;
|
||
|
|
||
|
import java.lang.reflect.Constructor;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
|
||
|
public class SplitLinesListPane extends VanChartUIListControlPane {
|
||
|
|
||
|
private xxGanttChart chart;
|
||
|
|
||
|
private HashMap paneMap;
|
||
|
private HashMap jsonMap;
|
||
|
|
||
|
public SplitLinesListPane() {
|
||
|
paneMap = new HashMap(6);
|
||
|
paneMap.put(CustomJsonObject.GROUP_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttGroupLinesCreator.class);
|
||
|
paneMap.put(CustomJsonObject.MON_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttMonLinesCreator.class);
|
||
|
paneMap.put(CustomJsonObject.QUARTER_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttQuarterLinesCreator.class);
|
||
|
paneMap.put(CustomJsonObject.TODAY_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttTodayLinesCreator.class);
|
||
|
paneMap.put(CustomJsonObject.TYPE_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttTypeLinesCreator.class);
|
||
|
paneMap.put(CustomJsonObject.YEAR_LINE_TITLE, xxGanttSplitLinesCreator.xxGanttYearLinesCreator.class);
|
||
|
|
||
|
jsonMap = new HashMap(6);
|
||
|
jsonMap.put(CustomJsonObject.GROUP_LINE_TITLE, GroupLineJson.class);
|
||
|
jsonMap.put(CustomJsonObject.MON_LINE_TITLE, MonLineJson.class);
|
||
|
jsonMap.put(CustomJsonObject.QUARTER_LINE_TITLE, QuarterLineJson.class);
|
||
|
jsonMap.put(CustomJsonObject.TODAY_LINE_TITLE, TodayLineJson.class);
|
||
|
jsonMap.put(CustomJsonObject.TYPE_LINE_TITLE, TypeLineJson.class);
|
||
|
jsonMap.put(CustomJsonObject.YEAR_LINE_TITLE, YearLineJson.class);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void update(Plot plot) {
|
||
|
}
|
||
|
|
||
|
public void populateStyle(xxGanttChart chart) {
|
||
|
this.chart = chart;
|
||
|
|
||
|
JSONArray splitLineConf = chart.getSplitLineCond();
|
||
|
ArrayList noList = new ArrayList();
|
||
|
for (int i = 0; null != splitLineConf && i < splitLineConf.size(); i++) {
|
||
|
JSONObject line = splitLineConf.getJSONObject(i);
|
||
|
if (null != line) {
|
||
|
try {
|
||
|
CustomJsonObject json = (CustomJsonObject)this.getJsonByTitle(line.getString("title")).newInstance();
|
||
|
json.put(line);
|
||
|
UIMenuNameableCreator var11 = new UIMenuNameableCreator(line.getString("titleName"), json, this.getEditPaneByTitle(line.getString("title")));
|
||
|
noList.add(new NameObject(var11.getName(), var11.getObj()));
|
||
|
} catch (InstantiationException e) {
|
||
|
e.printStackTrace();
|
||
|
} catch (IllegalAccessException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.populate((Nameable[])noList.toArray(new NameObject[noList.size()]));
|
||
|
this.doLayout();
|
||
|
|
||
|
}
|
||
|
|
||
|
public void updateStyle(xxGanttChart chart) {
|
||
|
Nameable[] nameables = this.update();
|
||
|
|
||
|
JSONArray splitLineConf = JSONArray.create();
|
||
|
for (int i = 0; i < nameables.length; i++) {
|
||
|
CustomJsonObject noObj = (CustomJsonObject)((NameObject)nameables[i]).getObject();
|
||
|
if (null == noObj) {
|
||
|
noObj = new CustomJsonObject();
|
||
|
noObj.put(JSONObject.create());
|
||
|
}
|
||
|
if (null == noObj.get()) {
|
||
|
noObj.put(JSONObject.create());
|
||
|
}
|
||
|
|
||
|
noObj.get().put("titleName", ((NameObject)nameables[i]).getName());
|
||
|
splitLineConf.add(noObj.get());
|
||
|
}
|
||
|
|
||
|
chart.setSplitLineCond(splitLineConf);
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public NameableCreator[] createNameableCreators() {
|
||
|
ListMap creatorMap = new ListMap();
|
||
|
|
||
|
|
||
|
|
||
|
NameableCreator quarter = new NameObjectCreator(Toolkit.i18nText("Plugin-xxGantt-Cond-quarterLine"), QuarterLineJson.class, xxGanttSplitLinesCreator.xxGanttQuarterLinesCreator.class);
|
||
|
creatorMap.put(quarter.menuName(), quarter);
|
||
|
|
||
|
NameableCreator year = new NameObjectCreator(Toolkit.i18nText("Plugin-xxGantt-Cond-yearLine"), YearLineJson.class, xxGanttSplitLinesCreator.xxGanttYearLinesCreator.class);
|
||
|
creatorMap.put(year.menuName(), year);
|
||
|
|
||
|
NameableCreator today = new NameObjectCreator(Toolkit.i18nText("Plugin-xxGantt-Cond-todayLine"), TodayLineJson.class, xxGanttSplitLinesCreator.xxGanttTodayLinesCreator.class);
|
||
|
creatorMap.put(today.menuName(), today);
|
||
|
|
||
|
return (NameableCreator[])creatorMap.values().toArray(new NameableCreator[creatorMap.size()]);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String title4PopupWindow() {
|
||
|
return Toolkit.i18nText("Plugin-xxGantt-Cond-AddCondtion");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getAddItemText() {
|
||
|
return Toolkit.i18nText("Plugin-xxGantt-Cond-AddCondtion");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public BasicBeanPane createPaneByCreators(NameableCreator nameableCreator) {
|
||
|
Constructor var2 = null;
|
||
|
try {
|
||
|
var2 = nameableCreator.getUpdatePane().getConstructor();
|
||
|
return (BasicBeanPane)var2.newInstance();
|
||
|
} catch (InstantiationException var4) {
|
||
|
FineLoggerFactory.getLogger().error(var4.getMessage(), var4);
|
||
|
} catch (IllegalAccessException var5) {
|
||
|
FineLoggerFactory.getLogger().error(var5.getMessage(), var5);
|
||
|
} catch (NoSuchMethodException var6) {
|
||
|
return super.createPaneByCreators(nameableCreator);
|
||
|
} catch (InvocationTargetException var7) {
|
||
|
FineLoggerFactory.getLogger().error(var7.getMessage(), var7);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private Class<? extends BasicBeanPane> getEditPaneByTitle(String title) {
|
||
|
return (Class)paneMap.get(title);
|
||
|
}
|
||
|
|
||
|
private Class getJsonByTitle(String title) {
|
||
|
return (Class)jsonMap.get(title);
|
||
|
}
|
||
|
|
||
|
}
|