The 1 minute and 50 second GIF video below demonstrates how to define and use a SWT control model through a model called BlueButton.
The core elements that define the SWT model are summarized as follows:
The process of writing the code for create() is omitted in the video. create is written in Groovy. The code is as follows.
import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import xworker.swt.widgets.ControlCreator; //Create button object, parent is putted by parent model def button = new Button(parent, SWT.NONE); button.setBackground(button.getDisplay().getSystemColor(SWT.COLOR_BLUE)); //Apply control common features ControlCreator.init(button, self, actionContext); //Set button attributes with model button.setText(self.getMetadata().getLabel()); //Invoke children's create method, put button as parent actionContext.peek().put("parent", button); for(child : self.getChilds()){ child.doAction("create", actionContext); } //Put button to global context actionContext.g().put(self.getMetadata().getName(), button); //Return return button;
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号