青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
发表于 2015-10-18 22:05 | 显示全部楼层 |阅读模式
/**
; w9 E' X7 n5 j0 L: R * CNXObject.java:所有开发的ug/Java主程序类的基类;8 Z4 Q1 W: @% Z; H
*/9 D. O- b7 ^. V
7 Y  {& O) O) y4 p# u4 ^
//package com.hunix.UGjava.nxopen;
7 c, ?+ J9 g! F; X, B, b
# T3 f! A  T2 H" _9 i8 G: himport nxopen.*;3 {* d9 g$ R! j
import nxopen.uf.*;% w6 F- z5 R3 b3 s) R1 b
import nxopen.features.*;' P' Q* @$ ]3 F; ]- s+ ?( w
import java.io.*;7 p! `! c0 X+ @4 p' t
import java.net.*;3 J2 \- k. O0 q
import java.rmi.*;
% }/ ?2 E! P7 kimport java.rmi.registry.*;
( X# G! T0 q0 W6 C% g* A# Y9 jpublic abstract class CNXObject {
5 {9 g1 K+ A" q  R$ P* ^& a0 m* {. ]% F/ @& R
    public CNXObject() throws NXException,RemoteException{0 a. p. m7 [: V/ i& _
        theSession = (Session)SessionFactory.get("Session");
/ w2 X$ C% z( P4 j" Y5 u8 [4 A        theUFSession = (UFSession)SessionFactory.get("UFSession");8 h# |7 N) Z  t: K" Q8 `' F, b4 n
        theUI = (UI)SessionFactory.get("UI");/ Y% J) C. W$ L! `  i* F
    }
9 ]4 f) i( n. s$ O" i2 D& ^: k    public void writeListingWindow(String content)throws NXException,RemoteException{/ j, K4 M$ y/ f6 F
        if(theUFSession==null){
- ]! ^0 }( y% z( a* I" f; X+ q% |$ y            return;
; W% K. n' J; x, `" Z/ _        }
5 I3 p+ Z# k$ B+ W! |# v        if(!theUFSession.ui().isListingWindowOpen()){6 T" J' @4 K. F# l- a2 ?2 g3 V2 D3 ^7 `
            theUFSession.ui().openListingWindow();- I3 l& X" E! T3 A' H
        }
6 ~& t% v' }; X        theUFSession.ui().writeListingWindow(content);1 l0 k$ W1 o5 y+ J! p3 s! n
    }
+ P, U4 T! ~% j9 v) i; ]% s9 q+ S    public void closeListingWindow()throws NXException,RemoteException{
; k7 _# b' J% s' p) T        if(theUFSession==null){8 S& Q- b) D4 K/ M+ y
            return;
2 v3 x7 z& a) r% i1 x6 h        }
! \& w+ o0 k$ i+ h9 G1 y& s9 l1 W        theUFSession.ui().closeListingWindow();
5 v) G+ F0 u' Z% \6 _, ~% G! C: [    }
, ^/ T# Z. }$ F/ p( J    public Session getSession(){
  u. }' W3 _' [6 s" p7 `) |8 f        return theSession;
$ g9 ^7 _% d+ U" _# t  B    }: ~3 K3 t9 F# |+ b; l. A
    public UFSession getUFSession(){
1 `! }' R* [/ _  K: x        return theUFSession;' U; Y$ Q5 z; ]9 |0 ]
    }
" X" q2 P: u! E1 X4 s( V    public UI getUI(){
5 ^( F( }. \. ]' y        return theUI;
) U8 b9 h) a. S' s    }
* l+ K7 _+ z$ |0 E3 h- B+ J  g    public static final int getUnloadOption() { * ?1 D4 z1 g% ^
        return BaseSession.LibraryUnloadOption.IMMEDIATELY;   [' R; u- N; y& y( Q; k# o
    }
& U% y  P. j7 k    % R7 B3 G- F; R: _) H
    public abstract String toString();/ K6 G  \7 V0 Y& r) y
   
7 Y0 Z8 X6 ]) @, f2 H2 w    Session theSession=null ;
: ]* r# _0 S; A: e( B0 z    UFSession theUFSession=null ;
1 o* o$ Z  \9 D7 M    UI theUI=null;
7 q  {' b& k  z6 U, Z}
: I5 K/ S$ u# ]6 n" A: u& X
发表于 2018-4-23 14:01 | 显示全部楼层
楼主QQ多少,想加个朋友讨论下JAVA
回复 支持 反对

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-27 13:55 , Processed in 0.090850 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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