Create the underlying widget.
488464
def create_widget(self):
        
        d = self.declaration
        self.widget = Flexbox(self.get_context(), None, d.style)
754578
def init_widget(self):
        
        super(AndroidCompoundButton, self).init_widget()
        w = self.widget
        w.setOnCheckedChangeListener(w.getId())
        w.onCheckedChanged.connect(self.on_checked)
1096293
def init_widget(self):
        
        super(AndroidSeekBar, self).init_widget()
        w = self.widget

        #: Setup listener
        w.setOnSeekBarChangeListener(w.getId())
        w.onProgressChanged.connect(self.on_progress_changed)
917558
def create_widget(self):
        
        context = self.get_context()
        d = self.declaration
        style = d.style or '@attr/autoCompleteTextViewStyle'
        self.widget = AutoCompleteTextView(context, None, style)
        self.adapter = ArrayAdapter(context, '@layout/simple_list_item_1')
50978
Widget createWidget() {

        if (isTrue(m_jsonConfig, CmsDataViewConstants.CONFIG_PREVIEW)) {
            return new CmsDataViewPreviewWidget(
                m_config,
                m_valueAccessor,
                new CmsDataViewPreviewWidget.ContentImageLoader());
        } else {
            I_ImageProvider provider = null;
            CmsDataViewValue val = m_valueAccessor.getValue();
            JSONValue iconVal = m_jsonConfig.get(CmsDataViewConstants.CONFIG_ICON);
            if ((iconVal != null) && (iconVal.isString() != null)) {
                provider = new CmsDataViewPreviewWidget.SimpleImageLoader(iconVal.isString().stringValue());
            }
            return new CmsDataViewPreviewWidget(m_config, m_valueAccessor, provider);
        }

    }
745742
def init_widget(self):
        
        super(AndroidPicker, self).init_widget()
        d = self.declaration
        w = self.widget
        if d.items:
            self.set_items(d.items)
        else:
            if d.max_value:
                self.set_max_value(d.max_value)
            if d.min_value:
                self.set_min_value(d.min_value)
        self.set_value(d.value)
        if d.wraps:
            self.set_wraps(d.wraps)

        if d.long_press_update_interval:
            self.set_long_press_update_interval(d.long_press_update_interval)

        w.setOnValueChangedListener(w.getId())
        w.onValueChange.connect(self.on_value_change)
547297
private void buildGui() {
		initWidget(UI_BINDER.createAndBindUi(this));
		zoomInElement.getElement().setInnerText("+");
		zoomOutElement.getElement().setInnerText("-");
		getElement().getStyle().setPosition(Position.ABSOLUTE);
		getElement().getStyle().setTop(5, Unit.PX);
		getElement().getStyle().setLeft(5, Unit.PX);

		if (Dom.isTouchSupported()) {
			initializeForTouchDevice();
		} else {
			initializeForDesktop();
		}
	}
14890
def init_widget(self):
        
        if not self.widget:
            return
        super(AndroidSnackbar, self).init_widget()

        d = self.declaration

        #: Bind events
        self.widget.onClick.connect(self.on_click)

        #: Use the custom callback to listen to events
        callback = BridgedSnackbarCallback()
        callback.setListener(self.widget.getId())
        self.widget.onDismissed.connect(self.on_dismissed)
        self.widget.onShown.connect(self.on_shown)
        self.widget.addCallback(callback)


        #: if d.text: #: Set during creation
        #: self.set_duration(d.duration) #: Set during creation
        if d.action_text:
            self.set_action_text(d.action_text)
        if d.action_text_color:
            self.set_action_text_color(d.action_text_color)
        if d.show:
            self.set_show(d.show)
679390
def create_widget(self):
        
        d = self.declaration
        Snackbar.make(self.parent_widget(), d.text,
                      0 if d.duration else -2).then(self.on_widget_created)
656488
def init_widget(self):
        
        super(UiKitEditText, self).init_widget()

        #: Init font properties etc...
        self.init_text()

        d = self.declaration
        if d.placeholder:
            self.set_placeholder(d.placeholder)
        if d.input_type != 'text':
            self.set_input_type(d.input_type)
        if d.style:
            self.set_style(d.style)

        #: A really ugly way to add the target
        #: would be nice if we could just pass the block pointer here :)
        self.get_app().bridge.addTarget(
            self.widget,
            forControlEvents=UITextField.UIControlEventEditingChanged,
            andCallback=self.widget.getId(),
            usingMethod="onValueChanged",
            withValues=["text"]#,"selected"]
        )

        self.widget.onValueChanged.connect(self.on_value_changed)
