Search in sources :

Example 1 with TabListItem

use of org.gwtbootstrap3.client.ui.TabListItem in project ovirt-engine by oVirt.

the class AbstractModeSwitchingPopupWidget method switchMode.

public void switchMode(boolean advanced) {
    Set<Widget> allConfiguredWidgets = widgetConfiguration.getAll().keySet();
    for (Widget widget : allConfiguredWidgets) {
        widget.setVisible(widgetConfiguration.get(widget).isCurrentlyVisible(advanced, createInstanceMode));
    }
    TabListItem activeTab = ((DialogTabPanel) getWidget()).getActiveTab();
    // select the first tab if the selected tab has been hidden
    if (!advanced && widgetConfiguration.getVisibleInAdvanceMode().keySet().contains(activeTab)) {
        ((DialogTabPanel) getWidget()).switchTab(defaultTab);
    }
}
Also used : DialogTabPanel(org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel) Widget(com.google.gwt.user.client.ui.Widget) TabListItem(org.gwtbootstrap3.client.ui.TabListItem)

Example 2 with TabListItem

use of org.gwtbootstrap3.client.ui.TabListItem in project ovirt-engine by oVirt.

the class DialogTabPanel method switchTab.

public void switchTab(TabListItem tabItem) {
    boolean found = false;
    for (int i = 0; i < navTabs.getWidgetCount(); i++) {
        TabListItem currentTabItem = (TabListItem) navTabs.getWidget(i);
        if (tabItem.getText().equals(currentTabItem.getText())) {
            currentTabItem.showTab();
            TabPane tabPane = (TabPane) tabContent.getWidget(i);
            // Detach and immediately re-attach so the content gets the onAttach event so they can react to being
            // made visible. Otherwise there is no way for the content to know if they are visible or not due to
            // the visibility being controlled by the 'active' class on the tab, which doesn't trigger any GWT
            // events when added.
            tabContent.remove(tabPane);
            tabContent.insert(tabPane, i);
            ((FlowPanel) tabPane.getWidget(0)).insert(tabHeaderContainer, 0);
            tabPane.getWidget(0).setHeight(height);
            tabPane.setActive(true);
            activeTab = (TabListItem) navTabs.getWidget(i);
            found = true;
        } else {
            TabPane tabPane = (TabPane) tabContent.getWidget(i);
            ((FlowPanel) tabPane.getWidget(0)).remove(tabHeaderContainer);
            tabPane.setActive(false);
        }
    }
    // If not found, set first active.
    if (!found && navTabs.getWidgetCount() > 0) {
        ((TabListItem) navTabs.getWidget(0)).showTab();
        TabPane tabPane = (TabPane) tabContent.getWidget(0);
        ((FlowPanel) tabPane.getWidget(0)).insert(tabHeaderContainer, 0);
        tabPane.setActive(true);
    }
}
Also used : TabPane(org.gwtbootstrap3.client.ui.TabPane) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) TabListItem(org.gwtbootstrap3.client.ui.TabListItem)

Example 3 with TabListItem

use of org.gwtbootstrap3.client.ui.TabListItem in project drools-wb by kiegroup.

the class FromAccumulateCompositeFactPatternWidget method getCompositeLabel.

