0001: // @@
0002: // @@
0003: /*
0004: * Wi.Ser Framework
0005: *
0006: * LGPL Version: 1.8.1, 20-September-2007
0007: * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
0008: *
0009: * This library is free software; you can redistribute it and/or
0010: * modify it under the terms of the GNU Lesser General Public
0011: * License as published by the Free Software Foundation; either
0012: * version 2 of the License, or (at your option) any later version.
0013: *
0014: * This library is distributed in the hope that it will be useful,
0015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0017: * Lesser General Public License for more details.
0018: *
0019: * You should have received a copy of the GNU Lesser General Public
0020: * License along with this library located in LGPL.txt in the
0021: * license directory; if not, write to the
0022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0023: * Boston, MA 02111-1307, USA.
0024: *
0025: * If this agreement does not cover your requirements, please contact us
0026: * via email to get detailed information about the commercial license
0027: * or our service offerings!
0028: *
0029: */
0030: // @@
0031: package de.ug2t.channel.ho.client.swing;
0032:
0033: import java.awt.*;
0034: import java.awt.event.*;
0035: import java.beans.*;
0036: import java.io.*;
0037: import java.lang.reflect.*;
0038: import java.util.*;
0039:
0040: import javax.swing.*;
0041: import javax.swing.event.*;
0042: import javax.swing.plaf.*;
0043: import javax.swing.plaf.metal.*;
0044:
0045: import de.ug2t.channel.ho.*;
0046: import de.ug2t.channel.ho.session.*;
0047: import de.ug2t.kernel.*;
0048: import de.ug2t.process.*;
0049: import de.ug2t.unifiedGui.*;
0050: import de.ug2t.unifiedGui.interfaces.*;
0051: import de.ug2t.workflow.*;
0052: import de.ug2t.xmlScript.*;
0053:
0054: class MyMetal extends DefaultMetalTheme {
0055: private IUnApplication pem_appl = null;
0056:
0057: public MyMetal(IUnApplication xAppl) {
0058: this .pem_appl = xAppl;
0059: }
0060:
0061: public FontUIResource getSystemTextFont() {
0062: UnFontDescriptor l_font = this .pem_appl.pcmf_getUnComponent()
0063: .pcmf_getFont();
0064: if (l_font == null)
0065: return new FontUIResource(super .getSystemTextFont()
0066: .getName(), Font.PLAIN, 11);
0067: else
0068: return new FontUIResource(l_font.pcmf_getFontName(), l_font
0069: .pcmf_getFontStyle(), l_font.pcmf_getFontSize());
0070: }
0071:
0072: public FontUIResource getSubTextFont() {
0073: UnFontDescriptor l_font = this .pem_appl.pcmf_getUnComponent()
0074: .pcmf_getFont();
0075: if (l_font == null)
0076: return new FontUIResource(super .getSubTextFont().getName(),
0077: Font.PLAIN, 11);
0078: else
0079: return new FontUIResource(l_font.pcmf_getFontName(), l_font
0080: .pcmf_getFontStyle(), l_font.pcmf_getFontSize());
0081: }
0082:
0083: public FontUIResource getUserTextFont() {
0084: UnFontDescriptor l_font = this .pem_appl.pcmf_getUnComponent()
0085: .pcmf_getFont();
0086: if (l_font == null)
0087: return new FontUIResource(
0088: super .getUserTextFont().getName(), Font.PLAIN, 11);
0089: else
0090: return new FontUIResource(l_font.pcmf_getFontName(), l_font
0091: .pcmf_getFontStyle(), l_font.pcmf_getFontSize());
0092: }
0093:
0094: public FontUIResource getControlTextFont() {
0095: UnFontDescriptor l_font = this .pem_appl.pcmf_getUnComponent()
0096: .pcmf_getFont();
0097: if (l_font == null)
0098: return new FontUIResource(super .getControlTextFont()
0099: .getName(), Font.PLAIN, 11);
0100: else
0101: return new FontUIResource(l_font.pcmf_getFontName(), l_font
0102: .pcmf_getFontStyle(), l_font.pcmf_getFontSize());
0103: }
0104:
0105: public FontUIResource getMenuTextFont() {
0106: UnFontDescriptor l_font = this .pem_appl.pcmf_getUnComponent()
0107: .pcmf_getFont();
0108: if (l_font == null)
0109: return new FontUIResource(
0110: super .getMenuTextFont().getName(), Font.PLAIN, 11);
0111: else
0112: return new FontUIResource(l_font.pcmf_getFontName(), l_font
0113: .pcmf_getFontStyle(), l_font.pcmf_getFontSize());
0114: }
0115: }
0116:
0117: final class MyKeyDispatcher extends KeyAdapter {
0118: private HoSwingClient pem_client = null;
0119:
0120: public MyKeyDispatcher(HoSwingClient xCl) {
0121: this .pem_client = xCl;
0122: }
0123:
0124: public void keyReleased(KeyEvent arg0) {
0125: if (arg0.getSource() == this .pem_client.pdm_virtKeyEventEmit)
0126: return;
0127:
0128: pem_client.pcmf_getClientFrame().dispatchEvent(arg0);
0129: }
0130: }
0131:
0132: public final class HoSwingClient extends JApplet implements
0133: IUnApplication {
0134: private HoSwingPage pem_active = null;
0135: private UnComponent pem_guiObj = null;
0136: private JFrame pem_frame = null;
0137: private IHoRequest pem_submitValues = null;
0138: private boolean pem_autoShow = true;
0139:
0140: private MyJDesktopPane pem_mdiPane = null;
0141: private boolean pem_mdi = false;
0142:
0143: private JInternalFrame pem_actFrame = null;
0144: private HoSwingMenu pem_mainmenu = null;
0145: private IHoSession pem_session = null;
0146: private HoSwingSplashScreen pem_splash = null;
0147: private HashMap pem_keyChannels = null;
0148: private boolean pem_appResized = false;
0149:
0150: protected JLabel pdm_virtKeyEventEmit = new JLabel();
0151: public static JPanel pcm_vPanel = new JPanel();
0152:
0153: protected IUnImage pdm_bgImg = null;
0154: private HoSwingPage pem_desktop = null;
0155: private boolean pem_submitReshapes = false;
0156: private ClientPollThread pem_pollThread = null;
0157:
0158: static MyKeyDispatcher pem_kdp = null;
0159:
0160: private int pem_eventLatency = -1;
0161:
0162: private boolean pem_bubble = true;
0163:
0164: public void pcmf_setEventBubbling(boolean xBubble) {
0165: KeLog
0166: .pcmf_logNotSupported("public void pcmf_setEventBubbling(boolean xBubble)");
0167: }
0168:
0169: public boolean pcmf_isEventBubbling() {
0170: KeLog
0171: .pcmf_logNotSupported("public void pcmf_setEventBubbling(boolean xBubble)");
0172: return (true);
0173: }
0174:
0175: class ClientPollThread extends Thread {
0176: private int pem_pollTime = 1000;
0177: private volatile boolean pem_alive = true;
0178:
0179: public ClientPollThread(int xPollTime) {
0180: this .pem_pollTime = xPollTime;
0181: this .start();
0182: }
0183:
0184: public void pcmf_stop() {
0185: this .pem_alive = false;
0186: }
0187:
0188: public void run() {
0189: try {
0190: while (pem_alive) {
0191: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
0192: "");
0193:
0194: if (pem_session.pcmf_isInTransaction()) {
0195: ScXmlScript.pcmf_createPBody(l_remCall);
0196: } else {
0197: ScXmlScript.pcmf_createxScriptString(l_remCall,
0198: null);
0199: ScXmlScript.pcmf_addProc(l_remCall, null);
0200: }
0201: ;
0202:
0203: ScXmlScript
0204: .pcmf_addCall(
0205: l_remCall,
0206: null,
0207: KeRegisteredObject
0208: .pcmf_getObjName(HoSwingClient.this ),
0209: "pcmf_work");
0210: ScXmlScript.pcmf_addCallPar(l_remCall, "null",
0211: "false", "java.lang.Object");
0212: ScXmlScript.pcmf_addCallPar(l_remCall, "null",
0213: "false", "java.lang.Object");
0214: ScXmlScript.pcmf_addCallPar(l_remCall, "true",
0215: "false", "boolean");
0216:
0217: ScXmlScript.pcmf_endAll(l_remCall);
0218:
0219: pem_session.pcmf_call(l_remCall.toString(), null);
0220:
0221: Thread.sleep(this .pem_pollTime);
0222: }
0223: } catch (Exception e) {
0224: KeLog.pcmf_log("ug2t",
0225: "client poll thread teminated by error", this ,
0226: KeLog.ERROR);
0227: }
0228: }
0229: }
0230:
0231: public IHoRequest pcmf_getSubmitValues() {
0232: return (this .pem_submitValues);
0233: }
0234:
0235: public void pcmf_addKeyDispatcher(Container xCont) {
0236: if (HoSwingClient.pem_kdp == null)
0237: HoSwingClient.pem_kdp = new MyKeyDispatcher(this );
0238:
0239: xCont.addKeyListener(HoSwingClient.pem_kdp);
0240:
0241: return;
0242: }
0243:
0244: public void pcmf_addKeyDispatcher(HoSwingComponent xObj) {
0245: if (HoSwingClient.pem_kdp == null)
0246: HoSwingClient.pem_kdp = new MyKeyDispatcher(this );
0247:
0248: if (xObj.pcmf_getSwingWidget() != xObj.pcmf_getRealSwingObj())
0249: xObj.pcmf_getSwingWidget().addKeyListener(
0250: HoSwingClient.pem_kdp);
0251:
0252: xObj.pcmf_getRealSwingObj().addKeyListener(
0253: HoSwingClient.pem_kdp);
0254: }
0255:
0256: /**
0257: * @param xName
0258: * @param xAppl
0259: * @throws Exception
0260: */
0261: protected class MyJDesktopPane extends JDesktopPane {
0262: private ImageIcon pem_bg = null;
0263:
0264: /**
0265: * <p>
0266: * Does...
0267: * </p>
0268: * <p>
0269: *
0270: * @return a Type with
0271: * </p>
0272: * <p>
0273: * @param
0274: * </p>
0275: */
0276: protected void paintComponent(Graphics g) {
0277: if (this .pem_bg != null) {
0278: int hi = (int) this .getHeight();
0279: int wi = (int) this .getWidth();
0280: if (hi != 0 && wi != 0) {
0281: Image l_img = this .pem_bg.getImage()
0282: .getScaledInstance(wi, hi,
0283: Image.SCALE_DEFAULT);
0284: new ImageIcon(l_img).paintIcon(this , g, 0, 0);
0285: }
0286: } else
0287: super .paintComponent(g);
0288: }
0289:
0290: public void pcmf_setBgImage(IUnImage xImg) {
0291: this .pem_bg = (ImageIcon) ((HoSwingImage) xImg)
0292: .pcmf_getIcon();
0293: }
0294: }
0295:
0296: protected class MyComponentListener extends ComponentAdapter {
0297: private IUnPage pem_page = null;
0298: private HoDelayedCall pem_callM = null;
0299: private HoDelayedCall pem_callR = null;
0300:
0301: public MyComponentListener(IUnPage xPage) {
0302: this .pem_page = xPage;
0303: }
0304:
0305: public void componentMoved(ComponentEvent e) {
0306: boolean l_max = ((JInternalFrame) e.getSource())
0307: .isMaximum();
0308: if (l_max)
0309: return;
0310:
0311: JInternalFrame l_frame = (JInternalFrame) e.getSource();
0312: this .pem_page.pcmf_setInnerPosition(l_frame.getBounds().x,
0313: l_frame.getBounds().y, l_frame.getWidth(), l_frame
0314: .getHeight());
0315:
0316: if (this .pem_page.pcmf_getGenerateReshapeEvents())
0317: this .pcmf_handle(IUnPage.PAGE_MOVED, l_frame);
0318: }
0319:
0320: public void componentResized(ComponentEvent e) {
0321: boolean l_max = ((JInternalFrame) e.getSource())
0322: .isMaximum();
0323: if (l_max)
0324: return;
0325:
0326: JInternalFrame l_frame = (JInternalFrame) e.getSource();
0327: this .pem_page.pcmf_setInnerPosition(l_frame.getBounds().x,
0328: l_frame.getBounds().y, l_frame.getWidth(), l_frame
0329: .getHeight());
0330:
0331: if (this .pem_page.pcmf_getGenerateReshapeEvents())
0332: this .pcmf_handle(IUnPage.PAGE_RESIZED, l_frame);
0333: }
0334:
0335: public void pcmf_handle(String xValue, JInternalFrame xFrame) {
0336: try {
0337: if (this .pem_page.pcmf_getUnComponent()
0338: .pcmf_isDeleted())
0339: return;
0340:
0341: if (xValue.equals(IUnPage.PAGE_MOVED))
0342: this .pem_page.pcmf_setValue(xValue + ":"
0343: + (int) xFrame.getBounds().getX() + "px,"
0344: + (int) xFrame.getBounds().getY() + "px");
0345: else
0346: this .pem_page.pcmf_setValue(xValue + ":"
0347: + xFrame.getWidth() + "px,"
0348: + xFrame.getHeight() + "px");
0349:
0350: this .pem_page.pcmf_setRefresh();
0351: this .pem_page.pcmf_getUnComponent()
0352: .pcmf_dispatchEvent();
0353:
0354: if (HoSwingClient.this .pem_session.pcmf_isDisabled())
0355: return;
0356:
0357: // Werte setzen um diese zum Server zu übertragen
0358: if ((HoSwingPage) this .pem_page.pcmf_getAppl()
0359: .pcmf_getActive() == null)
0360: return;
0361:
0362: if (xValue.equals(IUnPage.PAGE_MOVED)) {
0363: if (this .pem_callM == null
0364: || this .pem_callM.pcmf_isReady())
0365: this .pem_callM = new HoDelayedCall(null,
0366: HoSwingClient.this .pem_session,
0367: IUnComponent.EVENT_LATENCY_MOVE,
0368: this .pem_page, this .pem_page
0369: .pcmf_getValue().toString());
0370: else
0371: this .pem_callM.pcmf_refreshCall(null,
0372: this .pem_page.pcmf_getValue()
0373: .toString());
0374: } else {
0375: if (this .pem_callR == null
0376: || this .pem_callR.pcmf_isReady())
0377: this .pem_callR = new HoDelayedCall(null,
0378: HoSwingClient.this .pem_session,
0379: IUnComponent.EVENT_LATENCY_RESIZE,
0380: this .pem_page, this .pem_page
0381: .pcmf_getValue().toString());
0382: else
0383: this .pem_callR.pcmf_refreshCall(null,
0384: this .pem_page.pcmf_getValue()
0385: .toString());
0386: }
0387: } catch (Exception e) {
0388: KeLog.pcmf_logException("ug2t", this , e);
0389: }
0390:
0391: return;
0392: }
0393: }
0394:
0395: protected class MyFrameComponentListener extends ComponentAdapter {
0396: private HoDelayedCall pem_callM = null;
0397: private HoDelayedCall pem_callR = null;
0398:
0399: public MyFrameComponentListener() {
0400: }
0401:
0402: public void componentMoved(ComponentEvent e) {
0403: if (HoSwingClient.this .pcmf_getGenerateReshapeEvents())
0404: this .pcmf_handle(IUnApplication.APPL_MOVED, (JFrame) e
0405: .getSource());
0406: }
0407:
0408: public void componentResized(ComponentEvent e) {
0409: if (HoSwingClient.this .pcmf_getGenerateReshapeEvents())
0410: this .pcmf_handle(IUnApplication.APPL_RESIZED,
0411: (JFrame) e.getSource());
0412: }
0413:
0414: public void pcmf_handle(String xValue, JFrame xFrame) {
0415: try {
0416: if (HoSwingClient.this .pcmf_getUnComponent()
0417: .pcmf_isDeleted())
0418: return;
0419:
0420: String l_sValue = null;
0421: if (xValue.equals(IUnApplication.APPL_MOVED))
0422: l_sValue = xValue + ":"
0423: + (int) xFrame.getBounds().getX() + "px,"
0424: + (int) xFrame.getBounds().getY() + "px";
0425: else
0426: l_sValue = xValue + ":" + xFrame.getWidth() + "px,"
0427: + xFrame.getHeight() + "px";
0428:
0429: HoSwingClient.this .pcmf_getUnComponent().pcmf_setValue(
0430: l_sValue);
0431: HoSwingClient.this .pcmf_getUnComponent()
0432: .pcmf_setRefresh();
0433: HoSwingClient.this .pcmf_getUnComponent()
0434: .pcmf_dispatchEvent();
0435:
0436: if (HoSwingClient.this .pem_session.pcmf_isDisabled())
0437: return;
0438:
0439: // Werte setzen um diese zum Server zu übertragen
0440: if ((HoSwingPage) HoSwingClient.this .pcmf_getActive() == null)
0441: return;
0442:
0443: if (xValue.equals(IUnApplication.APPL_MOVED)) {
0444: if (this .pem_callM == null
0445: || this .pem_callM.pcmf_isReady())
0446: this .pem_callM = new HoDelayedCall(null,
0447: HoSwingClient.this .pem_session,
0448: IUnComponent.EVENT_LATENCY_MOVE,
0449: HoSwingClient.this
0450: .pcmf_getUnComponent(),
0451: HoSwingClient.this
0452: .pcmf_getUnComponent()
0453: .pcmf_getValue().toString());
0454: else
0455: this .pem_callM.pcmf_refreshCall(null,
0456: HoSwingClient.this
0457: .pcmf_getUnComponent()
0458: .pcmf_getValue().toString());
0459: } else {
0460: if (this .pem_callR == null
0461: || this .pem_callR.pcmf_isReady())
0462: this .pem_callR = new HoDelayedCall(null,
0463: HoSwingClient.this .pem_session,
0464: IUnComponent.EVENT_LATENCY_RESIZE,
0465: HoSwingClient.this
0466: .pcmf_getUnComponent(),
0467: HoSwingClient.this
0468: .pcmf_getUnComponent()
0469: .pcmf_getValue().toString());
0470: else
0471: this .pem_callR.pcmf_refreshCall(null,
0472: HoSwingClient.this
0473: .pcmf_getUnComponent()
0474: .pcmf_getValue().toString());
0475: }
0476: } catch (Exception e) {
0477: KeLog.pcmf_logException("ug2t", this , e);
0478: }
0479:
0480: return;
0481: }
0482: }
0483:
0484: protected class MyPropertyChangeListener implements
0485: PropertyChangeListener {
0486: private HoSwingPage pem_page = null;
0487:
0488: public MyPropertyChangeListener(HoSwingPage xPage) {
0489: this .pem_page = xPage;
0490: }
0491:
0492: public void propertyChange(PropertyChangeEvent evt) {
0493: if (JInternalFrame.IS_MAXIMUM_PROPERTY.equals(evt
0494: .getPropertyName())) {
0495: try {
0496: boolean l_max = ((JInternalFrame) evt.getSource())
0497: .isMaximum();
0498: this .pem_page.pdmf_setMaximizedFlag(l_max);
0499: this .pem_page
0500: .pcmf_setValue(((JInternalFrame) evt
0501: .getSource()).isMaximum() ? IUnPage.PAGE_MAXIMIZED
0502: : IUnPage.PAGE_WINDOWED);
0503: this .pem_page.pcmf_setRefresh();
0504: this .pem_page.pcmf_dispatchEvent();
0505:
0506: // Werte setzen um diese zum Server zu übertragen
0507: if ((HoSwingPage) this .pem_page.pcmf_getAppl()
0508: .pcmf_getActive() == null)
0509: return;
0510:
0511: ((HoSwingPage) this .pem_page.pcmf_getAppl()
0512: .pcmf_getActive()).pcmf_setSubmitValue(
0513: this .pem_page.pcmf_getObjName(),
0514: this .pem_page.pcmf_getValue().toString());
0515: if (this .pem_page.pcmf_isSubmit() == true)
0516: ((HoSwingPage) this .pem_page.pcmf_getAppl()
0517: .pcmf_getActive()).pcmf_submit();
0518: } catch (Exception e) {
0519: KeLog.pcmf_logException("ug2t", this , e);
0520: }
0521:
0522: }
0523: }
0524:
0525: }
0526:
0527: protected class MyInternalFrameListener implements
0528: InternalFrameListener {
0529: private HoSwingComponent pem_page = null;
0530:
0531: public MyInternalFrameListener(HoSwingComponent xPage) {
0532: this .pem_page = xPage;
0533: }
0534:
0535: public void internalFrameActivated(InternalFrameEvent arg0) {
0536: if (this .pem_page == this .pem_page.pcmf_getAppl()
0537: .pcmf_getActive())
0538: return;
0539:
0540: this .pem_page.pcmf_getAppl().pcmf_getUnComponent()
0541: .pcmf_addNodeLocal(this .pem_page.pcmf_getName(),
0542: this .pem_page);
0543: this .pem_page.pcmf_getAppl().pcmf_setActive(
0544: this .pem_page.pcmf_getName());
0545:
0546: this .pcmf_handle(IUnPage.PAGE_ACTIVATED);
0547: }
0548:
0549: public void internalFrameClosed(InternalFrameEvent arg0) {
0550: this .pcmf_handle(IUnPage.PAGE_CLOSED);
0551: }
0552:
0553: public void internalFrameClosing(InternalFrameEvent arg0) {
0554: this .pcmf_handle(IUnPage.PAGE_CLOSING);
0555: }
0556:
0557: public void internalFrameDeactivated(InternalFrameEvent arg0) {
0558: this .pcmf_handle(IUnPage.PAGE_DEACTIVATED);
0559: }
0560:
0561: public void internalFrameDeiconified(InternalFrameEvent arg0) {
0562: this .pcmf_handle(IUnPage.PAGE_DEICONIFIED);
0563: }
0564:
0565: public void internalFrameIconified(InternalFrameEvent arg0) {
0566: this .pcmf_handle(IUnPage.PAGE_ICONIFIED);
0567: }
0568:
0569: public void internalFrameOpened(InternalFrameEvent arg0) {
0570: this .pcmf_handle(IUnPage.PAGE_OPENED);
0571: }
0572:
0573: public void pcmf_handle(String xValue) {
0574: try {
0575: if (this .pem_page.pcmf_isDeleted())
0576: return;
0577:
0578: this .pem_page.pcmf_setValue(xValue);
0579: this .pem_page.pcmf_setRefresh();
0580: this .pem_page.pcmf_dispatchEvent();
0581:
0582: // Werte setzen um diese zum Server zu übertragen
0583: if ((HoSwingPage) this .pem_page.pcmf_getAppl()
0584: .pcmf_getActive() == null)
0585: return;
0586:
0587: ((HoSwingPage) this .pem_page.pcmf_getAppl()
0588: .pcmf_getActive()).pcmf_setSubmitValue(
0589: this .pem_page.pcmf_getObjName(), this .pem_page
0590: .pcmf_getValue().toString());
0591: if (this .pem_page.pcmf_isSubmit() == true)
0592: ((HoSwingPage) this .pem_page.pcmf_getAppl()
0593: .pcmf_getActive()).pcmf_submit();
0594: } catch (Exception e) {
0595: KeLog.pcmf_logException("ug2t", this , e);
0596: }
0597:
0598: return;
0599: }
0600: }
0601:
0602: protected class MyKeyAdapter extends KeyAdapter {
0603: private UnComponent pem_gui = null;
0604: private HoSwingClient pem_cl = null;
0605:
0606: public MyKeyAdapter(UnComponent xGui, HoSwingClient xCl) {
0607: this .pem_gui = xGui;
0608: this .pem_cl = xCl;
0609: }
0610:
0611: public void keyReleased(KeyEvent e) {
0612: try {
0613: HoSwingPage l_page = (HoSwingPage) ((IUnApplication) this .pem_cl)
0614: .pcmf_getActive();
0615: if (l_page == null)
0616: return;
0617:
0618: e.setSource(this .pem_cl.pdm_virtKeyEventEmit);
0619:
0620: if (this .pem_cl.pcmf_isKeyChannel(l_page))
0621: pdmf_dispatchKeyEvent(e, l_page
0622: .pcmf_getSwingWidget());
0623: //l_page.pcmf_getSwingWidget().dispatchEvent(e);
0624:
0625: Iterator l_it = l_page.pcmf_getDeepSubNodeIt();
0626:
0627: Object l_obj = null;
0628: while (l_it.hasNext()) {
0629: l_obj = l_it.next();
0630: if (l_obj instanceof HoSwingComponent) {
0631: if (l_obj instanceof IUnDialog
0632: && ((IUnDialog) l_obj).pcmf_isDisplay() == false)
0633: continue;
0634:
0635: if (this .pem_cl
0636: .pcmf_isKeyChannel((HoSwingComponent) l_obj))
0637: pdmf_dispatchKeyEvent(e,
0638: ((HoSwingComponent) l_obj)
0639: .pcmf_getSwingWidget());
0640: //((HoSwingComponent) l_obj).pcmf_getSwingWidget().dispatchEvent(e);
0641: }
0642: }
0643: } catch (Exception ex) {
0644: KeLog.pcmf_log("ug2t",
0645: "error while dispatching key events", this ,
0646: KeLog.ERROR);
0647: KeLog.pcmf_logException("ug2t", this , ex);
0648: }
0649: }
0650: }
0651:
0652: protected void pdmf_dispatchKeyEvent(KeyEvent e, Container xComp) {
0653: KeyListener l_listen[] = xComp.getKeyListeners();
0654: for (int i = 0; i < l_listen.length; i++) {
0655: if (!(l_listen[i] instanceof MyKeyDispatcher))
0656: l_listen[i].keyReleased(e);
0657: }
0658: }
0659:
0660: protected class MyWindowListener extends WindowAdapter {
0661: private IUnApplication pem_appl = null;
0662:
0663: public MyWindowListener(IUnApplication xAppl) {
0664: this .pem_appl = xAppl;
0665: }
0666:
0667: public void windowClosing(WindowEvent arg0) {
0668: this .pcmf_handle(IUnApplication.APPL_CLOSING);
0669: }
0670:
0671: public void windowClosed(WindowEvent arg0) {
0672: this .pcmf_handle(IUnApplication.APPL_CLOSED);
0673: }
0674:
0675: public void windowDeiconified(WindowEvent arg0) {
0676: this .pcmf_handle(IUnApplication.APPL_DEICONIFIED);
0677: }
0678:
0679: public void windowIconified(WindowEvent arg0) {
0680: this .pcmf_handle(IUnApplication.APPL_ICONIFIED);
0681: }
0682:
0683: public void windowOpened(WindowEvent arg0) {
0684: this .pcmf_handle(IUnApplication.APPL_OPENED);
0685: }
0686:
0687: public void pcmf_handle(String xValue) {
0688: try {
0689: if (this .pem_appl.pcmf_getUnComponent()
0690: .pcmf_isDeleted())
0691: return;
0692:
0693: this .pem_appl.pcmf_getUnComponent().pcmf_setValue(
0694: xValue);
0695: this .pem_appl.pcmf_getUnComponent().pcmf_setRefresh();
0696: this .pem_appl.pcmf_getUnComponent()
0697: .pcmf_dispatchEvent();
0698:
0699: // Werte setzen um diese zum Server zu übertragen
0700: if ((HoSwingPage) this .pem_appl.pcmf_getActive() == null)
0701: return;
0702:
0703: ((HoSwingPage) this .pem_appl.pcmf_getActive())
0704: .pcmf_setSubmitValue(IUnApplication.MY_APPL,
0705: this .pem_appl.pcmf_getUnComponent()
0706: .pcmf_getValue().toString());
0707: if (this .pem_appl.pcmf_getUnComponent().pcmf_isSubmit() == true)
0708: ((HoSwingPage) this .pem_appl.pcmf_getActive())
0709: .pcmf_submit();
0710: } catch (Exception e) {
0711: KeLog.pcmf_logException("ug2t", this , e);
0712: }
0713:
0714: return;
0715: }
0716: }
0717:
0718: public HoSwingClient(String xName, boolean xMDI) throws Exception {
0719: this .pem_session = (IHoSession) KeRegisteredObject
0720: .pcmf_getObjByName(IHoSession.SESSION_NAME);
0721: // Session global verfügbar machen
0722: if (KeRegisteredObject
0723: .pcmf_getGlobalObjByName(IHoSession.SESSION_NAME) == null)
0724: KeRegisteredObject.pcmf_registerGlobal(
0725: IHoSession.SESSION_NAME, this .pem_session);
0726:
0727: if (!this .pem_session.pcmf_isClientSide())
0728: this .pem_session.pcmf_setClientSide(true,
0729: new HoSwingCommandDispatcher());
0730:
0731: this .pem_session.pcmf_setDisabled(true);
0732:
0733: this .pem_submitValues = new HoRequest(this .pem_session, this );
0734:
0735: this .pem_guiObj = new HoSwingApplicationShadow(xName, this );
0736: this .pem_guiObj.pcmf_setAppl(this );
0737: pem_frame = new JFrame(xName);
0738: pem_mdi = xMDI;
0739: this .pem_guiObj.pcmf_enableSubmit();
0740:
0741: HoSwingClient.pcm_vPanel.setSize(0, 0);
0742: HoSwingClient.pcm_vPanel.setVisible(true);
0743: this .pem_frame.getContentPane().add(HoSwingClient.pcm_vPanel);
0744:
0745: this .pdm_virtKeyEventEmit.setMaximumSize(new Dimension(0, 0));
0746: this .getContentPane().add(this .pdm_virtKeyEventEmit);
0747:
0748: this .pem_frame.addKeyListener(new MyKeyAdapter(this .pem_guiObj,
0749: this ));
0750: this .pcmf_addKeyDispatcher(this );
0751:
0752: MetalLookAndFeel.setCurrentTheme(new MyMetal(this ));
0753:
0754: try {
0755: UIManager.setLookAndFeel(UIManager
0756: .getSystemLookAndFeelClassName());
0757: } catch (Exception e) {
0758: KeLog.pcmf_logException("ug2t", this , e);
0759: }
0760:
0761: WindowListener l = new MyWindowListener(this );
0762: MyFrameComponentListener lc = new MyFrameComponentListener();
0763: this .pem_frame.addWindowListener(l);
0764: this .pem_frame.addComponentListener(lc);
0765:
0766: this .pem_frame
0767: .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
0768:
0769: if (this .pem_mdi == false) {
0770: pem_frame.getContentPane().add("Center", this );
0771: } else {
0772: this .pem_mdiPane = new MyJDesktopPane();
0773: this .pem_mdiPane
0774: .setDesktopManager(new DefaultDesktopManager());
0775: this .pcmf_addKeyDispatcher(this .pem_mdiPane);
0776:
0777: // this.pem_mdiPane.setLayout(new GridLayout());
0778: pem_frame.getContentPane().add("Center", this .pem_mdiPane);
0779: }
0780:
0781: return;
0782: }
0783:
0784: public HoSwingClient(String xName, boolean xMDI, String xPlaf)
0785: throws Exception {
0786: this .pem_session = (IHoSession) KeRegisteredObject
0787: .pcmf_getObjByName(IHoSession.SESSION_NAME);
0788: // Session global verfügbar machen
0789: if (KeRegisteredObject
0790: .pcmf_getGlobalObjByName(IHoSession.SESSION_NAME) == null)
0791: KeRegisteredObject.pcmf_registerGlobal(
0792: IHoSession.SESSION_NAME, this .pem_session);
0793:
0794: if (!this .pem_session.pcmf_isClientSide())
0795: this .pem_session.pcmf_setClientSide(true,
0796: new HoSwingCommandDispatcher());
0797:
0798: this .pem_session.pcmf_setDisabled(true);
0799:
0800: this .pem_submitValues = new HoRequest(this .pem_session, this );
0801:
0802: this .pem_guiObj = new HoSwingApplicationShadow(xName, this );
0803: this .pem_guiObj.pcmf_setAppl(this );
0804: pem_frame = new JFrame(xName);
0805: pem_mdi = xMDI;
0806: this .pem_guiObj.pcmf_enableSubmit();
0807:
0808: HoSwingClient.pcm_vPanel.setSize(0, 0);
0809: HoSwingClient.pcm_vPanel.setVisible(true);
0810: this .pem_frame.getContentPane().add(HoSwingClient.pcm_vPanel);
0811:
0812: this .pdm_virtKeyEventEmit.setMaximumSize(new Dimension(0, 0));
0813: this .getContentPane().add(this .pdm_virtKeyEventEmit);
0814:
0815: this .pem_frame.addKeyListener(new MyKeyAdapter(this .pem_guiObj,
0816: this ));
0817: this .pcmf_addKeyDispatcher(this );
0818:
0819: MetalLookAndFeel.setCurrentTheme(new MyMetal(this ));
0820:
0821: try {
0822: KeLog.pcmf_log("ug2t", "set L&F: " + xPlaf, this ,
0823: KeLog.MESSAGE);
0824: UIManager.setLookAndFeel(xPlaf);
0825: } catch (Exception e) {
0826: KeLog.pcmf_log("ug2t", "cannot set L&F: " + xPlaf
0827: + " try default", this , KeLog.ERROR);
0828: try {
0829: UIManager.setLookAndFeel(UIManager
0830: .getSystemLookAndFeelClassName());
0831: } catch (Exception e2) {
0832: KeLog.pcmf_logException("ug2t", this , e2);
0833: }
0834: }
0835:
0836: WindowListener l = new MyWindowListener(this );
0837: MyFrameComponentListener lc = new MyFrameComponentListener();
0838: this .pem_frame.addWindowListener(l);
0839: this .pem_frame.addComponentListener(lc);
0840:
0841: this .pem_frame
0842: .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
0843:
0844: if (this .pem_mdi == false) {
0845: pem_frame.getContentPane().add("Center", this );
0846: } else {
0847: this .pem_mdiPane = new MyJDesktopPane();
0848: this .pem_mdiPane
0849: .setDesktopManager(new DefaultDesktopManager());
0850: this .pcmf_addKeyDispatcher(this .pem_mdiPane);
0851:
0852: // this.pem_mdiPane.setLayout(new GridLayout());
0853: pem_frame.getContentPane().add("Center", this .pem_mdiPane);
0854: }
0855:
0856: return;
0857: }
0858:
0859: public boolean pcmf_isMDI() {
0860: return (this .pem_mdi);
0861: }
0862:
0863: public Object pcmf_execObj(Object xObj) {
0864: this .pem_desktop = (HoSwingPage) KeRegisteredObject
0865: .pcmf_getObjByName("_MY_DESKTOP");
0866:
0867: if (this .pem_active == null)
0868: this .pem_active = this .pem_desktop;
0869: else
0870: this .pcmf_setActive(this .pem_active.pcmf_getName());
0871:
0872: if (!this .pem_appResized)
0873: this .pcmf_setApplWinSize(1024, 768);
0874:
0875: if (this .pem_autoShow) {
0876: pem_frame.setVisible(true);
0877: if (this .pem_mdi)
0878: this
0879: .pemf_setSelectedMdi(this .pem_active
0880: .pcmf_getName());
0881: }
0882: ;
0883:
0884: if (!this .pem_session.pcmf_inResume())
0885: this .pem_session.pcmf_setDisabled(false);
0886:
0887: this .pem_active.pcmf_submit();
0888:
0889: if (this .pem_autoShow == false)
0890: this .pem_session.pcmf_setDisabled(true);
0891:
0892: return (this );
0893: };
0894:
0895: public KeTreeElement pcmf_addListener(String xPage, String xPath,
0896: IUnGuiEventListener xListener) {
0897: UnComponent l_guiobj = null;
0898: KeTreeNode l_page = (KeTreeNode) this .pem_guiObj
0899: .pcmf_getSubNode(xPage);
0900:
0901: if (l_page == null)
0902: return (null);
0903:
0904: l_guiobj = (UnComponent) l_page.pcmf_getByPath(xPath);
0905: if (l_guiobj == null)
0906: return (null);
0907:
0908: l_guiobj.pcmf_addListener(xListener);
0909:
0910: return (l_guiobj);
0911: }
0912:
0913: public KeTreeElement pcmf_addListener(String xPath,
0914: IUnGuiEventListener xListener) {
0915: UnComponent l_guiobj = (UnComponent) this .pem_guiObj
0916: .pcmf_getByPath(xPath);
0917:
0918: if (l_guiobj == null)
0919: return (null);
0920:
0921: l_guiobj.pcmf_addListener(xListener);
0922:
0923: return (l_guiobj);
0924: }
0925:
0926: public void pcmf_setState(WfState xState) {
0927: throw (new UnsupportedOperationException());
0928: }
0929:
0930: public WfState pcmf_getState() {
0931: throw (new UnsupportedOperationException());
0932: }
0933:
0934: public String pcmf_getHostName() {
0935: throw (new UnsupportedOperationException());
0936: }
0937:
0938: public int pcmf_getPort() {
0939: throw (new UnsupportedOperationException());
0940: }
0941:
0942: // @@
0943:
0944: public IUnPage pcmf_addPage(String xName, IUnPage xPage) {
0945: xPage.pcmf_getUnComponent().pcmf_setAppl((IUnApplication) this );
0946: return ((IUnPage) this .pcmf_addNode(xName, xPage
0947: .pcmf_getUnComponent()));
0948: }
0949:
0950: public UnComponent pcmf_setActive(String xName) {
0951: try {
0952: if (this .pem_splash != null) {
0953: this .pem_splash.pcmf_close(1500);
0954: this .pem_splash = null;
0955: }
0956:
0957: if (xName == null && this .pem_active == null)
0958: return (null);
0959: else if (xName == null)
0960: xName = this .pem_active.pcmf_getName();
0961:
0962: if (this .pem_mdi == false) {
0963: if (pem_active != null)
0964: pem_active.pcmf_getRealSwingObj().setVisible(false);
0965:
0966: pem_active = (HoSwingPage) this .pem_guiObj
0967: .pcmf_getSubNode(xName);
0968: ((JPanel) ((HoSwingPage) pem_active)
0969: .pcmf_getSwingWidget()).setPreferredSize(null);
0970:
0971: // Entfernen und am Ende neu einfügen, Es werden immer alle Seiten
0972: // gezeichnet, nur die aktive ist sichtbar !
0973: this .getContentPane().remove(
0974: pem_active.pcmf_getRealSwingObj());
0975: this .getContentPane().add(
0976: pem_active.pcmf_getRealSwingObj());
0977: pem_active.pcmf_getRealSwingObj().setVisible(true);
0978: } else {
0979: KeTreeElement l_active = this .pem_guiObj
0980: .pcmf_getSubNode(xName);
0981: if (l_active == null) {
0982: KeLog.pcmf_log(this .pcmf_getUnComponent()
0983: .pcmf_getName(), "page: " + xName
0984: + " not found", this , KeLog.MESSAGE);
0985: this .pcmf_setMenu();
0986: pem_frame.validate();
0987: pem_frame.repaint();
0988: return (this .pem_active);
0989: }
0990:
0991: if (this .pem_active == l_active) {
0992: this .pcmf_setMenu();
0993: pem_frame.validate();
0994: pem_frame.repaint();
0995: return (this .pem_active);
0996: }
0997: pem_active = (HoSwingPage) l_active;
0998: this .pemf_setSelectedMdi(xName);
0999: }
1000: this .pcmf_setMenu();
1001: pem_frame.validate();
1002: pem_frame.repaint();
1003: } catch (Exception e) {
1004: KeLog.pcmf_log("ug2t", "error setting new active page",
1005: this , KeLog.MESSAGE);
1006: }
1007: return (pem_active);
1008: }
1009:
1010: private void pemf_setSelectedMdi(String xName) {
1011: JInternalFrame l_ifs[] = this .pem_mdiPane.getAllFrames();
1012: for (int i = 0; i < l_ifs.length; i++) {
1013: if (l_ifs[i].getTitle().equals(xName)) {
1014: l_ifs[i].toFront();
1015: try {
1016: l_ifs[i].setSelected(true);
1017: l_ifs[i].validate();
1018: l_ifs[i].repaint();
1019: } catch (Exception e) {
1020: KeLog.pcmf_logException(this .pcmf_getUnComponent()
1021: .pcmf_getName(), this , e);
1022: }
1023: ;
1024:
1025: this .pem_actFrame = l_ifs[i];
1026: this .pem_actFrame.requestFocus();
1027: break;
1028: }
1029: }
1030: }
1031:
1032: public UnComponent pcmf_getActive() {
1033: return (this .pem_active);
1034: }
1035:
1036: public void pcmf_work(Object xReq, Object xResp, boolean xRobust)
1037: throws Exception {
1038: throw (new UnsupportedOperationException());
1039: }
1040:
1041: public Object pcmf_execView() {
1042: return (this .pcmf_execObj(null));
1043: }
1044:
1045: public HashMap pcmf_getContext() {
1046: throw (new UnsupportedOperationException());
1047: }
1048:
1049: public String pcmf_getUser() {
1050: throw (new UnsupportedOperationException());
1051: }
1052:
1053: public String pcmf_setUser(String xUser) {
1054: throw (new UnsupportedOperationException());
1055: }
1056:
1057: public String pcmf_getRole() {
1058: throw (new UnsupportedOperationException());
1059: }
1060:
1061: public String pcmf_setRole(String xRole) {
1062: throw (new UnsupportedOperationException());
1063: }
1064:
1065: public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
1066: if (xNode instanceof IUnPage || xNode instanceof IUnDialog
1067: || xNode instanceof IUnOptionDialog
1068: || xNode instanceof IUnFileChooser) {
1069: if (this .pem_mdi == false || xNode instanceof IUnDialog
1070: || xNode instanceof IUnOptionDialog
1071: || xNode instanceof IUnFileChooser) {
1072: if (xNode instanceof HoSwingPage) {
1073: KeTreeNode l_ret = null;
1074: ((HoSwingPage) xNode).pcmf_getRealSwingObj()
1075: .setVisible(false);
1076: this .getContentPane().add(
1077: ((HoSwingPage) xNode)
1078: .pcmf_getRealSwingObj());
1079: l_ret = this .pem_guiObj.pcmf_addNode(xName, xNode);
1080: this .pcmf_setActive(null);
1081:
1082: return (l_ret);
1083: } else
1084: return (this .pem_guiObj.pcmf_addNode(xName, xNode));
1085: } else {
1086: KeTreeNode l_ret = this .pem_guiObj.pcmf_addNode(xName,
1087: xNode);
1088: try {
1089: HoSwingPage l_page = (HoSwingPage) xNode;
1090:
1091: JInternalFrame l_if = new JInternalFrame(xNode
1092: .pcmf_getName(), true, true, true, true);
1093: this .pcmf_addKeyDispatcher(l_if);
1094: this .pem_mdiPane.add(l_if);
1095: l_if
1096: .addInternalFrameListener(new MyInternalFrameListener(
1097: l_page));
1098: l_if.addComponentListener(new MyComponentListener(
1099: (IUnPage) xNode));
1100: l_if
1101: .addPropertyChangeListener(new MyPropertyChangeListener(
1102: l_page));
1103: l_if.getContentPane().add(
1104: l_page.pcmf_getRealSwingObj());
1105:
1106: l_if.reshape(l_page.pcmf_getXPos(), l_page
1107: .pcmf_getYPos(), l_page.pcmf_getWi(),
1108: l_page.pcmf_getHi());
1109: if (l_page.pcmf_isMaximized())
1110: l_if.setMaximum(true);
1111:
1112: l_if.show();
1113: l_page.pcmf_setGlobal(true);
1114: if (l_page.pcmf_getIcon() != null)
1115: l_page.pcmf_setIcon(((HoSwingPage) xNode)
1116: .pcmf_getIcon());
1117: } catch (Exception e) {
1118: KeLog.pcmf_log("ug2t", "error inserting mdi-page: "
1119: + xName, this , KeLog.ERROR);
1120: }
1121: ;
1122:
1123: return (l_ret);
1124: }
1125: } else if (xNode instanceof HoSwingImage) {
1126: this .pem_splash = new HoSwingSplashScreen(
1127: (HoSwingImage) xNode, this .pem_frame);
1128: return (this .pem_guiObj.pcmf_addNode(xName, xNode));
1129: } else {
1130: KeLog
1131: .pcmf_log(
1132: this .pcmf_getUnComponent().pcmf_getName(),
1133: "cannot insert node due to wrong type, no page or dialog",
1134: this , KeLog.ERROR);
1135: return (null);
1136: }
1137: }
1138:
1139: public KeTreeNode pcmf_removeNode(KeTreeNode xNode) {
1140: KeTreeNode l_ret = this .pem_guiObj.pcmf_removeNode(xNode);
1141: if (l_ret instanceof HoSwingComponent) {
1142: if (this .pem_mdi) {
1143: JInternalFrame l_ifs[] = this .pem_mdiPane
1144: .getAllFrames();
1145: for (int i = 0; i < l_ifs.length; i++) {
1146: if (l_ifs[i].getTitle().equals(xNode)) {
1147: if (l_ifs[i].isIcon())
1148: this .pem_mdiPane.remove(l_ifs[i]
1149: .getDesktopIcon());
1150: else
1151: this .pem_mdiPane.remove(l_ifs[i]);
1152:
1153: if (this .pem_active == l_ret)
1154: this .pem_active = this .pem_desktop;
1155:
1156: break;
1157: }
1158: }
1159: } else {
1160: if (this .pem_active == l_ret)
1161: KeLog
1162: .pcmf_log(
1163: "ug2t",
1164: "trying to remove active page, application may crash",
1165: this , KeLog.MESSAGE);
1166:
1167: this .getContentPane().remove(
1168: ((HoSwingComponent) l_ret)
1169: .pcmf_getRealSwingObj());
1170: }
1171: }
1172:
1173: return (l_ret);
1174: }
1175:
1176: public KeTreeNode pcmf_removeNode(String xName) {
1177: KeTreeNode l_ret = this .pem_guiObj.pcmf_removeNode(xName);
1178: if (l_ret instanceof HoSwingComponent) {
1179: if (this .pem_mdi) {
1180: JInternalFrame l_ifs[] = this .pem_mdiPane
1181: .getAllFrames();
1182: for (int i = 0; i < l_ifs.length; i++) {
1183: if (l_ifs[i].getTitle().equals(xName)) {
1184: if (l_ifs[i].isIcon())
1185: this .pem_mdiPane.remove(l_ifs[i]
1186: .getDesktopIcon());
1187: else
1188: this .pem_mdiPane.remove(l_ifs[i]);
1189:
1190: break;
1191: }
1192: }
1193: } else {
1194: if (this .pem_active == l_ret)
1195: KeLog
1196: .pcmf_log(
1197: "ug2t",
1198: "trying to remove active page, application may crash",
1199: this , KeLog.MESSAGE);
1200:
1201: this .getContentPane().remove(
1202: ((HoSwingComponent) l_ret)
1203: .pcmf_getRealSwingObj());
1204: }
1205: }
1206:
1207: return (l_ret);
1208: }
1209:
1210: public void pcmf_reshape(String xName, int x, int y, int w, int l) {
1211: Object l_obj = this .pem_guiObj.pcmf_getSubNode(xName);
1212: if (l_obj instanceof HoSwingDialog)
1213: ((HoSwingDialog) l_obj).pcmf_setDialogPos(x, y, w, l);
1214:
1215: if (this .pem_mdi == false)
1216: return;
1217:
1218: JInternalFrame l_ifs[] = this .pem_mdiPane.getAllFrames();
1219: for (int i = 0; i < l_ifs.length; i++) {
1220: if (l_ifs[i].getTitle().equals(xName)) {
1221: l_ifs[i].reshape(x, y, w, l);
1222: if (((JPanel) ((HoSwingPage) l_obj)
1223: .pcmf_getSwingWidget()).getLayout() == null) {
1224: ((JPanel) ((HoSwingPage) l_obj)
1225: .pcmf_getSwingWidget())
1226: .setPreferredSize(new Dimension(w, l));
1227: ((JPanel) ((HoSwingPage) l_obj)
1228: .pcmf_getSwingWidget())
1229: .setMaximumSize(new Dimension(w, l));
1230: ((JPanel) ((HoSwingPage) l_obj)
1231: .pcmf_getSwingWidget())
1232: .setMinimumSize(new Dimension(w, l));
1233: } else {
1234: ((JPanel) ((HoSwingPage) l_obj)
1235: .pcmf_getSwingWidget())
1236: .setPreferredSize(null);
1237: }
1238: ;
1239: break;
1240: }
1241: ;
1242: }
1243: ;
1244: return;
1245: }
1246:
1247: public KeTreeElement pcmf_addElement(String xName,
1248: KeTreeElement xNode) {
1249: throw (new UnsupportedOperationException());
1250: }
1251:
1252: public KeTreeElement pcmf_removeElement(String xName) {
1253: throw (new UnsupportedOperationException());
1254: }
1255:
1256: public final String pcmf_getObjName() {
1257: return (this .pem_guiObj.pcmf_getObjName());
1258: }
1259:
1260: public final String pcmf_getObjLongName() {
1261: return (this .pem_guiObj.pcmf_getObjLongName());
1262: }
1263:
1264: public UnComponent pcmf_getUnComponent() {
1265: return (this .pem_guiObj);
1266: }
1267:
1268: public void pcmf_setMenu() {
1269: Iterator l_it = pem_active.pcmf_getAllSubs().iterator();
1270: Object l_menu = null;
1271:
1272: if (this .pem_mainmenu != null && this .pem_mdi)
1273: this .pem_frame.setJMenuBar((JMenuBar) this .pem_mainmenu
1274: .pcmf_getRealSwingObj());
1275: else if (this .pem_mainmenu != null)
1276: this .setJMenuBar((JMenuBar) this .pem_mainmenu
1277: .pcmf_getRealSwingObj());
1278:
1279: while (l_it.hasNext()) {
1280: l_menu = l_it.next();
1281: if (l_menu instanceof HoSwingMenu) {
1282: if (this .pem_active.pcmf_getOwnsMenu() == false) {
1283: if (this .pem_mdi)
1284: this .pem_frame
1285: .setJMenuBar((JMenuBar) ((HoSwingMenu) l_menu)
1286: .pcmf_getRealSwingObj());
1287: else
1288: this
1289: .setJMenuBar((JMenuBar) ((HoSwingMenu) l_menu)
1290: .pcmf_getRealSwingObj());
1291: } else if (this .pem_mdi)
1292: this .pem_actFrame
1293: .setJMenuBar((JMenuBar) ((HoSwingMenu) l_menu)
1294: .pcmf_getRealSwingObj());
1295:
1296: break;
1297: }
1298: }
1299: return;
1300: }
1301:
1302: public void pcmf_setMainMenu(IUnMenu xMainMenu) {
1303: this .pem_mainmenu = (HoSwingMenu) xMainMenu;
1304: }
1305:
1306: public IUnMenu pcmf_getMainMenu() {
1307: return (this .pem_mainmenu);
1308: }
1309:
1310: public void pcmf_setIcon(String xName) {
1311: HoSwingImage l_image = (HoSwingImage) KeRegisteredObject
1312: .pcmf_getObjByName(xName);
1313: this .pem_frame.setIconImage(((ImageIcon) ((JLabel) l_image
1314: .pcmf_getRealSwingObj()).getIcon()).getImage());
1315:
1316: return;
1317: }
1318:
1319: public void pcmf_repaint() {
1320: try {
1321: pem_frame.validate();
1322: pem_frame.repaint();
1323:
1324: Iterator l_it = this .pcmf_getUnComponent()
1325: .pcmf_getSubIterator();
1326: Object l_obj = null;
1327: while (l_it.hasNext()) {
1328: l_obj = l_it.next();
1329: if (l_obj instanceof IUnDialog)
1330: ((IUnDialog) l_obj).pcmf_getUnComponent()
1331: .pcmf_repaint();
1332: }
1333: return;
1334: } catch (Exception e) {
1335: KeLog.pcmf_log("ug2t", "error repainting page", this ,
1336: KeLog.MESSAGE);
1337: }
1338: }
1339:
1340: public void pcmf_setInitFct(IKeExecutable xInit) {
1341: throw (new UnsupportedOperationException());
1342: }
1343:
1344: public String pcmf_getRootUrl() {
1345: return (null);
1346: };
1347:
1348: public final void pcmf_setRootUrl(String xUrl) {
1349: throw (new UnsupportedOperationException());
1350: };
1351:
1352: public void pcmf_setComponentFactory(UnComponentFactory xFact) {
1353: throw (new UnsupportedOperationException());
1354: }
1355:
1356: public UnComponentFactory pcmf_getComponentFactory() {
1357: return (null);
1358: }
1359:
1360: public JFrame pcmf_getClientFrame() {
1361: return (this .pem_frame);
1362: }
1363:
1364: public IHoSession pcmf_getSession() {
1365: return (this .pem_session);
1366: }
1367:
1368: public void pcmf_setFont(UnFontDescriptor xFont) {
1369: this .pem_guiObj.pcmf_setFont(xFont);
1370: Font l_font = Font.getFont(xFont.pcmf_getFontFullSpec(),
1371: new Font(null, xFont.pcmf_getFontStyle(), xFont
1372: .pcmf_getFontSize()));
1373: this .setFont(l_font);
1374: }
1375:
1376: public void pcmf_close() {
1377: System.exit(0);
1378: }
1379:
1380: public void pcmf_setBgImage(IUnImage xImg) {
1381: this .pdm_bgImg = xImg;
1382: if (this .pem_mdiPane != null)
1383: this .pem_mdiPane.pcmf_setBgImage(xImg);
1384: }
1385:
1386: public IUnImage pcmf_getBgImage() {
1387: return (this .pdm_bgImg);
1388: }
1389:
1390: public void pcmf_delete() throws Exception {
1391: this .pem_guiObj.pcmf_delete();
1392: this .pem_desktop.pcmf_delete();
1393: }
1394:
1395: public int pcmf_getApplType() {
1396: return (UnComponentFactory.HALFOBJECT);
1397: }
1398:
1399: public void pcmf_setScroll(boolean xScroll) {
1400: // Ist immer Scrollable
1401: KeLog
1402: .pcmf_log(
1403: this .pcmf_getUnComponent().pcmf_getName(),
1404: "client-frame is scrollable per default, setting is ignored",
1405: this , KeLog.MESSAGE);
1406: return;
1407: }
1408:
1409: public boolean pcmf_getScroll() {
1410: return (true);
1411: }
1412:
1413: public void pcmf_setGuiObjPosition(UnComponent xObj, int xPos,
1414: int yPos, int xWi, int xHi, String xAlign) {
1415: try {
1416: this
1417: .pcmf_reshape(xObj.pcmf_getName(), xPos, yPos, xWi,
1418: xHi);
1419: } catch (Exception e) {
1420: KeLog.pcmf_log("ug2t", "no valid alignment: " + xAlign,
1421: this , KeLog.ERROR);
1422: }
1423: }
1424:
1425: /**
1426: * <p>
1427: * Does...
1428: * </p>
1429: * <p>
1430: *
1431: * @return a Type with
1432: * </p>
1433: * <p>
1434: * @param
1435: * </p>
1436: */
1437: public void pcmf_setGuiObjPosition(String xName, int xPos,
1438: int yPos, int xWi, int xHi, String xAlign) {
1439: try {
1440: this .pcmf_reshape(xName, xPos, yPos, xWi, xHi);
1441: } catch (Exception e) {
1442: KeLog.pcmf_log("ug2t", "no valid alignment: " + xAlign,
1443: this , KeLog.ERROR);
1444: }
1445: }
1446:
1447: public void pcmf_addWidget(String xName, UnComponent xObj) {
1448: this .pcmf_addNode(xName, xObj);
1449: }
1450:
1451: public UnComponent pcmf_removeWidget(String xName) {
1452: return ((UnComponent) this .pcmf_removeNode(xName));
1453: }
1454:
1455: public UnComponent pcmf_removeWidget(UnComponent xObj) {
1456: return ((UnComponent) this .pcmf_removeNode(xObj.pcmf_getName()));
1457: }
1458:
1459: public UnComponent pcmf_getWidget(String xName) {
1460: return ((UnComponent) this .pem_guiObj.pcmf_getSubNode(xName));
1461: }
1462:
1463: public boolean pcmf_contains(UnComponent xObj) {
1464: return (this .pem_guiObj.pcmf_getAllSubs().contains(xObj));
1465: }
1466:
1467: public void pcmf_setApplWinSize(int xWi, int xHi) {
1468: this .pem_appResized = true;
1469: this .pem_frame.setSize(xWi, xHi);
1470: this .pem_frame.repaint();
1471:
1472: return;
1473: }
1474:
1475: public void pcmf_setValue(Object xValue) {
1476: this .pem_guiObj.pcmf_setValue(xValue);
1477: }
1478:
1479: public void pcmf_addKeyChannel(HoSwingComponent xChannel) {
1480: if (this .pem_keyChannels == null)
1481: this .pem_keyChannels = new HashMap();
1482:
1483: this .pem_keyChannels.put(xChannel, "");
1484:
1485: return;
1486: }
1487:
1488: public boolean pcmf_isKeyChannel(HoSwingComponent xChannel) {
1489: if (this .pem_keyChannels == null)
1490: this .pem_keyChannels = new HashMap();
1491:
1492: return (this .pem_keyChannels.containsKey(xChannel));
1493: }
1494:
1495: public void pcmf_removeKeyChannel(HoSwingComponent xChannel) {
1496: if (this .pem_keyChannels == null)
1497: this .pem_keyChannels = new HashMap();
1498:
1499: this .pem_keyChannels.remove(xChannel);
1500:
1501: return;
1502: }
1503:
1504: public boolean pcmf_processKey(KeyEvent xKey) {
1505: if (xKey.getSource() == this .pdm_virtKeyEventEmit)
1506: return (true);
1507: else
1508: return (false);
1509: }
1510:
1511: public void pcmf_beginSessionTR() {
1512: this .pem_session.pcmf_beginTr();
1513: }
1514:
1515: public void pcmf_commitSessionTR() {
1516: this .pem_session.pcmf_commitTr();
1517: };
1518:
1519: public void pcmf_rollbackSessionTR() {
1520: this .pem_session.pcmf_rollbackTr();
1521: }
1522:
1523: public String pcmf_getCurrentTemplateKitName() {
1524: return (null);
1525: }
1526:
1527: public final void pcmf_setHostName(String xHost) {
1528: return;
1529: }
1530:
1531: public final void pcmf_setHttpPort(int xPort) {
1532: return;
1533: }
1534:
1535: class ClientCommandController extends Thread {
1536: public static final int ERR = 0;
1537: public static final int STD = 1;
1538:
1539: private Process pem_proc = null;
1540: private int pem_stream = ClientCommandController.STD;
1541: private byte pem_bytes[] = new byte[1024];
1542:
1543: public ClientCommandController(Process xProc, int xStream) {
1544: this .pem_proc = xProc;
1545: this .pem_stream = xStream;
1546: }
1547:
1548: public ClientCommandController(Process xProc) {
1549: this .pem_proc = xProc;
1550: }
1551:
1552: public void pcmf_exitProc() {
1553: this .pem_proc.destroy();
1554: }
1555:
1556: public byte[] pcmf_getOutBytes() {
1557: return (this .pem_bytes);
1558: }
1559:
1560: public void run() {
1561: try {
1562: InputStream l_ip = null;
1563: int l_idx = 0;
1564:
1565: if (this .pem_stream == STD)
1566: l_ip = this .pem_proc.getInputStream();
1567: else
1568: l_ip = this .pem_proc.getErrorStream();
1569:
1570: while (true) {
1571: int l_res = l_ip.read();
1572: if (l_res == -1)
1573: break;
1574:
1575: this .pem_bytes[l_idx++] = (byte) l_res;
1576: if (l_idx == this .pem_bytes.length) {
1577: byte l_new[] = new byte[this .pem_bytes.length << 1];
1578: System.arraycopy(this .pem_bytes, 0, l_new, 0,
1579: this .pem_bytes.length);
1580: this .pem_bytes = l_new;
1581: }
1582: }
1583: } catch (Exception e) {
1584: if (this .pem_stream == STD)
1585: KeLog
1586: .pcmf_log(
1587: "ug2t",
1588: "error reading from sub process InputStream",
1589: this , KeLog.MESSAGE);
1590: else
1591: KeLog
1592: .pcmf_log(
1593: "ug2t",
1594: "error reading from sub process ErrorStream",
1595: this , KeLog.MESSAGE);
1596: } finally {
1597: if (this .pem_stream == STD)
1598: KeLog.pcmf_log("ug2t",
1599: "sub process InputStream closed", this ,
1600: KeLog.MESSAGE);
1601: else
1602: KeLog.pcmf_log("ug2t",
1603: "sub process ErrorStream closed", this ,
1604: KeLog.MESSAGE);
1605: }
1606: }
1607: }
1608:
1609: public final void pcmf_execClientCommand(String xCommand) {
1610: try {
1611: KeLog.pcmf_log("ug2t", "running external command: "
1612: + xCommand, this , KeLog.MESSAGE);
1613: Process l_process = Runtime.getRuntime().exec(xCommand);
1614: new ClientCommandController(l_process,
1615: ClientCommandController.ERR).start();
1616: new ClientCommandController(l_process,
1617: ClientCommandController.STD).start();
1618: } catch (Exception e) {
1619: KeLog.pcmf_log("ug2t", "error running external command",
1620: this , KeLog.ERROR);
1621: }
1622: }
1623:
1624: public final void pcmf_execInternalClientCommand(String xCommand,
1625: final String xParam) {
1626: try {
1627: Class l_class = Class.forName(xCommand);
1628: final Method l_main = l_class.getMethod("main",
1629: new Class[] { String[].class });
1630:
1631: final Thread l_thread = new Thread() {
1632: public void run() {
1633: try {
1634: l_main
1635: .invoke(
1636: null,
1637: new Object[] { new String[] { xParam } });
1638: } catch (Exception e) {
1639: KeLog.pcmf_logException("ug2t", this , e);
1640: }
1641: }
1642: };
1643: l_thread.start();
1644: } catch (Exception e) {
1645: KeLog.pcmf_log("ug2t", "error running internal command",
1646: this , KeLog.ERROR);
1647: }
1648: }
1649:
1650: public void pcmf_disableLazyWidgets() {
1651: throw (new UnsupportedOperationException());
1652: }
1653:
1654: public void pcmf_setExternalCss(String xCss) {
1655: return;
1656: }
1657:
1658: public String pcmf_getExternalCss() {
1659: return (null);
1660: }
1661:
1662: // New methods (delegates only) due to interface harmonisation
1663: public void pcmf_addWidget(String xName, IUnComponent xObj) {
1664: this .pcmf_addWidget(xName, (UnComponent) xObj);
1665: }
1666:
1667: public boolean pcmf_contains(IUnComponent xObj) {
1668: return (this .pcmf_contains((UnComponent) xObj));
1669: }
1670:
1671: public IUnComponent pcmf_getWidgetbyName(String xName) {
1672: return ((IUnComponent) this .pcmf_getWidget(xName));
1673: }
1674:
1675: public IUnComponent pcmf_removeWidget(IUnComponent xObj) {
1676: return ((IUnComponent) this
1677: .pcmf_removeWidget((UnComponent) xObj));
1678: }
1679:
1680: public void pcmf_setGuiObjPosition(IUnComponent xObj, int xPos,
1681: int yPos, int xWi, int xHi, String xAlign) {
1682: this .pcmf_setGuiObjPosition((UnComponent) xObj, xPos, yPos,
1683: xWi, xHi, xAlign);
1684: }
1685:
1686: public void pcmf_setGenerateReshapeEvents(boolean xReshapes) {
1687: this .pem_submitReshapes = xReshapes;
1688: return;
1689: }
1690:
1691: public boolean pcmf_getGenerateReshapeEvents() {
1692: return (this .pem_submitReshapes);
1693: }
1694:
1695: public void pcmf_enableSubmit() {
1696: this .pcmf_getUnComponent().pcmf_enableSubmit();
1697: }
1698:
1699: public void pcmf_disableSubmit() {
1700: this .pcmf_getUnComponent().pcmf_disableSubmit();
1701: }
1702:
1703: public void pcmf_setFgColor(String xCol) {
1704: try {
1705: if (this .pem_mdi)
1706: this .pem_mdiPane.setForeground(HoSwingComponent
1707: .pcmf_createColor(xCol));
1708: } catch (Exception e) {
1709: KeLog.pcmf_logException("ug2t", this , e);
1710: }
1711:
1712: return;
1713: }
1714:
1715: public void pcmf_setBgColor(String xCol) {
1716: try {
1717: if (this .pem_mdi)
1718: this .pem_mdiPane.setBackground(HoSwingComponent
1719: .pcmf_createColor(xCol));
1720: } catch (Exception e) {
1721: KeLog.pcmf_logException("ug2t", this , e);
1722: }
1723:
1724: return;
1725: }
1726:
1727: public void pcmf_setAutoShow(boolean xShow) {
1728: this .pem_autoShow = xShow;
1729: }
1730:
1731: public void pcmf_show() {
1732: this .pem_frame.setVisible(true);
1733:
1734: if (this .pem_mdi)
1735: this .pemf_setSelectedMdi(this .pem_active.pcmf_getName());
1736:
1737: if (!this .pem_session.pcmf_inResume())
1738: this .pem_session.pcmf_setDisabled(false);
1739: }
1740:
1741: public boolean pcmf_isCssSupported() {
1742: return (false);
1743: }
1744:
1745: public PcProcess pcmf_getService() {
1746: throw (new UnsupportedOperationException());
1747: }
1748:
1749: public void pcmf_setService(IKeExecutable xServiceFct,
1750: int xPollService, int xRefresh) {
1751: throw (new UnsupportedOperationException());
1752: }
1753:
1754: public void pcmf_setServiceProcess(PcProcess xServiceProc,
1755: int xRefresh) {
1756: throw (new UnsupportedOperationException());
1757: }
1758:
1759: public PcProcess pcmf_detachService() {
1760: throw (new UnsupportedOperationException());
1761: }
1762:
1763: public void pcmf_startClientPoll(int xPollTime) {
1764: this .pem_pollThread = new ClientPollThread(xPollTime);
1765: }
1766:
1767: public void pcmf_stopClientPoll() {
1768: this .pem_pollThread.pcmf_stop();
1769: this .pem_pollThread = null;
1770: }
1771:
1772: public boolean pcmf_getClientPoll() {
1773: return (this .pem_pollThread == null ? false : true);
1774: }
1775:
1776: public Object pcmf_persist() throws Throwable {
1777: throw (new UnsupportedOperationException());
1778: }
1779:
1780: // private IKeExecutable pem_resumeHdl = null;
1781:
1782: public void pcmf_resumed() {
1783: throw (new UnsupportedOperationException());
1784: }
1785:
1786: public void pcmf_prePersit() {
1787: throw (new UnsupportedOperationException());
1788: }
1789:
1790: public void pcmf_setResumeHandler(IKeExecutable xResHdl) {
1791: throw (new UnsupportedOperationException());
1792: }
1793:
1794: public void pcmf_refreshSession() {
1795: throw (new UnsupportedOperationException());
1796: }
1797:
1798: public void pcmf_record(boolean xRecord) {
1799: throw (new UnsupportedOperationException());
1800: }
1801:
1802: public void pcmf_playback() {
1803: throw (new UnsupportedOperationException());
1804: }
1805:
1806: public void pcmf_playback(String xSession) {
1807: throw (new UnsupportedOperationException());
1808: }
1809:
1810: public void pcmf_toLastCheckPoint() {
1811: throw (new UnsupportedOperationException());
1812: }
1813:
1814: public void pcmf_setInPlayBack(boolean xIn) {
1815: // @@
1816: }
1817:
1818: public void pcmf_clearSubmitValues() {
1819: this .pem_submitValues.pcmf_clearSubmitValues();
1820: }
1821:
1822: // @@
1823:
1824: public void pcmf_setIterativeEventLatency(int xLatency) {
1825: this .pem_eventLatency = xLatency;
1826: this .pem_guiObj.pcmf_setIterativeEventLatency(xLatency);
1827: }
1828:
1829: public int pcmf_getIterativeEventLatency() {
1830: return (this .pem_eventLatency);
1831: }
1832:
1833: public void pcmf_setProtocol(String xProto) {
1834: KeLog.pcmf_logNotSupported("pcmf_setProtocol(String xProto)");
1835: return;
1836: }
1837:
1838: public String pcmf_getProtocol() {
1839: KeLog.pcmf_logNotSupported("pcmf_getProtocol(String xProto)");
1840: return ("http");
1841: }
1842:
1843: public void pcmf_addMappingListener(IUnMappingEventListener xListen) {
1844: return;
1845: }
1846:
1847: public void pcmf_removeMappingListener(
1848: IUnMappingEventListener xListen) {
1849: return;
1850: }
1851: }
|