50334
def create_widget(self):
        
        d = self.declaration
        self.widget = EditText(self.get_context(), None,
                               d.style or "@attr/editTextStyle")
423012
def create_ui(self):
        
        self.entry = gtk.Entry()
        self.widget.add(self.entry)
972887
def create_widget(self):
        
        d = self.declaration
        self.widget = CalendarView(self.get_context(), None,
                                   d.style or "@attr/calendarViewStyle")
360929
@Override
    public Widget createWidget() {

        serverColumn = new FinderColumn<Server>(
                FinderColumn.FinderId.RUNTIME,
                "Server",
                new FinderColumn.Display<Server>() {

                    @Override
                    public boolean isFolder(Server data) {
                        return data.isStarted();
                    }

                    @Override
                    public SafeHtml render(String baseCss, Server server) {
                        String context = presenter.getFilter().equals(FilterType.HOST) ? server.getGroup() : server
                                .getHostName();
                        return SERVER_TEMPLATE.item(baseCss, "", server.getName(), context);
                    }

                    @Override
                    public String rowCss(Server server) {

                        String css = "";
                        // TODO: reload state
                        if (!server.isStarted()) {
                            css = "paused";
                        } else if (server.getServerState() == SrvState.RELOAD_REQUIRED) {
                            css = "warn";
                        } else if (server.getServerState() == SrvState.RESTART_REQUIRED) {
                            css = "warn";
                        } else if (server.getSuspendState() == SuspendState.SUSPENDED) {
                            css = "info";
                        } else if (server.isStarted()) {
                            css = "good";
                        }

                        return css;
                    }
                },
                new ProvidesKey<Server>() {
                    @Override
                    public Object getKey(Server item) {
                        return item.getName() + item.getHostName() + ":" + item.getServerState();
                    }
                }, presenter.getProxy().getNameToken());

        serverColumn.setShowSize(true);
        serverColumn.setFilter((item, token) -> {
            return item.getName().contains(token);
        });

        serverColumn.setValueProvider(new ValueProvider<Server>() {
            @Override
            public String get(Server item) {
                return item.getName();
            }
        });

        serverColumn.setTopMenuItems(
                new MenuDelegate<Server>(
                        Console.CONSTANTS.common_label_add(), new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {
                        presenter.launchNewConfigDialoge();
                    }
                }, MenuDelegate.Role.Operation),
                new MenuDelegate<Server>(
                        Console.CONSTANTS.common_label_refresh(), new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {
                        presenter.refreshServer();
                    }
                }, MenuDelegate.Role.Navigation)
        );

        serverColumn.setPreviewFactory(new PreviewFactory<Server>() {

            @Override
            public void createPreview(Server data, AsyncCallback<SafeHtml> callback) {
                SafeHtmlBuilder html = new SafeHtmlBuilder();
                html.appendHtmlConstant("<div class='preview-content'>");

                html.appendHtmlConstant("<h2>");
                html.appendEscaped("Server Configuration");
                html.appendHtmlConstant("</h2>");


                html.appendEscaped(Console.CONSTANTS.serverDescription());

                // TODO: reload state
                if (!data.isStarted()) {
                    PreviewState.paused(html, "Server is stopped");
                } else if (data.getServerState() == SrvState.RELOAD_REQUIRED) {
                    PreviewState.warn(html, Console.CONSTANTS.server_instance_reloadRequired());
                } else if (data.getServerState() == SrvState.RESTART_REQUIRED) {
                    PreviewState.warn(html, "Server needs to be restarted");
                } else if (data.getSuspendState() == SuspendState.SUSPENDED) {
                    PreviewState.info(html, "Server is suspended");
                } else if (data.getServerState() == SrvState.RUNNING) {
                    String id = "port-offset-" + data.getGroup() + "-" + data.getName();
                    html.appendHtmlConstant("<p>")
                            .appendEscaped("Port offset: ")
                            .appendHtmlConstant("<span id=\"" + id + "\">").appendHtmlConstant("</span>")
                            .appendHtmlConstant("</p>");
                    new ReadPortOffsetOp(dispatcher).execute(data, id);
                }

                html.appendHtmlConstant("</div>");
                callback.onSuccess(html.toSafeHtml());
            }

        });


        serverColumn.setMenuItems(
                new MenuDelegate<Server>(
                        "View", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(final Server server) {

                        placeManager.revealRelativePlace(
                                new PlaceRequest(NameTokens.ServerPresenter).with("action", "edit")
                        );

                    }
                }),
                new MenuDelegate<Server>(
                        "Remove", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(final Server server) {

                        Feedback.confirm(
                                "Remove server",
                                "Do you really want to remove server " + server.getName() + "?",
                                new Feedback.ConfirmationHandler() {

                                    @Override
                                    public void onConfirmation(boolean isConfirmed) {
                                        if (isConfirmed) { presenter.tryDelete(presenter.getSelectedServer()); } else {
                                            presenter.closeWindow();
                                        }
                                    }
                                });
                    }
                }, MenuDelegate.Role.Operation),
                new MenuDelegate<Server>(
                        "Copy", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {
                        presenter.onLaunchCopyWizard(server);
                    }
                }, MenuDelegate.Role.Operation),
                new MenuDelegate<Server>(
                        "Start/Stop", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {

                        LifecycleOperation op = (server.getRuntimeState() == RuntimeState.STOPPED
                            || server.getRuntimeState() == RuntimeState.DISABLED) ?
                                LifecycleOperation.START : LifecycleOperation.STOP;

                        if (LifecycleOperation.START == op) {
                            Feedback.confirm(
                                    "Server " + op.name(),
                                    "Do you really want to " + op.name() + " server " + server.getName() + "?",
                                    new Feedback.ConfirmationHandler() {

                                        @Override
                                        public void onConfirmation(boolean isConfirmed) {
                                            if (isConfirmed) {
                                                presenter.onServerInstanceLifecycle(server.getHostName(),
                                                        server.getName(), op);
                                            }
                                        }
                                    });


                        } else {
                            presenter.onLaunchStopDialogue(server);
                        }
                    }

                }, MenuDelegate.Role.Operation) {

                    @Override
                    public String render(Server server) {
                        return server.isStarted() ? "Stop" : "Start";
                    }
                }.setOperationAddress("/{implicit.host}/server-config=*", "start"),

                new MenuDelegate<Server>(
                        "Suspend or not", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {

                        LifecycleOperation op = server.getSuspendState() == SuspendState.SUSPENDED ?
                                LifecycleOperation.RESUME : LifecycleOperation.SUSPEND;

                        if (LifecycleOperation.RESUME == op) {
                            presenter.onServerInstanceLifecycle(server.getHostName(), server.getName(), op);
                        } else {
                            presenter.onLaunchSuspendDialogue(server);
                        }


                    }

                }, MenuDelegate.Role.Operation) {

                    @Override
                    public String render(Server server) {
                        return server.getSuspendState() == SuspendState.SUSPENDED ? "Resume" : "Suspend";
                    }
                }.setOperationAddress("/{implicit.host}/server-config=*", "resume"),

                new MenuDelegate<Server>(
                        "Reload", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {

                        Feedback.confirm(
                                "Reload Server",
                                "Do you really want to reload server " + server.getName() + "?",
                                new Feedback.ConfirmationHandler() {

                                    @Override
                                    public void onConfirmation(boolean isConfirmed) {
                                        if (isConfirmed) {
                                            presenter.onServerInstanceLifecycle(server.getHostName(), server.getName(),
                                                    LifecycleOperation.RELOAD);
                                        }
                                    }
                                });

                    }
                }, MenuDelegate.Role.Operation)
                        .setOperationAddress("/{implicit.host}/server-config=*", "reload"),

                new MenuDelegate<Server>(
                        "Restart", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {
                        Feedback.confirm(
                                "Restart Server",
                                "Do you really want to restart server " + server.getName() + "?",
                                new Feedback.ConfirmationHandler() {

                                    @Override
                                    public void onConfirmation(boolean isConfirmed) {
                                        if (isConfirmed) {
                                            presenter.onServerInstanceLifecycle(server.getHostName(), server.getName(),
                                                    LifecycleOperation.RESTART);
                                        }
                                    }
                                });


                    }
                }, MenuDelegate.Role.Operation)
                        .setOperationAddress("/{implicit.host}/server-config=*", "restart"),

                new MenuDelegate<Server>(
                        "Force Shutdown", new ContextualCommand<Server>() {
                    @Override
                    public void executeOn(Server server) {
                        Feedback.confirm(
                                "Shutdown Server",
                                "Do you really want to shutdown server " + server.getName() + "?",
                                new Feedback.ConfirmationHandler() {

                                    @Override
                                    public void onConfirmation(boolean isConfirmed) {
                                        if (isConfirmed) {
                                            presenter.onServerInstanceLifecycle(server.getHostName(), server.getName(),
                                                    LifecycleOperation.KILL);
                                        }
                                    }
                                });


                    }
                }, MenuDelegate.Role.Operation)
                        .setOperationAddress("/{implicit.host}/server-config=*", "kill")
        );

        serverColumn.setTooltipDisplay(new FinderColumn.TooltipDisplay<Server>() {
            @Override
            public SafeHtml render(Server server) {
                String message = server.isStarted() ? "running" : "not running";
                SafeHtmlBuilder sb = new SafeHtmlBuilder();
                /*if(data.isStarted())
                    sb.appendHtmlConstant("<i class=\"icon-ok\" style='color:#3F9C35'></i>&nbsp;");
                else
                    sb.appendHtmlConstant("<i class=\"icon-ban-circle\" style='color:#CC0000'></i>&nbsp;");*/
                sb.appendEscaped("Server is ").appendEscaped(message);

                if (server.getServerState() == SrvState.RELOAD_REQUIRED) {
                    sb.appendEscaped(". " + Console.CONSTANTS.server_instance_reloadRequired());
                } else if (server.getServerState() == SrvState.RESTART_REQUIRED) {
                    sb.appendEscaped(". " + Console.CONSTANTS.server_instance_servers_needRestart());
                } else if (server.getSuspendState() == SuspendState.SUSPENDED) { sb.appendEscaped(", but suspended"); }

                return sb.toSafeHtml();
            }
        });

        serverColWidget = serverColumn.asWidget();

        statusColumn = new FinderColumn<FinderItem>(
                FinderColumn.FinderId.RUNTIME,
                "Monitor",
                new FinderColumn.Display<FinderItem>() {

                    @Override
                    public boolean isFolder(FinderItem data) {
                        return data.isFolder();
                    }

                    @Override
                    public SafeHtml render(String baseCss, FinderItem data) {
                        String icon = data.isFolder() ? "icon-folder-close-alt" : "icon-file-alt";
                        return STATUS_TEMPLATE.item(baseCss, icon, data.getTitle());
                    }

                    @Override
                    public String rowCss(FinderItem data) {
                        return data.getTitle().equals("Subsystems") ? "no-menu" : "";
                    }
                },
                new ProvidesKey<FinderItem>() {
                    @Override
                    public Object getKey(FinderItem item) {
                        return item.getTitle();
                    }
                }, presenter.getProxy().getNameToken());

        statusColumn.setMenuItems(
                new MenuDelegate<FinderItem>("View", new ContextualCommand<FinderItem>() {
                    @Override
                    public void executeOn(FinderItem link) {
                        link.getCmd().execute();
                    }
                })
        );

        statusColWidget = statusColumn.asWidget();

        subsystemColumn = new FinderColumn<PlaceLink>(
                FinderColumn.FinderId.RUNTIME,
                "Subsystem",
                new FinderColumn.Display<PlaceLink>() {

                    @Override
                    public boolean isFolder(PlaceLink data) {
                        return false;
                    }

                    @Override
                    public SafeHtml render(String baseCss, PlaceLink data) {
                        return SUBSYSTEM_TEMPLATE.item(baseCss, "icon-file-alt", data.getTitle());
                    }

                    @Override
                    public String rowCss(PlaceLink data) {

                        return "";
                    }
                },
                new ProvidesKey<PlaceLink>() {
                    @Override
                    public Object getKey(PlaceLink item) {
                        return item.getTitle();
                    }
                }, presenter.getProxy().getNameToken());

        subsystemColumn.setPreviewFactory(new PreviewFactory<PlaceLink>() {
            @Override
            public void createPreview(PlaceLink data, AsyncCallback<SafeHtml> callback) {
                PreviewContent content = PreviewContent.INSTANCE;
                ExternalTextResource resource = (ExternalTextResource) content
                        .getResource("runtime_" + data.getToken().replace("-", "_"));
                if (resource != null) {
                    contentFactory.createContent(resource, callback);
                } else {
                    SafeHtmlBuilder builder = new SafeHtmlBuilder();
                    builder.appendHtmlConstant(
                            "<div class='preview-content'><span style='font-size:24px;'><i class='icon-bar-chart' style='font-size:48px;vertical-align:middle'></i>&nbsp;" + data
                                    .getTitle() + "</span></center>");
                    builder.appendHtmlConstant("</div>");
                    callback.onSuccess(builder.toSafeHtml());
                }
            }
        });

        subsystemColumn.setMenuItems(
                new MenuDelegate<PlaceLink>("View", new ContextualCommand<PlaceLink>() {
                    @Override
                    public void executeOn(PlaceLink link) {
                        link.getCmd().execute();
                    }
                })
        );


        subsysColWidget = subsystemColumn.asWidget();

        // server column is always present
        columnManager.addWest(serverColWidget);
        columnManager.addWest(statusColWidget);
        columnManager.addWest(subsysColWidget);
        columnManager.add(contentCanvas);

        columnManager.setInitialVisible(1);

        // selection handling

        serverColumn.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
            @Override
            public void onSelectionChange(SelectionChangeEvent event) {

                // column handling
                columnManager.reduceColumnsTo(1);

                if (serverColumn.hasSelectedItem()) {

                    // selection
                    columnManager.updateActiveSelection(serverColWidget);
                    final Server selectedServer = serverColumn.getSelectedItem();

                    // action
                    if (selectedServer.isStarted()) {
                        columnManager.appendColumn(statusColWidget);
                    }

                    Console.getCircuit().dispatch(
                            new SelectServer(selectedServer.getHostName(), selectedServer.getName())
                    );
                }
            }
        });

        statusColumn.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
            @Override
            public void onSelectionChange(SelectionChangeEvent event) {

                if (statusColumn.hasSelectedItem()) {

                    columnManager.updateActiveSelection(statusColWidget);

                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                        @Override
                        public void execute() {

                            if (statusColumn.getSelectedItem().getTitle().equals("Subsystems")) {
                                columnManager.appendColumn(subsysColWidget);
                                updateSubsystemColumn(subsystems);
                            } else {
                                columnManager.reduceColumnsTo(2);
                            }
                        }
                    });

                } else {
                    columnManager.reduceColumnsTo(2);
                }
            }
        });


        subsystemColumn.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
            @Override
            public void onSelectionChange(SelectionChangeEvent event) {

                if (subsystemColumn.hasSelectedItem()) {

                    columnManager.updateActiveSelection(subsysColWidget);
                }
            }
        });


        return splitlayout.asWidget();
    }
