Java Code Examples for com.google.gwt.user.client.ui.TabPanel#setStyleName()

The following examples show how to use com.google.gwt.user.client.ui.TabPanel#setStyleName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    serverName = new ContentHeaderLabel();

    table = new DefaultCellTable<>(10, ActivemqConnector::getName);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqConnector, String> name = new Column<ActivemqConnector, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqConnector object) {
            return object.getName();
        }
    };

    table.addColumn(name, "Name");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_add(),
                    clickEvent -> presenter.launchNewConnectorWizard(type)));

    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_remove(), clickEvent -> Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Connector"),
                    Console.MESSAGES.deleteConfirm("Connector " + getSelectedEntity().getSocketBinding()),
                    isConfirmed -> {
                        if (isConfirmed) {
                            presenter.onDeleteConnector(getSelectedEntity());
                        }
                    })));

    connectorForm = new ConnectorForm(presenter, new FormToolStrip.FormCallback<ActivemqConnector>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            presenter.onSaveConnector(getSelectedEntity(), changeset);
        }

        @Override
        public void onDelete(ActivemqConnector entity) {}
    }, type);

    properties = new PropertyEditor(presenter, true);

    VerticalPanel layout = new VerticalPanel();
    layout.add(tools);
    layout.add(table);
    layout.add(pager);

    connectorForm.getForm().bind(table);

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.getElement().setAttribute("style", "margin-top:15px;");
    tabs.addStyleName("master_detail-detail");

    tabs.add(connectorForm.asWidget(), Console.CONSTANTS.common_label_details());
    tabs.add(properties.asWidget(), Console.CONSTANTS.common_label_properties());

    layout.add(tabs);
    tabs.selectTab(0);

    table.getSelectionModel().addSelectionChangeHandler(selectionChangeEvent -> {
        List<PropertyRecord> props = getSelectedEntity().getParameter();
        String tokens = getSelectedEntity().getType().getResource() + "_#_" + getSelectedEntity().getName();
        properties.setProperties(tokens, props);
    });

    return layout;
}
 
Example 2
Source File: AcceptorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    serverName = new ContentHeaderLabel();
    table = new DefaultCellTable<>(10, ActivemqAcceptor::getName);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqAcceptor, String> name = new Column<ActivemqAcceptor, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqAcceptor object) {
            return object.getName();
        }
    };
    table.addColumn(name, "Name");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_add(),
                    clickEvent -> presenter.launchNewAcceptorWizard(type)));

    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_remove(), clickEvent -> Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Acceptor"),
                    Console.MESSAGES.deleteConfirm("Acceptor " + getSelectedEntity().getSocketBinding()),
                    isConfirmed -> {
                        if (isConfirmed) {
                            presenter.onDeleteAcceptor(getSelectedEntity());
                        }
                    })));

    acceptorForm = new AcceptorForm(presenter, new FormToolStrip.FormCallback<ActivemqAcceptor>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            presenter.onSaveAcceptor(getSelectedEntity(), changeset);
        }

        @Override
        public void onDelete(ActivemqAcceptor entity) {}
    }, type);

    properties = new PropertyEditor(presenter, true);

    VerticalPanel layout = new VerticalPanel();
    layout.add(tools);
    layout.add(table);
    layout.add(pager);

    acceptorForm.getForm().bind(table);

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addStyleName("master_detail-detail");
    tabs.getElement().setAttribute("style", "margin-top:15px;");

    tabs.add(acceptorForm.asWidget(), Console.CONSTANTS.common_label_details());
    tabs.add(properties.asWidget(), Console.CONSTANTS.common_label_properties());

    layout.add(tabs);
    tabs.selectTab(0);

    table.getSelectionModel().addSelectionChangeHandler(selectionChangeEvent -> {
        List<PropertyRecord> props = getSelectedEntity().getParameter();
        String tokens = getSelectedEntity().getType().getResource() + "_#_" + getSelectedEntity().getName();
        properties.setProperties(tokens, props);
    });

    return layout;
}
 
