Example usage for com.google.gwt.user.client.ui TabPanel addSelectionHandler

List of usage examples for com.google.gwt.user.client.ui TabPanel addSelectionHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TabPanel addSelectionHandler.

Prototype

public HandlerRegistration addSelectionHandler(SelectionHandler<Integer> handler) 

Source Link

Usage

From source file:asquare.gwt.tests.history.client.Demo.java

License:Apache License

public void onModuleLoad() {
    TabCollection tabSet = new TabCollection();
    tabSet.add("grains", "Grains", createGrains());
    tabSet.add("vegetables", "Vegetables", createVegetables());
    tabSet.add("fruit", "Fruit", createFruit());
    tabSet.add("stimulants", "Stimulants", createStimulants());

    TabPanel tabPanel = new TabPanel();
    for (int i = 0; i < tabSet.size(); i++) {
        tabPanel.add(tabSet.getWidget(i), tabSet.getDescription(i));
    }//from   w w w . j  a  va  2s .  co m

    String initialTabToken = History.getToken();
    if (initialTabToken.length() == 0) {
        initialTabToken = tabSet.getToken(0);
    }
    TabController controller = new TabController(tabSet, tabPanel, initialTabToken);
    tabPanel.addSelectionHandler(controller);
    History.addValueChangeHandler(controller);

    RootPanel.get().add(tabPanel);
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java

License:Apache License

public static void processEvents(ComponentGVO vo, UIObject ui, EventListenerGVO event,
        List<com.qualogy.qafe.gwt.client.vo.ui.event.InputVariableGVO> inputVariables, String appId) {
    if (ui != null) {
        String nonHandledEventName = null;
        String nonHandledEventMessage = null;
        if (event instanceof OnEnterEventListenerGVO) {
            if (ui instanceof HasAllKeyHandlers) {
                HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui;
                hasAllKeyHandlers.addKeyDownHandler(EventFactory.createOnEnterListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONENTER;
            }//from   w w  w . ja  va 2s  .c  om
        }
        if (event instanceof OnFocusEventListenerGVO) {
            if (ui instanceof HasFocusHandlers) {
                HasFocusHandlers hasFocusHandlers = (HasFocusHandlers) ui;
                hasFocusHandlers.addFocusHandler(EventFactory.createFocusListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONFOCUS;
            }
        }
        if (event instanceof OnExitEventListenerGVO) {
            if (ui instanceof HasBlurHandlers) {
                HasBlurHandlers hasBlurHandlers = (HasBlurHandlers) ui;
                hasBlurHandlers.addBlurHandler(EventFactory.createOnExitListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONEXIT;
            }
        }
        if (event instanceof ClickEventListenerGVO) {
            if (ui instanceof HasClickHandlers) {
                ui.addStyleName("qafe_hand");
                HasClickHandlers hasClickHandlers = (HasClickHandlers) ui;
                hasClickHandlers.addClickHandler(EventFactory.createClickListener(event, inputVariables));
            } else if (ui instanceof MenuItem) {
                MenuItem menuItem = (MenuItem) ui;
                menuItem.setCommand(EventFactory.createCommandListener(menuItem, event, inputVariables));
                ui.addStyleName("qafe_hand");
            } else if (ui instanceof AreaWidget) {
                AreaWidget area = (AreaWidget) ui;
                area.setCommand(EventFactory.createCommandListener(area, event, inputVariables));
                ui.addStyleName("qafe_hand");
            } else if (ui instanceof TabPanel) {
                TabPanel tabPanel = (TabPanel) ui;
                String eventComponentId = event.getEventComponentId();
                String[] components = eventComponentId.split("\\.");
                if (components.length == 1) {
                    tabPanel.addSelectionHandler(
                            EventFactory.createTabPanelListener(tabPanel, event, inputVariables));
                    ui.addStyleName("qafe_hand");
                }
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONCLICK;
            }
        }
        if (event instanceof DoubleClickEventListenerGVO) {
            if (ui instanceof HasDoubleClickHandlers) {
                //ui.addStyleName("qafe_hand");
                HasDoubleClickHandlers hasDoubleClickHandlers = (HasDoubleClickHandlers) ui;
                hasDoubleClickHandlers
                        .addDoubleClickHandler(EventFactory.createDoubleClickListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONDBLCLICK;
            }
        }
        if (event instanceof OnChangeEventListenerGVO) {
            if (ui instanceof QSuggestBox) {
                QSuggestBox suggestionBox = (QSuggestBox) ui;
                suggestionBox.addKeyUpHandler(
                        EventFactory.createSuggestionOnKeyUpHandler(suggestionBox, event, inputVariables));
            } else if (ui instanceof QDatePicker && ui instanceof HasValueChangeHandlers) {
                HasValueChangeHandlers hasValueChangeHandlers = (HasValueChangeHandlers) ui;
                hasValueChangeHandlers.addValueChangeHandler(
                        (EventFactory.createOnValueChangeHandler(event, inputVariables)));
            } else if (ui instanceof HasDataChangeHandlers) {
                HasDataChangeHandlers hasDataChangeHandlers = (HasDataChangeHandlers) ui;
                hasDataChangeHandlers
                        .addDataChangeHandler((EventFactory.createOnDataChangeHandler(event, inputVariables)));
            } else if (ui instanceof HasChangeHandlers) {
                HasChangeHandlers hasChangeHandlers = (HasChangeHandlers) ui;
                hasChangeHandlers
                        .addChangeHandler((EventFactory.createOnChangeListener(event, inputVariables)));
            } else if (ui instanceof SourcesChangeEvents) {
                SourcesChangeEvents sourcesChangeEvents = (SourcesChangeEvents) ui;
                sourcesChangeEvents
                        .addChangeListener(EventFactory.createLegacyOnChangeListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONCHANGE;
            }
        }
        if (event instanceof OnMouseEnterEventListenerGVO) {
            if (ui instanceof HasAllMouseHandlers) {
                HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui;
                hasAllMouseHandlers
                        .addMouseOverHandler(EventFactory.createOnMouseEnterListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_ENTER;
            }
        }
        if (event instanceof OnMouseExitEventListenerGVO) {
            if (ui instanceof HasAllMouseHandlers) {
                HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui;
                hasAllMouseHandlers
                        .addMouseOutHandler(EventFactory.createOnMouseExitListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_EXIT;
            }
        }
        if (event instanceof OnMouseMoveEventListenerGVO) {
            if (ui instanceof HasAllMouseHandlers) {
                HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui;
                hasAllMouseHandlers
                        .addMouseMoveHandler(EventFactory.createOnMouseMoveListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_MOVE;
            }
        }
        if (event instanceof OnMouseUpEventListenerGVO) {
            if (ui instanceof HasAllMouseHandlers) {
                HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui;
                hasAllMouseHandlers
                        .addMouseUpHandler(EventFactory.createOnMouseUpListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_UP;
            }
        }
        if (event instanceof OnMouseDownEventListenerGVO) {
            if (ui instanceof HasAllMouseHandlers) {
                HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui;
                hasAllMouseHandlers
                        .addMouseDownHandler(EventFactory.createOnMouseDownListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_DOWN;
            }
        }
        if (event instanceof OnKeyPressEventListenerGVO) {
            if (ui instanceof HasAllKeyHandlers) {
                HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui;
                hasAllKeyHandlers
                        .addKeyPressHandler(EventFactory.createOnKeyPressListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONKEYPRESS;
            }
        }
        if (event instanceof OnKeyDownEventListenerGVO) {
            if (ui instanceof HasAllKeyHandlers) {
                HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui;
                hasAllKeyHandlers
                        .addKeyDownHandler(EventFactory.createOnKeyDownListener(event, inputVariables));
            } else if (ui instanceof HasNativeKeyHandlers) {
                HasNativeKeyHandlers hasNativeKeyHandlers = (HasNativeKeyHandlers) ui;
                hasNativeKeyHandlers.addNativeKeyDownHandler(
                        EventFactory.createOnNativeKeyDownListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONKEYDOWN;
            }
        }
        if (event instanceof OnKeyUpEventListenerGVO) {
            if (ui instanceof HasAllKeyHandlers) {
                HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui;
                hasAllKeyHandlers.addKeyUpHandler(EventFactory.createOnKeyUpListener(event, inputVariables));
            } else if (ui instanceof HasNativeKeyHandlers) {
                HasNativeKeyHandlers hasNativeKeyHandlers = (HasNativeKeyHandlers) ui;
                hasNativeKeyHandlers
                        .addNativeKeyUpHandler(EventFactory.createOnNativeKeyUpListener(event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONKEYUP;
            }
        }
        if (event instanceof OnLoadEventListenerGVO) {
            if (!(vo instanceof WindowGVO)) {
                nonHandledEventName = QAMLConstants.EVENT_ONLOAD;
                nonHandledEventMessage = "Support on Window only.";
            }
        }
        if (event instanceof OnUnLoadEventListenerGVO) {
            if (!(vo instanceof WindowGVO)) {
                nonHandledEventName = QAMLConstants.EVENT_ONUNLOAD;
                nonHandledEventMessage = "Support on Window only.";
            }
        }
        if (event instanceof OnFinishEventListenerGVO) {
            if (ui instanceof FormPanel) {
                FormPanel formPanel = (FormPanel) ui;
                formPanel.addSubmitCompleteHandler(
                        EventFactory.createSubmitCompleteHandler(ui, event, inputVariables));
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONFINISH;
            }
        }
        if (event instanceof OnTimerEventListenerGVO) {
            //check a timer is already scheduled for this event- this happens when there are multiple component reference mentioned in that event
            if (!ClientApplicationContext.getInstance().isTimerScheduledForEvent(appId, vo.getWindow(),
                    event.getEventId())) {
                OnTimerHandler timerHandler = new OnTimerHandler();
                timerHandler.processOnTimer(ui, vo, appId, event, inputVariables);
            } else {
                nonHandledEventName = QAMLConstants.EVENT_ONTIMER;
                nonHandledEventMessage = "Timer is already scheduled.";
            }
        }
        if (nonHandledEventName != null) {
            if (nonHandledEventMessage == null) {
                nonHandledEventMessage = "";
            }
            ClientApplicationContext.getInstance()
                    .log("The component [" + DOM.getElementAttribute(ui.getElement(), "id") + "] for event ["
                            + event.getEventId() + "] does not support " + nonHandledEventName + " listener. "
                            + nonHandledEventMessage, null);
        }
    }
}

From source file:net.officefloor.demo.stocks.client.StockGraphWidget.java

License:Open Source License

/**
 * Initiate.//from  w  ww. jav a 2 s.  co m
 * 
 * @param historyPeriod
 *            Time in milliseconds to display history of prices.
 * @param redrawPeriod
 *            Time in milliseconds to allow before complete redraw of the
 *            graph.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param stocks
 *            {@link Stock} instances to graph.
 */
public StockGraphWidget(final long historyPeriod, final long redrawPeriod, final String width,
        final String height, Stock... stocks) {

    // Create sorted copy of stocks
    final Stock[] orderedStocks = new Stock[stocks.length];
    for (int i = 0; i < orderedStocks.length; i++) {
        orderedStocks[i] = stocks[i];
    }
    Arrays.sort(orderedStocks, new Comparator<Stock>() {
        @Override
        public int compare(Stock a, Stock b) {
            return String.CASE_INSENSITIVE_ORDER.compare(a.getName(), b.getName());
        }
    });

    // Load the chart visualisation
    Runnable loadGraph = new Runnable() {
        @Override
        public void run() {

            // Provide tab panel for graphs
            TabPanel tab = new TabPanel();
            tab.setWidth(width);
            tab.getTabBar().setWidth(width);
            tab.getDeckPanel().setWidth(width);
            StockGraphWidget.this.add(tab);

            // Load each graph onto a tab
            final StockGraph[] graphs = new StockGraph[orderedStocks.length];
            for (int i = 0; i < orderedStocks.length; i++) {
                Stock stock = orderedStocks[i];

                // Create the stock graph
                StockGraph graph = new StockGraph(stock, historyPeriod, redrawPeriod, width, height);
                graphs[i] = graph;

                // Add the stock graph
                tab.add(graph.getChart(), stock.getName());
            }

            // Provide the selection handler
            tab.addSelectionHandler(new SelectionHandler<Integer>() {
                @Override
                public void onSelection(SelectionEvent<Integer> event) {

                    // Unselect all graphs
                    for (StockGraph graph : graphs) {
                        graph.setSelected(false);
                    }

                    // Select the graph for the tab
                    Integer tabIndex = event.getSelectedItem();
                    graphs[tabIndex.intValue()].setSelected(true);
                }
            });

            // Display first tab selected (also sets up graph)
            tab.selectTab(0);
        }
    };
    VisualizationUtils.loadVisualizationApi(loadGraph, AnnotatedTimeLine.PACKAGE);
}

From source file:org.freemedsoftware.gwt.client.screen.PatientForm.java

License:Open Source License

public PatientForm() {
    final VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setWidth("100%");
    initWidget(verticalPanel);// w  w w  . j  a v  a  2  s  .c o m

    final CheckBox tabView = new CheckBox(_("Tab View"));
    tabView.setValue(true);

    verticalPanel.add(tabView);

    final TabPanel tabPanel = new TabPanel();
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            // TODO Auto-generated method stub
            if (event.getSelectedItem() == 0)
                title.setFocus(true);
            if (event.getSelectedItem() == 2)
                preferredContact.setFocus(true);
            if (event.getSelectedItem() == 3)
                martialStatus.setFocus(true);
            if (event.getSelectedItem() == 4)
                primaryFacility.setFocus(true);
        }
    });
    verticalPanel.add(tabPanel);

    final VerticalPanel nonTabViewContainer = new VerticalPanel();
    nonTabViewContainer.setWidth("100%");
    nonTabViewContainer.setVisible(false);
    verticalPanel.add(nonTabViewContainer);

    final FlexTable demographicsTable = new FlexTable();
    demographicsTable.setWidth("100%");
    tabPanel.add(demographicsTable, _("Demographics"));

    final Label titleLabel = new Label(_("Title"));
    demographicsTable.setWidget(0, 0, titleLabel);

    /*
    wTitle = new CustomListBox();
    demographicsTable.setWidget(0, 1, wTitle);
    wTitle.addItem("[Choose title]", "");
    wTitle.addItem("Mr");
    wTitle.addItem("Mrs");
    wTitle.addItem("Ms");
    wTitle.addItem("Dr");
    wTitle.addItem("Fr");
    wTitle.setVisibleItemCount(1);
    */
    title = new CustomRadioButtonGroup("title");
    title.setWidth("30%");
    demographicsTable.setWidget(0, 1, title);
    title.addItem("Mr");
    title.addItem("Mrs");
    title.addItem("Ms");
    title.addItem("Dr");
    title.addItem("Fr");

    final Label lastNameLabel = new Label(_("Last Name"));
    demographicsTable.setWidget(1, 0, lastNameLabel);

    wLastName = new TextBox();
    demographicsTable.setWidget(1, 1, wLastName);
    wLastName.setTabIndex(1);
    wLastName.setFocus(true);
    wLastName.setWidth("100%");
    wLastName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label firstNameLabel = new Label(_("First Name"));
    demographicsTable.setWidget(2, 0, firstNameLabel);

    wFirstName = new TextBox();
    demographicsTable.setWidget(2, 1, wFirstName);
    wFirstName.setTabIndex(2);
    wFirstName.setWidth("100%");
    wFirstName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label middleNameLabel = new Label(_("Middle Name"));
    demographicsTable.setWidget(3, 0, middleNameLabel);

    wMiddleName = new TextBox();
    demographicsTable.setWidget(3, 1, wMiddleName);
    wMiddleName.setTabIndex(3);
    wMiddleName.setWidth("100%");
    wMiddleName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label suffixLabel = new Label(_("Suffix"));
    demographicsTable.setWidget(4, 0, suffixLabel);

    /*
    wSuffix = new CustomListBox();
    demographicsTable.setWidget(4, 1, wSuffix);
    wSuffix.setTabIndex(4);
    wSuffix.addItem("[No Suffix]", "");
    wSuffix.addItem("Sr");
    wSuffix.addItem("Jr");
    wSuffix.addItem("II");
    wSuffix.addItem("III");
    wSuffix.addItem("IV");
    wSuffix.setVisibleItemCount(1);
    */

    suffix = new CustomRadioButtonGroup("suffix");
    suffix.setWidth("30%");
    demographicsTable.setWidget(4, 1, suffix);
    suffix.addItem("Sr");
    suffix.addItem("Jr");
    suffix.addItem("II");
    suffix.addItem("III");
    suffix.addItem("IV");

    final Label genderLabel = new Label(_("Gender"));
    demographicsTable.setWidget(5, 0, genderLabel);

    /*
    wGender = new CustomListBox();
    demographicsTable.setWidget(5, 1, wGender);
    wGender.setTabIndex(5);
    wGender.addItem("[Choose Value]", "");
    wGender.addItem("Male", "m");
    wGender.addItem("Female", "f");
    wGender.addItem("Transgendered", "t");
    wGender.setVisibleItemCount(1);
    */

    gender = new CustomRadioButtonGroup("gender");
    gender.setWidth("30%");
    demographicsTable.setWidget(5, 1, gender);
    gender.addItem(_("Male"), "m");
    gender.addItem(_("Female"), "f");
    gender.addItem(_("Transgendered"), "t");

    final Label dateOfBirthLabel = new Label(_("Date of Birth"));
    demographicsTable.setWidget(6, 0, dateOfBirthLabel);

    wDob = new CustomDatePicker();
    demographicsTable.setWidget(6, 1, wDob);
    // wDob.setTabIndex(6);

    addressContainer = new PatientAddresses();
    addressContainer.setWidth("100%");
    tabPanel.add(addressContainer, _("Address"));

    final FlexTable contactTable = new FlexTable();
    contactTable.setWidth("100%");
    tabPanel.add(contactTable, _("Contact"));

    final Label preferredContactLabel = new Label(_("Preferred Contact"));
    contactTable.setWidget(0, 0, preferredContactLabel);

    preferredContact = new CustomListBox();
    preferredContact.addItem(_("Home"), "home");
    preferredContact.addItem(_("Work"), "work");
    preferredContact.addItem(_("Mobile"), "mobile");
    preferredContact.addItem(_("Email"), "email");
    preferredContact.setVisibleItemCount(1);
    contactTable.setWidget(0, 1, preferredContact);

    final Label homePhoneLabel = new Label(_("Home Phone"));
    contactTable.setWidget(1, 0, homePhoneLabel);

    final Label workPhoneLabel = new Label(_("Work Phone"));
    contactTable.setWidget(2, 0, workPhoneLabel);

    final Label faxPhoneLabel = new Label(_("Fax Phone"));
    contactTable.setWidget(3, 0, faxPhoneLabel);

    final Label mobilePhoneLabel = new Label(_("Mobile Phone"));
    contactTable.setWidget(4, 0, mobilePhoneLabel);

    final Label emailAddressLabel = new Label(_("Email Address"));
    contactTable.setWidget(5, 0, emailAddressLabel);

    phoneHome = new TextBox();
    contactTable.setWidget(1, 1, phoneHome);
    phoneHome.setWidth("100%");

    phoneWork = new TextBox();
    contactTable.setWidget(2, 1, phoneWork);
    phoneWork.setWidth("100%");

    phoneFax = new TextBox();
    contactTable.setWidget(3, 1, phoneFax);
    phoneFax.setWidth("100%");

    phoneMobile = new TextBox();
    contactTable.setWidget(4, 1, phoneMobile);
    phoneMobile.setWidth("100%");

    emailAddress = new TextBox();
    contactTable.setWidget(5, 1, emailAddress);
    emailAddress.setWidth("100%");

    //creating personal tab
    final FlexTable personalTable = new FlexTable();
    personalTable.setWidth("100%");
    tabPanel.add(personalTable, _("Personal"));

    final Label martialStatusLabel = new Label(_("Marital Status"));
    personalTable.setWidget(0, 0, martialStatusLabel);

    martialStatus = new CustomRadioButtonGroup("martialStatus");
    martialStatus.addItem(_("Single"), "single");
    martialStatus.addItem(_("Married"), "married");
    martialStatus.addItem(_("Divorced"), "divorced");
    martialStatus.addItem(_("Separated"), "separated");
    martialStatus.addItem(_("Widowed"), "widowed");
    //      martialStatus.setVisibleItemCount(1);
    personalTable.setWidget(0, 1, martialStatus);

    final Label employmentStatusLabel = new Label(_("Employment Status"));
    personalTable.setWidget(1, 0, employmentStatusLabel);

    employmentStatus = new CustomListBox();
    employmentStatus.addItem(_("Yes"), "y");
    employmentStatus.addItem(_("No"), "n");
    employmentStatus.addItem(_("Part Time"), "p");
    employmentStatus.addItem(_("Self"), "s");
    employmentStatus.addItem(_("Retired"), "r");
    employmentStatus.addItem(_("Military"), "m");
    employmentStatus.addItem(_("Unknown"), "u");
    employmentStatus.setVisibleItemCount(1);
    personalTable.setWidget(1, 1, employmentStatus);

    final Label patientStatusLabel = new Label(_("Patient Status"));
    personalTable.setWidget(2, 0, patientStatusLabel);

    final Label patientStatusValueLabel = new Label(_("None"));
    personalTable.setWidget(2, 1, patientStatusValueLabel);

    final Label socialSecurityNumberLabel = new Label(_("Social Security Number"));
    personalTable.setWidget(3, 0, socialSecurityNumberLabel);

    socialSecurityNumber = new TextBox();
    personalTable.setWidget(3, 1, socialSecurityNumber);
    socialSecurityNumber.setWidth("100%");
    socialSecurityNumber.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label raceLabel = new Label(_("Race"));
    personalTable.setWidget(4, 0, raceLabel);

    race = new CustomListBox();
    race.addItem(_("Unknown race"), "7");
    race.addItem(_("Hispanic, white"), "1");
    race.addItem(_("Hispanic, black"), "2");
    race.addItem(_("American Indian or Alaska Native"), "3");
    race.addItem(_("Black, not of Hispanic origin"), "4");
    race.addItem(_("Asian or Pacific Islander"), "5");
    race.addItem(_("White, not of Hispanic origin"), "6");
    race.setVisibleItemCount(1);
    personalTable.setWidget(4, 1, race);

    final Label religionLabel = new Label(_("Religion"));
    personalTable.setWidget(5, 0, religionLabel);

    religion = new CustomListBox();
    religion.addItem(_("Unknown/No preference"), "29");
    religion.addItem(_("Catholic"), "0");
    religion.addItem(_("Jewish"), "1");
    religion.addItem(_("Eastern Orthodox"), "2");
    religion.addItem(_("Baptist"), "3");
    religion.addItem(_("Methodist"), "4");
    religion.addItem(_("Lutheran"), "5");
    religion.addItem(_("Presbyterian"), "6");
    religion.addItem(_("United Church of God"), "7");
    religion.addItem(_("Episcopalian"), "8");
    religion.addItem(_("Adventist"), "9");
    religion.addItem(_("Assembly of God"), "10");
    religion.addItem(_("Brethren"), "11");
    religion.addItem(_("Christian Scientist"), "12");
    religion.addItem(_("Church of Christ"), "13");
    religion.addItem(_("Church of God"), "14");
    religion.addItem(_("Disciples of Christ"), "15");
    religion.addItem(_("Evangelical Covenant"), "16");
    religion.addItem(_("Friends"), "17");
    religion.addItem(_("Jehovah's Witness"), "18");
    religion.addItem(_("Latter-Day Saints"), "19");
    religion.addItem(_("Islam"), "20");
    religion.addItem(_("Nazarene"), "21");
    religion.addItem(_("Other"), "22");
    religion.addItem(_("Pentecostal"), "23");
    religion.addItem(_("Protestant, Other"), "24");
    religion.addItem(_("Protestant, No Denomination"), "25");
    religion.addItem(_("Reformed"), "26");
    religion.addItem(_("Salvation Army"), "27");
    religion.addItem(_("Unitarian; Universalist"), "28");
    religion.addItem(_("Native American"), "30");
    religion.addItem(_("Buddhist"), "31");
    religion.setVisibleItemCount(1);
    personalTable.setWidget(5, 1, religion);

    final Label languageLabel = new Label(_("Language"));
    personalTable.setWidget(6, 0, languageLabel);
    languages = new CustomListBox();
    personalTable.setWidget(6, 1, languages);
    loadLanguages();

    final Label driverLicenceLabel = new Label(_("Driver's License (No State)"));
    personalTable.setWidget(7, 0, driverLicenceLabel);

    driverLicence = new TextBox();
    personalTable.setWidget(7, 1, driverLicence);
    driverLicence.setWidth("100%");

    final Label typeofBillingLabel = new Label(_("Type of Billing"));
    personalTable.setWidget(8, 0, typeofBillingLabel);

    typeofBilling = new CustomListBox();
    typeofBilling.addItem(_("NONE SELECTED"), "");
    typeofBilling.addItem(_("Monthly Billing On Account"), "mon");
    typeofBilling.addItem(_("Statement Billing"), "sta");
    typeofBilling.addItem(_("Charge Card Billing"), "chg");
    typeofBilling.setVisibleItemCount(1);
    personalTable.setWidget(8, 1, typeofBilling);

    final Label monthlyBudgetAmountLabel = new Label(_("Monthly Budget Amount"));
    personalTable.setWidget(9, 0, monthlyBudgetAmountLabel);

    monthlyBudgetAmount = new TextBox();
    personalTable.setWidget(9, 1, monthlyBudgetAmount);
    monthlyBudgetAmount.setWidth("100%");

    final Label patientPracticeIdLabel = new Label(_("Patient Practice ID"));
    personalTable.setWidget(10, 0, patientPracticeIdLabel);

    patientPracticeID = new TextBox();
    personalTable.setWidget(10, 1, patientPracticeID);
    patientPracticeID.setTabIndex(7);
    patientPracticeID.setWidth("100%");

    //creating Medical tab
    final FlexTable medicalTable = new FlexTable();
    medicalTable.setWidth("100%");
    tabPanel.add(medicalTable, _("Medical"));

    //      final Label bloodTypeLabel = new Label("Blood Type");
    //      medicalTable.setWidget(0, 0, bloodTypeLabel);
    //
    //      bloodType = new CustomListBox();
    //      bloodType.addItem("-","");
    //      bloodType.addItem("O","O");
    //      bloodType.addItem("O+","O+");
    //      bloodType.addItem("O-","O-");
    //      bloodType.addItem("A","A");
    //      bloodType.addItem("A+","A+");
    //      bloodType.addItem("A-","A-");
    //      bloodType.addItem("B","B");
    //      bloodType.addItem("B+","B+");
    //      bloodType.addItem("B-","B-");
    //      bloodType.addItem("AB","AB");
    //      bloodType.addItem("AB+","AB+");
    //      bloodType.addItem("AB-","AB-");
    //      bloodType.setVisibleItemCount(1);
    //      medicalTable.setWidget(0, 1, bloodType);

    final Label primaryFacilityLabel = new Label(_("Primary Facility"));
    medicalTable.setWidget(0, 0, primaryFacilityLabel);

    primaryFacility = new SupportModuleWidget("FacilityModule");
    medicalTable.setWidget(0, 1, primaryFacility);
    primaryFacility.setWidth("100%");

    final Label preferredPharmacyLabel = new Label(_("Preferred Pharmacy"));
    medicalTable.setWidget(1, 0, preferredPharmacyLabel);

    preferredPharmacy = new SupportModuleWidget("Pharmacy");
    medicalTable.setWidget(1, 1, preferredPharmacy);
    preferredPharmacy.setWidth("100%");

    final Label inHouseDoctorLabel = new Label(_("In House Doctor"));
    medicalTable.setWidget(2, 0, inHouseDoctorLabel);

    inHouseDoctor = new ProviderWidget();

    medicalTable.setWidget(2, 1, inHouseDoctor);
    inHouseDoctor.setWidth("100%");

    final Label referringDoctorLabel = new Label(_("Referring Doctor"));
    medicalTable.setWidget(3, 0, referringDoctorLabel);

    referringDoctor = new ProviderWidget();
    medicalTable.setWidget(3, 1, referringDoctor);
    referringDoctor.setWidth("100%");

    final Label primaryCarePhysicianLabel = new Label(_("Primary Care Physician"));
    medicalTable.setWidget(4, 0, primaryCarePhysicianLabel);

    primaryCarePhysician = new ProviderWidget();
    medicalTable.setWidget(4, 1, primaryCarePhysician);
    primaryCarePhysician.setWidth("100%");

    final Label numberofOtherPhysiciansLabel = new Label(_("Number of Other Physicians"));
    medicalTable.setWidget(5, 0, numberofOtherPhysiciansLabel);

    numberofOtherPhysicians = new CustomListBox();
    numberofOtherPhysicians.addItem("0", "0");
    numberofOtherPhysicians.addItem("1", "1");
    numberofOtherPhysicians.addItem("2", "2");
    numberofOtherPhysicians.addItem("3", "3");
    numberofOtherPhysicians.addItem("4", "4");
    numberofOtherPhysicians.setVisibleItemCount(1);
    medicalTable.setWidget(5, 1, numberofOtherPhysicians);

    numberofOtherPhysicians.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            // TODO Auto-generated method stub
            int selectedCount = Integer
                    .parseInt(numberofOtherPhysicians.getValue(numberofOtherPhysicians.getSelectedIndex()));
            updateOtherPhysiciansBoxes(selectedCount);
        }

    });

    otherPhysician1Label = new Label(_("Physician 1"));
    medicalTable.setWidget(6, 0, otherPhysician1Label);
    otherPhysician1 = new ProviderWidget();
    medicalTable.setWidget(6, 1, otherPhysician1);

    otherPhysician2Label = new Label(_("Physician 2"));
    medicalTable.setWidget(7, 0, otherPhysician2Label);
    otherPhysician2 = new ProviderWidget();
    medicalTable.setWidget(7, 1, otherPhysician2);

    otherPhysician3Label = new Label(_("Physician 3"));
    medicalTable.setWidget(8, 0, otherPhysician3Label);
    otherPhysician3 = new ProviderWidget();
    medicalTable.setWidget(8, 1, otherPhysician3);

    otherPhysician4Label = new Label(_("Physician 4"));
    medicalTable.setWidget(9, 0, otherPhysician4Label);
    otherPhysician4 = new ProviderWidget();
    medicalTable.setWidget(9, 1, otherPhysician4);

    updateOtherPhysiciansBoxes(0);

    // Select first tab "demographics" as active tag
    tabPanel.selectTab(0);

    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_CENTER);
    //      horizontalPanel.setWidth("100%");

    submitButton = new CustomButton(_("Commit"), AppConstants.ICON_ADD);
    horizontalPanel.add(submitButton);
    submitButton.addClickHandler(new ClickHandler() {
        @SuppressWarnings({ "rawtypes", "unchecked" })
        @Override
        public void onClick(ClickEvent evt) {
            //            submitButton.setEnabled(false);
            if (validateForm()) {
                if (patientId == null || patientId == 0) {
                    List params = new ArrayList();
                    HashMap<String, String> criteria = new HashMap<String, String>();
                    criteria.put("ptlname", (String) wLastName.getText());
                    criteria.put("ptfname", (String) wFirstName.getText());
                    criteria.put("ptdob", (String) wDob.getStoredValue());
                    params.add(criteria);

                    Util.callApiMethod("PatientInterface", "GetDuplicatePatients", params,
                            new CustomRequestCallback() {

                                @Override
                                public void onError() {
                                    //                     submitButton.setEnabled(true);
                                }

                                @Override
                                public void jsonifiedData(Object data) {
                                    HashMap<String, String> result = (HashMap<String, String>) data;
                                    if (result == null || result.size() == 0)
                                        commitChanges();
                                    else {
                                        String msg = _(
                                                "This patient is already in the system. Do you want to continue adding?");
                                        Util.confirm(msg, new Command() {

                                            @Override
                                            public void execute() {
                                                commitChanges();
                                            }
                                        }, null);
                                    }
                                }
                            }, "HashMap<String,String>");

                } else
                    commitChanges();
            }
        }
    });

    CustomButton cancelButton = new CustomButton(_("Cancel"), AppConstants.ICON_CANCEL);
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            // TODO Auto-generated method stub
            try {
                closeScreen();
            } catch (Exception e) {
            }

            if (patientId != 0)
                spawnPatientScreen(patientId);
        }
    });
    horizontalPanel.add(cancelButton);

    if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.SHOW)) {
        patientCoverages = new PatientCoverages();
        patientCoverages.setWidth("100%");
        tabPanel.add(patientCoverages, _("Coverages"));
    }
    if (CurrentState.isActionAllowed(AuthorizationsModuleName, AppConstants.SHOW)) {
        patientAuthorizations = new PatientAuthorizations();
        patientAuthorizations.setWidth("100%");
        tabPanel.add(patientAuthorizations, _("Authorizations"));
    }

    tabView.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
            if (arg0.getValue()) {
                tabPanel.clear();
                //Adding Demographics
                tabPanel.add(demographicsTable, _("Demographics"));
                //Adding Address
                tabPanel.add(addressContainer, _("Address"));
                //Adding Contact
                tabPanel.add(contactTable, _("Contact"));
                //Adding Personal
                tabPanel.add(personalTable, _("Personal"));
                //Adding Medical
                tabPanel.add(medicalTable, _("Medical"));
                //Adding Coverages
                tabPanel.add(patientCoverages, _("Coverages"));
                //Adding Authorizations
                tabPanel.add(patientAuthorizations, _("Authorizations"));

                nonTabViewContainer.setVisible(false);
                tabPanel.setVisible(true);
                tabPanel.selectTab(0);
            } else {
                nonTabViewContainer.clear();
                //Adding Demographics
                Label label = new Label(_("Demographics"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(demographicsTable);
                demographicsTable.setWidth("100%");

                //Adding Address
                label = new Label(_("Address"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(addressContainer);
                addressContainer.setWidth("100%");

                //Adding Contact
                label = new Label(_("Contact"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(contactTable);
                contactTable.setWidth("100%");

                //Adding Personal
                label = new Label(_("Personal"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(personalTable);
                personalTable.setWidth("100%");

                //Adding Medical
                label = new Label(_("Medical"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(medicalTable);
                medicalTable.setWidth("100%");

                //Adding Coverages
                label = new Label(_("Coverages"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(patientCoverages);
                patientCoverages.setWidth("100%");

                //Adding Authorizations
                label = new Label("Authorizations");
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(patientAuthorizations);
                patientAuthorizations.setWidth("100%");

                tabPanel.setVisible(false);
                nonTabViewContainer.setVisible(true);
            }

        }

    });

    Util.setFocus(title);
}

From source file:org.jboss.as.console.client.shared.subsys.jca.wizard.DatasourceStep2.java

License:Open Source License

Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.getElement().setAttribute("style", "margin:10px; vertical-align:center;width:95%");

    HTML desc = new HTML("<h3>" + Console.CONSTANTS.subsys_jca_dataSource_step2() + "</h3>");
    desc.getElement().setAttribute("style", "padding-bottom:10px;");

    layout.add(desc);//from ww  w  . jav  a2s.c  o m
    layout.add(new ContentDescription("Select one of the deployed JDBC driver."));

    // ---

    table = new DefaultCellTable<JDBCDriver>(5);

    TextColumn<JDBCDriver> nameColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getName();
        }
    };

    TextColumn<JDBCDriver> groupColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getGroup();
        }
    };

    table.addColumn(nameColumn, "Name");

    if (!isStandalone)
        table.addColumn(groupColumn, "Server Group");

    selectionModel = new SingleSelectionModel<JDBCDriver>();
    table.setSelectionModel(selectionModel);

    provisionTable(table);

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    VerticalPanel driverPanel = new VerticalPanel();
    driverPanel.add(table);
    driverPanel.add(pager);

    // --

    final Form<JDBCDriver> form = new Form<JDBCDriver>(JDBCDriver.class);
    TextBoxItem name = new TextBoxItem("name", "Name");
    TextBoxItem driverClass = new TextBoxItem("driverClass", "Driver Class");
    NumberBoxItem major = new NumberBoxItem("majorVersion", "Major Version");
    NumberBoxItem minor = new NumberBoxItem("minorVersion", "Minor Version");

    form.setFields(name, driverClass, major, minor);

    // --

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            selectedTab = event.getSelectedItem();
        }
    });

    tabs.add(driverPanel, "Chose Driver");
    //tabs.add(form.asWidget(), "Specify Driver");

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

    // ----

    ClickHandler submitHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            JDBCDriver driver = null;

            if (selectedTab == 0) {
                // reset state
                form.clearValues();

                SingleSelectionModel<JDBCDriver> selection = (SingleSelectionModel<JDBCDriver>) table
                        .getSelectionModel();
                driver = selection.getSelectedObject();
            } else {
                FormValidation formValidation = form.validate();
                if (!formValidation.hasErrors()) {
                    driver = form.getUpdatedEntity();
                }
            }

            if (driver != null) { // force selected driver
                editedEntity.setDriverName(driver.getName());
                editedEntity.setDriverClass(driver.getDriverClass());
                editedEntity.setMajorVersion(driver.getMajorVersion());
                editedEntity.setMinorVersion(driver.getMinorVersion());

                wizard.onConfigureDriver(editedEntity);
            } else {
                Console.warning(Console.CONSTANTS.subsys_jca_dataSource_select_driver(),
                        "If no driver is available you may need to deploy one!");
            }

        }
    };

    ClickHandler cancelHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            wizard.getPresenter().closeDialogue();
        }
    };

    DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_next(), submitHandler,
            Console.CONSTANTS.common_label_cancel(), cancelHandler);

    return new WindowContentBuilder(layout, options).build();
}