63562
def create_widget(self):
        
        d = self.declaration
        self.widget = Chronometer(self.get_context(), None, d.style)
1020450
def create_widget(self):
        
        d = self.declaration
        self.widget = LinearLayout(self.get_context(), None, d.style)
651032
def add_widget(self, wclass):
        """"""

        tree = self.treeview
        #  get the selected item:
        selected_item = ''
        tsel = tree.selection()
        if tsel:
            selected_item = tsel[0]

        #  Need to remove filter if set
        self.filter_remove()

        root = selected_item
        #  check if the widget can be added at selected point
        if not self._validate_add(root, wclass, False):
            #  if not try to add at item parent level
            parent = tree.parent(root)
            if parent != root:
                if self._validate_add(parent, wclass):
                    root = parent
                else:
                    return
            else:
                return

        #  root item should be set at this point
        #  setup properties
        widget_id = self.get_unique_id(wclass)

        data = WidgetDescr(wclass, widget_id)

        # setup default values for properties
        for pname in builder.CLASS_MAP[wclass].builder.properties:
            pdescription = {}
            if pname in properties.WIDGET_PROPERTIES:
                pdescription = properties.WIDGET_PROPERTIES[pname]
            if wclass in pdescription:
                pdescription = dict(pdescription, **pdescription[wclass])
            default_value = str(pdescription.get('default', ''))
            data.set_property(pname, default_value)
            # default text for widgets with text prop:
            if pname in ('text', 'label'):
                data.set_property(pname, widget_id)

        #
        #  default grid properties
        #
        # is_container = builder.CLASS_MAP[wclass].builder.container
        for prop_name in properties.GRID_PROPERTIES:
            pdescription = properties.LAYOUT_OPTIONS[prop_name]
            if wclass in pdescription:
                pdescription = dict(pdescription, **pdescription[wclass])
            default_value = str(pdescription.get('default', ''))
            data.set_layout_property(prop_name, default_value)

        rownum = '0'
        if root:
            rownum = str(self.get_max_row(root)+1)
        data.set_layout_property('row', rownum)
        data.set_layout_property('column', '0')

        item = self._insert_item(root, data)

        # Do redraw
        self.draw_widget(item)

        # Select and show the item created
        tree.after_idle(lambda: tree.selection_set(item))
        tree.after_idle(lambda: tree.focus(item))
        tree.after_idle(lambda: tree.see(item))