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.datatransfer.*;
0035: import java.awt.dnd.*;
0036: import java.awt.event.*;
0037: import java.util.*;
0038: import java.util.regex.*;
0039:
0040: import javax.swing.*;
0041: import javax.swing.border.*;
0042: import javax.swing.event.*;
0043: import javax.swing.text.*;
0044:
0045: import de.ug2t.channel.ho.*;
0046: import de.ug2t.channel.ho.session.*;
0047: import de.ug2t.kernel.*;
0048: import de.ug2t.unifiedGui.*;
0049: import de.ug2t.unifiedGui.interfaces.*;
0050:
0051: class DGListener implements DragGestureListener {
0052: private DSListener pem_dsListen = null;
0053: private HoSwingComponent pem_obj = null;
0054: IUnEventChannel pem_channel = null;
0055:
0056: public DGListener(DSListener xDs, HoSwingComponent xObj,
0057: IUnEventChannel xChannel) {
0058: this .pem_dsListen = xDs;
0059: this .pem_obj = xObj;
0060: this .pem_channel = xChannel;
0061: };
0062:
0063: public void dragGestureRecognized(DragGestureEvent e) {
0064:
0065: try {
0066: pem_channel.pcmf_getUnComponent().pcmf_setValue(
0067: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_DRAG]
0068: + ":" + this .pem_obj.pcmf_getObjName());
0069: pem_channel.pcmf_getUnComponent().pcmf_setRefresh();
0070: pem_channel.pcmf_getUnComponent().pcmf_dispatchEvent();
0071:
0072: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0073: .pcmf_setSubmitValue(pem_channel
0074: .pcmf_getUnComponent().pcmf_getObjName(),
0075: pem_channel.pcmf_getUnComponent()
0076: .pcmf_getValue().toString());
0077:
0078: KeTreeNode l_parent = pem_channel.pcmf_getUnComponent()
0079: .pcmf_getParentNode();
0080: if (l_parent != null
0081: && l_parent instanceof IUnSyncComponent)
0082: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0083: .pcmf_setSubmitValue(
0084: l_parent.pcmf_getObjName(),
0085: ((IUnSyncComponent) l_parent)
0086: .pcmf_getValueToSync()
0087: .toString());
0088:
0089: if (pem_channel.pcmf_getUnComponent().pcmf_isSubmit())
0090: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0091: .pcmf_submit();
0092: } catch (Exception ex) {
0093: KeLog.pcmf_logException("ug2t", this , ex);
0094: }
0095: ;
0096:
0097: Transferable transferable = new StringSelection(this .pem_obj
0098: .pcmf_getObjName());
0099: try {
0100: e.startDrag(DragSource.DefaultCopyNoDrop, transferable,
0101: this .pem_dsListen);
0102: } catch (InvalidDnDOperationException idoe) {
0103: KeLog.pcmf_logException("ug2t", this , idoe);
0104: }
0105: }
0106: }
0107:
0108: class DSListener implements DragSourceListener {
0109:
0110: public void dragDropEnd(DragSourceDropEvent e) {
0111: }
0112:
0113: /**
0114: * @param e
0115: * the event
0116: */
0117: public void dragEnter(DragSourceDragEvent e) {
0118: DragSourceContext context = e.getDragSourceContext();
0119: int myaction = e.getDropAction();
0120: if ((myaction & DnDConstants.ACTION_COPY) != 0)
0121: context.setCursor(DragSource.DefaultCopyDrop);
0122: else
0123: context.setCursor(DragSource.DefaultCopyNoDrop);
0124: }
0125:
0126: /**
0127: * @param e
0128: * the event
0129: */
0130: public void dragOver(DragSourceDragEvent e) {
0131: }
0132:
0133: /**
0134: * @param e
0135: * the event
0136: */
0137: public void dragExit(DragSourceEvent e) {
0138: DragSourceContext context = e.getDragSourceContext();
0139: context.setCursor(DragSource.DefaultCopyNoDrop);
0140: }
0141:
0142: public void dropActionChanged(DragSourceDragEvent e) {
0143: }
0144: }
0145:
0146: class SwingDndSupportDrag {
0147: protected DragSource pdm_dragSource = null;
0148: protected DGListener pdm_dgListener = null;
0149: protected DSListener pdm_dsListener = null;
0150: protected DragGestureRecognizer pdm_dgr = null;
0151:
0152: public SwingDndSupportDrag(HoSwingComponent xUiObj,
0153: IUnEventChannel xChannel) {
0154: this .pdm_dragSource = DragSource.getDefaultDragSource();
0155: this .pdm_dsListener = new DSListener();
0156: this .pdm_dgListener = new DGListener(this .pdm_dsListener,
0157: xUiObj, xChannel);
0158:
0159: // component, action, listener
0160: pdm_dgr = this .pdm_dragSource
0161: .createDefaultDragGestureRecognizer(xUiObj
0162: .pcmf_getSwingWidget(),
0163: DnDConstants.ACTION_COPY, this .pdm_dgListener);
0164: }
0165:
0166: public void pcmf_remove() {
0167: this .pdm_dgr.removeDragGestureListener(pdm_dgListener);
0168: this .pdm_dragSource.removeDragSourceListener(pdm_dsListener);
0169: }
0170: }
0171:
0172: class DTListener implements DropTargetListener {
0173: private HoSwingComponent pem_obj = null;
0174: private IUnEventChannel pem_channel = null;
0175:
0176: public DTListener(HoSwingComponent xObj, IUnEventChannel xChannel) {
0177: this .pem_obj = xObj;
0178: this .pem_channel = xChannel;
0179: };
0180:
0181: private boolean isDragFlavorSupported(DropTargetDragEvent e) {
0182: if (e.isDataFlavorSupported(DataFlavor.stringFlavor))
0183: return (true);
0184:
0185: return (false);
0186: }
0187:
0188: private DataFlavor chooseDropFlavor(DropTargetDropEvent e) {
0189: return (DataFlavor.stringFlavor);
0190: }
0191:
0192: private boolean isDragOk(DropTargetDragEvent e) {
0193: if (isDragFlavorSupported(e) == false)
0194: return false;
0195: else
0196: return true;
0197: }
0198:
0199: public void dragEnter(DropTargetDragEvent e) {
0200: if (isDragOk(e) == false) {
0201: e.rejectDrag();
0202: return;
0203: }
0204: e.acceptDrag(e.getDropAction());
0205: }
0206:
0207: public void dragOver(DropTargetDragEvent e) {
0208: if (isDragOk(e) == false) {
0209: e.rejectDrag();
0210: return;
0211: }
0212: e.acceptDrag(e.getDropAction());
0213: }
0214:
0215: public void dropActionChanged(DropTargetDragEvent e) {
0216: if (isDragOk(e) == false) {
0217: e.rejectDrag();
0218: return;
0219: }
0220: e.acceptDrag(e.getDropAction());
0221: }
0222:
0223: public void dragExit(DropTargetEvent e) {
0224: }
0225:
0226: public void drop(DropTargetDropEvent e) {
0227: DataFlavor chosen = chooseDropFlavor(e);
0228: if (chosen == null) {
0229: e.rejectDrop();
0230: return;
0231: }
0232: Object data = null;
0233: try {
0234: e.acceptDrop(DnDConstants.ACTION_COPY);
0235: data = e.getTransferable().getTransferData(chosen);
0236: } catch (Exception ex) {
0237: KeLog.pcmf_logException("ug2t", this , ex);
0238: }
0239:
0240: // Hier wird der Wert weiterverarbeitet
0241: try {
0242: pem_channel.pcmf_getUnComponent().pcmf_setValue(
0243: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_DROP]
0244: + ":" + data.toString());
0245: pem_channel.pcmf_getUnComponent().pcmf_setRefresh();
0246: pem_channel.pcmf_getUnComponent().pcmf_dispatchEvent();
0247:
0248: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0249: .pcmf_setSubmitValue(pem_channel
0250: .pcmf_getUnComponent().pcmf_getObjName(),
0251: pem_channel.pcmf_getUnComponent()
0252: .pcmf_getValue().toString());
0253:
0254: KeTreeNode l_parent = pem_channel.pcmf_getUnComponent()
0255: .pcmf_getParentNode();
0256: if (l_parent != null
0257: && l_parent instanceof IUnSyncComponent)
0258: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0259: .pcmf_setSubmitValue(
0260: l_parent.pcmf_getObjName(),
0261: ((IUnSyncComponent) l_parent)
0262: .pcmf_getValueToSync()
0263: .toString());
0264:
0265: if (pem_channel.pcmf_getUnComponent().pcmf_isSubmit())
0266: ((HoSwingPage) pem_obj.pcmf_getAppl().pcmf_getActive())
0267: .pcmf_submit();
0268: } catch (Exception ex) {
0269: KeLog.pcmf_logException("ug2t", this , ex);
0270: }
0271: ;
0272:
0273: e.dropComplete(true);
0274: }
0275: }
0276:
0277: class SwingDndSupportDrop {
0278: protected DropTarget pdm_dropTarget;
0279: protected DropTargetListener pdm_dtListener;
0280:
0281: public SwingDndSupportDrop(HoSwingComponent xUiObj,
0282: IUnEventChannel xChannel) {
0283: this .pdm_dtListener = new DTListener(xUiObj, xChannel);
0284: pdm_dropTarget = new DropTarget(xUiObj.pcmf_getSwingWidget(),
0285: DnDConstants.ACTION_COPY, this .pdm_dtListener, true);
0286: };
0287:
0288: public void pcmf_remove() {
0289: this .pdm_dropTarget.removeDropTargetListener(pdm_dtListener);
0290: this .pdm_dropTarget.setComponent(null);
0291: }
0292: };
0293:
0294: public class HoSwingComponent extends UnComponent {
0295: protected java.awt.Container pdm_realSwingCmp = null;
0296: protected IHoSession pem_session = null;
0297: protected SwingDndSupportDrag pdm_dndDrag = null;
0298: protected SwingDndSupportDrop pdm_dndDrop = null;
0299: private GridBagConstraints pem_myConstraints = null;
0300: private HashMap pem_channelListeners = null;
0301: private static Map pem_colors = Collections
0302: .synchronizedMap(new HashMap());
0303: private int pem_eventLatency = -1;
0304:
0305: // @@
0306:
0307: public HoSwingComponent(String xName, IUnApplication xAppl)
0308: throws Exception {
0309: super (xName);
0310: this .pem_session = xAppl.pcmf_getSession();
0311: this .pcmf_setAppl(xAppl);
0312: };
0313:
0314: public HoSwingComponent(String xName, IUnApplication xAppl,
0315: IHoSession xSess) throws Exception {
0316: super (xName);
0317: this .pem_session = xSess;
0318: this .pcmf_setAppl(xAppl);
0319: };
0320:
0321: public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
0322: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0323:
0324: if (l_cont instanceof JButton == false
0325: && xNode instanceof HoSwingComponent
0326: && xNode instanceof IUnMenu != true
0327: && this instanceof HoSwingContainer != true
0328: && xNode.pcmf_isHidden() == false)
0329: l_cont.add(((HoSwingComponent) xNode)
0330: .pcmf_getRealSwingObj());
0331:
0332: if (xNode instanceof IUnEventChannel)
0333: this .pdmf_addChannelListener((IUnEventChannel) xNode);
0334:
0335: return (super .pcmf_addNode(xName, xNode));
0336: };
0337:
0338: public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode,
0339: int xIdx) {
0340: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0341:
0342: if (l_cont instanceof JButton == false
0343: && xNode instanceof HoSwingComponent
0344: && xNode instanceof IUnMenu != true
0345: && this instanceof HoSwingContainer != true
0346: && xNode.pcmf_isHidden() == false)
0347: l_cont.add(((HoSwingComponent) xNode)
0348: .pcmf_getRealSwingObj(), xIdx);
0349:
0350: if (xNode instanceof IUnEventChannel)
0351: this .pdmf_addChannelListener((IUnEventChannel) xNode);
0352:
0353: return (super .pcmf_addNode(xName, xNode, xIdx));
0354: };
0355:
0356: public KeTreeNode pcmf_removeNode(String xName) {
0357: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0358:
0359: KeTreeNode l_ret = super .pcmf_removeNode(xName);
0360: if (l_ret instanceof HoSwingComponent
0361: && this instanceof HoSwingContainer != true)
0362: l_cont.remove(((HoSwingComponent) l_ret)
0363: .pcmf_getRealSwingObj());
0364:
0365: if (l_ret instanceof IUnEventChannel)
0366: this .pdmf_removeChannelListener((IUnEventChannel) l_ret);
0367:
0368: return (l_ret);
0369: };
0370:
0371: public KeTreeNode pcmf_removeNode(KeTreeNode xNode) {
0372: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0373:
0374: KeTreeNode l_ret = super .pcmf_removeNode(xNode);
0375: if (l_ret instanceof HoSwingComponent
0376: && this instanceof HoSwingContainer != true)
0377: l_cont.remove(((HoSwingComponent) l_ret)
0378: .pcmf_getRealSwingObj());
0379:
0380: if (l_ret instanceof IUnEventChannel)
0381: this .pdmf_removeChannelListener((IUnEventChannel) l_ret);
0382:
0383: return (l_ret);
0384: };
0385:
0386: public KeTreeElement pcmf_addElement(String xName,
0387: KeTreeElement xNode) {
0388: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0389:
0390: if (l_cont instanceof JButton == false
0391: && xNode instanceof HoSwingComponent
0392: && xNode instanceof IUnMenu != true
0393: && this instanceof HoSwingContainer != true)
0394: l_cont.add(((HoSwingComponent) xNode)
0395: .pcmf_getRealSwingObj());
0396:
0397: if (xNode instanceof IUnEventChannel) {
0398: this .pdmf_addChannelListener((IUnEventChannel) xNode);
0399: return (this );
0400: }
0401: ;
0402:
0403: return (super .pcmf_addElement(xName, xNode));
0404: };
0405:
0406: public KeTreeElement pcmf_removeElement(String xName) {
0407: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0408:
0409: KeTreeElement l_ret = super .pcmf_removeElement(xName);
0410: if (l_ret instanceof HoSwingComponent
0411: && this instanceof HoSwingContainer != true)
0412: l_cont.remove(((HoSwingComponent) l_ret)
0413: .pcmf_getRealSwingObj());
0414:
0415: if (l_ret instanceof IUnEventChannel)
0416: this .pdmf_removeChannelListener((IUnEventChannel) l_ret);
0417:
0418: return (l_ret);
0419: };
0420:
0421: public KeTreeElement pcmf_removeElement(KeTreeElement xNode) {
0422: java.awt.Container l_cont = this .pcmf_getRealSwingObj();
0423:
0424: KeTreeElement l_ret = super .pcmf_removeElement(xNode);
0425: if (l_ret instanceof HoSwingComponent
0426: && this instanceof HoSwingContainer != true)
0427: l_cont.remove(((HoSwingComponent) l_ret)
0428: .pcmf_getRealSwingObj());
0429:
0430: if (l_ret instanceof IUnEventChannel)
0431: this .pdmf_removeChannelListener((IUnEventChannel) l_ret);
0432:
0433: return (l_ret);
0434: };
0435:
0436: // gibt immer den zugehörigen container zurück der in das übergeordnet Obj
0437: // eingefügt werden muß
0438: public java.awt.Container pcmf_getRealSwingObj() {
0439: return (this .pdm_realSwingCmp);
0440: };
0441:
0442: // Ist zum überladen gedacht, soll immer das echte HALFOBJECT-Widget
0443: // zurückgeben
0444: public java.awt.Container pcmf_getSwingWidget() {
0445: return (this .pdm_realSwingCmp);
0446: };
0447:
0448: public void pcmf_disable() {
0449: this .pdm_realSwingCmp.setEnabled(false);
0450: super .pcmf_disable();
0451: return;
0452: };
0453:
0454: public void pcmf_enable() {
0455: this .pdm_realSwingCmp.setEnabled(true);
0456: super .pcmf_enable();
0457: return;
0458: };
0459:
0460: public void pcmf_setCursor(String xCursor) {
0461: try {
0462: Object l_obj = this .pcmf_getSwingWidget();
0463: if (l_obj instanceof JComponent)
0464: ((JComponent) l_obj)
0465: .setCursor(Cursor
0466: .getPredefinedCursor(((Integer) java.awt.Cursor.class
0467: .getDeclaredField(
0468: xCursor + "_CURSOR")
0469: .get(null)).intValue()));
0470:
0471: super .pcmf_setCursor(xCursor);
0472: } catch (Exception e) {
0473: KeLog.pcmf_log("ug2t", "error setting cursor: " + xCursor,
0474: null, KeLog.ERROR);
0475: }
0476:
0477: return;
0478: }
0479:
0480: public void pcmf_setToolTip(String xTip) {
0481: Object l_obj = this .pcmf_getSwingWidget();
0482: if (l_obj instanceof JComponent)
0483: ((JComponent) l_obj).setToolTipText(xTip);
0484:
0485: super .pcmf_setToolTip(xTip);
0486:
0487: return;
0488: };
0489:
0490: public static Color pcmf_createColor(String xCol) {
0491: try {
0492: Color l_col = (Color) HoSwingComponent.pem_colors.get(xCol);
0493: if (l_col == null) {
0494: if (xCol.charAt(0) == '#') {
0495: xCol = xCol.substring(1, xCol.length());
0496: int r = Integer.parseInt(xCol.substring(0, 2), 16);
0497: int g = Integer.parseInt(xCol.substring(2, 4), 16);
0498: int b = Integer.parseInt(xCol.substring(4, 6), 16);
0499: l_col = new Color(r, g, b);
0500: } else
0501: l_col = (Color) java.awt.Color.class
0502: .getDeclaredField(xCol).get(null);
0503:
0504: HoSwingComponent.pem_colors.put(xCol, l_col);
0505: }
0506: return (l_col);
0507: } catch (Exception e) {
0508: if (xCol.equals("") || xCol.equals("transparent"))
0509: return (null);
0510:
0511: KeLog.pcmf_log("ug2t", "error creating color-object: "
0512: + xCol, null, KeLog.ERROR);
0513: return (null);
0514: }
0515: }
0516:
0517: public void pcmf_setFgColor(String xCol) {
0518: try {
0519: if (this .pdm_realSwingCmp instanceof JComponent)
0520: ((JComponent) this .pdm_realSwingCmp)
0521: .setForeground(HoSwingComponent
0522: .pcmf_createColor(xCol));
0523:
0524: super .pcmf_setFgColor(xCol);
0525: } catch (Exception e) {
0526: KeLog.pcmf_logException("ug2t", this , e);
0527: }
0528: ;
0529:
0530: return;
0531: };
0532:
0533: public void pcmf_setBgColor(String xCol) {
0534: try {
0535: if (this .pdm_realSwingCmp instanceof JComponent) {
0536: if (xCol.equals("transparent")) {
0537: ((JComponent) this .pdm_realSwingCmp)
0538: .setOpaque(false);
0539: return;
0540: }
0541:
0542: ((JComponent) this .pdm_realSwingCmp).setOpaque(true);
0543: ((JComponent) this .pdm_realSwingCmp)
0544: .setBackground(HoSwingComponent
0545: .pcmf_createColor(xCol));
0546: }
0547:
0548: super .pcmf_setBgColor(xCol);
0549: } catch (Exception e) {
0550: KeLog.pcmf_logException("ug2t", this , e);
0551: }
0552: ;
0553:
0554: return;
0555: };
0556:
0557: public void pcmf_repaint() {
0558: this .pcmf_getRealSwingObj().validate();
0559: this .pcmf_getRealSwingObj().repaint();
0560:
0561: return;
0562: };
0563:
0564: public void pcmf_draw() {
0565: this .pcmf_getRealSwingObj().validate();
0566: this .pcmf_getRealSwingObj().repaint();
0567:
0568: return;
0569: };
0570:
0571: protected void pdmf_removeChannelListener(final IUnEventChannel xCh) {
0572: if (this .pem_channelListeners == null) {
0573: KeLog
0574: .pcmf_log(
0575: "ug2t",
0576: "try to remove an unknown channel listener, internal api error",
0577: this , KeLog.DEBUG);
0578: return;
0579: }
0580:
0581: Object l_listen = this .pem_channelListeners.remove(xCh);
0582: if (l_listen != null) {
0583: if (l_listen instanceof MouseListener)
0584: this .pcmf_getSwingWidget().removeMouseListener(
0585: (MouseListener) l_listen);
0586: else if (l_listen instanceof KeyListener)
0587: this .pcmf_getSwingWidget().removeKeyListener(
0588: (KeyListener) l_listen);
0589: else if (l_listen instanceof FocusListener)
0590: this .pcmf_getSwingWidget().removeFocusListener(
0591: (FocusListener) l_listen);
0592: else if (l_listen instanceof SwingDndSupportDrag) {
0593: ((SwingDndSupportDrag) this .pdm_dndDrag).pcmf_remove();
0594: this .pdm_dndDrag = null;
0595: } else if (l_listen instanceof SwingDndSupportDrop) {
0596: ((SwingDndSupportDrop) this .pdm_dndDrop).pcmf_remove();
0597: this .pdm_dndDrop = null;
0598: }
0599: }
0600: }
0601:
0602: protected void pdmf_addChannelListener(final IUnEventChannel xCh) {
0603: if (this .pem_channelListeners == null)
0604: this .pem_channelListeners = new HashMap();
0605:
0606: switch (xCh.pcmf_getType()) {
0607: case IUnEventChannel.EVENT_SCROLL: {
0608: // do nothing on client
0609: break;
0610: }
0611: case IUnEventChannel.EVENT_CLICK: {
0612: MouseAdapter l_click = new HoMouseAdapter() {
0613: IUnEventChannel pem_channel = xCh;
0614:
0615: public void mouseClicked(MouseEvent e) {
0616: try {
0617: MouseEvent l_root = SwingUtilities
0618: .convertMouseEvent((Component) e
0619: .getSource(), e, null);
0620:
0621: pem_channel
0622: .pcmf_getUnComponent()
0623: .pcmf_setValue(
0624: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_CLICK]
0625: + ":"
0626: + (int) e.getPoint()
0627: .getX()
0628: + ","
0629: + (int) e.getPoint()
0630: .getY()
0631: + ":"
0632: + (int) l_root
0633: .getPoint()
0634: .getX()
0635: + ","
0636: + (int) l_root
0637: .getPoint()
0638: .getY());
0639: pem_channel.pcmf_getUnComponent()
0640: .pcmf_setRefresh();
0641: pem_channel.pcmf_getUnComponent()
0642: .pcmf_dispatchEvent();
0643:
0644: ((HoSwingPage) HoSwingComponent.this
0645: .pcmf_getAppl().pcmf_getActive())
0646: .pcmf_setSubmitValue(pem_channel
0647: .pcmf_getUnComponent()
0648: .pcmf_getObjName(), pem_channel
0649: .pcmf_getUnComponent()
0650: .pcmf_getValue().toString());
0651:
0652: KeTreeNode l_parent = pem_channel
0653: .pcmf_getUnComponent()
0654: .pcmf_getParentNode();
0655: if (l_parent != null
0656: && l_parent instanceof IUnSyncComponent)
0657: ((HoSwingPage) HoSwingComponent.this
0658: .pcmf_getAppl().pcmf_getActive())
0659: .pcmf_setSubmitValue(
0660: l_parent.pcmf_getObjName(),
0661: ((IUnSyncComponent) l_parent)
0662: .pcmf_getValueToSync()
0663: .toString());
0664:
0665: if (pem_channel.pcmf_getUnComponent()
0666: .pcmf_isSubmit())
0667: ((HoSwingPage) HoSwingComponent.this
0668: .pcmf_getAppl().pcmf_getActive())
0669: .pcmf_submit();
0670: } catch (Exception ex) {
0671: KeLog.pcmf_logException("ug2t", this , ex);
0672: }
0673: ;
0674: }
0675: };
0676: this .pcmf_getSwingWidget().addMouseListener(l_click);
0677: this .pem_channelListeners.put(xCh, l_click);
0678:
0679: break;
0680: }
0681:
0682: case IUnEventChannel.EVENT_POSITION: {
0683: ComponentListener l_cl = new ComponentAdapter() {
0684: IUnEventChannel pem_channel = xCh;
0685:
0686: public void componentShown(ComponentEvent e) {
0687: this .pemf_handle(e);
0688: }
0689:
0690: public void componentMoved(ComponentEvent e) {
0691: this .pemf_handle(e);
0692: }
0693:
0694: public void componentResized(ComponentEvent e) {
0695: this .pemf_handle(e);
0696: }
0697:
0698: private void pemf_handle(ComponentEvent e) {
0699: try {
0700: Point l_p = ((HoSwingClient) HoSwingComponent.this
0701: .pcmf_getAppl()).pcmf_getClientFrame()
0702: .getLocationOnScreen();
0703: Point l_p2 = HoSwingComponent.this
0704: .pcmf_getSwingWidget()
0705: .getLocationOnScreen();
0706:
0707: Rectangle l_rect = HoSwingComponent.this
0708: .pcmf_getSwingWidget().getBounds();
0709:
0710: pem_channel
0711: .pcmf_getUnComponent()
0712: .pcmf_setValue(
0713: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_POSITION]
0714: + ":"
0715: + (l_p2.x - l_p.x)
0716: + ","
0717: + (l_p2.y - l_p.y)
0718: + ":"
0719: + (int) l_rect
0720: .getWidth()
0721: + ","
0722: + (int) l_rect
0723: .getHeight());
0724: pem_channel.pcmf_getUnComponent()
0725: .pcmf_setRefresh();
0726: pem_channel.pcmf_getUnComponent()
0727: .pcmf_dispatchEvent();
0728:
0729: ((HoSwingPage) HoSwingComponent.this
0730: .pcmf_getAppl().pcmf_getActive())
0731: .pcmf_setSubmitValue(pem_channel
0732: .pcmf_getUnComponent()
0733: .pcmf_getObjName(), pem_channel
0734: .pcmf_getUnComponent()
0735: .pcmf_getValue().toString());
0736:
0737: KeTreeNode l_parent = pem_channel
0738: .pcmf_getUnComponent()
0739: .pcmf_getParentNode();
0740: if (l_parent != null
0741: && l_parent instanceof IUnSyncComponent)
0742: ((HoSwingPage) HoSwingComponent.this
0743: .pcmf_getAppl().pcmf_getActive())
0744: .pcmf_setSubmitValue(
0745: l_parent.pcmf_getObjName(),
0746: ((IUnSyncComponent) l_parent)
0747: .pcmf_getValueToSync()
0748: .toString());
0749:
0750: if (pem_channel.pcmf_getUnComponent()
0751: .pcmf_isSubmit())
0752: ((HoSwingPage) HoSwingComponent.this
0753: .pcmf_getAppl().pcmf_getActive())
0754: .pcmf_submit();
0755: } catch (Exception ex) {
0756: KeLog.pcmf_logException("ug2t", this , ex);
0757: }
0758: ;
0759: }
0760: };
0761: this .pcmf_getSwingWidget().addComponentListener(l_cl);
0762: this .pem_channelListeners.put(xCh, l_cl);
0763:
0764: break;
0765: }
0766:
0767: case IUnEventChannel.EVENT_RCLICK: {
0768: MouseAdapter l_click = new HoMouseAdapter() {
0769: IUnEventChannel pem_channel = xCh;
0770:
0771: public void mouseClicked(MouseEvent e) {
0772: try {
0773: if (e.getButton() == MouseEvent.BUTTON1)
0774: return;
0775:
0776: MouseEvent l_root = SwingUtilities
0777: .convertMouseEvent((Component) e
0778: .getSource(), e, null);
0779:
0780: pem_channel
0781: .pcmf_getUnComponent()
0782: .pcmf_setValue(
0783: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_RCLICK]
0784: + ":"
0785: + (int) e.getPoint()
0786: .getX()
0787: + ","
0788: + (int) e.getPoint()
0789: .getY()
0790: + ":"
0791: + (int) l_root
0792: .getPoint()
0793: .getX()
0794: + ","
0795: + (int) l_root
0796: .getPoint()
0797: .getY());
0798: pem_channel.pcmf_getUnComponent()
0799: .pcmf_setRefresh();
0800: pem_channel.pcmf_getUnComponent()
0801: .pcmf_dispatchEvent();
0802:
0803: ((HoSwingPage) HoSwingComponent.this
0804: .pcmf_getAppl().pcmf_getActive())
0805: .pcmf_setSubmitValue(pem_channel
0806: .pcmf_getUnComponent()
0807: .pcmf_getObjName(), pem_channel
0808: .pcmf_getUnComponent()
0809: .pcmf_getValue().toString());
0810:
0811: KeTreeNode l_parent = pem_channel
0812: .pcmf_getUnComponent()
0813: .pcmf_getParentNode();
0814: if (l_parent != null
0815: && l_parent instanceof IUnSyncComponent)
0816: ((HoSwingPage) HoSwingComponent.this
0817: .pcmf_getAppl().pcmf_getActive())
0818: .pcmf_setSubmitValue(
0819: l_parent.pcmf_getObjName(),
0820: ((IUnSyncComponent) l_parent)
0821: .pcmf_getValueToSync()
0822: .toString());
0823:
0824: if (pem_channel.pcmf_getUnComponent()
0825: .pcmf_isSubmit())
0826: ((HoSwingPage) HoSwingComponent.this
0827: .pcmf_getAppl().pcmf_getActive())
0828: .pcmf_submit();
0829: } catch (Exception ex) {
0830: KeLog.pcmf_logException("ug2t", this , ex);
0831: }
0832: ;
0833: }
0834: };
0835: this .pcmf_getSwingWidget().addMouseListener(l_click);
0836: this .pem_channelListeners.put(xCh, l_click);
0837:
0838: break;
0839: }
0840: case IUnEventChannel.EVENT_DBCLICK: {
0841: MouseAdapter l_click = new HoMouseAdapter() {
0842: IUnEventChannel pem_channel = xCh;
0843:
0844: public void mouseClicked(MouseEvent e) {
0845: if (e.getClickCount() != 2)
0846: return;
0847:
0848: try {
0849: MouseEvent l_root = SwingUtilities
0850: .convertMouseEvent((Component) e
0851: .getSource(), e, null);
0852:
0853: pem_channel
0854: .pcmf_getUnComponent()
0855: .pcmf_setValue(
0856: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_DBCLICK]
0857: + ":"
0858: + (int) e.getPoint()
0859: .getX()
0860: + ","
0861: + (int) e.getPoint()
0862: .getY()
0863: + ":"
0864: + (int) l_root
0865: .getPoint()
0866: .getX()
0867: + ","
0868: + (int) l_root
0869: .getPoint()
0870: .getY());
0871: pem_channel.pcmf_getUnComponent()
0872: .pcmf_setRefresh();
0873: pem_channel.pcmf_getUnComponent()
0874: .pcmf_dispatchEvent();
0875:
0876: ((HoSwingPage) HoSwingComponent.this
0877: .pcmf_getAppl().pcmf_getActive())
0878: .pcmf_setSubmitValue(pem_channel
0879: .pcmf_getUnComponent()
0880: .pcmf_getObjName(), pem_channel
0881: .pcmf_getUnComponent()
0882: .pcmf_getValue().toString());
0883:
0884: KeTreeNode l_parent = pem_channel
0885: .pcmf_getUnComponent()
0886: .pcmf_getParentNode();
0887: if (l_parent != null
0888: && l_parent instanceof IUnSyncComponent)
0889: ((HoSwingPage) HoSwingComponent.this
0890: .pcmf_getAppl().pcmf_getActive())
0891: .pcmf_setSubmitValue(
0892: l_parent.pcmf_getObjName(),
0893: ((IUnSyncComponent) l_parent)
0894: .pcmf_getValueToSync()
0895: .toString());
0896:
0897: if (pem_channel.pcmf_getUnComponent()
0898: .pcmf_isSubmit())
0899: ((HoSwingPage) HoSwingComponent.this
0900: .pcmf_getAppl().pcmf_getActive())
0901: .pcmf_submit();
0902: } catch (Exception ex) {
0903: KeLog.pcmf_logException("ug2t", this , ex);
0904: }
0905: ;
0906: }
0907: };
0908: this .pcmf_getSwingWidget().addMouseListener(l_click);
0909: this .pem_channelListeners.put(xCh, l_click);
0910:
0911: break;
0912: }
0913: case IUnEventChannel.EVENT_MOVE: {
0914: MouseMotionListener l_click = new MouseMotionListener() {
0915: IUnEventChannel pem_channel = xCh;
0916: private HoDelayedCall pem_call = null;
0917:
0918: public void mouseDragged(MouseEvent e) {
0919: }
0920:
0921: public void mouseMoved(MouseEvent e) {
0922: try {
0923: MouseEvent l_root = SwingUtilities
0924: .convertMouseEvent((Component) e
0925: .getSource(), e, null);
0926:
0927: pem_channel
0928: .pcmf_getUnComponent()
0929: .pcmf_setValue(
0930: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_MOVE]
0931: + ":"
0932: + (int) e.getPoint()
0933: .getX()
0934: + ","
0935: + (int) e.getPoint()
0936: .getY()
0937: + ":"
0938: + (int) l_root
0939: .getPoint()
0940: .getX()
0941: + ","
0942: + (int) l_root
0943: .getPoint()
0944: .getY());
0945: pem_channel.pcmf_getUnComponent()
0946: .pcmf_setRefresh();
0947: pem_channel.pcmf_getUnComponent()
0948: .pcmf_dispatchEvent();
0949:
0950: ((HoSwingPage) HoSwingComponent.this
0951: .pcmf_getAppl().pcmf_getActive())
0952: .pcmf_setSubmitValue(pem_channel
0953: .pcmf_getUnComponent()
0954: .pcmf_getObjName(), pem_channel
0955: .pcmf_getUnComponent()
0956: .pcmf_getValue().toString());
0957:
0958: KeTreeNode l_parent = pem_channel
0959: .pcmf_getUnComponent()
0960: .pcmf_getParentNode();
0961: if (l_parent != null
0962: && l_parent instanceof IUnSyncComponent)
0963: ((HoSwingPage) HoSwingComponent.this
0964: .pcmf_getAppl().pcmf_getActive())
0965: .pcmf_setSubmitValue(
0966: l_parent.pcmf_getObjName(),
0967: ((IUnSyncComponent) l_parent)
0968: .pcmf_getValueToSync()
0969: .toString());
0970:
0971: if (this .pem_call == null
0972: || this .pem_call.pcmf_isReady())
0973: this .pem_call = new HoDelayedCall(null,
0974: HoSwingComponent.this .pem_session,
0975: IUnComponent.EVENT_LATENCY_MOVE,
0976: pem_channel.pcmf_getUnComponent(),
0977: pem_channel.pcmf_getUnComponent()
0978: .pcmf_getValue().toString());
0979: else
0980: this .pem_call
0981: .pcmf_refreshCall(null, pem_channel
0982: .pcmf_getUnComponent()
0983: .pcmf_getValue().toString());
0984:
0985: } catch (Exception ex) {
0986: KeLog.pcmf_logException("ug2t", this , ex);
0987: }
0988: ;
0989: }
0990: };
0991: this .pcmf_getSwingWidget().addMouseMotionListener(l_click);
0992: this .pem_channelListeners.put(xCh, l_click);
0993:
0994: break;
0995: }
0996:
0997: case IUnEventChannel.EVENT_SELECT: {
0998: CaretListener l_pcl = new CaretListener() {
0999: IUnEventChannel pem_channel = xCh;
1000: private HoDelayedCall pem_call = null;
1001:
1002: public void caretUpdate(CaretEvent e) {
1003: try {
1004: pem_channel
1005: .pcmf_getUnComponent()
1006: .pcmf_setValue(
1007: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_SELECT]
1008: + ":"
1009: + ((JTextComponent) HoSwingComponent.this
1010: .pcmf_getSwingWidget())
1011: .getSelectionStart()
1012: + ","
1013: + (((JTextComponent) HoSwingComponent.this
1014: .pcmf_getSwingWidget())
1015: .getSelectionEnd() - ((JTextComponent) HoSwingComponent.this
1016: .pcmf_getSwingWidget())
1017: .getSelectionStart()));
1018: pem_channel.pcmf_getUnComponent()
1019: .pcmf_setRefresh();
1020: pem_channel.pcmf_getUnComponent()
1021: .pcmf_dispatchEvent();
1022:
1023: ((HoSwingPage) HoSwingComponent.this
1024: .pcmf_getAppl().pcmf_getActive())
1025: .pcmf_setSubmitValue(pem_channel
1026: .pcmf_getUnComponent()
1027: .pcmf_getObjName(), pem_channel
1028: .pcmf_getUnComponent()
1029: .pcmf_getValue().toString());
1030:
1031: KeTreeNode l_parent = pem_channel
1032: .pcmf_getUnComponent()
1033: .pcmf_getParentNode();
1034: if (l_parent != null
1035: && l_parent instanceof IUnSyncComponent)
1036: ((HoSwingPage) HoSwingComponent.this
1037: .pcmf_getAppl().pcmf_getActive())
1038: .pcmf_setSubmitValue(
1039: l_parent.pcmf_getObjName(),
1040: ((IUnSyncComponent) l_parent)
1041: .pcmf_getValueToSync()
1042: .toString());
1043:
1044: if (this .pem_call == null
1045: || this .pem_call.pcmf_isReady())
1046: this .pem_call = new HoDelayedCall(null,
1047: HoSwingComponent.this .pem_session,
1048: IUnComponent.EVENT_LATENCY_MOVE,
1049: pem_channel.pcmf_getUnComponent(),
1050: pem_channel.pcmf_getUnComponent()
1051: .pcmf_getValue().toString());
1052: else
1053: this .pem_call
1054: .pcmf_refreshCall(null, pem_channel
1055: .pcmf_getUnComponent()
1056: .pcmf_getValue().toString());
1057: } catch (Exception ex) {
1058: KeLog.pcmf_logException("ug2t", this , ex);
1059: }
1060: ;
1061: }
1062: };
1063: ((JTextComponent) this .pcmf_getSwingWidget())
1064: .addCaretListener(l_pcl);
1065: this .pem_channelListeners.put(xCh, l_pcl);
1066:
1067: break;
1068: }
1069: case IUnEventChannel.EVENT_GETF: {
1070: FocusAdapter l_click = new FocusAdapter() {
1071: IUnEventChannel pem_channel = xCh;
1072:
1073: public void focusGained(FocusEvent e) {
1074: try {
1075: pem_channel
1076: .pcmf_getUnComponent()
1077: .pcmf_setValue(
1078: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_GETF]);
1079: pem_channel.pcmf_getUnComponent()
1080: .pcmf_setRefresh();
1081: pem_channel.pcmf_getUnComponent()
1082: .pcmf_dispatchEvent();
1083:
1084: ((HoSwingPage) HoSwingComponent.this
1085: .pcmf_getAppl().pcmf_getActive())
1086: .pcmf_setSubmitValue(pem_channel
1087: .pcmf_getUnComponent()
1088: .pcmf_getObjName(), pem_channel
1089: .pcmf_getUnComponent()
1090: .pcmf_getValue().toString());
1091:
1092: KeTreeNode l_parent = pem_channel
1093: .pcmf_getUnComponent()
1094: .pcmf_getParentNode();
1095: if (l_parent != null
1096: && l_parent instanceof IUnSyncComponent)
1097: ((HoSwingPage) HoSwingComponent.this
1098: .pcmf_getAppl().pcmf_getActive())
1099: .pcmf_setSubmitValue(
1100: l_parent.pcmf_getObjName(),
1101: ((IUnSyncComponent) l_parent)
1102: .pcmf_getValueToSync()
1103: .toString());
1104:
1105: if (pem_channel.pcmf_getUnComponent()
1106: .pcmf_isSubmit())
1107: ((HoSwingPage) HoSwingComponent.this
1108: .pcmf_getAppl().pcmf_getActive())
1109: .pcmf_submit();
1110: } catch (Exception ex) {
1111: KeLog.pcmf_logException("ug2t", this , ex);
1112: }
1113: ;
1114: }
1115: };
1116: this .pcmf_getSwingWidget().addFocusListener(l_click);
1117: this .pem_channelListeners.put(xCh, l_click);
1118:
1119: break;
1120: }
1121: case IUnEventChannel.EVENT_MOUSELEAVE: {
1122: MouseAdapter l_click = new HoMouseAdapter() {
1123: IUnEventChannel pem_channel = xCh;
1124:
1125: public void mouseExited(MouseEvent e) {
1126: try {
1127: MouseEvent l_root = SwingUtilities
1128: .convertMouseEvent((Component) e
1129: .getSource(), e, null);
1130:
1131: pem_channel
1132: .pcmf_getUnComponent()
1133: .pcmf_setValue(
1134: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_MOUSELEAVE]
1135: + ":"
1136: + (int) e.getPoint()
1137: .getX()
1138: + ","
1139: + (int) e.getPoint()
1140: .getY()
1141: + ":"
1142: + (int) l_root
1143: .getPoint()
1144: .getX()
1145: + ","
1146: + (int) l_root
1147: .getPoint()
1148: .getY());
1149: pem_channel.pcmf_getUnComponent()
1150: .pcmf_setRefresh();
1151: pem_channel.pcmf_getUnComponent()
1152: .pcmf_dispatchEvent();
1153:
1154: ((HoSwingPage) HoSwingComponent.this
1155: .pcmf_getAppl().pcmf_getActive())
1156: .pcmf_setSubmitValue(pem_channel
1157: .pcmf_getUnComponent()
1158: .pcmf_getObjName(), pem_channel
1159: .pcmf_getUnComponent()
1160: .pcmf_getValue().toString());
1161:
1162: KeTreeNode l_parent = pem_channel
1163: .pcmf_getUnComponent()
1164: .pcmf_getParentNode();
1165: if (l_parent != null
1166: && l_parent instanceof IUnSyncComponent)
1167: ((HoSwingPage) HoSwingComponent.this
1168: .pcmf_getAppl().pcmf_getActive())
1169: .pcmf_setSubmitValue(
1170: l_parent.pcmf_getObjName(),
1171: ((IUnSyncComponent) l_parent)
1172: .pcmf_getValueToSync()
1173: .toString());
1174:
1175: if (pem_channel.pcmf_getUnComponent()
1176: .pcmf_isSubmit())
1177: ((HoSwingPage) HoSwingComponent.this
1178: .pcmf_getAppl().pcmf_getActive())
1179: .pcmf_submit();
1180: } catch (Exception ex) {
1181: KeLog.pcmf_logException("ug2t", this , ex);
1182: }
1183: ;
1184: }
1185: };
1186: this .pcmf_getSwingWidget().addMouseListener(l_click);
1187: this .pem_channelListeners.put(xCh, l_click);
1188:
1189: break;
1190: }
1191: case IUnEventChannel.EVENT_MOUSEENTER: {
1192: MouseAdapter l_click = new HoMouseAdapter() {
1193: IUnEventChannel pem_channel = xCh;
1194:
1195: public void mouseEntered(MouseEvent e) {
1196: try {
1197: MouseEvent l_root = SwingUtilities
1198: .convertMouseEvent((Component) e
1199: .getSource(), e, null);
1200:
1201: pem_channel
1202: .pcmf_getUnComponent()
1203: .pcmf_setValue(
1204: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_MOUSEENTER]
1205: + ":"
1206: + (int) e.getPoint()
1207: .getX()
1208: + ","
1209: + (int) e.getPoint()
1210: .getY()
1211: + ":"
1212: + (int) l_root
1213: .getPoint()
1214: .getX()
1215: + ","
1216: + (int) l_root
1217: .getPoint()
1218: .getY());
1219: pem_channel.pcmf_getUnComponent()
1220: .pcmf_setRefresh();
1221: pem_channel.pcmf_getUnComponent()
1222: .pcmf_dispatchEvent();
1223:
1224: ((HoSwingPage) HoSwingComponent.this
1225: .pcmf_getAppl().pcmf_getActive())
1226: .pcmf_setSubmitValue(pem_channel
1227: .pcmf_getUnComponent()
1228: .pcmf_getObjName(), pem_channel
1229: .pcmf_getUnComponent()
1230: .pcmf_getValue().toString());
1231:
1232: KeTreeNode l_parent = pem_channel
1233: .pcmf_getUnComponent()
1234: .pcmf_getParentNode();
1235: if (l_parent != null
1236: && l_parent instanceof IUnSyncComponent)
1237: ((HoSwingPage) HoSwingComponent.this
1238: .pcmf_getAppl().pcmf_getActive())
1239: .pcmf_setSubmitValue(
1240: l_parent.pcmf_getObjName(),
1241: ((IUnSyncComponent) l_parent)
1242: .pcmf_getValueToSync()
1243: .toString());
1244:
1245: if (pem_channel.pcmf_getUnComponent()
1246: .pcmf_isSubmit())
1247: ((HoSwingPage) HoSwingComponent.this
1248: .pcmf_getAppl().pcmf_getActive())
1249: .pcmf_submit();
1250: } catch (Exception ex) {
1251: KeLog.pcmf_logException("ug2t", this , ex);
1252: }
1253: ;
1254: }
1255: };
1256: this .pcmf_getSwingWidget().addMouseListener(l_click);
1257: this .pem_channelListeners.put(xCh, l_click);
1258:
1259: break;
1260: }
1261: case IUnEventChannel.EVENT_LOSTF: {
1262: FocusAdapter l_click = new FocusAdapter() {
1263: IUnEventChannel pem_channel = xCh;
1264:
1265: public void focusLost(FocusEvent e) {
1266: try {
1267: pem_channel
1268: .pcmf_getUnComponent()
1269: .pcmf_setValue(
1270: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_LOSTF]);
1271: pem_channel.pcmf_getUnComponent()
1272: .pcmf_setRefresh();
1273: pem_channel.pcmf_getUnComponent()
1274: .pcmf_dispatchEvent();
1275:
1276: ((HoSwingPage) HoSwingComponent.this
1277: .pcmf_getAppl().pcmf_getActive())
1278: .pcmf_setSubmitValue(pem_channel
1279: .pcmf_getUnComponent()
1280: .pcmf_getObjName(), pem_channel
1281: .pcmf_getUnComponent()
1282: .pcmf_getValue().toString());
1283:
1284: KeTreeNode l_parent = pem_channel
1285: .pcmf_getUnComponent()
1286: .pcmf_getParentNode();
1287: if (l_parent != null
1288: && l_parent instanceof IUnSyncComponent)
1289: ((HoSwingPage) HoSwingComponent.this
1290: .pcmf_getAppl().pcmf_getActive())
1291: .pcmf_setSubmitValue(
1292: l_parent.pcmf_getObjName(),
1293: ((IUnSyncComponent) l_parent)
1294: .pcmf_getValueToSync()
1295: .toString());
1296:
1297: if (pem_channel.pcmf_getUnComponent()
1298: .pcmf_isSubmit())
1299: ((HoSwingPage) HoSwingComponent.this
1300: .pcmf_getAppl().pcmf_getActive())
1301: .pcmf_submit();
1302: } catch (Exception ex) {
1303: KeLog.pcmf_logException("ug2t", this , ex);
1304: }
1305: ;
1306: }
1307: };
1308: this .pcmf_getSwingWidget().addFocusListener(l_click);
1309: this .pem_channelListeners.put(xCh, l_click);
1310:
1311: break;
1312: }
1313: case IUnEventChannel.EVENT_KEYACTION: {
1314: ((HoSwingClient) this .pcmf_getAppl())
1315: .pcmf_addKeyChannel(this );
1316:
1317: KeyAdapter l_kl = new KeyAdapter() {
1318: IUnEventChannel pem_channel = xCh;
1319: long pem_last = 0;
1320:
1321: public void keyReleased(KeyEvent e) {
1322: try {
1323: if (((HoSwingClient) HoSwingComponent.this
1324: .pcmf_getAppl()).pcmf_processKey(e) == false)
1325: return;
1326:
1327: if (e.getWhen() == this .pem_last)
1328: return;
1329:
1330: if (!(HoSwingComponent.this instanceof HoSwingContainer
1331: || HoSwingComponent.this instanceof HoSwingSplitPane || HoSwingComponent.this instanceof HoSwingTabbedPane)
1332: && HoSwingComponent.this
1333: .pcmf_getSwingWidget()
1334: .hasFocus() == false)
1335: return;
1336:
1337: // Eventuell kontrolle ob es möglich ist dass 2 Events den selben
1338: // Zeitstempel tragen
1339: // Dann kann es zu 'prellen' kommen
1340: // Debug
1341: // System.out.println(e.getWhen());
1342:
1343: this .pem_last = e.getWhen();
1344:
1345: int l_code = e.getKeyCode();
1346: if (l_code == KeyEvent.VK_CONTROL
1347: || l_code == KeyEvent.VK_ALT
1348: || l_code == KeyEvent.VK_ALT_GRAPH
1349: || l_code == KeyEvent.VK_SHIFT)
1350: return;
1351:
1352: Pattern l_pattern = null;
1353: l_pattern = Pattern.compile(xCh
1354: .pcmf_getKeyFilter());
1355:
1356: String l_key = "";
1357:
1358: if (e.isControlDown())
1359: l_key += "CTRL+";
1360: if (e.isAltDown())
1361: l_key += "ALT+";
1362: if (e.isAltGraphDown())
1363: l_key += "ALTGR+";
1364: if (e.isShiftDown())
1365: l_key += "SHIFT+";
1366:
1367: switch (l_code) {
1368: case KeyEvent.VK_F1:
1369: l_key += "F1";
1370: break;
1371: case KeyEvent.VK_F2:
1372: l_key += "F2";
1373: break;
1374: case KeyEvent.VK_F3:
1375: l_key += "F3";
1376: break;
1377: case KeyEvent.VK_F4:
1378: l_key += "F4";
1379: break;
1380: case KeyEvent.VK_F5:
1381: l_key += "F5";
1382: break;
1383: case KeyEvent.VK_F6:
1384: l_key += "F6";
1385: break;
1386: case KeyEvent.VK_F7:
1387: l_key += "F7";
1388: break;
1389: case KeyEvent.VK_F8:
1390: l_key += "F8";
1391: break;
1392: case KeyEvent.VK_F9:
1393: l_key += "F9";
1394: break;
1395: case KeyEvent.VK_F10:
1396: l_key += "F10";
1397: break;
1398: case KeyEvent.VK_F11:
1399: l_key += "F11";
1400: break;
1401: case KeyEvent.VK_F12:
1402: l_key += "F12";
1403: break;
1404: case KeyEvent.VK_ESCAPE:
1405: l_key += "ESC";
1406: break;
1407: case KeyEvent.VK_ENTER:
1408: l_key += "ENTER";
1409: break;
1410: case KeyEvent.VK_DOWN:
1411: l_key += "DOWN";
1412: break;
1413: case KeyEvent.VK_UP:
1414: l_key += "UP";
1415: break;
1416: case KeyEvent.VK_LEFT:
1417: l_key += "LEFT";
1418: break;
1419: case KeyEvent.VK_RIGHT:
1420: l_key += "RIGHT";
1421: break;
1422: case KeyEvent.VK_PAGE_DOWN:
1423: l_key += "PG_DOWN";
1424: break;
1425: case KeyEvent.VK_PAGE_UP:
1426: l_key += "PG_UP";
1427: break;
1428: case KeyEvent.VK_TAB:
1429: l_key += "TAB";
1430: break;
1431: case KeyEvent.VK_BACK_SPACE:
1432: l_key += "BACKSPC";
1433: break;
1434: case KeyEvent.VK_INSERT:
1435: l_key += "INSERT";
1436: break;
1437: case KeyEvent.VK_DELETE:
1438: l_key += "DELETE";
1439: break;
1440: case KeyEvent.VK_END:
1441: l_key += "END";
1442: break;
1443: case KeyEvent.VK_HOME:
1444: l_key += "POS1";
1445: break;
1446: default:
1447: l_key += String.valueOf(e.getKeyChar());
1448: }
1449:
1450: // Debug
1451: // System.out.println (l_key);
1452:
1453: if (l_pattern.matcher(l_key).matches()) {
1454: // Debug
1455: // System.out.println (l_key);
1456: pem_channel.pcmf_getUnComponent()
1457: .pcmf_setValue("KEY:" + l_key);
1458: pem_channel.pcmf_getUnComponent()
1459: .pcmf_setRefresh();
1460: pem_channel.pcmf_getUnComponent()
1461: .pcmf_dispatchEvent();
1462:
1463: ((HoSwingPage) HoSwingComponent.this
1464: .pcmf_getAppl().pcmf_getActive())
1465: .pcmf_setSubmitValue(
1466: pem_channel
1467: .pcmf_getUnComponent()
1468: .pcmf_getObjName(),
1469: pem_channel
1470: .pcmf_getUnComponent()
1471: .pcmf_getValue()
1472: .toString());
1473:
1474: KeTreeNode l_parent = pem_channel
1475: .pcmf_getUnComponent()
1476: .pcmf_getParentNode();
1477: if (l_parent != null
1478: && l_parent instanceof IUnSyncComponent)
1479: ((HoSwingPage) HoSwingComponent.this
1480: .pcmf_getAppl()
1481: .pcmf_getActive())
1482: .pcmf_setSubmitValue(
1483: l_parent
1484: .pcmf_getObjName(),
1485: ((IUnSyncComponent) l_parent)
1486: .pcmf_getValueToSync()
1487: .toString());
1488:
1489: if (pem_channel.pcmf_getUnComponent()
1490: .pcmf_isSubmit())
1491: ((HoSwingPage) HoSwingComponent.this
1492: .pcmf_getAppl()
1493: .pcmf_getActive())
1494: .pcmf_submit();
1495: }
1496: } catch (Exception ex) {
1497: KeLog.pcmf_logException("ug2t", this , ex);
1498: }
1499: ;
1500: }
1501: };
1502: this .pcmf_getSwingWidget().addKeyListener(l_kl);
1503: this .pem_channelListeners.put(xCh, l_kl);
1504:
1505: break;
1506: }
1507: case IUnEventChannel.EVENT_DRAG: {
1508: try {
1509: if (HoSwingComponent.this .pdm_dndDrag == null) {
1510: HoSwingComponent.this .pdm_dndDrag = new SwingDndSupportDrag(
1511: HoSwingComponent.this , xCh);
1512: this .pem_channelListeners.put(xCh,
1513: HoSwingComponent.this .pdm_dndDrag);
1514: }
1515: } catch (Exception ex) {
1516: KeLog.pcmf_logException("ug2t", this , ex);
1517: }
1518: ;
1519:
1520: break;
1521: }
1522: case IUnEventChannel.EVENT_DROP: {
1523: try {
1524: if (HoSwingComponent.this .pdm_dndDrop == null) {
1525: HoSwingComponent.this .pdm_dndDrop = new SwingDndSupportDrop(
1526: HoSwingComponent.this , xCh);
1527: this .pem_channelListeners.put(xCh,
1528: HoSwingComponent.this .pdm_dndDrop);
1529: }
1530: ;
1531: } catch (Exception ex) {
1532: KeLog.pcmf_logException("ug2t", this , ex);
1533: }
1534: ;
1535:
1536: break;
1537: }
1538: }
1539: }
1540:
1541: public void pcmf_setFont(UnFontDescriptor xFont) {
1542: Font l_font = Font.getFont(xFont.pcmf_getFontFullSpec(),
1543: new Font(null, xFont.pcmf_getFontStyle(), xFont
1544: .pcmf_getFontSize()));
1545: this .pcmf_getSwingWidget().setFont(l_font);
1546: super .pcmf_setFont(xFont);
1547:
1548: return;
1549: }
1550:
1551: /**
1552: * <p>
1553: * Requests focus for this widget
1554: * </p>
1555: * <p>
1556: *
1557: */
1558: public void pcmf_requestFocus() {
1559: this .pcmf_getSwingWidget().requestFocusInWindow();
1560: return;
1561: }
1562:
1563: public void pcmf_setBorder(int xBorder, String xColor, int xWidth) {
1564: switch (xBorder) {
1565: case IUnComponent.INSETS_BORDER:
1566: ((JComponent) this .pcmf_getRealSwingObj())
1567: .setBorder(new BevelBorder(BevelBorder.LOWERED,
1568: HoSwingComponent.pcmf_createColor(xColor),
1569: HoSwingComponent.pcmf_createColor(xColor)
1570: .darker().darker()));
1571: break;
1572: case IUnComponent.OUTSETS_BORDER:
1573: ((JComponent) this .pcmf_getRealSwingObj())
1574: .setBorder(new BevelBorder(BevelBorder.RAISED,
1575: HoSwingComponent.pcmf_createColor(xColor),
1576: HoSwingComponent.pcmf_createColor(xColor)
1577: .darker().darker()));
1578: break;
1579: case IUnComponent.LINE_BORDER:
1580: ((JComponent) this .pcmf_getRealSwingObj())
1581: .setBorder(new LineBorder(HoSwingComponent
1582: .pcmf_createColor(xColor), xWidth));
1583: break;
1584: default:
1585: ((JComponent) this .pcmf_getSwingWidget()).setBorder(null);
1586: break;
1587: }
1588: }
1589:
1590: public void pcmf_setFixedSize(int w, int h, int type) {
1591: super .pcmf_setFixedSize(w, h, type);
1592:
1593: if (h == -1) {
1594: if (((JComponent) this .pcmf_getRealSwingObj()).isShowing())
1595: h = (int) ((JComponent) this .pcmf_getRealSwingObj())
1596: .getPreferredSize().getHeight();
1597: else {
1598: h = 1;
1599: type = UnFixedSize.MIN_SIZE;
1600: }
1601: }
1602: if (w == -1) {
1603: if (((JComponent) this .pcmf_getRealSwingObj()).isShowing())
1604: w = (int) ((JComponent) this .pcmf_getRealSwingObj())
1605: .getPreferredSize().getWidth();
1606: else {
1607: w = 1;
1608: type = UnFixedSize.MIN_SIZE;
1609: }
1610: }
1611:
1612: Dimension l_dim = new Dimension(w, h);
1613:
1614: if ((type & UnFixedSize.MIN_SIZE) == UnFixedSize.MIN_SIZE)
1615: ((JComponent) this .pcmf_getRealSwingObj())
1616: .setMinimumSize(l_dim);
1617: if ((type & UnFixedSize.PREF_SIZE) == UnFixedSize.PREF_SIZE)
1618: ((JComponent) this .pcmf_getRealSwingObj())
1619: .setPreferredSize(l_dim);
1620: if ((type & UnFixedSize.MAX_SIZE) == UnFixedSize.MAX_SIZE)
1621: ((JComponent) this .pcmf_getRealSwingObj())
1622: .setMaximumSize(l_dim);
1623: }
1624:
1625: public void pcmf_deleteFixedSize() {
1626: super .pcmf_deleteFixedSize();
1627:
1628: ((JComponent) this .pcmf_getRealSwingObj()).setMinimumSize(null);
1629: ((JComponent) this .pcmf_getRealSwingObj())
1630: .setPreferredSize(null);
1631: ((JComponent) this .pcmf_getRealSwingObj()).setMaximumSize(null);
1632: }
1633:
1634: public void pcmf_delete() throws Exception {
1635: if (this .pdm_deleted == true)
1636: return;
1637:
1638: ((HoSwingClient) this .pcmf_getAppl())
1639: .pcmf_removeKeyChannel(this );
1640:
1641: Component l_comp = this .pcmf_getRealSwingObj();
1642: if (l_comp != null) {
1643: Container l_p = l_comp.getParent();
1644: if (l_p != null)
1645: l_p.remove(l_comp);
1646: }
1647:
1648: super .pcmf_delete();
1649: }
1650:
1651: public void pcmf_clearAndRelease() {
1652: this .pcmf_getSwingWidget().removeAll();
1653: super .pcmf_clearAndRelease();
1654:
1655: return;
1656: }
1657:
1658: public void pcmf_clear() {
1659: this .pcmf_getSwingWidget().removeAll();
1660: super .pcmf_clear();
1661:
1662: return;
1663: }
1664:
1665: public void pcmf_addSyncedWidgets(HoSwingPage xPage,
1666: UnComponent xParent) {
1667: IUnSyncComponent l_node = null;
1668: String l_objName = null;
1669:
1670: Iterator l_it = xParent.pcmf_getSynced();
1671: if (l_it != null) {
1672: while (l_it.hasNext()) {
1673: l_node = (IUnSyncComponent) l_it.next();
1674: l_objName = ((KeRegisteredObject) l_node)
1675: .pcmf_getObjName();
1676: xPage.pcmf_setSubmitValue(l_objName, l_node
1677: .pcmf_getValueToSync().toString());
1678: }
1679: }
1680: }
1681:
1682: public void pcmf_hide() {
1683: Object l_obj = this .pcmf_getParentNode();
1684: if (l_obj instanceof HoSwingComponent
1685: && this .pcmf_isHidden() == false
1686: && !this .pcmf_getRenderIfHidden()) {
1687: if (l_obj instanceof HoSwingContainer)
1688: this .pem_myConstraints = ((HoSwingContainer) l_obj)
1689: .pcmf_getConstraints(this
1690: .pcmf_getRealSwingObj());
1691:
1692: ((HoSwingComponent) l_obj).pcmf_getSwingWidget().remove(
1693: this .pcmf_getRealSwingObj());
1694: }
1695:
1696: super .pcmf_hide();
1697: return;
1698: };
1699:
1700: public void pcmf_unhide() {
1701:
1702: Object l_obj = this .pcmf_getParentNode();
1703: if (l_obj instanceof HoSwingComponent && this .pcmf_isHidden()) {
1704: ((HoSwingComponent) l_obj).pcmf_getSwingWidget().add(
1705: this .pcmf_getRealSwingObj());
1706:
1707: if (l_obj instanceof HoSwingContainer)
1708: ((HoSwingContainer) l_obj)
1709: .pcmf_setConstraints(this
1710: .pcmf_getRealSwingObj(),
1711: this .pem_myConstraints);
1712: }
1713:
1714: super .pcmf_unhide();
1715: return;
1716: };
1717:
1718: public HoSwingComponent pcmf_getUg2tPeer(Component xComp) {
1719: Iterator l_it = this .pcmf_getSubIterator();
1720: while (l_it.hasNext()) {
1721: Object l_obj = l_it.next();
1722: if (l_obj instanceof HoSwingComponent) {
1723: if (xComp == ((HoSwingComponent) l_obj)
1724: .pcmf_getRealSwingObj())
1725: return ((HoSwingComponent) l_obj);
1726: }
1727: }
1728: return (null);
1729: }
1730:
1731: public void pcmf_setCssClass(String xClass) {
1732: return;
1733: }
1734:
1735: public String pcmf_getCssClass() {
1736: return ("STANDARD_SWING");
1737: }
1738:
1739: public void pcmf_setIterativeEventLatency(int xLatency) {
1740: this .pem_eventLatency = xLatency;
1741: }
1742:
1743: public int pcmf_getIterativeEventLatency() {
1744: return (this.pem_eventLatency);
1745: }
1746: }
|