commit c88f98fd3f99e764d2cf06dc83cc0856332bac13 Author: lijh Date: Tue Mar 10 11:35:32 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..eca7bdb --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..37bff57 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.nhjs.screenshot + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +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.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..67a974f --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Screenshot +Bundle-SymbolicName: com.connor.nhjs.screenshot;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.util;bundle-version="13000.1.0" +Automatic-Module-Name: com.connor.nhjs.screenshot +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: com.connor.nhjs.screenshot diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..0d3d3a7 --- /dev/null +++ b/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/ diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..846ec4c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/nhjs/screenshot/ScreenShotAction.java b/src/com/connor/nhjs/screenshot/ScreenShotAction.java new file mode 100644 index 0000000..e2f9bfa --- /dev/null +++ b/src/com/connor/nhjs/screenshot/ScreenShotAction.java @@ -0,0 +1,32 @@ +package com.connor.nhjs.screenshot; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.util.Instancer; +import com.teamcenter.rac.util.MessageBox; + + +public class ScreenShotAction extends AbstractAIFAction{ + + ScreenShotAction(AbstractAIFUIApplication app, String string) { + super(app,string); + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + int ind = actionName.indexOf('#'); + String action=actionName; + String actionData=""; + if(ind>0) { + action=actionName.substring(0,ind); + actionData=actionName.substring(ind+1); + } + ScreenShotCommand command = (ScreenShotCommand) Instancer.newInstanceEx2(action, new Object[] { this.application, action, actionData }); + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/nhjs/screenshot/ScreenShotCommand.java b/src/com/connor/nhjs/screenshot/ScreenShotCommand.java new file mode 100644 index 0000000..0639d26 --- /dev/null +++ b/src/com/connor/nhjs/screenshot/ScreenShotCommand.java @@ -0,0 +1,50 @@ +package com.connor.nhjs.screenshot; + +import org.eclipse.swt.widgets.Display; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ScreenShotCommand extends AbstractAIFCommand{ + + private AbstractAIFUIApplication app; + private TCSession session; + protected String actionInfo; + private boolean hideTC; + private static final String PRE_SCREENSHOT = "Connor_ScreenShot_Command"; + public ScreenShotCommand() { + super(); + } + + public ScreenShotCommand(AbstractAIFUIApplication app, String commandId, String actionInfo) { + this.app = app; + session = (TCSession)app.getSession(); + this.actionInfo = actionInfo; + this.hideTC = "true".equals(actionInfo); + } + + public void executeModal() throws Exception { + String cmd = session.getPreferenceService().getStringValue(PRE_SCREENSHOT); + if(cmd!=null&&cmd.length()>0) { + System.out.println("cmd======"+cmd); + if(hideTC) { + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + // System.out.println(AIFDesktop.getActiveDesktop().getShell()); + AIFDesktop.getActiveDesktop().getShell().setMinimized(true); + } + }); + Thread.sleep(600); + } + Runtime.getRuntime().exec(cmd); + }else { + MessageBox.post("ÇëÅäÖÃConnor_ScreenShot_CommandÊ×Ñ¡Ïî","",MessageBox.INFORMATION); + } + + } +} diff --git a/src/com/connor/nhjs/screenshot/ScreenShotHandler.java b/src/com/connor/nhjs/screenshot/ScreenShotHandler.java new file mode 100644 index 0000000..87a924a --- /dev/null +++ b/src/com/connor/nhjs/screenshot/ScreenShotHandler.java @@ -0,0 +1,22 @@ +package com.connor.nhjs.screenshot; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + + +public class ScreenShotHandler extends AbstractHandler{ + + private AbstractAIFUIApplication app; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + app = AIFUtility.getCurrentApplication(); + new Thread(new ScreenShotAction(app,arg0.getCommand().getId())).start(); + return null; + } + +}