青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
发表于 2015-10-18 22:05 | 显示全部楼层 |阅读模式
/**
/ O) K* [" P: s3 c: M- C1 t! Y * CNXObject.java:所有开发的ug/Java主程序类的基类;6 R) g! W) b7 O
*/
) T. ?* a; G" O; M  y
1 l" u# V' ^. b; K//package com.hunix.UGjava.nxopen;2 T$ |1 h( j" L! G9 X; [. ?
. M# f: K! _1 D* q7 j
import nxopen.*;
6 R8 l3 s$ N( \' L, jimport nxopen.uf.*;" I0 F, b4 V* ~: `% v: U0 n4 y& b
import nxopen.features.*;
' `& H7 D2 a3 d9 |; ]import java.io.*;
# x9 i: z1 U7 I8 `' A0 _import java.net.*;
  J' g4 a  [/ u! G  yimport java.rmi.*;
- ]0 ~& R# w9 Fimport java.rmi.registry.*;% j' \; Q9 t' u9 }. V
public abstract class CNXObject {
1 w. g0 v6 g6 j* v3 g" o6 k; Y- N% U
    public CNXObject() throws NXException,RemoteException{" W& i& G  l, u- E0 V/ V
        theSession = (Session)SessionFactory.get("Session");
; H8 X4 ?% H, U        theUFSession = (UFSession)SessionFactory.get("UFSession");
: j3 \- ^2 V) A  q- V' s$ ^        theUI = (UI)SessionFactory.get("UI");( A! T1 A$ c7 E5 A' g
    }
! ?! h5 r1 d8 A- ]    public void writeListingWindow(String content)throws NXException,RemoteException{4 i- K; a  z4 p; @. j* ]
        if(theUFSession==null){3 g1 m. [5 G8 x1 m) }$ B
            return;
5 v* F) W5 V- a" t/ h        }
: V2 R% t1 D& R2 C* M& n4 A5 D7 j        if(!theUFSession.ui().isListingWindowOpen()){+ p: }" ]! f4 n5 c& x8 F
            theUFSession.ui().openListingWindow();
* O4 M+ [/ n2 H- p7 P. h- }, C  I        }
2 V7 F! Q! _- Q$ G4 e        theUFSession.ui().writeListingWindow(content);9 R+ `, P! ~0 O" l2 ]' R& F4 E, V
    }
9 S9 }2 E' E6 j; H8 A    public void closeListingWindow()throws NXException,RemoteException{
- w; x% Z% V. z$ i3 N        if(theUFSession==null){2 p) K* X( M6 O1 b8 K
            return;8 L* y* p! q) j& _
        }
& C" [% I8 j+ H3 X8 }6 c5 A        theUFSession.ui().closeListingWindow();- d% S! \7 H9 ]4 {) v* Y
    }% B1 G' K) A- L8 S# H/ ^
    public Session getSession(){
& O, R7 t( H5 q        return theSession;6 u5 }4 F% a" o, x5 v& I+ U
    }
3 ?) C; F( m, _9 D6 A6 q7 f    public UFSession getUFSession(){$ q. _2 _" Z! X) z% Q/ L! I3 |) s: n  S0 {
        return theUFSession;: m* H7 A, g$ _! ~
    }. l6 X8 X# n( K+ P6 w# v) V
    public UI getUI(){
; t, r/ i/ r' p) o' i; Q* ?6 A' S        return theUI;
! W1 S( C! I/ X/ @- Z    }* j, {3 m" u# Y) O5 ~, ]& L5 l) r
    public static final int getUnloadOption() { * E9 |" K3 k7 K. N
        return BaseSession.LibraryUnloadOption.IMMEDIATELY;
( V1 F; i; [* T' V( w    }9 ~9 w/ Z+ Q* Y& |1 j
   
! z2 h; C. I6 t/ J# }) S( I    public abstract String toString();
( K+ Q! x# f" }( W& k1 i    , y( R$ m6 O0 z
    Session theSession=null ;- ?  R- I+ B+ H* Z
    UFSession theUFSession=null ;
! x3 F  M* ]7 ]* x# @8 p    UI theUI=null;
* U) q* o) x2 C1 Z" f; E}! R% m( }$ q/ ^/ W! l% [7 ~
发表于 2018-4-23 14:01 | 显示全部楼层
楼主QQ多少,想加个朋友讨论下JAVA
回复 支持 反对

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 00:07 , Processed in 0.047406 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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