From source file:org.jboss.as.console.client.shared.subsys.jca.wizard.DriverStep.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
protected Widget asWidget(final Context<T> context) {
    // first tab: driver form
    form = new Form<>(JDBCDriver.class);
    TextBoxItem driverName = new TextBoxItem("name", "Name", true);
    TextBoxItem moduleName = new TextBoxItem("driverModuleName", "Module Name", true);
    TextBoxItem driverClass = new TextBoxItem("driverClass", "Driver Class", false);
    TextBoxItem xaDataSource = new TextBoxItem("xaDataSourceClass", "XA DataSource Class", false);
    if (context.xa) {
        form.setFields(driverName, moduleName, driverClass, xaDataSource);
    } else {/*from   ww  w.j a va 2s.c o m*/
        form.setFields(driverName, moduleName, driverClass);
    }

    FlowPanel formPanel = new FlowPanel();
    formPanel.add(new FormHelpPanel(context.jdbcDriverHelp, form).asWidget());
    formPanel.add(form);

    // second tab: existing drivers
    table = new DefaultCellTable<>(5);
    TextColumn<JDBCDriver> nameColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getName();
        }
    };
    TextColumn<JDBCDriver> moduleColumn = new TextColumn<JDBCDriver>() {
        @Override
        public String getValue(JDBCDriver record) {
            return record.getDriverModuleName();
        }
    };
    table.addColumn(nameColumn, "Name");
    if (!context.standalone) {
        table.addColumn(moduleColumn, "Module");
    }
    selectionModel = new SingleSelectionModel<>();
    table.setSelectionModel(selectionModel);
    provisionTable(table);

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    FlowPanel driverPanel = new FlowPanel();
    driverPanel.add(table);
    driverPanel.add(pager);

    // tabs
    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addSelectionHandler(event -> selectedTab = event.getSelectedItem());
    tabs.add(formPanel, "Specify Driver");
    tabs.add(driverPanel, "Detected Driver");

    // body
    FlowPanel body = new FlowPanel();
    body.add(new ContentDescription(
            "Select one of the installed JDBC drivers. If you do not see your driver, make sure that it is deployed as a module and properly registered."));
    body.add(tabs);
    tabs.selectTab(0);

    return body;
}

