青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

青华模具培训学院
查看: 1269|回复: 2

[原创] UG Java二次开发的主程序框架

[复制链接]
发表于 2015-10-18 22:05 | 显示全部楼层 |阅读模式
/**
, _" O. S, C! B7 t% `& n' w * CNXObject.java:所有开发的ug/Java主程序类的基类;0 K: I' U6 d4 y6 C  ~% K# n
*/6 h6 y5 H9 w1 H/ Z
+ a7 ]6 [, g4 g1 ~; c6 A
//package com.hunix.UGjava.nxopen;6 E6 `8 k0 |" [7 f5 e* [5 j- V
4 J1 {, N6 ~6 a% ^0 K+ c4 c
import nxopen.*;
5 O/ q$ D3 a9 c  `import nxopen.uf.*;8 q$ m4 T6 A( p
import nxopen.features.*;/ S8 R4 D. _- z7 l* E
import java.io.*;
5 x0 E1 A9 T5 T$ Aimport java.net.*;
: z' r* [0 u. N2 |4 w* b9 W# {import java.rmi.*;
6 H; A8 s1 s( ~9 R5 q5 j9 A. S: W9 \import java.rmi.registry.*;
1 z/ z/ o- M6 O, lpublic abstract class CNXObject {
( c4 S1 a* m/ E. M, g4 G, H( L+ S0 x$ [7 R& r6 \8 {7 Y9 p
    public CNXObject() throws NXException,RemoteException{$ Y: U" `3 `6 Q
        theSession = (Session)SessionFactory.get("Session");5 q5 @' i) A& K$ l5 f  X% q
        theUFSession = (UFSession)SessionFactory.get("UFSession");6 }  |) U( _9 {7 s1 e8 G' ?
        theUI = (UI)SessionFactory.get("UI");
1 X* m2 y# q8 S% o  P    }* l  G" K# u* Y" D' t1 ]; Y
    public void writeListingWindow(String content)throws NXException,RemoteException{2 [; I+ M; K( Z
        if(theUFSession==null){3 ~, E9 @) r9 K5 `9 p! C
            return;% u' Q6 |1 X$ E
        }4 {  g6 a3 S# x+ v$ m1 D
        if(!theUFSession.ui().isListingWindowOpen()){9 |( A5 p5 k9 P! y1 g5 B
            theUFSession.ui().openListingWindow();4 X) w9 L# a6 n. j- W4 Y/ Z
        }$ t4 ^" J' }9 o& ^- G3 H
        theUFSession.ui().writeListingWindow(content);( \) `/ d- }1 Y' k
    }
6 ]/ ]  G/ [4 P% s4 H; _" m& L4 z& V    public void closeListingWindow()throws NXException,RemoteException{2 p2 J% E- l+ T! ^& X3 `! w' R
        if(theUFSession==null){
( t8 u: i2 E7 [: H5 O            return;
; h! O1 ?3 W7 E) t# H7 c        }
+ M( [% u8 q. E9 C: C4 N        theUFSession.ui().closeListingWindow();# s2 q- H; o3 O' [) |, g; E
    }  q% r5 ^9 H9 _) Z8 g$ K9 `) L
    public Session getSession(){( Z# o3 q; Q1 g1 a( H0 Q
        return theSession;- {7 H7 A/ _; Z0 t( C- r
    }. r( v  f: ~, @9 S3 }9 q5 C9 j
    public UFSession getUFSession(){; s, E( o) c( w3 |) r8 e$ O
        return theUFSession;1 e$ l- T9 g4 U; m
    }
4 ?! [% a) W" K4 H* x; A6 [    public UI getUI(){2 R2 C  w, `1 f, F4 I5 b
        return theUI;
" J) T3 e6 Z" m3 d6 Q3 V, \    }
- P$ y) Z- e" a; _6 u+ w    public static final int getUnloadOption() {
) A- s6 k6 }* M. ]5 k        return BaseSession.LibraryUnloadOption.IMMEDIATELY;
# Y: e6 j9 d7 X7 X. E    }1 e5 g, ~( M- j, \* P$ N! p
    6 K/ H8 r$ k: C( O2 `: t
    public abstract String toString();! T+ |) I% }  M* q5 w( m
   
: ]; n3 R6 P* h" O- ]    Session theSession=null ;: A1 U% Q  p* d. d6 @
    UFSession theUFSession=null ;
1 |+ N$ H' a! G+ p* E    UI theUI=null;
% ~1 H) `3 n. ~( [}
# j- u1 Z5 K/ U+ l3 A, l6 ~& e
发表于 2018-4-23 14:01 | 显示全部楼层
楼主QQ多少,想加个朋友讨论下JAVA
回复 支持 反对

使用道具 举报

发表于 2018-4-23 14:07 | 显示全部楼层
加我QQ609719845
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|关于我们|sitemap|小黑屋|Archiver|手机版|UG网-UG技术论坛-青华数控模具培训学校 ( 粤ICP备15108561号 )

GMT+8, 2025-6-28 01:15 , Processed in 0.118991 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表