/*
 * Copyright (c) 2005-2006, Image Matters LLC. All Rights Reserved.
 * 
 * This software is distributed under the terms of the LICENSE file
 * included with the program and available here:
 * 
 * http://www.imagemattersllc.com/legal-notice/LICENSE-userSmartsGX.html
 */
namespace("userSmarts.ui");namespace("userSmarts.ui");$namespace.ActionBars=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(this,properties||{});this.toolbarManager=new userSmarts.wt.action.ToolbarManager();this.statusLineManager=new userSmarts.wt.action.StatusLineManager();this.layoutData={height:"*",width:"100%"};};$prototype.update=function(){this.toolbarManager.update();replaceChildNodes(this.getNode(),this.toolbarManager.getNode());};$prototype.getToolbarManager=function(){return this.toolbarManager;};$prototype.getStatusLineManager=function(){return this.statusLineManager;};userSmarts.ui.PlatformUI=Class.create();$class.createAndRunWorkbench=function(display,advisor){userSmarts.ui.PlatformUI.workbench=new userSmarts.ui.Workbench({display:display});var workbench=userSmarts.ui.PlatformUI.workbench;var wbConfigurer=new userSmarts.ui.application.WorkbenchConfigurer(workbench,advisor);advisor.initialize(wbConfigurer);advisor.preStartup();advisor.openWindows();advisor.postStartup();};$class.createDisplay=function(root){return new userSmarts.wt.widgets.Display(root);};$class.getWorkbench=function(){return userSmarts.ui.PlatformUI.workbench;};$class.isWorkbenchRunning=function(){return!!userSmarts.ui.PlatformUI.workbench;};userSmarts.ui.WorkbenchPlugin=Class.create();$prototype.initialize=function(superClass){if(userSmarts.ui.WorkbenchPlugin.inst){return userSmarts.ui.WorkbenchPlugin.inst;}
userSmarts.ui.WorkbenchPlugin.inst=this;this.viewRegistry=new userSmarts.ui.ViewRegistry();this.editorRegistry=new userSmarts.ui.EditorRegistry();this.perspectiveRegistry=new userSmarts.ui.PerspectiveRegistry();this.themeManager=new userSmarts.ui.ThemeManager();};$class.inst=null;$class.getDefault=function(){if(!userSmarts.ui.WorkbenchPlugin.inst){userSmarts.ui.WorkbenchPlugin.inst=new userSmarts.ui.WorkbenchPlugin();}
return userSmarts.ui.WorkbenchPlugin.inst;};$class.find=function(path){return userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-ui-plugin',path);};$prototype.getPerspectiveRegistry=function(){return this.perspectiveRegistry;};$prototype.getViewRegistry=function(){return this.viewRegistry;};$prototype.getEditorRegistry=function(){return this.editorRegistry;};$prototype.getThemeManager=function(){return this.themeManager;};$prototype.start=function(){};$prototype.stop=function(){};userSmarts.ui.WorkbenchSite=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);this.actionBars=new userSmarts.ui.ActionBars();};$prototype.getPage=function(){return this.page;};$prototype.getWorkbenchWindow=function(){return this.window;};namespace("userSmarts.ui");$namespace.WorkbenchPart=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);setdefault(this,{title:"",cacheable:true});};$prototype.dispose=function(){};$prototype.getSite=function(){return this.site;};$prototype.getTitle=function(){return this.label;};$prototype.createPartControl=function(parent){return new userSmarts.wt.widgets.Control();};$prototype.toString=function(){return"[Part: id = '"+this.id+"', label = '"+this.label+"']";};$prototype.setFocus=function(){};$prototype.isVisible=function(){return this.site&&this.site.isPartVisible();};$prototype.isCloseable=function(){return this.closeable||false;};namespace("userSmarts.ui");$namespace.WorkbenchPartReference=Class.create();$prototype.initialize=function(superClass,page,partDescription){this.page=page;this.partDescription=partDescription;};$prototype.getPart=function(restore){};$prototype.getId=function(){return this.partDescription.getId();};$prototype.getPage=function(){return this.page;};$prototype.getTitle=function(){return this.partDescription.getLabel();};$prototype.getTitleImage=function(){return this.partDescription.icon;};$prototype.getPartName=function(){return this.partDescription.getLabel();};$prototype.isCloseable=function(){return this.partDescription.isCloseable();};$prototype.toString=function(){return"[WorkbenchPartReference "+this.partDescription.getId()+"]";};userSmarts.ui.WorkbenchPartSite=Class.create(userSmarts.ui.WorkbenchSite);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.getId=function(){return this.id;};$prototype.getPart=function(){return this.part;};$prototype.getPartReference=function(){return this.partReference;};$prototype.getPropertyProvider=function(){return this.propertyProvider;};$prototype.setPropertyProvider=function(provider){this.propertyProvider=provider;this.getPage().setPropertyProvider(this.part,provider);};$prototype.getActionBars=function(){return this.actionBars;};$prototype.getPartControl=function(){if(!this.partControl){this.partControl=this.part.createPartControl();}
return this.partControl;};$prototype.isPartVisible=function(){var result=this.getPage().isPartVisible(this.part);return result;};namespace("userSmarts.ui");$namespace.WorkbenchPartDescriptor=Class.create(userSmarts.runtime.ExtensionDescriptor);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{closeable:false});superClass.call(this,properties);};$prototype.isCloseable=function(){return(this.closeable===true)||"true"===this.closeable;};$prototype.setCloseable=function(value){this.closeable=value;};userSmarts.ui.ViewPart=Class.create(userSmarts.ui.WorkbenchPart);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.init=function(site){this.site=site;};$namespace.ViewReference=Class.create($namespace.WorkbenchPartReference);$prototype.initialize=function(superClass,page,viewDescription){superClass.call(this,page,viewDescription);};$prototype.getPart=function(restore){return this.getView(restore);};$prototype.getView=function(restore){if(!this.view&&restore){var view=this.view=this.partDescription.createView();var window=this.page.getWorkbenchWindow();var site=new userSmarts.ui.ViewSite({page:this.page,id:this.partDescription.id,window:window,part:view,partReference:this});try{this.view.init(site);}catch(e){logError("Error initializing view: "+view);}
signal(this.page,"partOpened",this);}
return this.view;};$prototype.toString=function(){return"[ViewReference "+this.partDescription.id+"]";};userSmarts.ui.ViewSite=Class.create(userSmarts.ui.WorkbenchPartSite);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};userSmarts.ui.ViewDescriptor=Class.create(userSmarts.ui.WorkbenchPartDescriptor);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{label:"",description:""});superClass.call(this,properties);};$prototype.createView=function(){var view;var Ctor=this["class"]||this.ctor;if(typeof Ctor=="string"){view=newInstance(Ctor,this);}else if(typeof Ctor=="function"){view=new Ctor(this);}
return view;};$getAllowMultiple=function(){return this.allowMultiple;};userSmarts.ui.ViewRegistry=Class.create();$prototype.initialize=function(superClass){this.views=[];this.viewMap={};};$prototype.findViewWithId=function(viewId){return this.viewMap[viewId];};$prototype.addView=function(view){var id=view.id;this.views.push(view);this.viewMap[id]=view;};$prototype.getViews=function(){return this.views;};userSmarts.ui.EditorInput=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.exists=function(){return this.exists;};$prototype.getName=function(){return this.name;};$prototype.getToolTipText=function(){return this.toolTipText;};$prototype.getImage=function(){return this.image;};$prototype.equals=function(other){return this.name=other.getName();};userSmarts.ui.BindingInput=Class.create(userSmarts.ui.EditorInput);$prototype.initialize=function(superClass,properties){userSmarts.ui.EditorInput.call(this,properties);};$prototype.getBinding=function(){return this.binding;};userSmarts.ui.EditorPart=Class.create(userSmarts.ui.WorkbenchPart);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{dirty:false,input:null,closeable:true});superClass.call(this,properties);};$prototype.getEditorInput=function(){return this.input;};$prototype.init=function(site,input){this.site=site;this.input=input;};$prototype.askSave=function(){if(userSmarts.wt.dialogs.MessageDialog.openConfirm("Confirm Save","Save changes before closing editor?")){this.doSave();}};$prototype.doSave=function(){alert("doSave not implemented");};$prototype.doCancel=function(){alert("doCancel not implemented");};$prototype.reset=function(){alert("reset not implemented.");};$prototype.isDirty=function(){return this.dirty;};$prototype.isSaveOnCloseNeeded=function(){return this.isDirty();};$prototype.getTitle=function(){return this.input.getTitle()||"";};$namespace.EditorProxyControl=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=properties||{};superClass.call(this,properties);};$prototype.getNode=function(){if(!this.node){this.node=DIV();}
if(this.editorArea){this.editorArea.setParent(this.parent);this.editorArea.setLayoutData(this.layoutData);replaceChildNodes(this.node,this.editorArea.getNode());}
return this.node;};$prototype.update=function(){this.getNode();if(this.editorArea){this.editorArea.setParent(this.parent);this.editorArea.setLayoutData(this.layoutData);this.editorArea.update();}};$prototype.setSize=function(width,height){if(this.editorArea){this.editorArea.setSize(width,height);}};$prototype.setLocation=function(left,top){if(this.editorArea){this.editorArea.setLocation(left,top);}};$prototype.setParent=function(parent){if(this.editorArea){this.editorArea.setParent(parent);}
this.parent=parent;};$prototype.getParent=function(){if(this.editorArea){return this.editorArea.getParent();}
return this.parent;};$prototype.dispose=function(){if(this.editorArea){this.editorArea.dispose();}};$prototype.isDisposed=function(){if(this.editorArea){return this.editorArea.isDisposed();}
return false;};$prototype.isVisible=function(){if(this.editorArea){return this.editorArea.isVisible();}
return false;};$prototype.getShell=function(){if(this.editorArea){this.editorArea.getShell();}
return this.getParent().getShell();};$prototype.getSize=function(){if(this.editorArea){return this.editorArea.getSize();}
return this.size;};$prototype.getLocation=function(){if(this.editorArea){return this.editorArea.getLocation();}
return{left:this.left,top:this.y};};$prototype.setBounds=function(left,top,width,height){if(this.editorArea){this.editorArea.setBounds(left,top,width,height);}};$prototype.getBounds=function(){if(this.editorArea){return this.editorArea.getBounds();}
return{x:this.left,y:this.top,width:this.size.width,height:this.size.height};};$prototype.setLayoutData=function(layoutData){if(this.editorArea){this.editorArea.setLayoutData(layoutData);}
this.layoutData=layoutData;};$prototype.getLayoutData=function(){if(this.editorArea){return this.editorArea.getLayoutData();}
return this.layoutData;};$prototype.setVisibility=function(visible){if(this.editorArea){this.editorArea.setVisibility(visible);}};namespace("userSmarts.ui");$namespace.EditorReference=Class.create($namespace.WorkbenchPartReference);$prototype.initialize=function(superClass,manager,input,editorDescription,page){superClass.call(this,page,editorDescription);this.input=input;this.internalId=userSmarts.ui.EditorReference.nextId++;};$class.nextId=1;$prototype.getEditorInput=function(){return this.input;};$prototype.getFactoryId=function(){return this.factoryId;};$prototype.isDirty=function(){return this.getPart().isDirty();};$prototype.getPart=function(restore){return this.getEditor(restore);};$prototype.getEditor=function(restore){if(!this.editor&&restore){try{this.editor=this.partDescription.createEditor();var site=new userSmarts.ui.EditorSite({page:this.page,id:this.partDescription.id,window:this.page.getWorkbenchWindow(),part:this.editor,partReference:this});this.editor.init(site,this.input);}catch(e){logError("Error realizing editor: "+e);}}
return this.editor;};$prototype.isPinned=function(){return false;};$prototype.getName=function(){return this.getEditorInput().getName();};$prototype.getTitle=function(){return this.getEditorInput().getName();};$prototype.toString=function(){return"[EditorReference ("+this.internalId+")]";};userSmarts.ui.EditorSite=Class.create(userSmarts.ui.WorkbenchPartSite);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};namespace("userSmarts.ui");$namespace.EditorDescriptor=Class.create($namespace.WorkbenchPartDescriptor);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{label:"",description:"",closeable:true});superClass.call(this,properties);};$prototype.createEditor=function(){var result;if(this["class"]){result=newInstance(this["class"],this);}
return result;};userSmarts.ui.EditorRegistry=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);this.editors=[];this.editorMap={};};$prototype.findEditor=function(editorId){var desc=this.editorMap[editorId];return desc;};$prototype.addEditor=function(editor){var id=editor.id;this.editors.push(editor);this.editorMap[id]=editor;};$namespace.MultiPageEditorPart=Class.create(userSmarts.ui.EditorPart);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{loadAll:false});superClass.call(this,properties);this.tabItems=[];this.pages=[];};$prototype.createPartControl=function(parent){if(!this.outer){this.outer=new userSmarts.wt.widgets.Composite({'class':'multi-editor',updateOnBoundsChange:true,layoutData:{width:'100%',height:'100%'}});this.outer.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));}
this.createPageContainer();if(this.pages.length==0){this.createPages();}
if(!this.tabControl){this.tabControl=new userSmarts.wt.widgets.Composite({parent:this.outer,"class":"btabs",layoutData:{width:"100%",height:'25px'}});this.tabControl.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal"}));}
this.outer.update();return this.outer;};$prototype.addPage=function(editor){editor.init(this.site,this.input);var container=this.getContainer();connect(editor,"dirty",this,this.onPageDirtyChange);editor.parent=this;if(container.getLayout().topControl==null){var control=editor.createPartControl();index=container.add(control);this.pages[index]=editor;this.addTabItem(new userSmarts.ui.MultiPageEditorTabItem({multiPageEditor:this,pageIndex:index}));this.setActivePage(index);}else{var control;if(this.loadAll){control=editor.createPartControl();}else{control=new userSmarts.ui.EditorPlaceHolder({editor:editor});}
index=container.add(control);this.pages[index]=editor;this.addTabItem(new userSmarts.ui.MultiPageEditorTabItem({multiPageEditor:this,pageIndex:index}));}};$prototype.createPageContainer=function(parent){if(!this.composite){this.composite=new userSmarts.wt.widgets.Composite({'class':'page-container',parent:this.outer,updateOnBoundsChange:true,layoutData:{width:"100%",height:'*'}});this.composite.setLayout(new userSmarts.wt.layout.StackLayout());}};$prototype.createPages=function(){};$prototype.dispose=function(){this.composite.dispose();};$prototype.getActiveEditor=function(){return null;};$prototype.getContainer=function(){return this.composite;};$prototype.getEditor=function(pageIndex){return this.pages[pageIndex];};$prototype.getControl=function(pageIndex){return this.getContainer().getChildren()[pageIndex];};$prototype.getPageCount=function(){return this.composite.getChildren().length;};$prototype.getPageImage=function(pageIndex){return null;};$prototype.getPageText=function(pageIndex){var editor=this.getEditor(pageIndex);if(editor){return editor.label;}
return"";};$prototype.hasPages=function(){return this.getPageCount()>0;};$prototype.pageChange=function(newPageIndex){var bars=this.getSite().getActionBars();var tbmgr=bars.getToolbarManager();tbmgr.removeAll();var editor=this.getEditor(newPageIndex);if(editor&&typeof(editor.contributeToActionBars)=="function"){editor.contributeToActionBars(tbmgr);}
tbmgr.update();};$prototype.removePage=function(pageIndex){this.pages.splice(pageIndex,1);this.composite.remove(this.getControl(pageIndex));this.removeTabItem(this.resolve(pageIndex));};$prototype.setActivePage=function(pageIndex){var control=this.getControl(pageIndex);if(control){if(control.isPlaceHolder){var ph=control;control=ph.getEditor().createPartControl();control.setVisibility(false);this.getContainer().replace(control,ph);delete ph.editor;}
this.composite.getLayout().topControl=control;this.composite.update();this.pageChange(pageIndex);}
this.setSelection(pageIndex);};$prototype.setFocus=function(){};$prototype.addTabItem=function(tabItem){this.tabItems.push(tabItem);this.tabControl.add(tabItem);if(!this.selected){this.setSelection(tabItem);}};$prototype.removeTabItem=function(tabItem){tabItem=this.resolve(tabItem);if(tabItem){this.tabItems.remove(tabItem);this.tabControl.remove(tabItem);this.setSelection(0);}
return tabItem;};$prototype.setSelection=function(tabItem){var previous=this.selected;tabItem=this.resolve(tabItem);if(previous!=tabItem){if(previous instanceof userSmarts.wt.widgets.TabItem){previous.setProperty("selected",false);}
if(tabItem instanceof Bean){tabItem.setProperty("selected",true);}
this.setProperty("selected",tabItem);this.updateTabs();}};$prototype.resolve=function(tabItem){if(typeof tabItem=="number"){tabItem=this.tabItems[tabItem];}else if(typeof tabItem=="string"){for(var i=0;i<this.tabItems.length;++i){if(this.tabItems[i].name==tabItem){tabItem=this.tabItems[i];break;}}}else if(!(tabItem instanceof userSmarts.wt.widgets.TabItem)){tabItem=null;}
return tabItem;};$prototype.updateTabs=function(){userSmarts.wt.widgets.Composite.prototype.update.apply(this.tabControl);};$prototype.onPageDirtyChange=function(event){if(!this.isDirty()){if(event.newValue==true){this.dirty=true;}}else{if(event.newValue==false){for(var i=0;i<this.pages.length;++i){if(this.pages[i].isDirty()){return;}}
this.dirty=false;}}};$namespace.EditorPlaceHolder=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{isPlaceHolder:true});superClass.call(this,properties);this.label=this.editor.label;this['class']=this.label;};$prototype.getEditor=function(){return this.editor;};$namespace.MultiPageEditorTabItem=Class.create(userSmarts.wt.widgets.TabItem);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:"80px",height:'18px'},border:{top:0,bottom:1,left:1,right:1},padding:{top:0,bottom:0,left:0,right:0},margin:{top:0,bottom:0,left:3,right:0}});superClass.call(this,properties);this.text=this.multiPageEditor.getPageText(this.pageIndex);if(!this.text){this.text="Page "+this.pageIndex;}};$prototype.onClick=function(){this.multiPageEditor.setActivePage(this.pageIndex);};$prototype.isCloseable=function(){return false;};$prototype.getEditor=function(){return this.editor;};userSmarts.ui.Perspective=Class.create();$prototype.initialize=function(superClass,properties){setallp(this,properties);this.factory=newInstance(this.description.factory||this.description["class"]);};$prototype.createInitialLayout=function(layout){this.factory.createInitialLayout(layout);};userSmarts.ui.PerspectiveDescriptor=Class.create();$prototype.initialize=function(superClass,properties){setallp(this,{label:"",description:""});setallp(this,properties);};$prototype.getId=function(){return this.id;};$prototype.getDescription=function(){return this.description;};$prototype.getLabel=function(){return this.name;};$prototype.getTitleImage=function(){return this.icon;};userSmarts.ui.PerspectiveRegistry=Class.create();$prototype.initialize=function(superClass){this.perspectives=[];this.perspectiveMap={};};$prototype.findPerspectiveWithId=function(perspectiveId){return this.perspectiveMap[perspectiveId];};$prototype.addPerspective=function(perspective){var id=perspective.id;this.perspectives.push(perspective);this.perspectiveMap[id]=perspective;if(!this.defaultPerspective){this.defaultPerspective=id;}};$prototype.getPerspectives=function(){return this.perspectives;};$prototype.getDefaultPerspective=function(){return this.defaultPerspective||this.perspectives[0];};userSmarts.ui.Workbench=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$class.viewRegistry=new userSmarts.ui.ViewRegistry();$class.editorRegistry=new userSmarts.ui.EditorRegistry();$class.perspectiveRegistry=new userSmarts.ui.PerspectiveRegistry();$prototype.close=function(){};$prototype.getActiveWorkbenchWindow=function(){return this.activeWindow||null;};$prototype.showPerspective=function(perspectiveId,wbWindow){if(!perspectiveId){logError("showPerspective:  no perspective specified");return;}
var perspective=this.getPerspectiveRegistry().findPerspectiveWithId(perspectiveId);if(!perspective){logError("Unknown Perspective: "+perspectiveId);return;}
try{var page=wbWindow.getActivePage();page.setPerspective(perspective);page.doLayout();}catch(e){logError("Error (showPerspective) : "+e.message);}
return this;};$prototype.saveAllEditors=function(confirm){};$prototype.isClosing=function(){return this.isClosing;};$prototype.getPerspectiveRegistry=function(){return userSmarts.ui.WorkbenchPlugin.getDefault().getPerspectiveRegistry();};$prototype.getViewRegistry=function(){return userSmarts.ui.WorkbenchPlugin.getDefault().getViewRegistry();};$prototype.getEditorRegistry=function(){return userSmarts.ui.WorkbenchPlugin.getDefault().getEditorRegistry();};$prototype.getDisplay=function(){return this.display;};userSmarts.ui.WorkbenchWindow=Class.create(Bean);$prototype.initialize=function(superClass,workbench,shell){this.workbench=workbench;this.shell=shell;this.pageComposite=new userSmarts.wt.widgets.Composite();superClass.call(this);};$prototype.getWorkbench=function(){return this.workbench;};$prototype.setActivePage=function(page){this.activePage=page;};$prototype.getActivePage=function(){return this.activePage;};$prototype.close=function(){logWarning("WorkbenchWindow.close not implemented");};$prototype.getShell=function(){return this.shell;};$prototype.createPageComposite=function(parent){if(this.activePage){this.pageComposite=new userSmarts.wt.widgets.Composite({parent:parent,id:'pageControl'});this.pageComposite.setLayout(new userSmarts.wt.layout.StackLayout());}
return this.pageComposite;};$prototype.getPageComposite=function(){return this.pageComposite;};namespace("userSmarts.ui");userSmarts.ui.BoxLayout=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{orientation:userSmarts.ui.BoxLayout.HORIZONTAL,id:""});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:properties.orientation}));};$class.HORIZONTAL="horizontal";$class.VERTICAL="vertical";$prototype.toString=function(){return"[BoxLayout "+this.orientation+"]";};userSmarts.ui.EditorManager=Class.create();$prototype.initialize=function(superClass,window,page,editorPresentation){this.window=window;this.page=page;this.editors=[];};$prototype.containsEditor=function(editorRef){var editors=this.editors;for(var i=0;i<editors.length;++i){if(ref==editors[i]){return true;}}
return false;};$prototype.getEditorReferences=function(){return this.editors;};$prototype.getEditorCount=function(){return this.editors.length;};$prototype.findEditor=function(editorId,input,matchFlags){var refs=this.findEditors(input,editorId,matchFlags);if(refs.length===0){return null;}
return refs[0].getEditor(true);};$prototype.findEditors=function(input,editorId,matchFlags){var result=[];if(matchFlags==userSmarts.ui.WorkbenchPage.MATCH_NONE){return result;}
var editors=this.editors.slice(0);for(var i=0;i<editors.length;++i){var ref=editors[i];var refInput=ref.getEditorInput();if(matchFlags==userSmarts.ui.WorkbenchPage.MATCH_INPUT&&input.equals(refInput)){result.push(ref);}else if(matchFlags==userSmarts.ui.WorkbenchPage.MATCH_ID&&editorId==ref.getId()){result.push(ref);}}
return result;};$prototype.openEditor=function(editorId,input,setVisible){if(editorId===null||input===null){throw"IllegalArgumentException";}
var reg=this.getEditorRegistry();var desc=reg.findEditor(editorId);if(desc===null){throw"PartInitException: "+editorId;}
var result=this.openEditorFromDescriptor(desc,input);return result;};$prototype.openEditorFromDescriptor=function(desc,input){var result=null;result=new userSmarts.ui.EditorReference(this,input,desc,this.page);this.editors.push(result);return result;};$prototype.closeEditor=function(editor){var page=this.page;var result=false;for(var i=0;i<this.editors.length;++i){var e=this.editors[i];if(e==editor){this.editors.splice(i,1);result=true;break;}}
if(page.getReference(page.getActiveEditor())==editor){var newActiveEditor=null;if(this.editors.length>0){newActiveEditor=this.editors[0].getPart();}
this.page.setProperty("activeEditor",newActiveEditor);}
var layout=this.page.getPerspective().layout;if(layout){var editorArea=layout.getLayout(userSmarts.ui.PageLayout.ID_EDITOR_AREA);if(editorArea){editorArea.removePart(editor);}}
return result;};$prototype.getEditorRegistry=function(){return userSmarts.ui.WorkbenchPlugin.getDefault().getEditorRegistry();};userSmarts.ui.EditorTabItem=Class.create(userSmarts.wt.widgets.TabItem);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.getToolbar=function(){var partRef=this.control.partRef;var part=partRef.getPart(true);var site=part.getSite();var abs=site.getActionBars();return abs;};userSmarts.ui.EditorAreaLayout=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:"*",height:"*"},"class":"ui-folder-layout"});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.tabFolder=new userSmarts.wt.widgets.TabFolder({parent:this,layoutData:{width:"*",height:"*"}});this.editorTabMap={};};$prototype.activate=function(ref){var part=ref.getPart();this.page.activate(part);};$prototype.showEditor=function(part){var editorTab;if(typeof part=="string"){editorTab=this.editorTabMap[part];}else{editorTab=this.editorTabMap[part.id];}
if(editorTab){this.tabFolder.setSelection(editorTab);}};$prototype.toString=function(){return"[EditorAreaLayout id: "+this.id+"]";};userSmarts.ui.PartLayout=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{standalone:false,showTitle:true,closeable:false,moveable:false,width:'100%',height:'100%',valign:'top'});superClass.call(this,properties);};$prototype.getId=function(){return this.id;};$prototype.isStandalone=function(){return this.standalone;};$prototype.getShowTitle=function(){return this.showTitle;};$prototype.isCloseable=function(){return this.closeable;};$prototype.setCloseable=function(closeable){this.closeable=!!closeable;};$prototype.isMoveable=function(){return this.movable;};$prototype.setMoveable=function(moveable){this.movable=!!moveable;};$prototype.getNode=function(){try{var node=userSmarts.wt.widgets.Composite.prototype.getNode.call(this);return node;}catch(e){logError("Error creating view: "+e.message);}};$prototype.initNode=function(){};$prototype.update=function(){var content=null;try{content=this.getPartControl();}catch(e){logError("error creating part control: "+this.view+" error: "+e.message);content=DIV();}
if(content instanceof userSmarts.wt.widgets.Control){var location=content.getLocation();if(location&&this.size.width>0&&this.size.height>0){content.setBounds(location.left,location.top,this.size.width,this.size.height);}
try{var node=content.getNode();replaceChildNodes(this.node,node);}catch(e){replaceChildNodes(this.node,DIV(null,"Error rendering view"));}}else{replaceChildNodes(this.node,content);}};$prototype.getPartControl=function(){if(!this.partControl){var part=this.partRef.getPart(true);this.partControl=part.getSite().getPartControl();if(this.partControl instanceof userSmarts.wt.widgets.Control){this.partControl.parent=this;}}
return this.partControl;};namespace("userSmarts.ui");$namespace.ViewLayout=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{standalone:false,showTitle:true,closeable:false,moveable:false,width:'100%',height:'100%',valign:'top'});superClass.call(this,properties);};$prototype.getId=function(){return this.id;};$prototype.isStandalone=function(){return this.standalone;};$prototype.getShowTitle=function(){return this.showTitle;};$prototype.isCloseable=function(){return this.closeable;};$prototype.setCloseable=function(closeable){this.closeable=!!closeable;};$prototype.isMoveable=function(){return this.movable;};$prototype.setMoveable=function(moveable){this.movable=!!moveable;};$prototype.getNode=function(){try{var node=userSmarts.wt.widgets.Composite.prototype.getNode.call(this);return node;}catch(e){logError("Error creating view: "+e.message);}};$prototype.initNode=function(){};$prototype.update=function(){if(!this.view){this.view=this.page.findView(this.id,true);if(!this.view){logWarning("View not found: "+id);return;}}
var content=null;try{content=this.getPartControl();}catch(e){logError("error creating part control: "+this.view+" error: "+e.message);content=DIV();}
if(content instanceof userSmarts.wt.widgets.Control){var location=content.getLocation();if(location&&this.size.width>0&&this.size.height>0){content.setBounds(location.left,location.top,this.size.width,this.size.height);}
try{var node=content.getNode();replaceChildNodes(this.node,node);}catch(e){replaceChildNodes(this.node,DIV(null,"Error rendering view"));}}else{replaceChildNodes(this.node,content);}};$prototype.getPartControl=function(){if(!this.partControl){this.partControl=this.view.getSite().getPartControl();if(this.partControl instanceof userSmarts.wt.widgets.Control){this.partControl.parent=this;}}
return this.partControl;};namespace("userSmarts.ui");$namespace.ViewTabItem=Class.create(userSmarts.wt.widgets.TabItem);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.getToolbar=function(){var partRef=this.control.partRef;var part=partRef.getPart(true);var site=part.getSite();var abs=site.getActionBars();return abs;};$prototype.isCloseable=function(){return this.control.isCloseable();}
$namespace.EditorTabItem=Class.create($namespace.ViewTabItem);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.onClick=function(){var page=userSmarts.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();page.activate(this.control.partRef.getPart(false));};$prototype.close=function(){var part=this.control.partRef.getPart(true);if(part instanceof userSmarts.ui.EditorPart){if(part.isCloseable()){part.site.getPage().closeEditor(part,true);}}};$namespace.FolderLayout=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:"*",height:"*"},"class":"ui-folder-layout",border:{style:"solid",left:1,right:1,top:1,bottom:1},margin:{top:0,bottom:2,left:0,right:0}});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.tabFolder=new userSmarts.wt.widgets.TabFolder({parent:this,layoutData:{width:"*",height:"*"}});this.tabMap={};};$prototype.addView=function(viewId){try{var partRef=this.pageLayout.page.findViewReference(viewId,true);if(partRef){var viewLayout=new userSmarts.ui.PartLayout({parent:null,partRef:partRef,closeable:partRef.isCloseable(),page:this.pageLayout.page,folder:this});this.pageLayout.views[viewId]=viewLayout;var text=partRef.getTitle();var image=partRef.getTitleImage();var tab=new userSmarts.ui.ViewTabItem({parent:this.tabFolder,text:text,image:image,control:viewLayout});this.tabMap[partRef]=tab;}else{logError("ERROR adding view: "+viewId);}}catch(e){logError("ERROR adding view, viewId: "+viewId+", e:"+e.message);}};$prototype.addEditor=function(partRef){var partId=partRef.getId();try{var partLayout=new userSmarts.ui.PartLayout({parent:null,partRef:partRef,closeable:partRef.isCloseable(),id:partId,page:this.pageLayout.page,folder:this});this.pageLayout.views[partId]=partLayout;this.tabMap[partRef]=new userSmarts.ui.EditorTabItem({parent:this.tabFolder,text:partRef.getTitle(),image:partRef.getTitleImage(),closeable:partRef.isCloseable(),control:partLayout});}catch(e){logError("ERROR adding view, viewId: "+partId+", e:"+e.message);}};$prototype.showView=function(view){this.showPart(view);}
$prototype.showEditor=function(editorRef){if(!this.tabMap[editorRef]){this.addEditor(editorRef);}else{var input=editorRef.getEditorInput();}
this.showPart(editorRef);}
$prototype.showPart=function(part){var tab=this.findTab(part);if(tab){this.tabFolder.setSelection(tab);}}
$prototype.removePart=function(partRef){var tab=this.findTab(partRef);delete this.tabMap[partRef];tab=this.tabFolder.removeItem(tab);this.tabFolder.update();}
$prototype.findTab=function(partRef){var tab=null;if(typeof partRef=="string"){tab=this.tabMap[partRef];}else{tab=this.tabMap[partRef];}
return tab;}
$prototype.toString=function(){return"[FolderLayout id: "+this.id+"]";};userSmarts.ui.PageLayout=Class.create();$prototype.initialize=function(superClass,page){this.page=page;this.layouts={};this.views={};this.control=new userSmarts.ui.BoxLayout({id:userSmarts.ui.PageLayout.ID_ROOT_BOX,parent:page.getClientComposite(),label:userSmarts.ui.PageLayout.ID_ROOT_BOX,orientation:"horizontal",layoutData:{height:"100%",width:"100%"},margin:{left:2,right:0,top:0,bottom:0}});this.control.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal",spacing:2}));this.layouts[userSmarts.ui.PageLayout.ID_ROOT_BOX]=this.control;};$class.ID_EDITOR_AREA="EDITOR_AREA";$class.ID_ROOT_BOX="ROOT_BOX";$class.LEFT="left";$class.RIGHT="right";$class.TOP="top";$class.BOTTOM="bottom";$prototype.createBox=function(boxId,parentId,layoutData){var parent=this.layouts[parentId];var box=null;if(!parent){logWarning("Cannot create box without a valid parent.");}else{var orientation=layoutData.orientation;box=new userSmarts.ui.BoxLayout({parent:parent,layoutData:layoutData,id:boxId,orientation:orientation});box.label=boxId;this.layouts[boxId]=box;}
return box;};$prototype.createFolder=function(folderId,parentId,layoutData){var parent=this.layouts[parentId];if(!parent){logWarning("parent not found: "+referenceId);return;}
if(!(parent instanceof userSmarts.ui.BoxLayout)){logWarning("Error creating folder: "+folderId);return;}
var folder;if(folderId==userSmarts.ui.PageLayout.ID_EDITOR_AREA){if(!this.page.editorFolderInstance){folderProperties={id:folderId,pageLayout:this};folder=new userSmarts.ui.FolderLayout(folderProperties);this.page.editorFolderInstance=folder;}else{folder=this.page.editorFolderInstance;}
var editorProxy=new userSmarts.ui.EditorProxyControl({editorArea:folder,parent:parent,layoutData:layoutData});}else{folderProperties={id:folderId,parent:parent,pageLayout:this,layoutData:layoutData};folder=new userSmarts.ui.FolderLayout(folderProperties);}
this.layouts[folderId]=folder;return folder;};$prototype.getLayout=function(layoutId){return this.layouts[layoutId];};$prototype.getViewLayout=function(viewId){return this.views[viewId];};$prototype.addView=function(viewId,attributes,folderId){try{attributes=setdefault(attributes,{id:viewId,page:this.page,showTitle:false});var viewLayout=new userSmarts.ui.ViewLayout(attributes);var folder=this.layouts[folderId];folder.add(viewLayout);this.views[viewId]=viewLayout;}catch(e){logError("Error adding view ("+viewId+") :"+e.message);}};$prototype.getViews=function(){return this.views;};$prototype.addStandaloneView=function(viewId,attributes,parentId,showTitle){var box=this.layouts[parent];if(!box){logDebug("Error adding standalone view, parent not found: "+parentId);return;}
attributes=setdefault(attributes,{id:viewId,standalone:true,showTitle:showTitle,page:this.page});var viewLayout=new userSmarts.ui.ViewLayout(box,attributes);this.views[viewId]=viewLayout;};$prototype.getControl=function(){var control=this.control;return control;};userSmarts.ui.PropertyService=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);this.pcsMap={};this.defaultPcs=new PropertyChangeSupport();this.providerMap={};this.listenerMap={};};$prototype.init=function(window){};$prototype.onPropertyChange=function(part,event){this.firePropertyChange(part,event.propertyName,event.oldValue,event.newValue);};$prototype.setPropertyProvider=function(part,provider){var partId=part.getSite().getId();var oldProvider=this.providerMap[partId];var oldListener=this.listenerMap[partId];if(oldProvider){oldProvider.removeChangeListener(oldListener,"*");}
this.providerMap[partId]=provider;this.listenerMap[partId]=bind(this.onPropertyChange,this,part);provider.addChangeListener(this.listenerMap[partId],"*");};$prototype.addPropertyListener=function(listener,propertyName,partId){if(!propertyName||!listener){return;}
var pcs;if(!partId){pcs=this.defaultPcs;}else{pcs=this.pcsMap[partId];if(!pcs){pcs=this.pcsMap[partId]=new PropertyChangeSupport();}}
pcs.addListener(listener,propertyName);var provider=this.providerMap[partId];if(provider){var value=provider.getProperty(propertyName);var part=this.findView(partId);var event=new PropertyChangeEvent(provider,propertyName,value,value);try{listener(event);}catch(e){}}};$prototype.getProperty=function(propertyName,partId){var part;if(partId){part=this.findView(partId);}else{part=this.getActivePart();}
if(!part){return;}
var provider=part.getSite().getPropertyProvider();if(provider){return provider.getProperty(propertyName);}else{return null;}};$prototype.removePropertyListener=function(listener,propertyName,partId){if(!propertyName||!listener){return;}
var pcs;if(!partId){pcs=this.defaultPcs;}else{pcs=this.pcsMap[partId];}
if(pcs){pcs.removeListener(listener,propertyName);}};$prototype.firePropertyChange=function(part,propertyName,oldValue,newValue){if(!part){return;}
var pcs=this.pcsMap[part.getSite().getId()];if(pcs){pcs.firePropertyChange(part,propertyName,oldValue,newValue);}
this.defaultPcs.firePropertyChange(part,propertyName,oldValue,newValue);};$prototype.getActivePart=function(){return null;};userSmarts.ui.WorkbenchPage=Class.create(userSmarts.ui.PropertyService);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{views:{},visibleViews:[],editors:{},perspectives:{},document:document});superClass.call(this,properties);this.editors=[];userSmarts.runtime.Platform.getPropertyService().setController("page",this);};$class.ID_PAGE_TABLE="page";$class.MATCH_NONE=1;$class.MATCH_INPUT=2;$class.MATCH_ID=4;$prototype.init=function(window){userSmarts.ui.PropertyService.prototype.init.call(this,window);this.window=window;this.editorManager=new userSmarts.ui.EditorManager(window,this);};$prototype.getWorkbenchWindow=function(){return this.window;};$prototype.setPerspective=function(desc){if(this.currentPerspective&&(this.currentPerspective.description.getId()==desc.getId())){return;}
var perspective=this.perspectives[desc.getId()];if(!perspective){perspective=new userSmarts.ui.Perspective({description:desc,layout:new userSmarts.ui.PageLayout(this)});this.perspectives[desc.id]=perspective;this.currentPerspective=perspective;perspective.createInitialLayout(perspective.layout);}else{this.currentPerspective=perspective;}
var viewLayouts=perspective.layout.getViews();this.visibleViews=[];for(var viewId in viewLayouts){if(!this.views[viewId]){var desc=this.workbench.getViewRegistry().findViewWithId(viewId);if(desc){this.views[viewId]=new userSmarts.ui.ViewReference(this,desc);}}
var desc=this.views[viewId];if(desc){this.visibleViews.push(desc);}}
this.touch("currentPerspective");this.doLayout();this.document.title=this.currentPerspective.description.getLabel();};$prototype.showView=function(viewId){var view=this.findView(viewId);if(view){this.activate(view);}};$prototype.findViewReference=function(viewId,create){var viewReference=this.views[viewId];if(!viewReference&&create){var desc=this.workbench.getViewRegistry().findViewWithId(viewId);if(desc){viewReference=this.views[viewId]=new userSmarts.ui.ViewReference(this,desc);}}
if(!viewReference){logWarning("Unable to find view reference: "+viewId);}
return viewReference;};$prototype.findView=function(viewId,create){var viewReference=this.findViewReference(viewId,create);if(viewReference){return viewReference.getView(true);}};$prototype.getViewReferences=function(){return this.visibleViews;};$prototype.activate=function(part){if((part instanceof userSmarts.ui.ViewPart)&&(part.getSite().getPage()==this)){var partId=part.getSite().getId();var layout=this.currentPerspective.layout;var viewLayout=layout.getViewLayout(partId);var folder=viewLayout.folder;var ref=this.findViewReference(partId);this.activePartReference=ref;try{part.setFocus();}catch(e){logError("Error setting focus: "+e.message);}
folder.showView(viewLayout);signal(this,"partActivated",ref);}else if(part instanceof userSmarts.ui.EditorPart&&(part.getSite().getPage()==this)){var layout=this.currentPerspective.layout;var editorLayout=layout.getLayout(userSmarts.ui.PageLayout.ID_EDITOR_AREA);if(editorLayout){var ref=this.getReference(part);editorLayout.showEditor(ref);signal(this,"partActivated",ref);}
this.setProperty("activeEditor",part);}};$prototype.isPartVisible=function(part){var result=false;if((part instanceof userSmarts.ui.ViewPart)&&(part.getSite().getPage()==this)){var partId=part.getSite().getId();var layout=this.currentPerspective.layout;var viewLayout=layout.getViewLayout(partId);result=(viewLayout&&viewLayout.isVisible());}else if(part instanceof userSmarts.ui.EditorPart&&(part.getSite().getPage()==this)){logError("Not Implemented");}
return result;};$prototype.getActivePart=function(){var ref=this.getActivePartReference();if(ref){return ref.getActivePart(true);}
return null;};$prototype.getActivePartReference=function(){return this.activePartReference;};$prototype.getActiveEditor=function(){return this.activeEditor;};$prototype.openEditor=function(input,editorId,activate){var editor=this.getEditorManager().findEditor(editorId,input,userSmarts.ui.WorkbenchPage.MATCH_INPUT);if(editor!==null){if(activate){this.activate(editor);}else{this.bringToTop(editor);}}else{var ref=this.getEditorManager().openEditor(editorId,input,true);if(ref!==null){editor=ref.getEditor(true);}
if(editor!==null){this.setEditorAreaVisible(true);if(activate){this.activate(editor);}else{this.bringToTop(editor);}}}
return editor;};$prototype.closeEditor=function(editor,save){var saveNeeded=save&&editor.isSaveOnCloseNeeded();if(saveNeeded){editor.askSave();}
this.editorManager.closeEditor(this.getReference(editor));};$prototype.findEditor=function(input){return this.findEditors(input,null,0);};$prototype.findEditors=function(input,editorId,matchFlags){return this.editorManager.findEditors(input,editorId,matchFalgs);};$prototype.saveAllEditors=function(confirm){logError("Not Implemented");};$prototype.getEditorReferences=function(){return this.editorManager.getEditorReferences();};$prototype.close=function(confirm){logError("Not Implemented");};$prototype.doLayout=function(){if(!this.currentPerspective||!this.window){return;}
var layout=this.currentPerspective.layout;var control=layout.getControl();this.composite.getLayout().topControl=control;this.composite.update();};$prototype.getWidgetBarManager=function(){return this.widgetBarManager;};$prototype.getClientComposite=function(){if(!this.composite){this.composite=this.window.getPageComposite();}
return this.composite;};$prototype.getEditorManager=function(){if(!this.editorManager){this.editorManager=new userSmarts.ui.EditorManager(this);}
return this.editorManager;};$prototype.getReference=function(part){if(!(part instanceof userSmarts.ui.WorkbenchPart)){return null;}
var site=part.getSite();if(site instanceof userSmarts.ui.WorkbenchPartSite){return site.getPartReference();}
return null;};$prototype.certifyPart=function(part){if((part instanceof userSmarts.ui.WorkbenchPart)&&!(part.getSite()instanceof userSmarts.ui.PartSite)){return false;}
if(part instanceof userSmarts.ui.EditorPart){var ref=this.getReference(part);return ref!==null&&this.getEditorManager().containsEditor(ref);}
if(part instanceof userSmarts.ui.ViewPart){var persp=this.getActivePerspective();return persp!==null&&persp.containsView(part);}
return false;};$prototype.setEditorAreaVisible=function(showEditorArea){};$prototype.bringToTop=function(part){};$prototype.getPerspective=function(){return this.currentPerspective;};$namespace.Section=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:null,description:null,'class':'section',updateOnBoundsChange:true,collapseable:true});superClass.call(this,properties);if(this.expanded==undefined){this.setExpanded(true);}else{this.setExpanded(this.expanded);}
if(!this.width){this.width="100%";}
if(!this.height){this.height="100%";}
this.layoutData={width:this.width,height:this.height};this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));var tbar=new userSmarts.wt.widgets.Control({'class':'section-title',layoutData:{width:"100%",height:"20px"}});this.setTextClient(tbar);var dbar=new userSmarts.wt.widgets.Control({'class':'section-description',layoutData:{top:'0px',width:"100%",height:"100px"}});this.setDescriptionControl(dbar);var client=new userSmarts.wt.widgets.Composite({'class':'section-body',updateOnBoundsChange:true,layoutData:{width:"100%",height:"*"}});var node=client.getNode();this.setClient(client);};$prototype.getText=function(){return this.title;};$prototype.setText=function(title){this.title=title;var textControl=this.getTextClient();if(textControl){if(textControl instanceof userSmarts.ui.SectionTitleBar){textControl.setText(title);}else{replaceChildNodes(textControl.getNode(),title);}}};$prototype.getTextClient=function(){return this.titleControl;};$prototype.setTextClient=function(textClient){if(textClient instanceof userSmarts.wt.widgets.Control){if(this.titleControl){this.replace(textClient,this.titleControl);}else{this.add(textClient);}
this.titleControl=textClient;this.setText(this.title);if(this.expandCollapseListener){disconnect(this.expandCollapseListener);}
this.expandCollapseListener=connect(this.titleControl.getNode(),"onclick",this,this.onTitleBarClicked);}};$prototype.hasTitleBar=function(){return!!this.title;};$prototype.onTitleBarClicked=function(){this.setExpanded(!this.isExpanded());};$prototype.getDescription=function(){return this.description;};$prototype.setDescription=function(description){this.description=description;var descControl=this.getDescriptionControl();if(descControl){replaceChildNodes(descControl.getNode(),description);}};$prototype.getDescriptionControl=function(){return this.descControl;};$prototype.setDescriptionControl=function(descriptionControl){if(descriptionControl instanceof userSmarts.wt.widgets.Control){if(this.descControl){this.replace(descriptionControl,this.descControl);}else{this.add(descriptionControl);}
this.descControl=descriptionControl;this.descControl.setVisibility(this.isExpanded());replaceChildNodes(this.descControl.getNode(),this.getDescription());}};$prototype.getClient=function(){return this.client;};$prototype.setClient=function(client){if(client instanceof userSmarts.wt.widgets.Control){if(this.client){this.replace(client,this.client);}else{this.add(client);}
this.client=client;addElementClass(this.client.getNode(),"section-body");this.client.setVisibility(this.isExpanded());}};$prototype.isExpanded=function(){return this.expanded;};$prototype.setExpanded=function(expanded){if(this.collapseable||this.expanded==undefined){this.expanded=expanded;this.internalSetExpanded(expanded);}};$prototype.internalSetExpanded=function(expanded){var desc=this.getDescriptionControl();if(desc){desc.setVisibility(expanded);}
var client=this.getClient();if(client){client.setVisibility(expanded);}
if(expanded){}else{}};$namespace.SectionTitleBar=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'section-title',updateOnBoundsChange:true,layoutData:{width:"100%",height:"20px"}});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal",spacing:0}));this.leftBorder=new userSmarts.wt.widgets.Control({parent:this,'class':'section-title-left',layoutData:{width:"4px",height:"100%"}});this.middle=new userSmarts.wt.widgets.Control({parent:this,'class':'section-title-middle',layoutData:{width:"*",height:"100%"}});this.rightBorder=new userSmarts.wt.widgets.Control({parent:this,'class':'section-title-right',layoutData:{width:"7px",height:"100%"}});};$prototype.setText=function(text){replaceChildNodes(this.middle.getNode(),text);};$namespace.Theme=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,{name:properties.name||"Untitled Theme",id:properties.id});this.styles=[];};$prototype.getName=function(){return this.name;};$prototype.get=function(id){return this.styles[id];};$prototype.getImage=function(id,fallback){var val=this.get(id);if(val){return IMG({src:val,alt:id});}else{return fallback;}};$prototype.set=function(id,style){this.styles[id]=style;};$namespace.ThemeDescriptor=Class.create(userSmarts.runtime.ExtensionDescriptor);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.getTheme=function(){if(!this.theme&&this["class"]){this.theme=newInstance(this["class"],{name:this.name,id:this.id});}
return this.theme;};$prototype.includeStyleSheet=function(parent){if(this['extends']&&typeof(this['extends'])=="string"){var superClass=this['extends'];var extReg=userSmarts.runtime.Platform.getExtensionRegistry();var thDesc=extReg.findExtensionWithId(superClass);if(thDesc){thDesc.includeStyleSheet(parent);}}
var sheet=this.style;if(sheet&&!sheet.endsWith(".css")){sheet+=".css";}
sheet=userSmarts.runtime.Platform.find(this.pluginId,sheet);var link=document.createElement("LINK");link.href=sheet;link.rel="stylesheet";parent.appendChild(link);};$namespace.ThemeManager=Class.create();$prototype.initialize=function(superClass,properties){this.themes=[];this.themeMap=[];};$prototype.EXTENSION_POINT_ID="userSmarts.ui.themes";$prototype.addTheme=function(theme){if(this.themes.length==0||typeof(theme['default'])!="undefined"){this.defaultTheme=theme;}
this.themeMap[theme.id]=theme;this.themes.push(theme);};$prototype.getThemeById=function(id){var themes=userSmarts.runtime.Platform.getExtensionRegistry().getExtensions(this.EXTENSION_POINT_ID);var theme=themes[id];return theme;};$prototype.getThemes=function(){var themes=userSmarts.runtime.Platform.getExtensionRegistry().getExtensions(this.EXTENSION_POINT_ID);return themes;};$prototype.getDefaultTheme=function(){if(!this.defaultTheme){this.defaultTheme=this.getThemes()[0];}
return this.defaultTheme;};$prototype.initializeTheme=function(){};$prototype.loadDefaultTheme=function(){var thDesc=this.getDefaultTheme();var result=null;if(thDesc){result=thDesc.getInstance();var head=document.getElementsByTagName('head').item(0);this.includeStyleSheet(thDesc,head);}
return result;};$prototype.includeStyleSheet=function(themeDesc,parent){if(themeDesc['extends']&&typeof(themeDesc['extends'])=="string"){var superClass=themeDesc['extends'];var extReg=userSmarts.runtime.Platform.getExtensionRegistry();var thDesc=extReg.findExtensionWithId(superClass);if(thDesc){this.includeStyleSheet(thDesc,parent);}}
var sheet=themeDesc.style;if(sheet&&!sheet.endsWith(".css")){sheet+=".css";}
sheet=userSmarts.runtime.Platform.find(themeDesc.pluginId,sheet);var link=document.createElement("LINK");link.href=sheet;link.rel="stylesheet";parent.appendChild(link);};userSmarts.ui.PerspectiveBar=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:"perspectiveBar",perspectives:[],items:[]});if(!properties.perspectiveFilter){properties.perspectiveFilter={filter:function(item){return true;}};}
superClass.call(this,properties);connect(userSmarts.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),"currentPerspective",this,this.update);};$prototype.showPerspective=function(event){var perspectiveId=event.target().perspectiveId;if(!perspectiveId){perspectiveId=getNodeAttribute(event.target(),"perspectiveId");}
if(perspectiveId){var wb=userSmarts.ui.PlatformUI.getWorkbench();wb.showPerspective(perspectiveId,wb.getActiveWorkbenchWindow());this.selected=perspectiveId;}};$prototype.update=function(){var per=userSmarts.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective();var selected;if(per){selected=per.description.getId();}
var newTabs=[];var workbench=userSmarts.ui.PlatformUI.getWorkbench();var perspectives=workbench.getPerspectiveRegistry().getPerspectives();perspectives=perspectives.filter(this.perspectiveFilter.filter,this.perspectiveFilter);disconnectAll(this.node);connect(this.node,"onclick",this,this.showPerspective);for(var i=0;i<perspectives.length;++i){var perspective=perspectives[i];var p;var iconURL=perspective.getTitleImage();if(iconURL){var icon;var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage(iconURL,null);if(!icon){icon=IMG({src:iconURL});}}else{icon=IMG({src:iconURL});}
p=SPAN({'class':'perspective'},icon," "+perspective.getLabel());}else{p=SPAN({'class':'perspective'},DIV({}," "+perspective.getLabel()));}
p.style.marginLeft="3px";p.style.marginRight="0px";p.style.borderLeftWidth="1px";p.style.borderRightWidth="1px";p.style.borderTopWidth="1px";p.style.borderBottomWidth="1px";p.style.borderStyle="solid";p.style.padding="5px";if(selected==perspective.getId()){addElementClass(p,"selected");}else{p.perspectiveId=perspective.getId();}
newTabs.push(p);}
replaceChildNodes(this.node,newTabs);};namespace("userSmarts.ui.application");userSmarts.ui.application.ActionBarAdvisor=Class.create();$prototype.initialize=function(superClass,configurer){this.configurer=configurer;};$prototype.fillActionBars=function(flags){var menuBar=this.configurer.getMenuManager();var coolBar=this.configurer.getCoolBarManager();var statusLine=this.configurer.getStatusLineManager();if(menuBar){this.fillMenuBar(menuBar);}
if(coolBar){this.fillCoolBar(coolBar);}
if(statusLine){this.fillStatusLine(statusLine);}};$prototype.makeActions=function(action){};$prototype.register=function(action){};$prototype.getAction=function(menuBar){};$prototype.fillMenuBar=function(menuBar){};$prototype.fillCoolBar=function(coolBar){coolBar.addItem(new userSmarts.wt.widgets.Clock(null,{id:"PerspectiveBarClock",'class':'clock'}));coolBar.addItem(SPAN({src:'images/CSSA-Logo.gif',width:'32',height:'16'},"Demo"));coolBar.addItem(new userSmarts.ui.PerspectiveBar());};$prototype.fillStatusLine=function(statusLine){};$prototype.dispose=function(){};$prototype.disposeActions=function(){};$prototype.disposeAction=function(action){};userSmarts.ui.application.ActionBarConfigurer=Class.create();$prototype.initialize=function(superClass,windowConfigurer){this.windowConfigurer=windowConfigurer;};$prototype.getCoolBarManager=function(){var page=this.windowConfigurer.getWindow().getActivePage();var wbm=page.getWidgetBarManager();return wbm;};$prototype.getMenuManager=function(){};$prototype.getStatusLineManager=function(){};$prototype.getWindowConfigurer=function(){return this.windowConfigurer;};$prototype.registerGlobalAction=function(action){};userSmarts.ui.application.WorkbenchAdvisor=Class.create();$prototype.initialize=function(superClass){};$prototype.getDefaultPageInput=function(){return null;};$prototype.getInitialWindowPerspectiveId=function(){var preg=userSmarts.ui.WorkbenchPlugin.getDefault().getPerspectiveRegistry();var pid=preg.getPerspectives()[0].getId();return pid;};$prototype.initialize=function(configurer){this.configurer=configurer;};$prototype.getWorkbenchConfigurer=function(){return this.configurer;};$prototype.preStartup=function(){};$prototype.postStartup=function(){};$prototype.preShutdown=function(){};$prototype.postShutdown=function(){};$prototype.createWorkbenchWindowAdvisor=function(configurer){return new userSmarts.ui.application.WorkbenchWindowAdvisor(configurer);};$prototype.openWindows=function(){this.configurer.openFirstTimeWindow();};userSmarts.ui.application.WorkbenchConfigurer=Class.create();$prototype.initialize=function(superClass,workbench,advisor){this.workbench=workbench;this.advisor=advisor;};$prototype.getWorkbench=function(){return this.workbench;};$prototype.openFirstTimeWindow=function(){var advisor=this.advisor;var perspectiveId=advisor.getInitialWindowPerspectiveId();var input=advisor.getDefaultPageInput();var shell=new userSmarts.wt.widgets.Shell({display:this.workbench.getDisplay()});var wbWindow=new userSmarts.ui.WorkbenchWindow(this.workbench,shell);var windowConfigurer=this.getWindowConfigurer(wbWindow);var wb=this.workbench;wb.activeWindow=wbWindow;var windowAdvisor=advisor.createWorkbenchWindowAdvisor(windowConfigurer);windowConfigurer.windowAdvisor=windowAdvisor;windowConfigurer.advisor=advisor;windowAdvisor.postWindowCreate();windowAdvisor.preWindowOpen();var page=new userSmarts.ui.WorkbenchPage({workbench:wb,window:this.window});page.init(wbWindow);wbWindow.setActivePage(page);windowAdvisor.createWindowContents(wbWindow.getShell());shell.getNode();shell.update();perspectiveId=this.advisor.getInitialWindowPerspectiveId()||wb.getPerspectiveRegistry().getDefaultPerspective();wb.showPerspective(perspectiveId,wbWindow);windowAdvisor.postWindowOpen();window.advisor=windowAdvisor;};$prototype.getWindowConfigurer=function(wbWindow){return new userSmarts.ui.application.WorkbenchWindowConfigurer(wbWindow);};namespace("userSmarts.ui.application");$namespace.WorkbenchWindowAdvisor=Class.create();$prototype.initialize=function(superClass,configurer){this.configurer=configurer;};$prototype.getWindowConfigurer=function(){return this.configurer;};$prototype.preWindowOpen=function(){};$prototype.createActionBarAdvisor=function(configurer){var result=new userSmarts.ui.application.ActionBarAdvisor(configurer);return result;};$prototype.openIntro=function(){};$prototype.postWindowCreate=function(){};$prototype.postWindowClose=function(){};$prototype.postWindowOpen=function(){};$prototype.postWindowRestore=function(){};$prototype.preWindowShellClose=function(){return true;};$prototype.createWindowContents=function(shell){this.getWindowConfigurer().createDefaultContents(shell);};$prototype.dispose=function(){};userSmarts.ui.application.WorkbenchWindowConfigurer=Class.create();$prototype.initialize=function(superClass,window){this.window=window;};$prototype.getWindow=function(){return this.window;};$prototype.createPageComposite=function(parent){this.window.createPageComposite(parent);};$prototype.createDefaultContents=function(shell){shell.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));var display=shell.getDisplay();shell.setBounds(0,0,display.getWidth(),display.getHeight());var pb=new userSmarts.ui.PerspectiveBar({parent:shell,layoutData:{height:20,width:"100%"}});this.createPageComposite(shell);this.window.getPageComposite().setLayoutData({width:"100%",height:"*"});var fb=new userSmarts.wt.widgets.Control({parent:shell,layoutData:{height:"20px"},node:SPAN({},"Copyright Notice Goes Here!")});shell.layout();};namespace("userSmarts.ui.views");$namespace.TableView=Class.create(userSmarts.ui.ViewPart);$prototype.initialize=function(superClass,desc){superClass.call(this,desc);if(!this.className){this.className='table-view';}
this.table=new userSmarts.wt.widgets.Table({model:this.model,'class':this.className});};$prototype.init=function(site){userSmarts.ui.ViewPart.prototype.init.call(this,site);site.setPropertyProvider(this);this.contributeToActionBars();};$prototype.createPartControl=function(){if(this.model){setTimeout(bind(this.buildTable,this),1000);}
connect(this.table,'selected',this,this.onTableSelectionChange);return this.table;};$prototype.buildTable=function(){if(this.model){this.table.setProperty("model",this.model);}};$prototype.contributeToActionBars=function(){var bars=this.getSite().getActionBars();var tbmgr=bars.getToolbarManager();tbmgr.add(new userSmarts.wt.action.RefreshTableAction({control:this.table}));tbmgr.add(new userSmarts.wt.action.ConfigureTableAction({control:this.table}));};$prototype.onTableSelectionChange=function(event){this.setProperty("selected",event.newValue);this.setProperty("resource",event.newValue);};namespace("userSmarts.ui.views");$namespace.ListView=Class.create(userSmarts.ui.ViewPart);$prototype.initialize=function(superClass,desc){superClass.call(this,desc);if(!this.className){this.className='wt-list';}
this.list=new userSmarts.wt.widgets.List({'class':this.className});connect(this.list,'selected',this,this.onSelectionChange);};$prototype.init=function(site){userSmarts.ui.ViewPart.prototype.init.call(this,site);site.setPropertyProvider(this);this.contributeToActionBars();};$prototype.createPartControl=function(){if(this.model){setTimeout(bind(this.buildList,this),1000);}
return this.list;};$prototype.buildList=function(){if(this.model){this.list.setModel(this.model);}};$prototype.contributeToActionBars=function(){var bars=this.getSite().getActionBars();var tbmgr=bars.getToolbarManager();tbmgr.add(new userSmarts.wt.action.SortOnColumnAction({control:this.list}));tbmgr.add(new userSmarts.wt.action.RefreshListAction({list:this.list}));tbmgr.add(new userSmarts.wt.action.ExpandListAction({list:this.list}));tbmgr.add(new userSmarts.wt.action.CollapseListAction({list:this.list}));};$prototype.onSelectionChange=function(event){this.setProperty("selected",event.newValue);this.setProperty("resource",event.newValue);};namespace("userSmarts.debug.ui");$namespace.Logger=Class.create(Bean);$prototype.initialize=function(superClass){superClass.call(this,arguments);this.filter=function(){return true;};var logger=MochiKit.Logging.logger;this.logger=logger;this.logger.addListener("LoggerListener",this.filter,bind(this.addMessage,this));this.messages=[];};$class.DEBUG='DEBUG';$class.ERROR='ERROR';$class.WARNING='WARN';$class.INFO='INFO';$class.NONE='NONE';$class.ALL='ALL';$prototype.addMessage=function(msg){this.messages.push(msg);this.setProperty("updated",msg);};$prototype.getMessages=function(){return this.messages;};$prototype.clear=function(){this.messages=[];};userSmarts.debug.ui.log=new userSmarts.debug.ui.Logger();namespace("userSmarts.debug.ui");userSmarts.debug.ui.LogView=Class.create(userSmarts.ui.ViewPart);$prototype.initialize=function(superClass){superClass.call(this,arguments);this.logger=userSmarts.debug.ui.log;this.logFilter=bind(function(msg){var msgLvl=msg.level;var result=false;if(this.logLevel==userSmarts.debug.ui.Logger.ALL||msgLvl==userSmarts.debug.ui.Logger.ERROR||this.logLevel==msgLvl){result=true;}
return result;},this);this.logger.addChangeListener(bind(function(event){this.displayMessage(event.newValue);},this),'updated',this.logFilter);this.logPane=DIV({id:'','class':'log-view'});this.logPane.style.overflow='auto';this.logPane.style.height='100%';this.logPane.style.width='100%';this.levels=[];this.levels['NONE']=userSmarts.debug.ui.Logger.NONE;this.levels['INFO']=userSmarts.debug.ui.Logger.INFO;this.levels['WARN']=userSmarts.debug.ui.Logger.WARNING;this.levels['ERROR']=userSmarts.debug.ui.Logger.ERROR;this.levels['DEBUG']=userSmarts.debug.ui.Logger.DEBUG;this.levels['ALL']=userSmarts.debug.ui.Logger.ALL;this.setLogLevel(userSmarts.debug.ui.Logger.ALL);};$prototype.paint=function(){return this.logPane;};$prototype.repaint=function(){var results=[];var msgs=this.logger.getMessages();var msg;for(var i=0;i<msgs.length;i++){msg=msgs[i];if(this.logFilter(msg)){results.push(DIV({'class':'log-message '+msg.level.toLowerCase()},'['+msg.level+']'+' '+msg.info[0]));}}
replaceChildNodes(this.logPane,results);};$prototype.displayMessage=function(msg){this.logPane.appendChild(DIV({'class':'log-message '+msg.level.toLowerCase()},'['+msg.level+']'+' '+msg.info[0]));if(this.logPane.offsetHeight>this.logPane.scrollHeight){this.logPane.scrollTop=0;}else{this.logPane.scrollTop=this.logPane.scrollHeight;}};$prototype.setLogLevel=function(lvl){if(this.levels[lvl]){this.logLevel=this.levels[lvl];}else{logError("Unable to set log level to specified value '"+lvl+"'");}};userSmarts.runtime.Platform.registerPluginJSON({"id":"com.usersmarts.rcp.rcp-ui-plugin","prerequisites":["com.usersmarts.rcp.rcp-wt-plugin"],"pluginClass":"userSmarts.ui.WorkbenchPlugin","providerName":"","extensionPoints":{},"name":"userSmarts UI","installURL":"${installURL}","label":"userSmarts UI","version":"0.1"});