From source file:org.opendatakit.aggregate.client.AggregateUI.java

License:Apache License

void setSubMenuSelectionHandler(final TabPanel menuTab, final Tabs menu, final SubTabs[] subMenus) {
    // add the mainNav selection handler for this menu...
    mainNav.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override/*from www  .  jav  a 2  s  . c o  m*/
        public void onSelection(SelectionEvent<Integer> event) {
            if (userInfo == null) {
                GWT.log("getSubMenuSelectionHandler: No userInfo - not setting selection");
                return;
            }

            int selected = event.getSelectedItem();
            String tabHash = menu.getHashString();

            Tabs tab = tabPosition.get(selected);

            if (tab == null) {
                return;
            }

            if (tabHash.equals(tab.getHashString())) {

                if (!authorizedForTab(tab)) {
                    return;
                }

                // and select the appropriate subtab...
                AggregateTabBase tabObj = tabMap.get(menu);
                if (tabObj != null) {
                    tabObj.selectTab(tabObj.findSubTabIndexFromHash(hash));
                }
            }
        }
    });

    menuTab.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {

        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            // allow the currently-selected SubTab to refuse the tab selection.
            // refusal should only occur after user confirmation.
            if (!getTimer().canLeaveCurrentSubTab()) {
                event.cancel();
            }
        }

    });

    menuTab.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            if (userInfo == null) {
                GWT.log("getSubMenuSelectionHandler: No userInfo - not setting subMenu selection");
                return;
            }
            int selected = event.getSelectedItem();
            clearError();
            hash.clear();
            hash.set(UrlHash.MAIN_MENU, menu.getHashString());
            hash.set(UrlHash.SUB_MENU, subMenus[selected].getHashString());
            getTimer().setCurrentSubTab(subMenus[selected]);
            hash.put();
            changeHelpPanel(subMenus[selected]);
        }
    });
}