@Override
protected Widget getCompositeLabel() {
    ClickHandler leftPatternclick = new ClickHandler() {

        public void onClick(ClickEvent event) {
            showFactTypeSelector();
        }
    };
    ClickHandler sourcePatternClick = new ClickHandler() {

        public void onClick(ClickEvent event) {
            showSourcePatternSelector();
        }
    };
    String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from accumulate") + "</div>";
    FlexTable panel = new FlexTable();
    int r = 0;
    if (pattern.getFactPattern() == null) {
        panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPattern() + "</font>", leftPatternclick, !this.readOnly));
    }
    panel.setWidget(r++, 0, new HTML(lbl));
    if (this.getFromAccumulatePattern().getSourcePattern() == null) {
        panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPattern() + "</font>", sourcePatternClick, !this.readOnly));
    } else {
        IPattern rPattern = this.getFromAccumulatePattern().getSourcePattern();
        RuleModellerWidget sourcePatternWidget;
        if (rPattern instanceof FactPattern) {
            sourcePatternWidget = new FactPatternWidget(this.getModeller(), getEventBus(), rPattern, true, true, this.readOnly);
        } else if (rPattern instanceof FromAccumulateCompositeFactPattern) {
            sourcePatternWidget = new FromAccumulateCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromAccumulateCompositeFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromCollectCompositeFactPattern) {
            sourcePatternWidget = new FromCollectCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCollectCompositeFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromEntryPointFactPattern) {
            sourcePatternWidget = new FromEntryPointFactPatternWidget(this.getModeller(), this.getEventBus(), (FromEntryPointFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromCompositeFactPattern) {
            sourcePatternWidget = new FromCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCompositeFactPattern) rPattern, this.readOnly);
        } else {
            throw new IllegalArgumentException("Unsupported pattern " + rPattern + " for right side of FROM ACCUMULATE");
        }
        sourcePatternWidget.addOnModifiedCommand(new Command() {

            public void execute() {
                setModified(true);
            }
        });
        panel.setWidget(r++, 0, addRemoveButton(sourcePatternWidget, new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisBlockOfData())) {
                    setModified(true);
                    getFromAccumulatePattern().setSourcePattern(null);
                    getModeller().refreshWidget();
                }
            }
        }));
    }
    final TabPanel tPanel = new TabPanel() {

        {
            addStyleName("uf-tabbar-panel");
        }
    };
    final NavTabs navTabs = new NavTabs() {

        {
            addStyleName("uf-tabbar-panel-nav-tabs");
            addStyleName("nav-tabs-pf");
        }
    };
    final TabContent content = new TabContent();
    tPanel.add(navTabs);
    tPanel.add(content);
    FlexTable codeTable = new FlexTable();
    int codeTableRow = 0;
    int codeTableCol = 0;
    codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Init() + ":</div>"));
    final TextBox initField = new TextBox();
    initField.setTitle(GuidedRuleEditorResources.CONSTANTS.InitCode());
    initField.setText(getFromAccumulatePattern().getInitCode());
    initField.setEnabled(!this.readOnly);
    codeTable.setWidget(codeTableRow++, codeTableCol--, initField);
    codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Action() + ":</div>"));
    final TextBox actionField = new TextBox();
    actionField.setTitle(GuidedRuleEditorResources.CONSTANTS.ActionCode());
    actionField.setText(getFromAccumulatePattern().getActionCode());
    actionField.setEnabled(!this.readOnly);
    codeTable.setWidget(codeTableRow++, codeTableCol--, actionField);
    codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Reverse() + ":</div>"));
    final TextBox reverseField = new TextBox();
    reverseField.setTitle(GuidedRuleEditorResources.CONSTANTS.ReverseCode());
    reverseField.setText(getFromAccumulatePattern().getReverseCode());
    reverseField.setEnabled(!this.readOnly);
    codeTable.setWidget(codeTableRow++, codeTableCol--, reverseField);
    codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Result() + ":</div>"));
    final TextBox resultField = new TextBox();
    resultField.setTitle(GuidedRuleEditorResources.CONSTANTS.ResultCode());
    resultField.setText(getFromAccumulatePattern().getResultCode());
    resultField.setEnabled(!this.readOnly);
    codeTable.setWidget(codeTableRow++, codeTableCol--, resultField);
    // panel.setWidget(r++, 0, codeTable);
    final ScrollPanel codePanel = new ScrollPanel();
    codePanel.add(codeTable);
    final TabPane codeTabPane = new TabPane() {

        {
            add(codePanel);
        }
    };
    final TabListItem codeTabListItem = new TabListItem(GuidedRuleEditorResources.CONSTANTS.CustomCode()) {

        {
            addStyleName("uf-dropdown-tab-list-item");
            setDataTargetWidget(codeTabPane);
            getElement().getStyle().setFontSize(12, Style.Unit.PX);
        }
    };
    navTabs.add(codeTabListItem);
    content.add(codeTabPane);
    FlexTable functionTable = new FlexTable();
    functionTable.setWidget(0, 0, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Function() + ":</div>"));
    final TextBox functionField = new TextBox();
    functionField.setTitle(GuidedRuleEditorResources.CONSTANTS.FunctionCode());
    functionField.setText(getFromAccumulatePattern().getFunction());
    functionField.setEnabled(!this.readOnly);
    functionTable.setWidget(0, 1, functionField);
    // panel.setWidget(r++, 0, functionTable);
    final ScrollPanel functionPanel = new ScrollPanel();
    functionPanel.add(functionTable);
    final TabPane functionTabPane = new TabPane() {

        {
            add(functionPanel);
        }
    };
    final TabListItem functionTabListItem = new TabListItem(GuidedRuleEditorResources.CONSTANTS.Function()) {

        {
            addStyleName("uf-dropdown-tab-list-item");
            setDataTargetWidget(functionTabPane);
            getElement().getStyle().setFontSize(12, Style.Unit.PX);
        }
    };
    navTabs.add(functionTabListItem);
    content.add(functionTabPane);
    ChangeHandler changehandler = new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            Widget sender = (Widget) event.getSource();
            TextBox senderTB = (TextBox) event.getSource();
            String code = senderTB.getText();
            setModified(true);
            if (sender == initField) {
                getFromAccumulatePattern().setFunction(null);
                functionField.setText("");
                getFromAccumulatePattern().setInitCode(code);
            } else if (sender == actionField) {
                getFromAccumulatePattern().setFunction(null);
                functionField.setText("");
                getFromAccumulatePattern().setActionCode(code);
            } else if (sender == reverseField) {
                getFromAccumulatePattern().setFunction(null);
                functionField.setText("");
                getFromAccumulatePattern().setReverseCode(code);
            } else if (sender == resultField) {
                getFromAccumulatePattern().setFunction(null);
                functionField.setText("");
                getFromAccumulatePattern().setResultCode(code);
            } else if (sender == functionField) {
                getFromAccumulatePattern().clearCodeFields();
                initField.setText("");
                actionField.setText("");
                reverseField.setText("");
                resultField.setText("");
                getFromAccumulatePattern().setFunction(code);
            }
        }
    };
    initField.addChangeHandler(changehandler);
    actionField.addChangeHandler(changehandler);
    reverseField.addChangeHandler(changehandler);
    resultField.addChangeHandler(changehandler);
    functionField.addChangeHandler(changehandler);
    boolean useFunction = getFromAccumulatePattern().useFunctionOrCode().equals(FromAccumulateCompositeFactPattern.USE_FUNCTION);
    if (useFunction) {
        functionTabListItem.setActive(true);
        functionTabPane.setActive(true);
    } else {
        codeTabListItem.setActive(true);
        codeTabPane.setActive(true);
    }
    panel.setWidget(r++, 0, tPanel);
    return panel;
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) Widget(com.google.gwt.user.client.ui.Widget) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) HTML(com.google.gwt.user.client.ui.HTML) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TextBox(org.gwtbootstrap3.client.ui.TextBox) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) TabPanel(org.gwtbootstrap3.client.ui.TabPanel) TabPane(org.gwtbootstrap3.client.ui.TabPane) FlexTable(com.google.gwt.user.client.ui.FlexTable) TabContent(org.gwtbootstrap3.client.ui.TabContent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) NavTabs(org.gwtbootstrap3.client.ui.NavTabs) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) Command(com.google.gwt.user.client.Command) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) TabListItem(org.gwtbootstrap3.client.ui.TabListItem)

Aggregations

TabListItem (org.gwtbootstrap3.client.ui.TabListItem)3 Widget (com.google.gwt.user.client.ui.Widget)2 TabPane (org.gwtbootstrap3.client.ui.TabPane)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Command (com.google.gwt.user.client.Command)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)1 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)1 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)1 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)1 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)1 NavTabs (org.gwtbootstrap3.client.ui.NavTabs)1 TabContent (org.gwtbootstrap3.client.ui.TabContent)1