@xworker.doc.utils.CreateThingsMenu
sname
CreateThingsMenu
slabel
CreateThingsMenu
sid
CreateThingsMenu
sdescriptors
xworker.swt.widgets.Display
@xworker.doc.utils.CreateThingsMenu/@shell
sname
shell
stext
"创建事物列表菜单"
sNO_TRIM
false
sCLOSE
true
sTITLE
true
sMIN
true
sMAX
true
sBORDER
false
sRESIZE
false
sON_TOP
false
sTOOL
false
sNO_FOCUS
false
swidth
-1
sheight
-1
scenterScreen
true
spack
true
smaximized
false
sfullScreen
false
sH_SCROLL
false
sV_SCROLL
false
sNO_BACKGROUND
false
sNO_MERGE_PAINTS
false
sNO_REDRAW_RESIZE
false
sNO_RADIO_GROUP
false
sEMBEDDED
false
sDOUBLE_BUFFERED
false
scapture
false
senabled
true
sredraw
true
svisible
true
sid
shell
sdescriptors
xworker.swt.widgets.Display/@Shell
@xworker.doc.utils.CreateThingsMenu/@shell/@shellGridLayout
sname
shellGridLayout
snumColumns
2
smakeColumnsEqualWidth
false
smarginWidth
5
smarginHeight
5
smarginLeft
0
smarginTop
0
smarginRight
0
smarginBottom
0
shorizontalSpacing
5
sverticalSpacing
5
sid
shellGridLayout
slabel
shellGridLayout
sdescriptors
xworker.swt.Layouts/@GridLayout
@xworker.doc.utils.CreateThingsMenu/@shell/@menuObjLabel
sname
menuObjLabel
stext
"菜单事物路径："
stype
HORIZONTAL
sshadow
SHADOW_OUT
sBORDER
false
salignment
LEFT
scapture
false
senabled
true
sredraw
true
svisible
true
sid
menuObjLabel
slabel
menuObjLabel
sdescriptors
xworker.swt.Widgets/@Label
@xworker.doc.utils.CreateThingsMenu/@shell/@menuObjText
sname
menuObjText
sstyle
SINGLE
sH_SCROLL
false
sV_SCROLL
false
sWRAP
false
sREAD_ONLY
false
sPASSWORD
false
sSEARCH
false
sCANCEL
false
sBORDER
true
salign
LEFT
scapture
false
senabled
true
sredraw
true
svisible
true
sid
menuObjText
slabel
menuObjText
sdescriptors
xworker.swt.Widgets/@Text
@xworker.doc.utils.CreateThingsMenu/@shell/@menuObjText/@menuObjTextGridDat
sname
menuObjTextGridDat
shorizontalIndent
0
swidth
200
sheight
-1
shorizontalAlignment
BEGINNING
sverticalAlignment
CENTER
shorizontalSpan
1
sverticalSpan
1
sgrabExcessHorizontalSpace
false
sgrabExcessVerticalSpace
false
sid
menuObjTextGridDat
slabel
menuObjTextGridDat
sdescriptors
xworker.swt.layout.LayoutDatas/@GridData
@xworker.doc.utils.CreateThingsMenu/@shell/@thingsPathLabel
sname
thingsPathLabel
stext
"事物目录："
stype
HORIZONTAL
sshadow
SHADOW_OUT
sBORDER
false
salignment
LEFT
scapture
false
senabled
true
sredraw
true
svisible
true
sid
thingsPathLabel
slabel
thingsPathLabel
sdescriptors
xworker.swt.Widgets/@Label
@xworker.doc.utils.CreateThingsMenu/@shell/@thingsPathText
sname
thingsPathText
sstyle
SINGLE
sH_SCROLL
false
sV_SCROLL
false
sWRAP
false
sREAD_ONLY
false
sPASSWORD
false
sSEARCH
false
sCANCEL
false
sBORDER
true
salign
LEFT
scapture
false
senabled
true
sredraw
true
svisible
true
sid
thingsPathText
slabel
thingsPathText
sdescriptors
xworker.swt.Widgets/@Text
@xworker.doc.utils.CreateThingsMenu/@shell/@thingsPathText/@thingsPathTextGridData
sname
thingsPathTextGridData
shorizontalIndent
0
swidth
200
sheight
-1
shorizontalAlignment
BEGINNING
sverticalAlignment
CENTER
shorizontalSpan
1
sverticalSpan
1
sgrabExcessHorizontalSpace
false
sgrabExcessVerticalSpace
false
sid
thingsPathTextGridData
slabel
thingsPathTextGridData
sdescriptors
xworker.swt.layout.LayoutDatas/@GridData
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite
sname
buttonComposite
sBORDER
false
sH_SCROLL
false
sV_SCROLL
false
sNO_BACKGROUND
false
sNO_FOCUS
false
sNO_MERGE_PAINTS
false
sNO_REDRAW_RESIZE
false
sNO_RADIO_GROUP
false
sEMBEDDED
false
sDOUBLE_BUFFERED
false
scapture
false
senabled
true
sredraw
true
svisible
true
sid
buttonComposite
sdescriptors
xworker.swt.Widgets/@Composite
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@buttonCompostieGridData
sname
buttonCompostieGridData
shorizontalIndent
0
swidth
-1
sheight
-1
shorizontalAlignment
CENTER
sverticalAlignment
CENTER
shorizontalSpan
2
sverticalSpan
1
sgrabExcessHorizontalSpace
false
sgrabExcessVerticalSpace
false
sid
buttonCompostieGridData
slabel
buttonCompostieGridData
sdescriptors
xworker.swt.layout.LayoutDatas/@GridData
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@buttonCompositeRowLayout
sname
buttonCompositeRowLayout
sfill
false
sjustify
false
smarginWidth
0
smarginHeight
0
smarginLeft
3
smarginTop
3
smarginRight
3
smarginBottom
3
spack
true
sspacing
3
stype
SWT.HORIZONTAL
swrap
true
sid
buttonCompositeRowLayout
slabel
buttonCompositeRowLayout
sdescriptors
xworker.swt.Layouts/@RowLayout
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@okButton
sname
okButton
stext
"确定"
stype
SWT.PUSH
sflat
false
sborder
false
sselected
false
scapture
false
senabled
true
sredraw
true
svisible
true
sid
okButton
slabel
okButton
sdescriptors
xworker.swt.Widgets/@Button
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@okButton/@okButtonSelectionListener
sname
okButtonSelectionListener
sid
okButtonSelectionListener
slabel
okButtonSelectionListener
sdescriptors
xworker.swt.widgets.Button/@SelectionListener
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@okButton/@okButtonSelectionListener/@actions
sname
actions
sid
actions
slabel
actions
sdescriptors
xworker.swt.events.SelectionListener/@actions1
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@okButton/@okButtonSelectionListener/@actions/@widgetSelected
sname
widgetSelected
sisSynchronized
false
sthrowException
false
suseOtherAction
false
svarScope
Global
Scode
#$@text#$@
import org.xmeta.Category;
import org.xmeta.ThingManager;
import org.xmeta.Thing;