From source file:org.pentaho.ui.xul.gwt.widgets.GwtTabWidget.java

License:Open Source License

public GwtTabWidget(String text, String tooltip, final TabPanel tabPanel, final Widget tabContent) {
    this.tabPanel = tabPanel;
    this.tabContent = tabContent;
    this.fullText = text;
    setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panel.setStyleName("pentaho-tabWidget"); //$NON-NLS-1$
    Image leftCapImage = new Image(GWT.getModuleBaseURL() + "images/spacer.gif");
    leftCapImage.setStylePrimaryName("tab-spacer");

    setLabelText(text);//  www . j  a v  a2s . c  om
    setLabelTooltip(tooltip);
    textLabel.setStyleName("pentaho-tabWidgetLabel");
    textLabel.setWordWrap(false);
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {

        public void onSelection(SelectionEvent<Integer> event) {
            int tabIndex = event.getSelectedItem();
            ElementUtils.blur(getElement().getParentElement());
            if (tabIndex == tabPanel.getWidgetIndex(tabContent)) {
                panel.addStyleName("pentaho-tabWidget-selected"); //$NON-NLS-1$
            } else {
                panel.removeStyleName("pentaho-tabWidget-selected"); //$NON-NLS-1$
            }
        }
    });

    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panel.add(textLabel);
    add(leftCapImage);
    leftCapImage.getElement().getParentElement().setAttribute("class", "tab-spacer-wrapper");
    add(panel);
    sinkEvents(Event.ONDBLCLICK | Event.ONMOUSEUP);
}

