Merge pull request 'zouxk' (#7) from zouxk into master
Reviewed-on: http://plmserver.cn:3000/jd/com.connor.jd.plm/pulls/7main
commit
3fa180150b
@ -0,0 +1,94 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.DialogUtil;
|
||||||
|
import com.connor.jd.plm.utils.DialogUtil.TableMsg;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class BatchReviseAction extends AbstractAIFAction {
|
||||||
|
private TCSession session;
|
||||||
|
private TCComponentFolder folder;
|
||||||
|
|
||||||
|
public BatchReviseAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.session = (TCSession) arg0.getSession();
|
||||||
|
TCComponent target = (TCComponent) arg0.getTargetComponent();
|
||||||
|
System.out.println("类型===>" + target.getType());
|
||||||
|
if (target instanceof TCComponentFolder) {
|
||||||
|
this.folder = (TCComponentFolder) target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (folder == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TCComponent[] comps = folder.getRelatedComponents("contents");
|
||||||
|
List<String[]> unpublished = new ArrayList<String[]>();
|
||||||
|
check(comps, unpublished);
|
||||||
|
if (unpublished.size() > 0) {
|
||||||
|
TableMsg msg = DialogUtil.createTableMsg(new String[] { "序号", "名称", "原因" }, unpublished);
|
||||||
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
|
content.setSize(new Dimension(msg.panel.getWidth(), msg.panel.getHeight() + 50));
|
||||||
|
JLabel text = new JLabel("操作已取消,下列目标未满足要求:");
|
||||||
|
content.add(text, BorderLayout.NORTH);
|
||||||
|
content.add(msg.panel, BorderLayout.CENTER);
|
||||||
|
JOptionPane.showMessageDialog(null, content, "信息", JOptionPane.PLAIN_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<TCComponentItemRevision> newRevs = new ArrayList<>();
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (!(comp instanceof TCComponentItemRevision)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
|
||||||
|
newRevs.add(rev.saveAs(rev.getItem().getNewRev()));
|
||||||
|
}
|
||||||
|
if (comps.length > 0) {
|
||||||
|
folder.cutOperation("contents", comps);
|
||||||
|
folder.add("contents", newRevs);
|
||||||
|
folder.refresh();
|
||||||
|
JOptionPane.showMessageDialog(null, "升版成功", "信息", JOptionPane.WARNING_MESSAGE);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(TCComponent[] comps, List<String[]> unpublished) throws Exception {
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (!(comp instanceof TCComponentItemRevision)) {
|
||||||
|
unpublished.add(
|
||||||
|
new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "目标类型错误,请放版本" });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean isAccess = session.getTCAccessControlService()
|
||||||
|
.checkPrivilege(((TCComponentItemRevision) comp).getItem(), "WRITE");
|
||||||
|
if (!isAccess) {
|
||||||
|
unpublished.add(new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "无权限" });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TCComponent[] status = comp.getRelatedComponents("release_status_list");
|
||||||
|
if (status.length == 0) {
|
||||||
|
unpublished.add(new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "未发布" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCProperty;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
public class DeleteItemRevisionAction extends AbstractAIFAction {
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
|
||||||
|
public DeleteItemRevisionAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.app = arg0;
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent[] targets = app.getTargetComponents();
|
||||||
|
String[] allow = JDMethodUtil.getPrefStrArray("jd2_wltz_Revise_allow", session);
|
||||||
|
System.out.println(Arrays.toString(allow));
|
||||||
|
List<String> pref = Arrays.asList(allow);
|
||||||
|
for (InterfaceAIFComponent target : targets) {
|
||||||
|
System.out.println(target.getType());
|
||||||
|
if (target instanceof TCComponentItemRevision && pref.contains(target.getType())) {
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) target;
|
||||||
|
try {
|
||||||
|
String loginUser = session.getUser().getProperty("object_string");
|
||||||
|
String owningUser = rev.getProperty("owning_user");
|
||||||
|
System.out.println("loginUser===>" + loginUser);
|
||||||
|
System.out.println("owningUser===>" + owningUser);
|
||||||
|
if (loginUser.equals(owningUser)) {
|
||||||
|
TCComponentItem item = rev.getItem();
|
||||||
|
TCComponent[] released = item.getReleasedItemRevisions();
|
||||||
|
for (TCComponent comp : released) {
|
||||||
|
if (comp.getUid().equals(rev.getUid())) {
|
||||||
|
MessageBox.post("无法删除,物料已经发布", "提示", MessageBox.WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!loginUser.equals(item.getProperty("owning_user"))) {
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { true });
|
||||||
|
AIFComponentContext[] aifs = rev.whereReferenced();
|
||||||
|
for (AIFComponentContext aif : aifs) {
|
||||||
|
if (aif.getComponent() instanceof TCComponentItemRevision) {
|
||||||
|
TCComponentItemRevision temp = (TCComponentItemRevision) aif.getComponent();
|
||||||
|
TCProperty[] tcProps = temp.getAllTCProperties();
|
||||||
|
for (TCProperty tcProp : tcProps) {
|
||||||
|
TCComponent[] comps = tcProp.getReferenceValueArray();
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (comp.getUid().equals(rev.getUid())) {
|
||||||
|
temp.cutOperation(tcProp.getPropertyName(), new TCComponent[] { rev });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rev.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class BOMLogBean {
|
||||||
|
private String target1;
|
||||||
|
private String target2;
|
||||||
|
private String parent;
|
||||||
|
private String operation;
|
||||||
|
private String unit;
|
||||||
|
private String oldNum;
|
||||||
|
private String num;
|
||||||
|
|
||||||
|
public BOMLogBean(String target1, String target2, String parent, String operation, String unit, String oldNum,
|
||||||
|
String num) {
|
||||||
|
super();
|
||||||
|
this.target1 = target1;
|
||||||
|
this.target2 = target2;
|
||||||
|
this.parent = parent;
|
||||||
|
this.operation = operation;
|
||||||
|
this.unit = unit;
|
||||||
|
this.oldNum = oldNum;
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget1() {
|
||||||
|
return target1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget1(String target1) {
|
||||||
|
this.target1 = target1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget2() {
|
||||||
|
return target2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget2(String target2) {
|
||||||
|
this.target2 = target2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(String parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperation(String operation) {
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOldNum() {
|
||||||
|
return oldNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOldNum(String oldNum) {
|
||||||
|
this.oldNum = oldNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(String num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.BatchReviseAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class BatchReviseHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
new Thread(new BatchReviseAction(app, "")).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.DeleteItemRevisionAction;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class DeleteItemRevisionHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
DeleteItemRevisionAction action = new DeleteItemRevisionAction(AIFUtility.getCurrentApplication(), "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.connor.jd.plm.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.aspose.cells.Cells;
|
||||||
|
import com.aspose.cells.License;
|
||||||
|
import com.aspose.cells.Workbook;
|
||||||
|
import com.aspose.cells.WorksheetCollection;
|
||||||
|
|
||||||
|
public class SimpleExcelUtil {
|
||||||
|
public static void exportExcel(String path, String[] header, List<String[]> data) {
|
||||||
|
if (path == null || data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file = new File(path);
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
getLicense();
|
||||||
|
|
||||||
|
Workbook excel = new Workbook(path);
|
||||||
|
WorksheetCollection wc = excel.getWorksheets();
|
||||||
|
Cells cells = wc.get(0).getCells();
|
||||||
|
int rowIndex = 0;
|
||||||
|
if (header != null) {
|
||||||
|
for (int columnIndex = 0; columnIndex < header.length; columnIndex++) {
|
||||||
|
cells.get(rowIndex, columnIndex).setValue(header[columnIndex]);
|
||||||
|
}
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
for (String[] arr : data) {
|
||||||
|
for (int columnIndex = 0; columnIndex < arr.length; columnIndex++) {
|
||||||
|
cells.get(rowIndex, columnIndex).setValue(arr[columnIndex]);
|
||||||
|
}
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
excel.save(path);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getLicense() throws Exception {
|
||||||
|
boolean result = false;
|
||||||
|
try {
|
||||||
|
InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml");
|
||||||
|
License aposeLic = new License();
|
||||||
|
aposeLic.setLicense(is);
|
||||||
|
result = true;
|
||||||
|
is.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<String[]> test = new ArrayList<String[]>();
|
||||||
|
test.add(new String[] { "zzz", "xxx" });
|
||||||
|
SimpleExcelUtil.exportExcel(System.getenv("temp") + File.separator + "xxxxxxxxxxxxxxxxxxxx.xlsx",
|
||||||
|
new String[] { "1", "2" }, test);
|
||||||
|
System.out.println(System.getenv("temp"));
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,871 @@
|
|||||||
|
package com.teamcenter.rac.commands.open;
|
||||||
|
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.ui.IPerspectiveDescriptor;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AIFDesktop;
|
||||||
|
import com.teamcenter.rac.aif.AIFPortal;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFCommand;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||||
|
import com.teamcenter.rac.aif.ICommandListener;
|
||||||
|
import com.teamcenter.rac.aif.ICommandListenerEvent;
|
||||||
|
import com.teamcenter.rac.aif.IPerspectiveDef;
|
||||||
|
import com.teamcenter.rac.aif.IPerspectiveDefService;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AifrcpPlugin;
|
||||||
|
import com.teamcenter.rac.commands.newobjectlink.NewObjectLinkCommand;
|
||||||
|
import com.teamcenter.rac.commands.properties.PropertiesCommand;
|
||||||
|
import com.teamcenter.rac.common.Activator;
|
||||||
|
import com.teamcenter.rac.common.services.IOpenConfigurationService;
|
||||||
|
import com.teamcenter.rac.common.viewedit.IViewEditOperationListener;
|
||||||
|
import com.teamcenter.rac.common.viewedit.ViewEditHelper;
|
||||||
|
import com.teamcenter.rac.kernel.NamedReferenceContext;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMView;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMViewRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentCfgAttachmentLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentDatasetDefinition;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFnd0AbstractMarkupSpace;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentReleaseStatus;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentStructureContext;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentTcFile;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentType;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentWolfObject;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentWorkContext;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
||||||
|
import com.teamcenter.rac.kernel.TCProperty;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.services.IOpenService;
|
||||||
|
import com.teamcenter.rac.util.ConfirmationDialog;
|
||||||
|
import com.teamcenter.rac.util.Instancer;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
import com.teamcenter.rac.util.OSGIUtil;
|
||||||
|
import com.teamcenter.rac.util.PlatformHelper;
|
||||||
|
import com.teamcenter.rac.util.Registry;
|
||||||
|
import com.teamcenter.rac.util.SWTUIUtilities;
|
||||||
|
import com.teamcenter.rac.util.Utilities;
|
||||||
|
import com.teamcenter.rac.util.event.ClientEventDispatcher;
|
||||||
|
import com.teamcenter.rac.util.log.Debug;
|
||||||
|
|
||||||
|
public class OpenCommand extends com.teamcenter.rac.aif.commands.open.OpenCommand {
|
||||||
|
private static final String[] SPECIAL_TYPES = new String[] { "Specification", "SpecElement",
|
||||||
|
"Specification Revision", "SpecElementRevision" };
|
||||||
|
|
||||||
|
private static final int TC_not_a_valid_operation_Tool = 9130;
|
||||||
|
|
||||||
|
private static final int TC_asynchronous_upload_error = 0;
|
||||||
|
|
||||||
|
protected AIFDesktop frame;
|
||||||
|
|
||||||
|
private static final String[] MSOFILES = new String[] { ".doc", ".dot", ".xls", ".xlt", ".ppt", ".pot", ".docx",
|
||||||
|
".dotx", ".xlsx", ".xltx", ".pptx", ".potx", ".docm", ".dotm", ".xlsm", ".xltm", ".pptm", ".potm", ".msg" };
|
||||||
|
|
||||||
|
public OpenCommand(AIFPortal paramAIFPortal, InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
super(paramAIFPortal, paramInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCommand(AIFPortal paramAIFPortal, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) {
|
||||||
|
super(paramAIFPortal, paramArrayOfInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCommand(AIFDesktop paramAIFDesktop, InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
super(paramAIFDesktop, paramInterfaceAIFComponent);
|
||||||
|
this.frame = paramAIFDesktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCommand(AIFDesktop paramAIFDesktop, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) {
|
||||||
|
super(paramAIFDesktop, paramArrayOfInterfaceAIFComponent);
|
||||||
|
this.frame = paramAIFDesktop;
|
||||||
|
InterfaceAIFComponent interfaceAIFComponent = paramArrayOfInterfaceAIFComponent[0];
|
||||||
|
if (interfaceAIFComponent instanceof TCComponentStructureContext) {
|
||||||
|
TCComponentStructureContext tCComponentStructureContext = (TCComponentStructureContext) interfaceAIFComponent;
|
||||||
|
TCComponentWorkContext tCComponentWorkContext = null;
|
||||||
|
TCSession tCSession = (TCSession) interfaceAIFComponent.getSession();
|
||||||
|
try {
|
||||||
|
tCComponentWorkContext = (TCComponentWorkContext) tCComponentStructureContext
|
||||||
|
.getReferenceProperty("default_workcontext");
|
||||||
|
if (tCComponentWorkContext != null && tCSession != null
|
||||||
|
&& tCComponentWorkContext != tCSession.getCurrentWorkContext())
|
||||||
|
tCSession.setCurrentWorkContext(tCComponentWorkContext);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCommand(AIFDesktop paramAIFDesktop, Dialog paramDialog,
|
||||||
|
InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
super(paramAIFDesktop, paramDialog, paramInterfaceAIFComponent);
|
||||||
|
this.frame = paramAIFDesktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenCommand(AIFDesktop paramAIFDesktop, Dialog paramDialog,
|
||||||
|
InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) {
|
||||||
|
super(paramAIFDesktop, paramDialog, paramArrayOfInterfaceAIFComponent);
|
||||||
|
this.frame = paramAIFDesktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean checkReadOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int postReadOnlyConfirmation(String paramString) {
|
||||||
|
Registry registry = Registry.getRegistry(this);
|
||||||
|
return ConfirmationDialog.post(this.desktop,
|
||||||
|
String.valueOf(registry.getString("readOnly.TITLE")) + " " + paramString,
|
||||||
|
registry.getStringWithSubstitution("readOnly.MSG", new String[] { paramString }),
|
||||||
|
"FormReadOnlyConfirmation");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String resolveType(String[] paramArrayOfString, InterfaceAIFComponent paramInterfaceAIFComponent)
|
||||||
|
throws Exception {
|
||||||
|
String str1 = null;
|
||||||
|
TCComponent tCComponent = (TCComponent) paramInterfaceAIFComponent;
|
||||||
|
if (tCComponent.isTypeOf(SPECIAL_TYPES))
|
||||||
|
return "Specification";
|
||||||
|
if (tCComponent instanceof TCComponentBOMViewRevision) {
|
||||||
|
TCComponentBOMViewRevision tCComponentBOMViewRevision = (TCComponentBOMViewRevision) tCComponent;
|
||||||
|
TCComponent tCComponent1 = tCComponentBOMViewRevision.getRelatedComponent("bom_view");
|
||||||
|
TCComponent tCComponent2 = tCComponent1.getRelatedComponent("parent_item");
|
||||||
|
if (tCComponent2.isTypeOf(SPECIAL_TYPES))
|
||||||
|
return "Specification";
|
||||||
|
}
|
||||||
|
if (tCComponent instanceof TCComponentBOMView) {
|
||||||
|
TCComponentBOMView tCComponentBOMView = (TCComponentBOMView) tCComponent;
|
||||||
|
TCComponent tCComponent1 = tCComponentBOMView.getRelatedComponent("parent_item");
|
||||||
|
if (tCComponent1.isTypeOf(SPECIAL_TYPES))
|
||||||
|
return "Specification";
|
||||||
|
}
|
||||||
|
List<String> list = Arrays.asList(paramArrayOfString);
|
||||||
|
String str2 = tCComponent.getType();
|
||||||
|
if (!(tCComponent instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder) && list.contains(str2)) {
|
||||||
|
str1 = str2;
|
||||||
|
} else {
|
||||||
|
(new String[1])[0] = "POM_object";
|
||||||
|
String[] arrayOfString = (tCComponent instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder)
|
||||||
|
? new String[1]
|
||||||
|
: tCComponent.getClassNameHierarchy();
|
||||||
|
if (arrayOfString != null) {
|
||||||
|
String[] arrayOfString1;
|
||||||
|
int i = (arrayOfString1 = arrayOfString).length;
|
||||||
|
for (byte b = 0; b < i; b++) {
|
||||||
|
String str = arrayOfString1[b];
|
||||||
|
if (list.contains(str)) {
|
||||||
|
str1 = str;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRegisteredClass(InterfaceAIFComponent paramInterfaceAIFComponent, String paramString)
|
||||||
|
throws Exception {
|
||||||
|
if (paramString.equals("APPLICATION")) {
|
||||||
|
IOpenConfigurationService iOpenConfigurationService = (IOpenConfigurationService) OSGIUtil
|
||||||
|
.getService(Activator.getDefault(), IOpenConfigurationService.class);
|
||||||
|
String str = iOpenConfigurationService.getPerspectiveIdToOpenWith(paramInterfaceAIFComponent);
|
||||||
|
return (str != null && !str.isEmpty()) ? str : null;
|
||||||
|
}
|
||||||
|
return super.getRegisteredClass(paramInterfaceAIFComponent, paramString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isReadOnly(InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
boolean bool = false;
|
||||||
|
if (paramInterfaceAIFComponent == null)
|
||||||
|
return bool;
|
||||||
|
if (this.session == null)
|
||||||
|
this.session = paramInterfaceAIFComponent.getSession();
|
||||||
|
if (this.session == null || !(this.session instanceof TCSession)
|
||||||
|
|| !(paramInterfaceAIFComponent instanceof TCComponent))
|
||||||
|
return bool;
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentDataset
|
||||||
|
|| paramInterfaceAIFComponent instanceof TCComponentForm) {
|
||||||
|
TCComponent tCComponent = (TCComponent) paramInterfaceAIFComponent;
|
||||||
|
try {
|
||||||
|
ArrayList<TCComponent> arrayList = new ArrayList();
|
||||||
|
arrayList.add(tCComponent);
|
||||||
|
TCComponentType.refresh(arrayList);
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentDataset) {
|
||||||
|
bool = ((TCComponentDataset) paramInterfaceAIFComponent).isEditable() ? false : true;
|
||||||
|
} else {
|
||||||
|
bool = tCComponent.okToModify() ? false : true;
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUploading(InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
if (paramInterfaceAIFComponent == null || !(paramInterfaceAIFComponent instanceof TCComponentDataset))
|
||||||
|
return false;
|
||||||
|
TCComponentDataset tCComponentDataset = (TCComponentDataset) paramInterfaceAIFComponent;
|
||||||
|
return tCComponentDataset.askUploadingFlag();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean openComponent(InterfaceAIFComponent paramInterfaceAIFComponent) throws Exception {
|
||||||
|
boolean bool1 = isSupportedComponent(paramInterfaceAIFComponent);
|
||||||
|
boolean bool2 = false;
|
||||||
|
if (bool1)
|
||||||
|
if (paramInterfaceAIFComponent.getType().equals("SimulationProcessStudio")) {
|
||||||
|
bool2 = openApplication(paramInterfaceAIFComponent);
|
||||||
|
} else if (((TCComponent) paramInterfaceAIFComponent).isTypeOf("Fnd0AbstractMarkupSpace")) {
|
||||||
|
bool2 = openMarkupSpaceInApplication((TCComponentFnd0AbstractMarkupSpace) paramInterfaceAIFComponent);
|
||||||
|
} else {
|
||||||
|
bool2 = super.openComponent(paramInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
return bool2;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isSupportedComponent(InterfaceAIFComponent paramInterfaceAIFComponent) throws TCException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean openByWindow(InterfaceAIFComponent paramInterfaceAIFComponent) throws Exception {
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentForm) {
|
||||||
|
if (((TCComponentForm) paramInterfaceAIFComponent).isTypeOf("Web Link")) {
|
||||||
|
TCComponentForm tCComponentForm = (TCComponentForm) paramInterfaceAIFComponent;
|
||||||
|
TCProperty[] arrayOfTCProperty = tCComponentForm.getFormTCProperties();
|
||||||
|
TCProperty tCProperty = null;
|
||||||
|
if (arrayOfTCProperty != null) {
|
||||||
|
TCProperty[] arrayOfTCProperty1;
|
||||||
|
int i = (arrayOfTCProperty1 = arrayOfTCProperty).length;
|
||||||
|
for (byte b = 0; b < i; b++) {
|
||||||
|
TCProperty tCProperty1 = arrayOfTCProperty1[b];
|
||||||
|
if (tCProperty1.getPropertyName().equals("url")) {
|
||||||
|
tCProperty = tCProperty1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tCProperty != null)
|
||||||
|
openWebLink(paramInterfaceAIFComponent.toString(), tCProperty.getStringValue());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TCPreferenceService tCPreferenceService = ((TCComponent) paramInterfaceAIFComponent).getSession()
|
||||||
|
.getPreferenceService();
|
||||||
|
String str = tCPreferenceService.getStringValue("Form_double_click");
|
||||||
|
if (str != null && str.equalsIgnoreCase("edit")) {
|
||||||
|
openFormBasedOnPrefValue((TCComponentForm) paramInterfaceAIFComponent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
openFormByOpenWindowMethod((TCComponentForm) paramInterfaceAIFComponent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponent
|
||||||
|
&& ((TCComponent) paramInterfaceAIFComponent).isTypeOf("WolfObject")) {
|
||||||
|
String str = NewObjectLinkCommand.getObjCurrentUrl((TCComponentWolfObject) paramInterfaceAIFComponent,
|
||||||
|
(Frame) this.frame, (TCSession) this.session);
|
||||||
|
if (str != null) {
|
||||||
|
if (Debug.isOn("proxylink"))
|
||||||
|
Debug.println("Object URL: " + str);
|
||||||
|
openWebLink((String) null, str);
|
||||||
|
} else if (Debug.isOn("proxylink")) {
|
||||||
|
Debug.println("Object URL is NULL");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (paramInterfaceAIFComponent instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder) ? false
|
||||||
|
: super.openByWindow(paramInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openFormBasedOnPrefValue(final TCComponentForm formComp) {
|
||||||
|
final ViewEditHelper veHelper = new ViewEditHelper(formComp.getSession());
|
||||||
|
Job job = new Job("") {
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor param1IProgressMonitor) {
|
||||||
|
param1IProgressMonitor.beginTask("Form Dialog..", -1);
|
||||||
|
try {
|
||||||
|
ViewEditHelper.CKO cKO = veHelper.getObjectState(formComp);
|
||||||
|
if (veHelper.isSWTPerspective()) {
|
||||||
|
OpenCommand.IC_PostReserveSWTListener iC_PostReserveSWTListener = new OpenCommand.IC_PostReserveSWTListener(
|
||||||
|
formComp);
|
||||||
|
if (ViewEditHelper.CKO.IMPLICITLY_CHECKOUTABLE.equals(cKO)) {
|
||||||
|
iC_PostReserveSWTListener.operationComplete(0);
|
||||||
|
} else {
|
||||||
|
veHelper.reserveSWTOperation(formComp, formComp.getSession(), iC_PostReserveSWTListener);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OpenCommand.IC_PostReserveCommandListener iC_PostReserveCommandListener = new OpenCommand.IC_PostReserveCommandListener(
|
||||||
|
formComp);
|
||||||
|
if (ViewEditHelper.CKO.IMPLICITLY_CHECKOUTABLE.equals(cKO)) {
|
||||||
|
iC_PostReserveCommandListener.commandDone(null);
|
||||||
|
} else {
|
||||||
|
veHelper.reserveOperation(formComp, iC_PostReserveCommandListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (TCException tCException) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(tCException.getLocalizedMessage(), tCException);
|
||||||
|
} finally {
|
||||||
|
param1IProgressMonitor.done();
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
job.setPriority(10);
|
||||||
|
job.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void openFormByOpenWindowMethod(TCComponentForm paramTCComponentForm) throws Exception {
|
||||||
|
IOpenService iOpenService = (IOpenService) OSGIUtil.getService(Activator.getDefault(), IOpenService.class,
|
||||||
|
"(objectType=" + paramTCComponentForm.getType() + ")");
|
||||||
|
if (iOpenService != null) {
|
||||||
|
Logger.getLogger(OpenCommand.class).debug("Open service is found, use it to open the form.");
|
||||||
|
boolean bool1 = iOpenService.open(paramTCComponentForm);
|
||||||
|
if (bool1) {
|
||||||
|
Logger.getLogger(OpenCommand.class).debug("Form is opened by open service.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.getLogger(OpenCommand.class).debug("No Open Service is found. Continue.");
|
||||||
|
}
|
||||||
|
String str = null;
|
||||||
|
TCPreferenceService tCPreferenceService = paramTCComponentForm.getSession().getPreferenceService();
|
||||||
|
String[] arrayOfString = tCPreferenceService.getStringValues("defaultViewerConfig.VIEWERCONFIG");
|
||||||
|
Boolean bool = tCPreferenceService.getLogicalValue("UsePropertyStylesheetPlatformRenderer");
|
||||||
|
if (bool.booleanValue()) {
|
||||||
|
str = this.registry.getString("openFormDialog");
|
||||||
|
} else if (arrayOfString != null && arrayOfString.length != 0) {
|
||||||
|
String str1 = String.valueOf(paramTCComponentForm.getType()) + ".FormViewer";
|
||||||
|
if (Utilities.contains(str1, arrayOfString) || Utilities.contains("Form.FormViewer", arrayOfString))
|
||||||
|
str = this.registry.getString("openFormDialog");
|
||||||
|
}
|
||||||
|
openByWindow(paramTCComponentForm, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean openByOpenMethod(InterfaceAIFComponent paramInterfaceAIFComponent) throws Exception {
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentDataset) {
|
||||||
|
if (paramInterfaceAIFComponent.getType().equals("FullText")) {
|
||||||
|
openFullText((TCComponentDataset) paramInterfaceAIFComponent);
|
||||||
|
} else if (paramInterfaceAIFComponent.getType().equals("ProgramView")) {
|
||||||
|
openProgramView((TCComponentDataset) paramInterfaceAIFComponent);
|
||||||
|
} else if (paramInterfaceAIFComponent.getType().equals("SnapShotViewData")) {
|
||||||
|
openProgramView((TCComponentDataset) paramInterfaceAIFComponent);
|
||||||
|
} else {
|
||||||
|
TCComponentDataset tCComponentDataset = (TCComponentDataset) paramInterfaceAIFComponent;
|
||||||
|
boolean bool = false;
|
||||||
|
TCComponentTcFile[] arrayOfTCComponentTcFile = tCComponentDataset.getTcFiles();
|
||||||
|
if (arrayOfTCComponentTcFile != null && arrayOfTCComponentTcFile.length > 0) {
|
||||||
|
bool = validFileForMSOIntegration(arrayOfTCComponentTcFile[0]);
|
||||||
|
} else {
|
||||||
|
String[] arrayOfString = null;
|
||||||
|
TCComponentDatasetDefinition tCComponentDatasetDefinition = tCComponentDataset
|
||||||
|
.getDatasetDefinitionComponent();
|
||||||
|
NamedReferenceContext[] arrayOfNamedReferenceContext = tCComponentDatasetDefinition
|
||||||
|
.getNamedReferenceContexts();
|
||||||
|
if (arrayOfNamedReferenceContext != null) {
|
||||||
|
arrayOfString = new String[arrayOfNamedReferenceContext.length];
|
||||||
|
for (byte b = 0; b < arrayOfNamedReferenceContext.length; b++) {
|
||||||
|
arrayOfString[b] = arrayOfNamedReferenceContext[b].getFileTemplate();
|
||||||
|
if (arrayOfString[b] != null && arrayOfString[b].indexOf('.') > 0) {
|
||||||
|
String str = arrayOfString[b].substring(arrayOfString[b].lastIndexOf('.'));
|
||||||
|
String[] arrayOfString1;
|
||||||
|
int i = (arrayOfString1 = MSOFILES).length;
|
||||||
|
for (byte b1 = 0; b1 < i; b1++) {
|
||||||
|
String str1 = arrayOfString1[b1];
|
||||||
|
if (str.equalsIgnoreCase(str1)) {
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bool)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bool)
|
||||||
|
tCComponentDataset.setOfficeType(bool);
|
||||||
|
openDataset(tCComponentDataset);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.openByOpenMethod(paramInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean openMarkupSpaceInApplication(
|
||||||
|
TCComponentFnd0AbstractMarkupSpace paramTCComponentFnd0AbstractMarkupSpace) throws Exception {
|
||||||
|
boolean bool = false;
|
||||||
|
TCComponent[] arrayOfTCComponent = paramTCComponentFnd0AbstractMarkupSpace
|
||||||
|
.getReferenceListProperty("fnd0ReferenceObjects");
|
||||||
|
if (arrayOfTCComponent != null && arrayOfTCComponent.length == 1) {
|
||||||
|
TCComponent tCComponent = arrayOfTCComponent[0];
|
||||||
|
String str = getRegisteredClass(tCComponent, "APPLICATION");
|
||||||
|
if (str != null) {
|
||||||
|
IPerspectiveDescriptor iPerspectiveDescriptor = PlatformHelper.getCurrentPerspective();
|
||||||
|
IPerspectiveDefService iPerspectiveDefService = (IPerspectiveDefService) OSGIUtil
|
||||||
|
.getService(AifrcpPlugin.getDefault(), IPerspectiveDefService.class);
|
||||||
|
IPerspectiveDef iPerspectiveDef = iPerspectiveDefService.findByLegacyAppId(str);
|
||||||
|
if (iPerspectiveDef != null) {
|
||||||
|
IPerspectiveDef iPerspectiveDef1 = iPerspectiveDefService.findByPerspective(iPerspectiveDescriptor);
|
||||||
|
if (iPerspectiveDef1 != null) {
|
||||||
|
String str1 = iPerspectiveDef1.getLegacyAppId();
|
||||||
|
final InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = new InterfaceAIFComponent[2];
|
||||||
|
arrayOfInterfaceAIFComponent[0] = tCComponent;
|
||||||
|
arrayOfInterfaceAIFComponent[1] = paramTCComponentFnd0AbstractMarkupSpace;
|
||||||
|
if (!iPerspectiveDefService.isTypeOfLegacyApp(str, str1)) {
|
||||||
|
final String perspectiveId = iPerspectiveDef.getId();
|
||||||
|
SWTUIUtilities.asyncExec(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AifrcpPlugin.getDefault().openPerspective(perspectiveId);
|
||||||
|
AifrcpPlugin.getDefault().openComponents(perspectiveId,
|
||||||
|
arrayOfInterfaceAIFComponent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bool = true;
|
||||||
|
} else {
|
||||||
|
final IOpenService openService = iPerspectiveDef1.getOpenService();
|
||||||
|
if (openService != null) {
|
||||||
|
Job job = new Job(Registry.getRegistry(this).getString("openComponent.MESSAGE")) {
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor param1IProgressMonitor) {
|
||||||
|
boolean bool = openService.open(arrayOfInterfaceAIFComponent);
|
||||||
|
return bool ? Status.OK_STATUS : Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
job.schedule();
|
||||||
|
bool = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bool = openApplication(paramTCComponentFnd0AbstractMarkupSpace);
|
||||||
|
}
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openDataset(TCComponentDataset paramTCComponentDataset) throws Exception {
|
||||||
|
boolean bool = true;
|
||||||
|
boolean bool1 = isReadOnly(paramTCComponentDataset);
|
||||||
|
if (!bool1)
|
||||||
|
try {
|
||||||
|
paramTCComponentDataset.openForEdit();
|
||||||
|
} catch (TCException | java.io.IOException tCException) {
|
||||||
|
if (tCException instanceof TCException) {
|
||||||
|
if (((TCException) tCException).getErrorCode() == 9130) {
|
||||||
|
MessageBox.post(tCException);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (((TCException) tCException).getErrorCode() == 0)
|
||||||
|
throw tCException;
|
||||||
|
}
|
||||||
|
int i = postReadOnlyConfirmation(paramTCComponentDataset.toString());
|
||||||
|
if (i != 2)
|
||||||
|
return;
|
||||||
|
bool = false;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
if (bool1 || !bool)
|
||||||
|
try {
|
||||||
|
paramTCComponentDataset.openForView();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openFullText(TCComponentDataset paramTCComponentDataset) {
|
||||||
|
boolean bool = isReadOnly(paramTCComponentDataset) ? false : true;
|
||||||
|
try {
|
||||||
|
AbstractAIFOperation abstractAIFOperation = (AbstractAIFOperation) Instancer.newInstanceEx(
|
||||||
|
"com.teamcenter.rac.requirementsmanager.commands.viewedit.ViewEditOperation",
|
||||||
|
new Object[] { paramTCComponentDataset, Boolean.valueOf(bool) });
|
||||||
|
abstractAIFOperation.executeModeless();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openProgramView(TCComponentDataset paramTCComponentDataset) {
|
||||||
|
try {
|
||||||
|
openApplication(paramTCComponentDataset);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isReleased(List<InterfaceAIFComponent> paramList) {
|
||||||
|
final AbstractAIFDialog effDia;
|
||||||
|
try {
|
||||||
|
if (!((TCSession) this.session).isInV7Mode())
|
||||||
|
return true;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
MessageBox.post(exception);
|
||||||
|
}
|
||||||
|
TCComponentReleaseStatus[] arrayOfTCComponentReleaseStatus = new TCComponentReleaseStatus[paramList.size()];
|
||||||
|
for (byte b = 0; b < arrayOfTCComponentReleaseStatus.length; b++)
|
||||||
|
arrayOfTCComponentReleaseStatus[b] = (TCComponentReleaseStatus) paramList.get(b);
|
||||||
|
try {
|
||||||
|
effDia = (AbstractAIFDialog) Instancer.newInstance(
|
||||||
|
"com.teamcenter.rac.effectivity.ReleaseStatusEffectivityDialog",
|
||||||
|
new Object[] { arrayOfTCComponentReleaseStatus, this.frame });
|
||||||
|
} catch (Exception exception) {
|
||||||
|
MessageBox.post(exception, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
effDia.run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SwingUtilities.invokeLater(runnable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isArchived(InterfaceAIFComponent paramInterfaceAIFComponent) {
|
||||||
|
boolean bool = false;
|
||||||
|
if (paramInterfaceAIFComponent == null)
|
||||||
|
return bool;
|
||||||
|
if (this.session == null)
|
||||||
|
this.session = paramInterfaceAIFComponent.getSession();
|
||||||
|
if (this.session == null || !(this.session instanceof TCSession)
|
||||||
|
|| !(paramInterfaceAIFComponent instanceof TCComponent))
|
||||||
|
return bool;
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentDataset
|
||||||
|
|| paramInterfaceAIFComponent instanceof TCComponentForm) {
|
||||||
|
TCComponent tCComponent = (TCComponent) paramInterfaceAIFComponent;
|
||||||
|
try {
|
||||||
|
String str = tCComponent.getProperty("archive_date");
|
||||||
|
if (str != null && str.length() > 0)
|
||||||
|
bool = true;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeCommand() throws Exception {
|
||||||
|
final Registry commandRegistry = Registry.getRegistry(this);
|
||||||
|
TCPreferenceService tCPreferenceService = (TCPreferenceService) OSGIUtil.getService(Activator.getDefault(),
|
||||||
|
TCPreferenceService.class);
|
||||||
|
final Integer prefValue = tCPreferenceService.getIntegerValue("TCMaxOpenViewsLimit");
|
||||||
|
InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = new InterfaceAIFComponent[prefValue.intValue()];
|
||||||
|
if (this.components.length > prefValue.intValue()) {
|
||||||
|
for (byte b = 0; b < prefValue.intValue(); b++)
|
||||||
|
arrayOfInterfaceAIFComponent[b] = this.components[b];
|
||||||
|
this.components = arrayOfInterfaceAIFComponent;
|
||||||
|
final Display display = PlatformHelper.getCurrentDisplay();
|
||||||
|
display.asyncExec(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MessageDialog messageDialog = new MessageDialog(display.getActiveShell(),
|
||||||
|
commandRegistry.getString("tooManyViews.TITLE"), null,
|
||||||
|
MessageFormat.format(commandRegistry.getString("tooManyViewsError.MSG"),
|
||||||
|
new Object[] { prefValue }),
|
||||||
|
4, new String[] { commandRegistry.getString("openViewDialog_buttonOK"),
|
||||||
|
commandRegistry.getString("openViewDialog_buttonCancel") },
|
||||||
|
0);
|
||||||
|
if (messageDialog.open() != 0)
|
||||||
|
return;
|
||||||
|
OpenCommand.this.openComponents();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
openComponents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openComponents() {
|
||||||
|
this.session.queueOperation(new AbstractAIFOperation(Registry.getRegistry(this).getString("opening")) {
|
||||||
|
@Override
|
||||||
|
public final void executeOperation() throws Exception {
|
||||||
|
Registry registry = Registry.getRegistry(this);
|
||||||
|
Vector<InterfaceAIFComponent> vector = new Vector();
|
||||||
|
InterfaceAIFComponent[] arrayOfInterfaceAIFComponent;
|
||||||
|
int i = (arrayOfInterfaceAIFComponent = OpenCommand.this.components).length;
|
||||||
|
for (byte b = 0; b < i; b++) {
|
||||||
|
InterfaceAIFComponent interfaceAIFComponent1 = arrayOfInterfaceAIFComponent[b];
|
||||||
|
InterfaceAIFComponent interfaceAIFComponent2 = interfaceAIFComponent1;
|
||||||
|
System.out.println(interfaceAIFComponent2);
|
||||||
|
// jd
|
||||||
|
if (interfaceAIFComponent2 instanceof TCComponentDataset) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
TCSession tcSession = (TCSession) interfaceAIFComponent2.getSession();
|
||||||
|
TCPreferenceService service = tcSession.getPreferenceService();
|
||||||
|
String[] pref = service.getStringValues("jd_dataset_download");
|
||||||
|
String[] pref2 = service.getStringValues("jd_wl_type_classify");
|
||||||
|
Map<String, List<String>> typeClassify = new HashMap<String, List<String>>();
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
if (pref != null && pref.length > 0) {
|
||||||
|
System.out.println("首选项配置===>" + Arrays.toString(pref));
|
||||||
|
list = Arrays.asList(pref);
|
||||||
|
}
|
||||||
|
if (pref2 != null && pref2.length > 0) {
|
||||||
|
System.out.println("首选项配置2===>" + Arrays.toString(pref2));
|
||||||
|
for (String str : pref2) {
|
||||||
|
String[] row = str.split(":");
|
||||||
|
typeClassify.put(row[0], Arrays.asList(row[1].split(",")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TCComponentDataset dataset = (TCComponentDataset) interfaceAIFComponent2;
|
||||||
|
System.out.println(dataset.getProperty("object_string"));
|
||||||
|
System.out.println(dataset.getType());
|
||||||
|
if (list.contains(dataset.getType())) {
|
||||||
|
boolean flag = false;
|
||||||
|
String currentUser = tcSession.getUser().getProperty("object_string");
|
||||||
|
String owningUser = dataset.getProperty("owning_user");
|
||||||
|
System.out.println("currentUser===>" + currentUser + ",owningUser===>" + owningUser);
|
||||||
|
if (currentUser.equals(owningUser)) {
|
||||||
|
System.out.println("所有者");
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
String loginGroup = tcSession.getUser().getProperty("login_group");
|
||||||
|
System.out.println("loginGroup===>" + loginGroup);
|
||||||
|
if (loginGroup.contains("dba")) {
|
||||||
|
System.out.println("dba");
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
AIFComponentContext[] revs = dataset.whereReferenced();
|
||||||
|
for (AIFComponentContext aif1 : revs) {
|
||||||
|
if (aif1.getComponent() != null
|
||||||
|
&& (aif1.getComponent() instanceof TCComponentItemRevision)) {
|
||||||
|
String type = aif1.getComponent().getType();
|
||||||
|
System.out.println("类型===>" + type);
|
||||||
|
if ((loginGroup.contains("研发一部") && typeClassify.get("GT") != null
|
||||||
|
&& typeClassify.get("GT").contains(type))
|
||||||
|
|| (loginGroup.contains("研发二部") && typeClassify.get("BL") != null
|
||||||
|
&& typeClassify.get("BL").contains(type))
|
||||||
|
|| (loginGroup.contains("研发五部") && typeClassify.get("BX") != null
|
||||||
|
&& typeClassify.get("BX").contains(type))) {
|
||||||
|
System.out.println("满足条件");
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
MessageBox.post("不允许打开", "提示", MessageBox.WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaceAIFComponent2 = OpenCommand.this.getOpeningComponent(interfaceAIFComponent2);
|
||||||
|
if (interfaceAIFComponent2 instanceof TCComponentReleaseStatus) {
|
||||||
|
vector.addElement(interfaceAIFComponent2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (OpenCommand.this.isArchived(interfaceAIFComponent2)) {
|
||||||
|
MessageBox.post(OpenCommand.this.desktop,
|
||||||
|
String.valueOf(interfaceAIFComponent2.toString()) + " "
|
||||||
|
+ registry.getString("archivedObject.MSG"),
|
||||||
|
registry.getString("archivedObject.TITLE"), 4);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (OpenCommand.this.checkReadOnly() && OpenCommand.this.isReadOnly(interfaceAIFComponent2)) {
|
||||||
|
TCComponent tCComponent = null;
|
||||||
|
if (interfaceAIFComponent2 instanceof TCComponent) {
|
||||||
|
tCComponent = (TCComponent) interfaceAIFComponent2;
|
||||||
|
tCComponent.clearCache("checked_out_user");
|
||||||
|
}
|
||||||
|
String str2 = "";
|
||||||
|
int j = 0;
|
||||||
|
String str1 = interfaceAIFComponent2.getProperty("checked_out_user").trim();
|
||||||
|
if (!str1.equals("")) {
|
||||||
|
Registry registry1 = Registry.getRegistry(this);
|
||||||
|
str2 = MessageFormat.format(registry1.getString("checkedOut.MSG"), new Object[] { str1 });
|
||||||
|
j = ConfirmationDialog.post(OpenCommand.this.desktop,
|
||||||
|
String.valueOf(registry1.getString("checkedOut.TITLE")) + " "
|
||||||
|
+ interfaceAIFComponent2.toString(),
|
||||||
|
String.valueOf(interfaceAIFComponent2.toString()) + " " + str2,
|
||||||
|
"FormReadOnlyConfirmation");
|
||||||
|
} else {
|
||||||
|
j = OpenCommand.this.postReadOnlyConfirmation(interfaceAIFComponent2.toString());
|
||||||
|
}
|
||||||
|
if (j != 2)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (OpenCommand.this.isUploading(interfaceAIFComponent2)) {
|
||||||
|
int j = OpenCommand.this.postUploadingConfirmation(interfaceAIFComponent2.toString());
|
||||||
|
if (j != 2)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
AbstractAIFSession abstractAIFSession = interfaceAIFComponent2.getSession();
|
||||||
|
try {
|
||||||
|
setStatus(interfaceAIFComponent2.toString());
|
||||||
|
OpenCommand.this.processOpen(interfaceAIFComponent2);
|
||||||
|
} catch (InvocationTargetException invocationTargetException) {
|
||||||
|
MessageBox messageBox = new MessageBox(OpenCommand.this.desktop,
|
||||||
|
invocationTargetException.getTargetException().getCause().toString(),
|
||||||
|
registry.getString("unableToOpen"), 1);
|
||||||
|
messageBox.setModal(true);
|
||||||
|
messageBox.setVisible(true);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
String str = String.valueOf(registry.getString("unableToOpen", "Unable to open ")) + " "
|
||||||
|
+ interfaceAIFComponent2.toString();
|
||||||
|
abstractAIFSession.setStatus(str);
|
||||||
|
MessageBox messageBox = new MessageBox(OpenCommand.this.desktop, str,
|
||||||
|
exception.getLocalizedMessage(), registry.getString("unableToOpen"), 1);
|
||||||
|
messageBox.setModal(true);
|
||||||
|
messageBox.setVisible(true);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!vector.isEmpty())
|
||||||
|
OpenCommand.this.isReleased(vector);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InterfaceAIFComponent getOpeningComponent(InterfaceAIFComponent paramInterfaceAIFComponent)
|
||||||
|
throws Exception {
|
||||||
|
TCComponent tCComponent = (TCComponent) paramInterfaceAIFComponent;
|
||||||
|
InterfaceAIFComponent interfaceAIFComponent = paramInterfaceAIFComponent;
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponentCfgAttachmentLine)
|
||||||
|
tCComponent = ((TCComponentCfgAttachmentLine) paramInterfaceAIFComponent).getUnderlyingComponent();
|
||||||
|
return tCComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openWebLink(String paramString1, String paramString2) {
|
||||||
|
ClientEventDispatcher.fireEventNow(OpenCommand.class, "com/teamcenter/rac/aifrcp/browser/launchRequest",
|
||||||
|
new Object[] { "com/teamcenter/rac/aifrcp/browser/urlToOpen", paramString2,
|
||||||
|
"com/teamcenter/rac/aifrcp/browser/title", paramString1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean openProperties(InterfaceAIFComponent paramInterfaceAIFComponent) throws Exception {
|
||||||
|
if (paramInterfaceAIFComponent instanceof TCComponent) {
|
||||||
|
TCComponent[] arrayOfTCComponent = { (TCComponent) paramInterfaceAIFComponent };
|
||||||
|
Window window = (this.parentWindow != null) ? this.parentWindow : this.desktop;
|
||||||
|
PropertiesCommand propertiesCommand = new PropertiesCommand(arrayOfTCComponent, window);
|
||||||
|
propertiesCommand.executeModeless();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validFileForMSOIntegration(TCComponentTcFile paramTCComponentTcFile) throws Exception {
|
||||||
|
boolean bool = false;
|
||||||
|
if (paramTCComponentTcFile != null) {
|
||||||
|
String str = paramTCComponentTcFile.getProperty("original_file_name");
|
||||||
|
if (str != null && str.indexOf('.') > 0) {
|
||||||
|
String str1 = str.substring(str.lastIndexOf('.'));
|
||||||
|
String[] arrayOfString;
|
||||||
|
int i = (arrayOfString = MSOFILES).length;
|
||||||
|
for (byte b = 0; b < i; b++) {
|
||||||
|
String str2 = arrayOfString[b];
|
||||||
|
if (str1.equalsIgnoreCase(str2)) {
|
||||||
|
bool = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openForm(final TCComponent component) {
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
OpenCommand.this.openFormByOpenWindowMethod((TCComponentForm) component);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(exception.getLocalizedMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SwingUtilities.invokeLater(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class IC_PostReserveCommandListener implements ICommandListener {
|
||||||
|
private final TCComponent m_component;
|
||||||
|
|
||||||
|
public IC_PostReserveCommandListener(TCComponent param1TCComponent) {
|
||||||
|
this.m_component = param1TCComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commandDone(ICommandListenerEvent param1ICommandListenerEvent) {
|
||||||
|
AbstractAIFCommand abstractAIFCommand = (param1ICommandListenerEvent != null)
|
||||||
|
? param1ICommandListenerEvent.getCommand()
|
||||||
|
: null;
|
||||||
|
OpenCommand.this.openForm(this.m_component);
|
||||||
|
if (abstractAIFCommand != null)
|
||||||
|
param1ICommandListenerEvent.getCommand().removeCommandListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commandStarting(ICommandListenerEvent param1ICommandListenerEvent) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class IC_PostReserveSWTListener implements IViewEditOperationListener {
|
||||||
|
private final TCComponent m_component;
|
||||||
|
|
||||||
|
public IC_PostReserveSWTListener(TCComponentForm param1TCComponentForm) {
|
||||||
|
this.m_component = param1TCComponentForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(int param1Int) {
|
||||||
|
OpenCommand.this.openForm(this.m_component);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationError(TCException param1TCException) {
|
||||||
|
Logger.getLogger(OpenCommand.class).error(param1TCException.getLocalizedMessage(), param1TCException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Location:
|
||||||
|
* C:\Users\5rKB5bPlusD\Desktop\com.teamcenter.rac.common_12000.2.0.jar!\com\
|
||||||
|
* teamcenter\rac\commands\open\OpenCommand.class Java compiler version: 8
|
||||||
|
* (52.0) JD-Core Version: 1.1.3
|
||||||
|
*/
|
Loading…
Reference in new issue