Skip to Content
0
Former Member
Jun 01, 2008 at 03:15 PM

Problem with Network UI Element

48 Views

Hi,

I have a big problem with Network UI Element

I am planing organization chart

when I deploy the App

Somtimes I See The App with arrow (it's OK)

but somtimes I see the App without arrow (It's wrong)

i don't change nothing in the source and it's change

plz help meeeee

Regards

Yossi

This is the source

public void buildDOM( )

{

//@@begin buildDOM()

// File fileName = new File ("orgchart.xml");

wdThis.wdGetEmpUserIdInterface().getemp();

wdContext.currentContextElement().setPernrRet(wdContext.currentContextElement().getPernrRet());

Zhr_Rfc_Disp_Manger_Employees2_Input input = new co.i.bnhp.model.Zhr_Rfc_Disp_Manger_Employees2_Input();

wdContext.nodeZhr_Rfc_Disp_Manger_Employees2_Input().bind(input);

input.setP_Pernr("1511");

// input.setP_Pernr(wdContext.currentContextElement().getPernrRet());

try{

String xmlFile =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "
tmp
tipex.xml");

File file = new File(xmlFile);

/////////////////////////////

//Creating an empty XML Document

//We need a Document

input.execute();

DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = dbfac.newDocumentBuilder();

// DOMImplementation impl = docBuilder.getDOMImplementation();

Document doc = docBuilder.newDocument();

////////////////////////

//Creating the XML tree

Element SapJNETData = doc.createElement("SAPJNetData");

SapJNETData.setAttribute("version","1.0");

doc.appendChild(SapJNETData);

Element typeRepository = doc.createElement("TypeRepository");

typeRepository.setAttribute("id","orgchart");

typeRepository.setAttribute("version","1.0");

SapJNETData.appendChild(typeRepository);

Element color = doc.createElement("COLOR");

typeRepository.appendChild(color);

Element type1 = doc.createElement("type");

type1.setAttribute("name","OCBlue");

Element rgb1 = doc.createElement("rgb");

Text textRGB1 = doc.createTextNode("0,0,128");

color.appendChild(type1);

rgb1.appendChild(textRGB1);

type1.appendChild(rgb1);

Element type2 = doc.createElement("type");

type2.setAttribute("name","OCGray");

Element rgb2 = doc.createElement("rgb");

Text textRGB2 = doc.createTextNode("215,220,216");

color.appendChild(type2);

rgb2.appendChild(textRGB2);

type2.appendChild(rgb2);

Element type3 = doc.createElement("type");

type3.setAttribute("name","OCGrayer");

Element rgb3 = doc.createElement("rgb");

Text textRGB3 = doc.createTextNode("195,200,196");

color.appendChild(type3);

rgb3.appendChild(textRGB3);

type3.appendChild(rgb3);

Element type4 = doc.createElement("type");

type4.setAttribute("name","OCLighter");

Element rgb4 = doc.createElement("rgb");

Text textRGB4 = doc.createTextNode("235,240,236");

color.appendChild(type4);

rgb4.appendChild(textRGB4);

type4.appendChild(rgb4);

Element layout = doc.createElement("LAYOUT");

typeRepository.appendChild(layout);

Element typeLayout = doc.createElement("type");

typeLayout.setAttribute("name","OCLayout");

Element style = doc.createElement("style");

Text textStyle = doc.createTextNode("VERTICAL_FLOW");

layout.appendChild(typeLayout);

typeLayout.appendChild(style);

style.appendChild(textStyle);

Element label = doc.createElement("LABEL");

typeRepository.appendChild(label);

Element typeLabel1 = doc.createElement("type");

typeLabel1.setAttribute("name","OCLabelBase");

Element colorLabel = doc.createElement("color");

colorLabel.setAttribute("type","Black");

Element font1 = doc.createElement("font");

Element size1 = doc.createElement("size");

Text textSize1 = doc.createTextNode("12");

Element multiLine =doc.createElement("multiLine");

Text textMultiLine=doc.createTextNode("TRUE");

Element hAlign = doc.createElement("halign");

Text textHalign = doc.createTextNode("CENTER");

Element hAlignText = doc.createElement("halignText");

Text textHalignText = doc.createTextNode("CENTER");

Element border1 = doc.createElement("border");

Element insets1 = doc.createElement("insets");

insets1.setAttribute("top","3");

Element typeLabel2 = doc.createElement("type");

typeLabel2.setAttribute("name","OCLabelOrgUnit");

typeLabel2.setAttribute("inherits","OCLabelBase");

Element colorLabel2 = doc.createElement("color");

colorLabel2.setAttribute("type","OCBlue");

Element fillColorLabel2 = doc.createElement("fillColor");

fillColorLabel2.setAttribute("type","OCGrayer");

Element font2 = doc.createElement("font");

Element style2 = doc.createElement("style");

Text textStyle2 = doc.createTextNode("BOLD");

Element border2 = doc.createElement("border");

Element thickness = doc.createElement("thickness");

Text textThickness = doc.createTextNode("1");

Element Side = doc.createElement("sides");

Text textSide = doc.createTextNode("SOUTH");

Element typeLabel3 = doc.createElement("type");

typeLabel3.setAttribute("name","OCLabelNumber");

typeLabel3.setAttribute("inherits","OCLabelBase");

Element colorLabel3 = doc.createElement("color");

colorLabel3.setAttribute("type","OCBlue");

Element size3 = doc.createElement("size");

Text textSize3 = doc.createTextNode("40,0");

Element halign3 = doc.createElement("halign");

Text textHalign3 = doc.createTextNode("RIGHT");

Element multiLine3 = doc.createElement("multiline");

Text textMultiLine3 = doc.createTextNode("FALSE");

Element border3 = doc.createElement("border");

Element Thickness3 = doc.createElement("thickness");

Text textThickness3 = doc.createTextNode("1");

Element insets3 = doc.createElement("insets");

insets3.setAttribute("top","0");

Element Sides3 = doc.createElement("sides");

Text textSides3 = doc.createTextNode("NORTH,WEST");

Element typeLabel4 = doc.createElement("type");

typeLabel4.setAttribute("name","OCLabelChief");

typeLabel4.setAttribute("inherits","OCLabelBase");

Element font4 = doc.createElement("font");

Element style4 = doc.createElement("style");

Element border4 = doc.createElement("border");

Element insets4 = doc.createElement("insets");

insets4.setAttribute("top","6");

Element edgeT = doc.createElement("EDGE");

Element typeEdge= doc.createElement("type");

typeEdge.setAttribute("name","OCLink");

Element Shape = doc.createElement("shape");

Element ThickNess =doc.createElement("thickness");

Element targetDeco = doc.createElement("targetdeco");

targetDeco.setAttribute("shape","NONE");

Element nodeT = doc.createElement("NODE");

Element typeNode = doc.createElement("type");

typeNode.setAttribute("name","OCNodeBase");

Element shape = doc.createElement("shape");

shape.setAttribute("type","Box");

Element fillColor = doc.createElement("fillColor");

fillColor.setAttribute("type","OCGray");

Element borderNode = doc.createElement("border");

Element styleNode = doc.createElement("style");

Element plugs = doc.createElement("plugs");

plugs.setAttribute("min","0");

plugs.setAttribute("position","SOUTH");

plugs.setAttribute("positionMode","CENTRIC");

Element socket = doc.createElement("sockets");

socket.setAttribute("min","0");

socket.setAttribute("position","NORTH");

socket.setAttribute("positionMode","CENTRIC");

Element OCNode = doc.createElement("type");

OCNode.setAttribute("name","OCNode");

OCNode.setAttribute("inherits","OCNodeBase");

Element OCNodeShape = doc.createElement("shape");

Element OCNodeSize = doc.createElement("size");

OCNodeSize.setAttribute("pack","true");

Element OClayout = doc.createElement("layout");

OClayout.setAttribute("type","OCLayout");

Element OCNodeArrowUp = doc.createElement("type");

OCNodeArrowUp.setAttribute("name","OCNodeArrowUp");

OCNodeArrowUp.setAttribute("inherits","OCNodeBase");

Element OCNodeArrowShape = doc.createElement("shape");

Element OcNodeArrowSize = doc.createElement("size");

Element OcNodeArrowLabel = doc.createElement("label");

Element OcNodeArrowicon = doc.createElement("icon");

Element OcNodeArrowHalign = doc.createElement("halign");

Element OCNodeArrowDown = doc.createElement("type");

OCNodeArrowDown.setAttribute("name","OCNodeArrowDown");

OCNodeArrowDown.setAttribute("inherits","OCNodeArrowUp");

Element OCNodeArrowDownLabel = doc.createElement("label");

Element OcNodeArrowDownIcon = doc.createElement("icon");

Element NodeGraph = doc.createElement("Graph");

Element OCGraph = doc.createElement("type");

OCGraph.setAttribute("name","OCGraph");

Element direction = doc.createElement("direction");

Element components = doc.createElement("components");

Element OCGraphLayouts = doc.createElement("layouts");

Element types = doc.createElement("types");

Element OCGraphlayout = doc.createElement("layout");

OCGraphlayout.setAttribute("type","TREE");

Element property1 = doc.createElement("property");

property1.setAttribute("name","STYLE");

property1.setAttribute("value","VARIABLE_SIZE");

Element property2 = doc.createElement("property");

property2.setAttribute("name","OFFS_X");

property2.setAttribute("value","50");

Element property3 = doc.createElement("property");

property3.setAttribute("name","OFFS_Y");

property3.setAttribute("value","30");

Element Graph = doc.createElement("Graph");

Graph.setAttribute("type","OCGraph");

Graph.setAttribute("version","1.0");

Element layouts = doc.createElement("layouts");

layouts.setAttribute("onLoad","TREE");

Element view = doc.createElement("view");

Element grid = doc.createElement("grid");

Text TextGrid = doc.createTextNode("80,80");

Element UserInterface = doc.createElement("userInterface");

UserInterface.setAttribute("version","1.0");

Element mode = doc.createElement("mode");

label.appendChild(typeLabel1);

typeLabel1.appendChild(colorLabel);

typeLabel1.appendChild(font1);

font1.appendChild(size1);

size1.appendChild(textSize1);

typeLabel1.appendChild(multiLine);

multiLine.appendChild(textMultiLine);

typeLabel1.appendChild(hAlign);

hAlign.appendChild(textHalign);

typeLabel1.appendChild(hAlignText);

hAlignText.appendChild(textHalignText);

typeLabel1.appendChild(border1);

border1.appendChild(insets1);

label.appendChild(typeLabel2);

typeLabel2.appendChild(colorLabel2);

typeLabel2.appendChild(fillColorLabel2);

typeLabel2.appendChild(font2);

font2.appendChild(style2);

style2.appendChild(textStyle2);

typeLabel2.appendChild(border2);

border2.appendChild(thickness);

thickness.appendChild(textThickness);

border2.appendChild(Side);

Side.appendChild(textSide);

label.appendChild(typeLabel4);

typeLabel4.appendChild(font4);

font4.appendChild(style4);

style4.appendChild(doc.createTextNode("BOLD"));

typeLabel4.appendChild(border4);

border4.appendChild(insets4);

label.appendChild(typeLabel3);

typeLabel3.appendChild(colorLabel3);

typeLabel3.appendChild(size3);

size3.appendChild(textSize3);

typeLabel3.appendChild(halign3);

halign3.appendChild(textHalign3);

typeLabel3.appendChild(multiLine3);

multiLine3.appendChild(textMultiLine3);

typeLabel3.appendChild(border3);

border3.appendChild(Thickness3);

Thickness3.appendChild(textThickness3);

border3.appendChild(insets3);

insets3.setAttribute("top","0");

border3.appendChild(Sides3);

Sides3.appendChild(textSides3);

typeRepository.appendChild(edgeT);

edgeT.appendChild(typeEdge);

typeEdge.appendChild(Shape);

Shape.appendChild(doc.createTextNode("BENT"));

typeEdge.appendChild(ThickNess);

ThickNess.appendChild(doc.createTextNode("1"));

typeEdge.appendChild(targetDeco);

typeRepository.appendChild(nodeT);

nodeT.appendChild(typeNode);

typeNode.appendChild(shape);

shape.appendChild(fillColor);

shape.appendChild(borderNode);

borderNode.appendChild(styleNode);

styleNode.appendChild(doc.createTextNode("RAISED"));

typeNode.appendChild(plugs);

typeNode.appendChild(socket);

nodeT.appendChild(OCNode);

OCNode.appendChild(OCNodeShape);

OCNodeShape.appendChild(OCNodeSize);

OCNodeSize.appendChild(doc.createTextNode("150,0"));

OCNode.appendChild(OClayout);

nodeT.appendChild(OCNodeArrowUp);

OCNodeArrowUp.appendChild(OCNodeArrowShape);

OCNodeArrowShape.appendChild(OcNodeArrowSize);

OcNodeArrowSize.appendChild(doc.createTextNode("22,21"));

OCNodeArrowUp.appendChild(OcNodeArrowLabel);

OcNodeArrowLabel.appendChild(OcNodeArrowicon);

OcNodeArrowicon.appendChild(doc.createTextNode("apps/orgchart/arrow-up.gif"));

OcNodeArrowLabel.appendChild(OcNodeArrowHalign);

OcNodeArrowHalign.appendChild(doc.createTextNode("CENTER"));

nodeT.appendChild(OCNodeArrowDown);

OCNodeArrowDown.appendChild(OCNodeArrowDownLabel);

OCNodeArrowDownLabel.appendChild(OcNodeArrowDownIcon);

OcNodeArrowDownIcon.appendChild(doc.createTextNode("apps/orgchart/arrow-down.gif"));

typeRepository.appendChild(NodeGraph);

NodeGraph.appendChild(OCGraph);

OCGraph.appendChild(direction);

direction.appendChild(doc.createTextNode("TOP_BOTTOM"));

OCGraph.appendChild(components);

components.appendChild(doc.createTextNode("OCNode"));

OCGraph.appendChild(OCGraphLayouts);

OCGraphLayouts.appendChild(types);

types.appendChild(doc.createTextNode("TREE"));

OCGraphLayouts.appendChild(OCGraphlayout);

OCGraphlayout.appendChild(property1);

OCGraphlayout.appendChild(property2);

OCGraphlayout.appendChild(property3);

SapJNETData.appendChild(UserInterface);

UserInterface.appendChild(mode);

mode.appendChild(doc.createTextNode("READONLY"));

SapJNETData.appendChild(Graph);

Graph.appendChild(layouts);

Graph.appendChild(view);

view.appendChild(grid);

grid.appendChild(TextGrid);

for (int i=0; i<wdContext.nodeZhr_Rfc_Employees2().size(); i++) {

IPublicOrgTree.IEmpElement Emp = wdContext.nodeEmp().createEmpElement();

IPublicOrgTree.IZhr_Rfc_Employees2Element curEmp = wdContext.nodeZhr_Rfc_Employees2().getZhr_Rfc_Employees2ElementAt(i);

Element node = doc.createElement("node");

node.setAttribute("id",curEmp.getEmp_Pernr());

node.setAttribute("type","OCNode");

Element label1 = doc.createElement("label");

label1.setAttribute("type","OCLabelOrgUnit");

Text TextLabel1 = doc.createTextNode(curEmp.getEmp_Name());

Element label2 = doc.createElement("label");

label2.setAttribute("type","OCLabelChief");

Text TextLabel2 = doc.createTextNode(curEmp.getEmp_Pernr());

Graph.appendChild(node);

node.appendChild(label1);

label1.appendChild(TextLabel1);

node.appendChild(label2);

label2.appendChild(TextLabel2);

wdContext.nodeEmp().addElement(Emp);

}

for (int i=0; i<wdContext.nodeZhr_Rfc_Employees2().size()-1; i++) {

IPublicOrgTree.IEmpElement Emp = wdContext.nodeEmp().createEmpElement();

IPublicOrgTree.IZhr_Rfc_Employees2Element curEmp = wdContext.nodeZhr_Rfc_Employees2().getZhr_Rfc_Employees2ElementAt(i);

for (int j=i1; j<wdContext.nodeZhr_Rfc_Employees2().size(); j+)

if (wdContext.nodeZhr_Rfc_Employees2().getZhr_Rfc_Employees2ElementAt(i).getEmp_Pernr().equals(wdContext.nodeZhr_Rfc_Employees2().getZhr_Rfc_Employees2ElementAt(j).getEmp_Manager()))

{

Element edge = doc.createElement("edge");

edge.setAttribute("type","OCLink");

Element from = doc.createElement("from");

from.setAttribute("node",curEmp.getEmp_Pernr());

Element to = doc.createElement("to");

to.setAttribute("node",wdContext.nodeZhr_Rfc_Employees2().getZhr_Rfc_Employees2ElementAt(j).getEmp_Pernr());

Graph.appendChild(edge);

edge.appendChild(from);

edge.appendChild(to);

}

}

// typeLabel3.appendChild()

// Element font = doc.createElement("font");

// .appendChild(color);

// type1.appendChild(rgb1);

//create a comment and put it in the root element

// Comment comment = doc.createComment("Just a thought");

// type1.appendChild(comment);

//create child element, add an attribute, and add to root

// Element child = doc.createElement("child");

//child.setAttribute("name", "value");

//type.appendChild(child);

//add a text element to the child

/////////////////

//Output the XML

//set up a transformer

TransformerFactory transfac = TransformerFactory.newInstance();

Transformer trans = transfac.newTransformer();

trans.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-8");

// trans.setOutputProperty(OutputKeys.STANDALONE, "yes");

trans.setOutputProperty(OutputKeys.INDENT, "yes");

//create string from xml tree

// StringWriter sw = new StringWriter();

StreamResult result = new StreamResult(file);

DOMSource source = new DOMSource(doc);

trans.transform(source, result);

// wdContext.currentContextElement().setXmlString(sw.toString());

} catch (DOMException e) {

wdComponentAPI.getMessageManager().reportException("2-"+e.getMessage(),true);

} catch (TransformerConfigurationException e) {

wdComponentAPI.getMessageManager().reportException("3-"+e.getMessage(),true);

} catch (IllegalArgumentException e) {

wdComponentAPI.getMessageManager().reportException("4-"+e.getMessage(),true);

} catch (FactoryConfigurationError e) {

wdComponentAPI.getMessageManager().reportException("5-"+e.getMessage(),true);

} catch (ParserConfigurationException e) {

wdComponentAPI.getMessageManager().reportException("6-"+e.getMessage(),true);

} catch (TransformerFactoryConfigurationError e) {

wdComponentAPI.getMessageManager().reportException("7-"+e.getMessage(),true);

} catch (TransformerException e) {

wdComponentAPI.getMessageManager().reportException("8!-"+e.getMessage(),true);

}

catch (WDDynamicRFCExecuteException e) {

wdComponentAPI.getMessageManager().reportException("9!-"+e.getMessage(),true);

}

catch (WDAliasResolvingException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

// catch (IOException e) {

// wdComponentAPI.getMessageManager().reportException("10-"+e.getMessage(),true);

//

// }

// catch (SAXException e) {

// // TODO Auto-generated catch block

// e.printStackTrace();

// }

//@@end

}

public void supplySource(IPrivateOrgTree.ISourceNode node, IPrivateOrgTree.IContextElement parentElement)

{

//@@begin supplySource(IWDNode,IWDNodeElement)

IPublicOrgTree.ISourceElement element =node.createSourceElement();

node.addElement(element);

try{

String orgChart =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "//tmp//tipex.xml");

String demo =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "orgchart.xml");

FileInputStream is = new FileInputStream(demo);

element.setXml(WDResourceFactory.createResource(is, "",WDWebResourceType.XML, false));

}

// handle exceptions properly ifthis were not a demo app

catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

catch (WDAliasResolvingException e)

{

wdComponentAPI.getMessageManager().reportWarning("****");

}

catch (IOException e){}

//@@end

}