From source file:org.sonar.plugins.core.ui.pageselector.client.PageSelector.java

License:Open Source License

private void displayResource(final Resource resource) {
    List<PageDef> pages = selectPages(resource);

    PageDef selectedPage = selectPage(pages);

    Title title = new Title(resource);
    final TabPanel tabs = new TabPanel();
    tabs.setWidth("100%");

    int selectedTabIndex = -1;
    for (int tabIndex = 0; tabIndex < pages.size(); tabIndex++) {
        PageDef page = pages.get(tabIndex);
        tabs.add(new PagePanel(page), page.getName());
        if (page == selectedPage) {
            selectedTabIndex = tabIndex;
        }//w w w.  j a va  2s.co m
    }

    container.clear(); // remove the loading icon
    container.add(title);
    container.add(tabs);

    tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> tabId) {
            ((PagePanel) tabs.getWidget(tabId.getSelectedItem())).display();
        }
    });

    if (selectedTabIndex > -1) {
        tabs.selectTab(selectedTabIndex);
    }
}

From source file:org.xwiki.gwt.wysiwyg.client.WysiwygEditor.java

License:Open Source License

/**
 * Build the editor tab panel. This panel contains two tabs, one for the WYSIWYG editor and one for the source
 * editor./*from ww w.ja v  a2 s  .  c om*/
 * 
 * @return the newly created tab panel
 */
private TabPanel createTabPanel() {
    PlainTextEditor plainTextEditor = new PlainTextEditor(config.getHook());

    TabPanel tabs = new TabPanel();
    tabs.add(getRichTextEditor(), Strings.INSTANCE.wysiwyg());
    tabs.add(plainTextEditor, Strings.INSTANCE.source());
    tabs.setStyleName("xRichTextEditorTabPanel");
    tabs.setAnimationEnabled(false);
    tabs.selectTab(config.getSelectedTabIndex());

    // Enable the appropriate text area based on the type of input (source or HTML).
    boolean richTextAreaEnabled = config.isInputConverted();
    plainTextEditor.getTextArea().setEnabled(!richTextAreaEnabled);
    getRichTextEditor().getTextArea().setEnabled(richTextAreaEnabled);

    saveRegistration(tabs.addBeforeSelectionHandler(switcher));
    saveRegistration(tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            // Cache the active text area.
            config.setSelectedTabIndex(event.getSelectedItem());
        }
    }));
    saveRegistration(tabs.addSelectionHandler(switcher));

    return tabs;
}