// @@
// @@
/*
* Wi.Ser Framework
*
* LGPL Version: 1.8.1, 20-September-2007
* Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library located in LGPL.txt in the
* license directory; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* If this agreement does not cover your requirements, please contact us
* via email to get detailed information about the commercial license
* or our service offerings!
*
*/
// @@
package de.ug2t.channel.ho.server.generic;
import java.util.*;
import de.ug2t.channel.ho.*;
import de.ug2t.kernel.*;
import de.ug2t.unifiedGui.*;
import de.ug2t.unifiedGui.interfaces.*;
import de.ug2t.xmlScript.*;
public final class HoSrvGenericTreeView extends AHoSrvGenericComponent implements IUnTreeView
{
private KeTreeNode pem_root = null;
private boolean pem_multiSelection = false;
private HoGenericDataContainer pem_container = null;
private KeTreeNode pem_toggled = null;
private int pem_xScroll = 0;
private int pem_yScroll = 0;
private IKeExecutable pem_cHandler = null;
public HoSrvGenericTreeView(String xName, KeTreeNode xRoot, IUnApplication xAppl, String xClass) throws Exception
{
super(xName);
this.pcmf_setAppl(xAppl);
this.pcmf_setEventOnChange(true);
if (xRoot != null)
this.pem_root = xRoot;
else
this.pem_root = this;
if (xClass == null)
pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingTreeView";
else
pdm_clientClass = xClass;
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
// Deklaration
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addDecl(l_remCall, this.pcmf_getRemName(), this.pdm_clientClass, "global");
ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false", "java.lang.String");
if (xRoot != null)
ScXmlScript.pcmf_addDeclPar(l_remCall, xRoot.pcmf_getRemName(), "true", "de.ug2t.kernel.KeTreeNode");
else
ScXmlScript.pcmf_addDeclPar(l_remCall, "null", "true", "de.ug2t.kernel.KeTreeNode");
ScXmlScript.pcmf_addDeclPar(l_remCall, ((HoSrvGenericApplication) xAppl).pcmf_getRemName(), "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
this.pcmf_enableSubmit();
return;
};
public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception
{
AHoSrvGenericComponent l_obj = new HoSrvGenericTreeView(this.pcmf_getName(), this.pem_root, this.pcmf_getAppl(), this.pdm_clientClass);
if (this.pcmf_isSubmit() == false)
l_obj.pcmf_disableSubmit();
l_obj.pcmf_setGlobal(true);
this.pcmf_setGlobal(true);
l_obj.pcmf_setAutoEcho(this.pcmf_doAutoEcho());
l_obj.pcmf_setRefFrom(this);
this.pcmf_addRef(l_obj);
return (l_obj);
};
public void pcmf_echoValue(Object xValue)
{
Object l_obj = xValue;
if (xValue instanceof KeTreeElement == false && xValue instanceof HoGenericDataContainer == false)
{
String l_oc = xValue.toString().substring(0, 1);
xValue = KeRegisteredObject.pcmf_getObjByLongName(xValue.toString().substring(1));
if (l_oc.equals("O") && xValue instanceof KeTreeNode)
return;
else if (l_oc.equals("C") && xValue instanceof KeTreeNode)
return;
if (xValue == null)
xValue = l_obj;
if (xValue instanceof HoGenericDataContainer)
((HoGenericDataContainer) xValue).pcmf_echoValues();
}
else if (xValue instanceof HoGenericDataContainer)
((HoGenericDataContainer) xValue).pcmf_echoValues();
super.pcmf_echoValue(xValue);
}
public void pcmf_setValues(HoGenericDataContainer xValues)
{
this.pcmf_setValue(xValues);
}
public void pcmf_setValue(Object xObj)
{
if (xObj != null && (xObj instanceof KeTreeElement == false && xObj instanceof HoGenericDataContainer == false))
xObj = KeRegisteredObject.pcmf_getObjByLongName(xObj.toString());
super.pcmf_setValue(xObj);
return;
};
public void pcmf_setLocalValue(Object xValue)
{
Object l_obj = xValue;
if (xValue instanceof KeTreeElement == false && xValue instanceof HoGenericDataContainer == false)
{
String l_oc = xValue.toString().substring(0, 1);
xValue = KeRegisteredObject.pcmf_getObjByLongName(xValue.toString().substring(1));
if (l_oc.equals("O") && xValue instanceof KeTreeNode)
{
((KeTreeNode) xValue).pcmf_unhide();
this.pem_toggled = ((KeTreeNode) xValue);
return;
}
else if (l_oc.equals("C") && xValue instanceof KeTreeNode)
{
((KeTreeNode) xValue).pcmf_hide();
this.pem_toggled = ((KeTreeNode) xValue);
return;
}
this.pem_toggled = null;
if (xValue == null)
xValue = l_obj;
}
super.pcmf_setLocalValue(xValue);
return;
};
public KeTreeNode pcmf_setRoot(KeTreeNode xRoot)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_setRoot");
ScXmlScript.pcmf_addCallPar(l_remCall, xRoot.pcmf_getRemName(), "true", "de.ug2t.kernel.KeTreeNode");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
KeTreeNode l_node = this.pem_root;
this.pem_root = xRoot;
return (l_node);
};
public void pcmf_setEditable(boolean xEditable)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_setEditable");
ScXmlScript.pcmf_addCallPar(l_remCall, xEditable ? "true" : "false", "false", "boolean");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public boolean pcmf_setMultiSelection(boolean xMulti)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (xMulti == true && this.pem_container == null)
this.pem_container = new HoGenericDataContainer();
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_setMultiSelection");
if (xMulti == true)
ScXmlScript.pcmf_addCallPar(l_remCall, this.pem_container.pcmf_getRemName(), "true", "de.ug2t.channel.ho.HoGenericDataContainer");
else
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
boolean l_old = this.pem_multiSelection;
this.pem_multiSelection = xMulti;
return (l_old);
};
public boolean pcmf_isMultiSelection()
{
return (this.pem_multiSelection);
}
public KeTreeNode pcmf_getRoot()
{
return (this.pem_root);
};
public Object pcmf_getValue()
{
Object l_obj = super.pcmf_getValue();
if (l_obj instanceof HoGenericDataContainer)
{
ArrayList l_vect = ((HoGenericDataContainer) l_obj).pcmf_getValueArray();
if (l_vect.size() > 0)
return (l_vect.get(l_vect.size() - 1));
}
return (l_obj);
}
public HoGenericDataContainer pcmf_getValues()
{
Object l_obj = super.pcmf_getValue();
if (l_obj instanceof HoGenericDataContainer)
return (((HoGenericDataContainer) l_obj));
else
return (null);
}
public void finalize()
{
try
{
if (this.pem_container != null)
this.pem_container.pcmf_delete();
}
catch (Exception e)
{
KeLog.pcmf_logException("ug2t", this, e);
}
}
public void pcmf_disable()
{
Iterator l_it = this.pem_root.pcmf_getSubIterator();
while (l_it.hasNext())
((KeTreeElement) l_it.next()).pcmf_disable();
super.pcmf_disable();
};
public void pcmf_enable()
{
Iterator l_it = this.pem_root.pcmf_getSubIterator();
while (l_it.hasNext())
((KeTreeElement) l_it.next()).pcmf_enable();
super.pcmf_enable();
};
public void pcmf_scrollXRel(int xPx)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_scrollXRel");
ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPx), "false", "int");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public void pcmf_scrollXAbs(int xPx)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_scrollXAbs");
ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPx), "false", "int");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public void pcmf_scrollYRel(int xPy)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_scrollYRel");
ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPy), "false", "int");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public void pcmf_scrollYAbs(int xPy)
{
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_scrollYAbs");
ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPy), "false", "int");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public void pcmf_setCommitHandler(IKeExecutable xHandler)
{
this.pem_cHandler = xHandler;
}
public void pcmf_clearCommitHandler()
{
this.pem_cHandler = null;
}
public void pcmf_commitTree()
{
if (this.pem_cHandler != null)
this.pem_cHandler.pcmf_execObj(this);
KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
if (this.pdm_session.pcmf_isInTransaction())
{
ScXmlScript.pcmf_createPBody(l_remCall);
}
else
{
ScXmlScript.pcmf_createxScriptString(l_remCall, null);
ScXmlScript.pcmf_addProc(l_remCall, null);
};
ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_commitTree");
ScXmlScript.pcmf_endAll(l_remCall);
this.pdm_session.pcmf_call(l_remCall.toString(), this);
return;
}
public int pcmf_getXScroll()
{
return (this.pem_xScroll);
}
public int pcmf_getYScroll()
{
return (this.pem_yScroll);
}
public KeTreeNode pcmf_getToggled()
{
return (this.pem_toggled);
}
public void pcmf_setScrollInfo(int xX, int xY)
{
if (xX != this.pem_xScroll || xY != this.pem_yScroll)
{
this.pem_xScroll = xX;
this.pem_yScroll = xY;
Iterator l_it = this.pcmf_getSubIterator();
while (l_it.hasNext())
{
Object l_obj = l_it.next();
if (l_obj instanceof IUnEventChannel)
{
if (((IUnEventChannel) l_obj).pcmf_getType() == IUnEventChannel.EVENT_SCROLL)
{
IUnEventChannel l_ch = (IUnEventChannel) l_obj;
l_ch.pcmf_getUnComponent().pcmf_setValue(IUnEventChannel.EVENTs[IUnEventChannel.EVENT_SCROLL] + ":" + xX + "," + xY);
l_ch.pcmf_getUnComponent().pcmf_setRefresh();
if (l_ch.pcmf_isRefreshParent())
((UnComponent) l_ch.pcmf_getUnComponent().pcmf_getParentNode()).pcmf_setRefresh();
try
{
if (l_ch.pcmf_getUnComponent().pcmf_isSubmit())
l_ch.pcmf_getUnComponent().pcmf_dispatchEvent();
}
catch (Exception e)
{
KeLog.pcmf_logException("ug2t", this, e);
KeLog.pcmf_log("ug2t", "error dispatch scroll event", this, KeLog.ERROR);
}
}
break;
}
}
}
}
}
|