def menuObj = world.getThing(menuObjText.getText().trim());
def things = world.get(thingsPathText.getText().trim());

if(menuObj == null){
    println "Menu object is not found!";
    return null;
}

if(things == null){
    println "Things is null!";
    return null;
}

menuObj.getChilds().clear();
initChilds(things, menuObj);
menuObj.save();

def initChilds(things, menuObj){
    if(things instanceof ThingManager){
        def category = things.getCategory("");
        initChilds(category, menuObj);        
    }else if(things instanceof Category){        
        for(category  in things.getCategorys()){
            def cateNode = createCategory(category);
            menuObj.addChild(cateNode); 
                  
            initChilds(category, cateNode);
        }

        for(thing in things.getThings(false)){
            menuObj.addChild(createThing(thing));
        }
    }else if(things instanceof Thing){
        menuObj.addChild(createThing(things));
    }
}

def createThing(thing){
    Thing th = new Thing("xworker.lang.Menu/@menu");
    th.set("name", thing.metadata.getName());
    th.set("label", thing.metadata.getLabel());
    th.set("url", "do?sc=xworker.ide.worldexplorer.swt.http.ThingDoc/@view&thing=" + thing.metadata.path);

    return th;   
}

def createCategory(cat){
    Thing thing = new Thing("xworker.lang.Menu/@menu");
    thing.set("name", cat.getSimpleName());
    thing.set("label", cat.getSimpleName());
    thing.set("url", "empty.html");

    return thing;    
}
println "ok";
#$@text#$@
sid
widgetSelected
sdescriptors
xworker.lang.actions.Actions/@GroovyAction
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@cancelButton
sname
cancelButton
stext
"取消"
stype
SWT.PUSH
sflat
false
sborder
false
sselected
false
scapture
false
senabled
true
sredraw
true
svisible
true
sid
cancelButton
slabel
cancelButton
sdescriptors
xworker.swt.Widgets/@Button
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@cancelButton/@Listeners
sname
Listeners
sid
Listeners
slabel
Listeners
sdescriptors
xworker.swt.widgets.Widget/@Listeners
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@cancelButton/@Listeners/@cancelButtonSelection
sname
cancelButtonSelection
stype
Selection
sid
cancelButtonSelection
slabel
cancelButtonSelection
sdescriptors
xworker.swt.events.Listeners/@listeners/@Listener
@xworker.doc.utils.CreateThingsMenu/@shell/@buttonComposite/@cancelButton/@Listeners/@cancelButtonSelection/@GroovyAction
sname
GroovyAction
sisSynchronized
false
sthrowException
true
suseOtherAction
false
svarScope
Global
scode
shell.dispose();
sid
GroovyAction
sdescriptors
xworker.lang.actions.Actions/@GroovyAction
