我们正在使用名为Teamcenter的OTB应用程序。我正在编写一个添加应用程序,该应用程序是从Teamcenter应用程序中的菜单选择中调用的。
当他们单击菜单项时,它会执行一个处理程序类,并为我的应用程序创建基本对话框。 它将在“打开”对话框中显示Teamcenter中的选定组件。 Dialog有一个带Button的文本字段。 用户返回父窗口并选择项目,然后单击对话框上的按钮,这将在打开的对话框中设置所选项目。
但是当Dialog打开并且我回到父母身份,即OTB团队中心申请选择项目时,它看起来好像被绞死了。
文本和按钮是相邻字段。
如果用户选择1200个部件并转到菜单并选择项目,则会显示弹出窗口然后单击父窗口以选择单个项目,单击父项需要时间 但如果我们有200个零件,然后返回并点击父窗口,则不会花费太多时间
有人可以建议如何改善时间表现吗?
// open():首次调用菜单选择将调用open()方法 // setSourceBomLinesOnSessionInfo():从Open方法()调用以设置需要在对话框列表组件上设置的会话中所需的选定项目信息 // SetScope():在打开的对话框上设置按钮选择的文本数据 //用户将进入父窗口并选择项目,然后返回打开的对话框并单击按钮
public void open()
{
eQOTMLoggerManager.logger.debug("open 'OTM Compare' Dialog");
eQOTMSessionInfo.getInstance().clearCurrentSelection();
Shell prevShell = getOTMCompareDialog();
if (prevShell != null)
{
prevShell.setMinimized(false);
}else{
try{
//Set Source BomLine on OTM Dialog Window
bSetInputOnDialog = setSourceBomLinesOnSessionInfo();
if( bSetInputOnDialog )
{
initializeUIComponents();
mainDialogShell.open();
Display display = mainDialogShell.getDisplay();
while (!mainDialogShell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
mainDialogShell.dispose();
}
else if (mainDialogShell != null)
{
mainDialogShell.dispose();
}
eQOTMLoggerManager.logger.error("INFO:Exit initialize UI Components for OTM compare dialog.");
}
catch (Throwable th)
{
eQOTMLoggerManager.logger.error("Exception occurred while initializing UI Components for OTM compare dialog. Error: "+th.getMessage(),th);
}
}
}
//Initialize UI Component
private void initializeUIComponents() throws TCException
{
eQOTMLoggerManager.logger.error("INFO:In initialize UI Components for OTM compare dialog !!!");
mainDialogShell = new Shell(this.m_parentShell, SWT.DIALOG_TRIM |SWT.MODELESS);
mainDialogShell.setText(this.m_sOTMDialogTitle);
mainDialogShell.setLocation(getParent().toDisplay(300, 200));
mainDialogShell.setSize(450, 400);
/* Image dialogicon = new Image(mainDialogShell.getDisplay(),"icon/ecubeIcon.png");
mainDialogShell.setImage(dialogicon);
*/
/*Main grid*/
GridLayout gridLayout = new GridLayout(4, false);
gridLayout.verticalSpacing = 10;
mainDialogShell.setLayout(gridLayout);
//Scope label to display on UI
new Label(mainDialogShell, SWT.NONE|SWT.CENTER).setText("Scope:");
//Text filed for scope
this.m_textScopeName = new Text(mainDialogShell,SWT.READ_ONLY|SWT.SINGLE | SWT.BORDER);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
this.m_textScopeName.setLayoutData(gridData);
//Button to set scope
Button btnsetscope = new Button(mainDialogShell, SWT.PUSH);
btnsetscope.setText("Set Scope");
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.horizontalAlignment = GridData.END;
btnsetscope.setLayoutData(gridData);
//Label for List of Parts to Compare
new Label(mainDialogShell, SWT.NONE).setText("List of Parts to Compare :");
//Text filed for List of Parts to Compare
m_listKitParts = new Text(mainDialogShell, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL);
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
gridData.horizontalSpan = 3;
gridData.grabExcessVerticalSpace = true;
m_listKitParts.setLayoutData(gridData);
final Button btnCompare = new Button(mainDialogShell, SWT.PUSH);
btnCompare.setText("Identify");
gridData = new GridData();
gridData.horizontalSpan = 3;
gridData.horizontalAlignment = GridData.END;
btnCompare.setLayoutData(gridData);
final Button btnCancel = new Button(mainDialogShell, SWT.PUSH);
btnCancel.setText(" Cancel ");
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.horizontalAlignment = GridData.END;
btnCancel.setLayoutData(gridData);
long start_time = System.nanoTime();
/*
TCComponentBOMLine[] alSelectedSRCBOMLinetemp = eQOTMSessionInfo.getInstance().getCurrentSourceBOMLines();
int componentsize=alSelectedSRCBOMLinetemp.length;
for(int i=0;i<componentsize;i++)
{
m_listKitParts.append(alSelectedSRCBOMLinetemp[i].toString()+"\n");
}
*/
InterfaceAIFComponent selectedcomponent[]=m_sourcepanel.getSelectedComponents();
int componentsize=selectedcomponent.length;
for(int i=0;i<componentsize;i++)
{
m_listKitParts.append(selectedcomponent[i]+"\n");
}
long end_time = System.nanoTime();
double difference = (end_time - start_time)/1e6;
eQOTMLoggerManager.logger.error("INFO:Response return to TC. Total time taken: "+(difference)/1000);
//Set scope Button Listener
btnsetscope.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
//Set Scope for Compare BOMLine operation
SetScope();
}
});
//Compare Button Listener
btnCompare.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
if(m_textScopeName.getText().length()<=0)
{
m_textScopeName.setFocus();
MessageBox.post(Messages.eQOTM_ScopeSelection_info,Messages.eQOTM_ScopeSelection_title, 2);
}
else
{
btnCompare.setEnabled(false);
btnCancel.setEnabled(false);
Job serverJob = new Job(eQOTMConstants.Stausmessage)
{
protected IStatus run(IProgressMonitor monitor)
{
eQOTMLoggerManager.logger.error("INFO:Started backgound thread to call MI process\n");
compareBOMLines();
mainDialogShell.getDisplay().syncExec(new Runnable()
{
public void run()
{
mainDialogShell.close();
}
});
return Status.OK_STATUS;
}
};
serverJob.setPriority(Job.SHORT);
serverJob.schedule();
}
}
});
//cancel Button Listener
btnCancel.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
mainDialogShell.close();
}
});
eQOTMLoggerManager.logger.error("INFO:Exit initialize UI Components for OTM compare dialog.");
}
private boolean setSourceBomLinesOnSessionInfo() throws TCException
{
eQOTMLoggerManager.logger.debug("In setSourceBomLinesOnCompareDialog");
InterfaceComparable sourcePanel = m_currentTcApplication.getActiveComparable();
eQOTMSessionInfo objOTMSession = eQOTMSessionInfo.getInstance();
this.m_sourcepanel=sourcePanel;
TCComponentBOMLine[] arrayOfTargetTCComponentBOMLine = null;
ArrayList<TCComponentBOMLine> arrlcheckedBOMLine = new ArrayList<TCComponentBOMLine>();
if(((BOMTreeTable)sourcePanel.getCompareTreeTable()).getBOMWindow().getTopBOMLine().getDisplayType().toString().equals(eQOTMConstants.IS_MFG_PLAN))
{
if( !SetScope() )//on error return false
return false;
if( !setCheckedBomlines(arrlcheckedBOMLine)){//on error return false
return false;
}
arrayOfTargetTCComponentBOMLine = (TCComponentBOMLine[])arrlcheckedBOMLine.toArray(new TCComponentBOMLine[arrlcheckedBOMLine.size()]);
}else
{
//EBOM Install to -EBOM Install /MBOM kit to EBOM install Comparison
arrayOfTargetTCComponentBOMLine = ((BOMTreeTable)sourcePanel.getCompareTreeTable()).getSelectedBOMLines();
}
if ( arrayOfTargetTCComponentBOMLine == null || arrayOfTargetTCComponentBOMLine.length == 0)
{
MessageBox.post(Messages.eQOTM_KitSelection_info,Messages.eQOTM_KitSelection_title, 2);
return false;
}
objOTMSession.setCurrentSourceBOMLines(arrayOfTargetTCComponentBOMLine);
eQOTMLoggerManager.logger.error("INFO:No. of Bomlines selected for comparison : "+arrayOfTargetTCComponentBOMLine.length);
eQOTMLoggerManager.logger.debug("Exit setSourceBomLinesOnCompareDialog");
return true;
}
private boolean SetScope()
{
InterfaceComparable targetPanel = m_currentTcApplication.getActiveComparable();
eQOTMSessionInfo objOTMSession = eQOTMSessionInfo.getInstance();
objOTMSession.setTargetBOMTreeTable((BOMTreeTable)targetPanel.getCompareTreeTable());
try
{
objOTMSession.addUserSessionVariable(eQOTMConstants.REVISIONRULE,((BOMTreeTable)targetPanel.getCompareTreeTable()).getBOMWindow().getRevisionRule().toString());
}
catch (Exception e)
{
eQOTMLoggerManager.logger.error("Error occurred while getting RevisionRule from TC user session. Error : "+e.getMessage(),e);
MessageBox.post(Messages.eQOTM_ScopeRevisionRule_info,Messages.eQOTM_ScopeSelection_title, 2);
return false;
}
TCComponentBOMLine[] arrayOfScopeTCComponentBOMLine = ((BOMTreeTable)targetPanel.getCompareTreeTable()).getSelectedBOMLines();
if( arrayOfScopeTCComponentBOMLine==null || arrayOfScopeTCComponentBOMLine.length<1 )
{
MessageBox.post(Messages.eQOTM_ScopeSelection_info,Messages.eQOTM_ScopeSelection_title, 2);
return false;
}
TCComponentBOMLine scopebomline = arrayOfScopeTCComponentBOMLine[0];
try
{
if (scopebomline.getChildrenCount() ==0)
{
MessageBox.post(Messages.eQOTM_ScopeNoChild_info,Messages.eQOTM_ScopeSelection_title, 2);
return false;
}
}
catch (TCException localTCException1)
{
eQOTMLoggerManager.logger.error("Exception Occurred while getting child count for scope");
}
this.m_textScopeName.setText(scopebomline.toString());
eQBOMLineBean currentScopeBOMLine = new eQBOMLineBean(scopebomline);
objOTMSession.setCurrentScopeBOMLine(currentScopeBOMLine);
return true;
}