Example 3
Source File: OneToOneLayout.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget build() {

        layout  = new LayoutPanel();
        layout.setStyleName("fill-layout");

        FakeTabPanel titleBar = null;
        if(!isPlain) {
            titleBar = new FakeTabPanel(title);
            layout.add(titleBar);
        }

        if(this.toolStrip !=null)
        {
            layout.add(toolStrip);
        }

        VerticalPanel panel = new VerticalPanel();
        panel.setStyleName("rhs-content-panel");

        ScrollPanel scroll = new ScrollPanel(panel);
        layout.add(scroll);

        // titlebar offset, if exists
        int offset = isPlain ? 0 : 40;

        if(toolStrip!=null)
        {
            if(!isPlain) layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 40, Style.Unit.PX);
            layout.setWidgetTopHeight(toolStrip, offset, Style.Unit.PX, 30, Style.Unit.PX);
            layout.setWidgetTopHeight(scroll, offset+30, Style.Unit.PX, 100, Style.Unit.PCT);
        }
        else
        {
            if(!isPlain) layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 40, Style.Unit.PX);
            layout.setWidgetTopHeight(scroll, offset, Style.Unit.PX, 100, Style.Unit.PCT);
        }


        if(null==headlineWidget)
        {
            panel.add(new ContentHeaderLabel(headline));
        }
        else
        {
            panel.add(headlineWidget);
        }

        panel.add(contentDescription);

        if(master!=null)
        {
            if(master.title!=null && !master.title.isEmpty())
                panel.add(new ContentGroupLabel(master.title));

            if(masterTools!=null) panel.add(masterTools);

            master.widget.getElement().setAttribute("role", "application");
            panel.add(master.widget);
        }

        // -----

        if(detail!=null)
        {
            detail.widget.getElement().addClassName("master_detail-detail");
            if(detail.title!=null && !detail.title.isEmpty())
                panel.add(new ContentGroupLabel(detail.title));
            panel.add(detail.widget);
            detail.widget.getElement().addClassName("fill-layout-width");
            detail.widget.getElement().setAttribute("role", "application");
        }
        else if(details.size()>0)
        {
            TabPanel tabs = new TabPanel();
            tabs.setStyleName("default-tabpanel");
            tabs.addStyleName("master_detail-detail");
            tabs.getElement().setAttribute("style", "margin-top:15px;");

            for(NamedWidget item : details)
            {
                tabs.add(item.widget, item.title);
                item.widget.getElement().addClassName("fill-layout-width");
                item.widget.getElement().setAttribute("role", "application");
            }

            panel.add(tabs);

            if(!details.isEmpty())
                tabs.selectTab(0);

        }

        //layout.getElement().setAttribute("style", "border:1px solid red");
        return layout;
    }
 
Example 4
Source File: ChoiceStrategy.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private TabPanelContract createDefaultTabPanel(InteractionUnit interactionUnit, EventBus eventBus) {
    final TabPanel tabPanel = new TabPanel();
    tabPanel.setStyleName("default-tabpanel");

    tabPanel.addBeforeSelectionHandler(new NavigationHandler(interactionUnit, childUnits, tabPanel));

    /*tabPanel.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {

            if(attachEvent.isAttached() && tabPanel.getWidgetCount()>0)
                tabPanel.selectTab(0);
        }
    });*/


    // activation listener
    eventBus.addHandler(SystemEvent.TYPE,
            new ChildActivationHandler<TabPanel>(tabPanel, childUnits, new ChildUnitCommand<TabPanel>() {
                @Override
                public void execute(TabPanel parent, int key) {
                    // TODO: this doesn't really work (rendering bugs) ...
                    parent.selectTab(key, false);
                    parent.getDeckPanel().showWidget(key); // workaround
                }
            })
    );

    TabPanelContract tabPanelContract = new TabPanelContract() {
        @Override
        public void add(InteractionUnit unit, Widget widget) {
            tabPanel.add(widget, unit.getLabel());

            // register tab2index mapping
            childUnits.put(tabPanel.getWidgetCount() - 1, unit.getId());
        }

        @Override
        public Widget as() {
            return tabPanel;
        }
    };

    // complement model

    getInteractionUnit().setOutputs(NAVIGATION);
    getInteractionUnit().setInputs(ACTIVATION);


    return tabPanelContract;
}