1.自动匹配工具初始化
commit
7a9a6378ae
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.sq.customization</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
@ -0,0 +1,8 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,26 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: Customization
|
||||||
|
Bundle-SymbolicName: com.sq.customization;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0
|
||||||
|
Bundle-Activator: com.sq.customization.Activator
|
||||||
|
Bundle-Vendor: SQ
|
||||||
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime,
|
||||||
|
com.teamcenter.rac.aifrcp;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.common;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.external;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.kernel;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.pca;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.pse;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.tcapps;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.ui;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.ui.views;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.util;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.pca.kernel;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.pse.pca;bundle-version="13000.3.0",
|
||||||
|
com.teamcenter.rac.cme.kernel;bundle-version="13000.3.0",
|
||||||
|
org.apache.poi.39;bundle-version="3.9.0"
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
|
Automatic-Module-Name: com.sq.customization
|
||||||
|
Bundle-ActivationPolicy: lazy
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
|||||||
|
RuleInheritanceDialog.sourcelabel=Source configuration object:
|
||||||
|
RuleInheritanceDialog.targetlabel=The target configuration object:
|
||||||
|
RuleInheritanceDialog.handoffbutton=Toggle the source and target
|
||||||
|
RuleInheritanceDialog.okbutton=OK
|
||||||
|
RuleInheritanceDialog.cancelbutton=Cancel
|
@ -0,0 +1,5 @@
|
|||||||
|
RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A
|
||||||
|
RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A
|
||||||
|
RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807
|
||||||
|
RuleInheritanceDialog.okbutton=\u786E\u5B9A
|
||||||
|
RuleInheritanceDialog.cancelbutton=\u53D6\u6D88
|
Binary file not shown.
@ -0,0 +1,2 @@
|
|||||||
|
BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
javacDefaultEncoding.. = UTF-8
|
||||||
|
bin.includes = plugin.xml,\
|
||||||
|
META-INF/,\
|
||||||
|
.,\
|
||||||
|
icons/
|
Binary file not shown.
After Width: | Height: | Size: 332 B |
Binary file not shown.
After Width: | Height: | Size: 526 B |
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.commands">
|
||||||
|
|
||||||
|
<command
|
||||||
|
categoryId="com.sq.customization.commands.category"
|
||||||
|
name="【自动匹配替换工具】"
|
||||||
|
id="com.sq.customization.commands.sampleCommand">
|
||||||
|
</command>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.handlers">
|
||||||
|
<handler
|
||||||
|
class="com.sq.customization.handlers.SampleHandler"
|
||||||
|
commandId="com.sq.customization.commands.sampleCommand">
|
||||||
|
</handler>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.menus">
|
||||||
|
<menuContribution
|
||||||
|
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
|
||||||
|
<menu
|
||||||
|
id="com.sq.customization.menus.sampleMenu"
|
||||||
|
label="【上汽TCM定制开发】"
|
||||||
|
mnemonic="M">
|
||||||
|
<command
|
||||||
|
commandId="com.sq.customization.commands.sampleCommand"
|
||||||
|
id="com.sq.customization.menus.sampleCommand"
|
||||||
|
mnemonic="S">
|
||||||
|
</command>
|
||||||
|
</menu>
|
||||||
|
</menuContribution>
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
</plugin>
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.sq.customization;
|
||||||
|
|
||||||
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The activator class controls the plug-in life cycle
|
||||||
|
*/
|
||||||
|
public class Activator extends AbstractUIPlugin {
|
||||||
|
|
||||||
|
// The plug-in ID
|
||||||
|
public static final String PLUGIN_ID = "com.sq.customization"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// The shared instance
|
||||||
|
private static Activator plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor
|
||||||
|
*/
|
||||||
|
public Activator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(BundleContext context) throws Exception {
|
||||||
|
super.start(context);
|
||||||
|
plugin = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop(BundleContext context) throws Exception {
|
||||||
|
plugin = null;
|
||||||
|
super.stop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shared instance
|
||||||
|
*
|
||||||
|
* @return the shared instance
|
||||||
|
*/
|
||||||
|
public static Activator getDefault() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
RuleInheritanceDialog.sourcelabel=Source configuration object:
|
||||||
|
RuleInheritanceDialog.targetlabel=The target configuration object:
|
||||||
|
RuleInheritanceDialog.handoffbutton=Toggle the source and target
|
||||||
|
RuleInheritanceDialog.okbutton=OK
|
||||||
|
RuleInheritanceDialog.cancelbutton=Cancel
|
@ -0,0 +1,5 @@
|
|||||||
|
RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A
|
||||||
|
RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A
|
||||||
|
RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807
|
||||||
|
RuleInheritanceDialog.okbutton=\u786E\u5B9A
|
||||||
|
RuleInheritanceDialog.cancelbutton=\u53D6\u6D88
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.sq.customization.handlers;
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.sq.customization.dialogs.AutoTransToolDialog;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPlantBOP;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentMECfgLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
import com.teamcenter.rac.util.Registry;
|
||||||
|
|
||||||
|
|
||||||
|
public class SampleHandler extends AbstractHandler {
|
||||||
|
private AbstractAIFUIApplication app;
|
||||||
|
private TCSession session;
|
||||||
|
// private Registry registry = Registry.getRegistry(SampleHandler.class);
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
app = AIFUtility.getCurrentApplication();
|
||||||
|
session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent[] target = app.getTargetComponents();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if(target == null || target.length != 1) {
|
||||||
|
// MessageBox.post(app.getDesktop(),registry.getString("BOPInitHandler.selecterror"), "Message", MessageBox.INFORMATION);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
System.out.println(target[0].getType());
|
||||||
|
System.out.println(target[0].getClass());
|
||||||
|
if("Mfg0BvrPlantBOP".equals(target[0].getType()) || "Mfg0BvrProcessLine".equals(target[0].getType()) || "Mfg0BvrProcessStation".equals(target[0].getType())) {
|
||||||
|
new AutoTransToolDialog(app.getDesktop(),target[0]);
|
||||||
|
// TCComponentMfgBvrPlantBOP targetline = (TCComponentMfgBvrPlantBOP) target[0];
|
||||||
|
// try {
|
||||||
|
// AIFComponentContext[] comcontext = targetline.getChildren();
|
||||||
|
// for(int i = 0; i < comcontext.length; i++) {
|
||||||
|
// System.out.println(comcontext[i].getComponent().getProperty("bl_indented_title"));
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C
|
||||||
|
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.sq.customization.util;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
|
|
||||||
|
public class ExcelUtil {
|
||||||
|
public static String getStringCellValue(Cell cell)
|
||||||
|
{
|
||||||
|
String strCell = "";
|
||||||
|
if(cell == null)
|
||||||
|
return "";
|
||||||
|
switch(cell.getCellType()){
|
||||||
|
case Cell.CELL_TYPE_STRING :
|
||||||
|
strCell = cell.getStringCellValue();
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_NUMERIC :
|
||||||
|
if(DateUtil.isCellDateFormatted(cell))
|
||||||
|
strCell = cell.getDateCellValue().toString();
|
||||||
|
else
|
||||||
|
// strCell = String.valueOf(cell.getNumericCellValue());
|
||||||
|
strCell = new DecimalFormat("#").format(cell.getNumericCellValue());
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_BOOLEAN :
|
||||||
|
strCell = String.valueOf(cell.getBooleanCellValue());
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_FORMULA :
|
||||||
|
strCell = cell.getCellFormula();
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_BLANK :
|
||||||
|
strCell = "";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strCell = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(strCell == null || strCell.equals(""))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return strCell;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,271 @@
|
|||||||
|
package com.sq.customization.util;
|
||||||
|
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||||
|
import com.teamcenter.rac.util.Registry;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class ProgressCustomDialog implements ActionListener
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String DEFAULT_STATUS = "Please Waiting";
|
||||||
|
|
||||||
|
|
||||||
|
private static JDialog dialog;
|
||||||
|
|
||||||
|
private JProgressBar progressBar;
|
||||||
|
|
||||||
|
|
||||||
|
public static JLabel lbStatus;
|
||||||
|
|
||||||
|
|
||||||
|
private JButton btnCancel;
|
||||||
|
|
||||||
|
|
||||||
|
private static Thread thread; //处理业务的线程
|
||||||
|
|
||||||
|
|
||||||
|
private String statusInfo;
|
||||||
|
|
||||||
|
|
||||||
|
public static String resultInfo;
|
||||||
|
|
||||||
|
|
||||||
|
public static String cancelInfo;
|
||||||
|
|
||||||
|
private Dialog parentDlg ;
|
||||||
|
|
||||||
|
String message = "";
|
||||||
|
|
||||||
|
|
||||||
|
public static void show(Thread thread,Dialog parentDlg)
|
||||||
|
{
|
||||||
|
|
||||||
|
new ProgressCustomDialog(thread, DEFAULT_STATUS, null, null,parentDlg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void show(Thread thread, String statusInfo,Dialog parentDlg)
|
||||||
|
{
|
||||||
|
new ProgressCustomDialog(thread, statusInfo, null, null,parentDlg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void show(Thread thread, String statusInfo,
|
||||||
|
|
||||||
|
String resultInfo, String cancelInfo,Dialog parentDlg)
|
||||||
|
{
|
||||||
|
new ProgressCustomDialog(thread, statusInfo, resultInfo, cancelInfo,parentDlg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ProgressCustomDialog(Thread thread, String statusInfo,
|
||||||
|
|
||||||
|
String resultInfo, String cancelInfo,Dialog parentDlg)
|
||||||
|
{
|
||||||
|
this.thread = thread;
|
||||||
|
this.statusInfo = statusInfo;//Status
|
||||||
|
this.resultInfo = resultInfo;//处理完毕
|
||||||
|
this.cancelInfo = cancelInfo;//Cancel
|
||||||
|
this.parentDlg = parentDlg ;
|
||||||
|
|
||||||
|
|
||||||
|
initUI();
|
||||||
|
startThread();
|
||||||
|
dialog.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (parentDlg == null)
|
||||||
|
{
|
||||||
|
dialog = new JDialog();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialog = new JDialog(parentDlg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final JPanel mainPane = new JPanel(null);
|
||||||
|
progressBar = new JProgressBar();
|
||||||
|
lbStatus = new JLabel("" + statusInfo);
|
||||||
|
btnCancel = new JButton("Cancel");
|
||||||
|
progressBar.setIndeterminate(true);
|
||||||
|
btnCancel.addActionListener(this);
|
||||||
|
|
||||||
|
mainPane.add(progressBar);
|
||||||
|
mainPane.add(lbStatus);
|
||||||
|
//mainPane.add(btnCancel);
|
||||||
|
|
||||||
|
dialog.getContentPane().add(mainPane);
|
||||||
|
//dialog.setUndecorated(true); // 除去title
|
||||||
|
dialog.setResizable(true);
|
||||||
|
dialog.setAlwaysOnTop(true);
|
||||||
|
dialog.setSize(590, 120);
|
||||||
|
dialog.setLocationRelativeTo(null); //设置此窗口相对于指定组件的位置
|
||||||
|
ImageIcon imageicon = Registry.getRegistry(AbstractAIFDialog.class).getImageIcon("aifDesktop.ICON");//new ImageIcon(getClass().getResource("images/aifdesktop_16.png"));
|
||||||
|
dialog.setIconImage(imageicon.getImage());
|
||||||
|
dialog.setTitle("进度信息");
|
||||||
|
// System.out.println("set @@@@@@@@@@@@@@@@@@@@#######====");
|
||||||
|
// dialog.setModal(true);
|
||||||
|
// dialog.setAlwaysOnTop(true);
|
||||||
|
// UIUtilities.centerToScreen(dialog, 1.0D, 0.75D);
|
||||||
|
dialog.requestFocusInWindow();
|
||||||
|
|
||||||
|
// dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // 不允许关闭
|
||||||
|
dialog.validate();
|
||||||
|
|
||||||
|
dialog.addWindowListener(new WindowAdapter()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e)
|
||||||
|
{
|
||||||
|
// MessageBox.post("提醒",
|
||||||
|
// "关闭该窗口后报表将无法生成。", MessageBox.INFORMATION);
|
||||||
|
dialog.dispose();
|
||||||
|
thread.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
mainPane.addComponentListener(new ComponentAdapter()
|
||||||
|
{
|
||||||
|
public void componentResized(ComponentEvent e)
|
||||||
|
{
|
||||||
|
layout(mainPane.getWidth(), mainPane.getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startThread()
|
||||||
|
{
|
||||||
|
new Thread()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
thread.start(); // 处理耗时任务
|
||||||
|
// 等待事务处理线程结束
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(new Dialog(dialog), e.getMessage(), "error",
|
||||||
|
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// 关闭进度提示框
|
||||||
|
if (dialog != null)
|
||||||
|
{
|
||||||
|
dialog.dispose();
|
||||||
|
if(resultInfo != null && !resultInfo.trim().equals(""))
|
||||||
|
{
|
||||||
|
String title = "进度信息";
|
||||||
|
JOptionPane.showMessageDialog(new Dialog(dialog), resultInfo, title,
|
||||||
|
|
||||||
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void layout(int width, int height)
|
||||||
|
{
|
||||||
|
progressBar.setBounds(20, 20, 550, 15);
|
||||||
|
lbStatus.setBounds(20, 40, 550, 25);
|
||||||
|
btnCancel.setBounds(width - 85, height - 31, 75, 21);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
resultInfo = cancelInfo;
|
||||||
|
thread.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void StopStatus()
|
||||||
|
{
|
||||||
|
if (dialog != null)
|
||||||
|
dialog.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception
|
||||||
|
{
|
||||||
|
Thread thread = new Thread()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while(index < 5)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sleep(1000);
|
||||||
|
System.out.println(++index);
|
||||||
|
}
|
||||||
|
catch(InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ProgressCustomDialog.show(thread, "Status", "数据处理完毕", "Cancel",null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Dialog getParentDlg() {
|
||||||
|
return parentDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setParentDlg(Dialog parentDlg) {
|
||||||
|
this.parentDlg = parentDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static JDialog getDialog() {
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setDialog(JDialog dialog) {
|
||||||
|
ProgressCustomDialog.dialog = dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue