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.
145 lines
5.0 KiB
145 lines
5.0 KiB
package com.connor.mbd.handlers;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Stream;
|
|
|
|
import org.eclipse.core.commands.AbstractHandler;
|
|
import org.eclipse.core.commands.ExecutionEvent;
|
|
import org.eclipse.core.commands.ExecutionException;
|
|
import org.osgi.service.prefs.PreferencesService;
|
|
|
|
import com.connor.mbd.dialogs.ProcessreviewDialog;
|
|
import com.connor.mdb.beans.GeneralBean;
|
|
import com.connor.mdb.beans.TableBean;
|
|
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
public class ProcessreviewHandler extends AbstractHandler {
|
|
|
|
TCSession session;
|
|
AbstractAIFUIApplication application;
|
|
|
|
public static TCPreferenceService service;
|
|
private int realPropSize = 0;
|
|
|
|
@Override
|
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
|
application = AIFUtility.getCurrentApplication();
|
|
session = (TCSession) application.getSession();
|
|
realPropSize = 0;
|
|
TCComponent target = (TCComponent) application.getTargetComponent();
|
|
if (target == null || !target.getType().equals("Ac5_GyscbdForm")) {
|
|
MessageBox.post("请选择协同审查表单执行", "", MessageBox.ERROR);
|
|
return null;
|
|
}
|
|
TCComponentForm form = (TCComponentForm) target;
|
|
String[] prefArray = getPrefStrArray("Connor_AVIC_GYSC_PropControl", session);
|
|
if (prefArray == null) {
|
|
MessageBox.post("请检查首选项配置...", "", MessageBox.ERROR);
|
|
return null;
|
|
}
|
|
// Map<String, String> prefMap = new HashMap<String, String>();
|
|
// Map<String, String> realPropMap = new HashMap<String,String>();
|
|
// Map<String, Map<String,String>> tablePropMap = new HashMap<>();
|
|
|
|
List<GeneralBean> generalList = new ArrayList<>();
|
|
List<TableBean> tableList = new ArrayList<>();
|
|
|
|
for (String prefOption : prefArray) {
|
|
String[] splitPropType = prefOption.split("=");
|
|
if (splitPropType.length == 2) {
|
|
if (splitPropType[0].equals("General")) {
|
|
String[] prefValues = splitPropType[1].split(":");
|
|
GeneralBean gBean = new GeneralBean();
|
|
String[] edits = prefValues[1].split(";");
|
|
gBean.setPropName(edits[0]);
|
|
gBean.setEditable(Boolean.parseBoolean(edits[1]));
|
|
if (edits.length > 2)
|
|
gBean.setColumSize(Integer.valueOf(edits[2]));
|
|
gBean.setDisplayName(prefValues[0]);
|
|
generalList.add(gBean);
|
|
|
|
} else if (splitPropType[0].contains("Table")) {
|
|
List<GeneralBean> chidList = new ArrayList<>();
|
|
TableBean tableBean = new TableBean();
|
|
int index = splitPropType[1].indexOf("(");
|
|
int index2 = splitPropType[1].indexOf(")");
|
|
int index3 = splitPropType[0].indexOf("(");
|
|
int index4 = splitPropType[0].indexOf(")");
|
|
String tableRow = splitPropType[0].substring(index3 + 1, index4);
|
|
String tableName = splitPropType[1].substring(0, index);
|
|
String tableString = splitPropType[1].substring(index + 1, index2);
|
|
String[] realProps = tableString.split(",");
|
|
for (String realProp : realProps) {
|
|
String[] prefValues = realProp.split(":");
|
|
GeneralBean gBean = new GeneralBean();
|
|
String[] edits = prefValues[1].split(";");
|
|
gBean.setPropName(edits[0]);
|
|
gBean.setEditable(Boolean.parseBoolean(edits[1]));
|
|
if (edits.length > 2)
|
|
gBean.setColumSize(Integer.valueOf(edits[2]));
|
|
gBean.setDisplayName(prefValues[0]);
|
|
chidList.add(gBean);
|
|
realPropSize++;
|
|
}
|
|
tableBean.setPropName(tableName);
|
|
tableBean.setPropList(chidList);
|
|
tableBean.setTableRow(tableRow);
|
|
tableList.add(tableBean);
|
|
// tablePropMap.put(tableName, realPropMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (TableBean bean : tableList) {
|
|
System.out.println(bean);
|
|
}
|
|
// System.out.println(prefMap);
|
|
try {
|
|
new Thread() {
|
|
boolean isOkModify = form.okToModify();
|
|
public void run() {
|
|
AIFComponentContext[] revisions = null;// Ac5_GYSCBD
|
|
try {
|
|
revisions = form.whereReferencedByTypeRelation(null, new String[] { "Ac5_GYSCBD" });
|
|
} catch (TCException e) {
|
|
e.printStackTrace();
|
|
}
|
|
if (revisions != null) {
|
|
new ProcessreviewDialog(generalList, form, revisions[0], session, tableList, realPropSize,isOkModify);
|
|
} else {
|
|
MessageBox.post("未找到表单以Ac5_GYSCBD关联的版本", "", MessageBox.ERROR);
|
|
}
|
|
};
|
|
}.start();
|
|
} catch (TCException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static String[] getPrefStrArray(String prefName, TCSession session) {
|
|
if (service == null) {
|
|
service = session.getPreferenceService();
|
|
}
|
|
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
|
|
service.getStringValues(prefName);
|
|
service.getStringValue(prefName);
|
|
// if (strs == null) {
|
|
// strs = new String[] { "" };
|
|
// }
|
|
return strs;
|
|
}
|
|
|
|
}
|