@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction
sname
OutlineTreeAction
slabel
OutlineTreeAction
sdescriptors
xworker.lang.MetaDescriptor3
smany
true
seditCols
2
sinitialization
false
smodifier
public
sinheritDescription
false
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree
sname
InitOutlineTree
sdescriptors
xworker.lang.MetaDescriptor3/@thing
sextends
xworker.lang.actions.SelfAction
smany
true
seditCols
2
sinitialization
false
sgroup
xworker.ide.outline
smodifier
public
sinheritDescription
false
sdescription
<p>把一个事物的节点列表初始化到一颗树上。</p>
sth_createIndex
true
sth_registThing
child|xworker.lang.actions.Actions
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@actions
sname
actions
sdescriptors
xworker.lang.MetaDescriptor3/@actions
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@actions/@run
sname
run
sisSynchronized
false
sthrowException
true
suseOtherAction
false
svarScope
Local
sdisableGlobalContext
false
Scode
#$@text#$@
import ognl.Ognl;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Display;

//变量
def tree = Ognl.getValue(self.treeVar, actionContext);
def thing = Ognl.getValue(self.thingVar, actionContext);
if(tree == null){
    log.info("Can not init thing outline, tree is null, treeVar=" + self.treeVar);
}
if(thing == null){
    log.info("Can not init thing outline, thing is null, thingVar=" + self.thingVar);
}

//初始化
initChild(tree, thing);

def initChild(treeItem, dataObj){
    TreeItem item = new TreeItem(treeItem, SWT.NONE);
    item.setText(dataObj.metadata.label + " (" + dataObj.thingName + ")");
    item.setData(dataObj);
    initItemColor(item, dataObj);
    
    for(child in dataObj.childs){
        initChild(item, child);
    }
    
    //打开第一层和第二层的节点
    if(dataObj.getParent() == null || dataObj.getParent().getParent() == null){
        item.setExpanded(true);
    }
}

def initItemColor(treeItem, thing){
    def desc = thing.getDescriptor();
    if(desc != null){
         if(desc.nodeBold == "true"){
             def font = world.getData("__xworker_editor_outline_BoldFont__")
             if(font == null){
                 def fontData = new FontData();
                 fontData.setStyle(SWT.BOLD);
                 fontData.setHeight(treeItem.getFont().getFontData()[0].getHeight());
                 font = new Font(Display.getCurrent(), fontData);
                 world.setData("__xworker_editor_outline_BoldFont__", font);
             }
             treeItem.setFont(font);
         }
         if(desc.nodeColor != null){
              def color = null;
              switch(desc.nodeColor){
                  case "BLUE":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
                      break;
                  case "CYAN":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_CYAN);
                      break;
                  case "DARK_BLUE":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
                      break;
                  case "DARK_CYAN":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_CYAN);
                      break;
                  case "DARK_GRAY":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
                      break;
                  case "DARK_GREEN":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
                      break;
                  case "DARK_MAGENTA":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_MAGENTA);
                      break;
                  case "DARK_RED":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
                      break;
                  case "DARK_YELLOW":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW);
                      break;
                  case "GRAY":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
                      break;
                  case "GREEN":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
                      break;
                  case "MAGENTA":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_MAGENTA);
                      break;
                  case "RED":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
                      break;
                  case "YELLOW":
                      color = Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW);
                      break;
              }          
              
              if(color != null){
                  treeItem.setForeground(color);
              }   
         }
    }
}
#$@text#$@
sinitBreakPoint
false
ssuccessBreakPoint
false
sexceptionBreakPoint
false
seditBreakPoint
false
sinterpretationType
Action
sdescriptors
xworker.lang.actions.Actions/@GroovyAction
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@name
sname
name
sreadOnly
false
sinheritDescription
false
svalidateAllowBlank
true
LvalidateOnBlur
true
LallowDecimals
true
LallowNegative
true
sdescriptors
xworker.lang.MetaDescriptor3/@attribute
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@label
sname
label
sreadOnly
false
sinheritDescription
false
svalidateAllowBlank
true
LvalidateOnBlur
true
LallowDecimals
true
LallowNegative
true
sdescriptors
xworker.lang.MetaDescriptor3/@attribute
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@treeVar
sname
treeVar
sreadOnly
false
sdefault
tree
sinheritDescription
false
sdescription
<p>树的变量名。</p>
svalidateAllowBlank
true
LvalidateOnBlur
true
LallowDecimals
true
LallowNegative
true
sdescriptors
xworker.lang.MetaDescriptor3/@attribute
sth_createIndex
false
@xworker.swt.ide.worldexplorer.swt.actions.OutlineTreeAction/@InitOutlineTree/@thingVar
sname
thingVar
sreadOnly
false
sdefault
thing
sinheritDescription
false
sdescription
<p>事物的变量名。</p>
svalidateAllowBlank
true
LvalidateOnBlur
true
LallowDecimals
true
LallowNegative
true
sdescriptors
xworker.lang.MetaDescriptor3/@attribute
sth_createIndex
false
