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

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

Introduction

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

Prototype

public void selectTab(int index) 

Source Link

Document

Programmatically selects the specified tab and fires events.

Usage

From source file:com.google.gwt.sample.simplexml.client.SimpleXML.java

License:Apache License

private void renderXML(String xmlText) {
    final TabPanel tab = new TabPanel();
    final FlowPanel xmlSource = new FlowPanel();
    final FlowPanel xmlParsed = new FlowPanel();
    tab.add(xmlParsed, "Customer Pane");
    tab.add(xmlSource, "XML Source");
    tab.selectTab(0);
    RootPanel.get().add(tab);/*from  w  ww  . j  ava 2 s  .  c om*/
    xmlPane(xmlText, xmlSource);
    customerPane(xmlText, xmlParsed);
}

From source file:com.GTDF.client.GWT_Transxchange2GoogleTransit.java

License:Apache License

public void onModuleLoad() {

    String wikiUserName = readUsername();

    //Service Start
    final TextBox textBoxServiceStartGz = new TextBox();

    TabPanel tabs = new TabPanel();
    tabs.setStyleName(".gwt-TabBar");

    tabs.setWidth("100%");
    tabs.setHeight("100%");

    //-------------------------EDJ ----------------
    DockPanel dock = new DockPanel();
    dock.setSize("663px", "220px");
    dock.setStyleName("gwt-TabBar");
    VerticalPanel TransformWindow = new VerticalPanel();
    TransformWindow.setStyleName("weather-input-panel");

    //Agency URL/*from   ww  w  .  j a va2  s .com*/
    HorizontalPanel AgencyURL = new HorizontalPanel();
    Label url_lbl = new Label("Agency URL:");
    url_lbl.setWidth("90");
    final TextBox textBoxUrl = new TextBox();
    textBoxUrl.setText("http://www.agency.org");
    textBoxUrl.setVisibleLength(40);
    AgencyURL.add(url_lbl);
    AgencyURL.add(textBoxUrl);
    //-----------

    //Route Type
    HorizontalPanel RType = new HorizontalPanel();
    Label rt_lbl = new Label("Route Type:");
    rt_lbl.setWidth("90");
    final ListBox listBoxDefaultRouteType = new ListBox();
    listBoxDefaultRouteType.setVisibleItemCount(1);
    listBoxDefaultRouteType.addItem("Tram");
    listBoxDefaultRouteType.addItem("Subway");
    listBoxDefaultRouteType.addItem("Rail");
    listBoxDefaultRouteType.addItem("Bus");
    listBoxDefaultRouteType.addItem("Ferry");
    listBoxDefaultRouteType.addItem("Cable car");
    listBoxDefaultRouteType.addItem("Gondola");
    listBoxDefaultRouteType.addItem("Funicular");
    listBoxDefaultRouteType.setSelectedIndex(0);
    RType.add(rt_lbl);
    RType.add(listBoxDefaultRouteType);
    //-----------

    //Time Zone
    VerticalPanel TZ = new VerticalPanel();
    Label tz_lbl = new Label("Time Zone:");
    tz_lbl.setWidth("90");

    HorizontalPanel Continent = new HorizontalPanel();
    Label continent_lbl = new Label("Continent:");
    continent_lbl.setWidth("90");
    final ListBox listBoxTimezoneP = new ListBox();
    listBoxTimezoneP.addItem("Africa");
    listBoxTimezoneP.addItem("America");
    listBoxTimezoneP.addItem("Antarctica");
    listBoxTimezoneP.addItem("Artic");
    listBoxTimezoneP.addItem("Asia");
    listBoxTimezoneP.addItem("Atlantic");
    listBoxTimezoneP.addItem("Australia");
    listBoxTimezoneP.addItem("Europe");
    listBoxTimezoneP.addItem("Indian");
    listBoxTimezoneP.addItem("Pacific");
    listBoxTimezoneP.setVisibleItemCount(1);
    listBoxTimezoneP.setSelectedIndex(0);

    Continent.add(continent_lbl);
    Continent.add(listBoxTimezoneP);

    HorizontalPanel Region = new HorizontalPanel();
    Label region_lbl = new Label("Region:");
    region_lbl.setWidth("90");
    final ListBox listBoxTimezoneS = new ListBox();
    switchTimezone(listBoxTimezoneS, 0);
    Region.add(region_lbl);
    Region.add(listBoxTimezoneS);

    TZ.add(tz_lbl);
    TZ.add(Continent);
    TZ.add(Region);
    //-----------

    Button dialogButton = new Button("Show Dialog", new ClickListener() {
        public void onClick(Widget sender) {
            //EDJ
            DialogBox dlg = new MyDialog();
            int left = 120;
            int top = 300;
            dlg.setPopupPosition(left, top);
            dlg.show();
        }
    });

    final Label labelOutdir = new Label(); // Displays wikiuser
    final Label labelResultGz = new Label();
    final Label labelResult = new Label();
    final Label labelResultUser = new Label();

    final FormPanel uploadFormGz = new FormPanel();
    uploadFormGz.setAction(GWT.getModuleBaseURL() + "upload");
    uploadFormGz.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadFormGz.setMethod(FormPanel.METHOD_POST);
    //Upload
    final HorizontalPanel uploadPanelGz = new HorizontalPanel();
    Label upload_lbl = new Label("Upload File:");
    upload_lbl.setWidth("90");
    uploadPanelGz.add(upload_lbl);
    //uploadPanelGz.add(upload_tb);
    //uploadPanelGz.add(upload_btn);
    //--------------

    // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table
    final Hidden hwGz = new Hidden("username", wikiUserName);
    uploadPanelGz.add(hwGz);

    // Add hidden widget to pass service start to FileUploadServlet
    final Hidden ssGz = new Hidden("prefix");
    uploadPanelGz.add(ssGz);

    final FileUpload uploadGz = new FileUpload();
    uploadGz.setName("uploadFormElement");
    uploadPanelGz.add(uploadGz);

    //final VerticalPanel uploadPanelGz = new VerticalPanel();
    uploadFormGz.setWidget(uploadPanelGz);

    /*
     * Add Transxchange2GoogleTransit file upload
     */
    final FormPanel uploadForm = new FormPanel();
    uploadForm.setAction(GWT.getModuleBaseURL() + "upload");
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);
    final VerticalPanel uploadPanel = new VerticalPanel();
    uploadForm.setWidget(uploadPanel);

    // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table
    final Hidden hw = new Hidden("username", wikiUserName);
    uploadPanel.add(hw);

    final FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    uploadPanel.add(upload);

    /*
    * Verify user and enable action buttons if user exists
    */
    WikiUserServiceAsync wikiUserService = (WikiUserServiceAsync) GWT.create(WikiUserService.class);

    ServiceDefTarget endpoint = (ServiceDefTarget) wikiUserService;
    String moduleRelativeURL = GWT.getModuleBaseURL() + "WikiUser";
    endpoint.setServiceEntryPoint(moduleRelativeURL);

    AsyncCallback callback = new AsyncCallback() {
        public void onSuccess(Object result) {
            Button buttonGz = new Button("Upload", new ClickListener() {
                public void onClick(Widget sender) {
                    // Extract service start and pass as prefix
                    String serviceStart = textBoxServiceStartGz.getText();
                    ssGz.setValue(serviceStart);
                    // Upload selected infile to server
                    uploadFormGz.submit();

                    //EDJ
                    DialogBox dlg = new MyDialog();
                    int left = 120;
                    int top = 300;
                    dlg.setPopupPosition(left, top);
                    dlg.show();
                }
            });
            Button button = new Button("Transform", new ClickListener() {
                public void onClick(Widget sender) {
                    // Upload selected infile to server
                    uploadForm.submit();
                }
            });

            if (result != "LOGGED") {
                button.setEnabled(false);
                buttonGz.setEnabled(false);
                labelResultUser.setText((String) result);
            }
            uploadPanel.add(button);
            uploadPanelGz.add(buttonGz);
        }

        public void onFailure(Throwable caught) {
            try {
                throw caught;
            } catch (InvocationException e) {
                labelResult.setText("InvocationException: " + e.getMessage());
            } catch (Throwable e) {
                labelResult.setText("callback failed: " + e.getMessage());
            }
        }
    };
    wikiUserService.wikiUserVerify(wikiUserName, callback);

    /*
     * Upload google_transit.zip file
     */
    uploadFormGz.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {

            labelResultGz.setText((String) event.getResults());

        }

        public void onSubmit(FormSubmitEvent event) {
            // Upload infile to server
            String inFilename = uploadGz.getFilename();
            if (inFilename.length() == 0) {
                Window.alert("Infile required");
                return;
            }
        }
    });

    /*
     * Upload TransXChange file and call Transxchange2GoogleTransit servlet when "transform" button is pushed
     */
    uploadForm.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {

            labelResult.setText((String) event.getResults());

            // Start transformation
            String parseArgs = upload.getFilename();
            parseArgs = parseArgs + " " + textBoxUrl.getText();
            parseArgs = parseArgs + " " + listBoxTimezoneP.getItemText(listBoxTimezoneP.getSelectedIndex());
            String helpString = listBoxTimezoneS.getItemText(listBoxTimezoneS.getSelectedIndex());
            parseArgs = parseArgs + "/" + helpString.substring(0, helpString.indexOf(' '));
            parseArgs = parseArgs + " " + listBoxDefaultRouteType.getSelectedIndex();
            parseArgs = parseArgs + " " + labelOutdir.getText();

            // call server through GWT asynchronous RPC
            Transxchange2GoogleTransitServiceAsync transxchange2GoogleTransitService = (Transxchange2GoogleTransitServiceAsync) GWT
                    .create(Transxchange2GoogleTransitService.class);

            ServiceDefTarget endpoint = (ServiceDefTarget) transxchange2GoogleTransitService;
            String moduleRelativeURL = GWT.getModuleBaseURL() + "GTDF";
            endpoint.setServiceEntryPoint(moduleRelativeURL);

            AsyncCallback callback = new AsyncCallback() {
                public void onSuccess(Object result) {
                    labelResult.setText((String) result);
                }

                public void onFailure(Throwable caught) {
                    try {
                        throw caught;
                    } catch (InvocationException e) {
                        labelResult.setText("InvocationException: " + e.getMessage());
                    } catch (Throwable e) {
                        labelResult.setText("callback failed: " + e.getMessage());
                    }
                }
            };
            transxchange2GoogleTransitService.transxchange2GoogleTransit_transform(parseArgs, callback);
        }

        public void onSubmit(FormSubmitEvent event) {
            // Upload infile to server
            String inFilename = upload.getFilename();
            if (inFilename.length() == 0) {
                Window.alert("Infile required");
                return;
            }
        }
    });

    /*
     * Add UI elements
     *       Better practice (for future reference): use CSS
     */
    TransformWindow.add(AgencyURL);
    TransformWindow.add(RType);
    TransformWindow.add(TZ);
    TransformWindow.add(uploadPanelGz);
    TransformWindow.add(uploadPanel);
    TransformWindow.add(dialogButton);
    tabs.add(TransformWindow, "TransXChange");
    //tabs.add(TZ, "Transformation2");
    tabs.selectTab(0);
    dock.add(tabs, DockPanel.CENTER);
    RootPanel.get("tab_area").add(dock);

    /*
    RootPanel.get("gz_servicestart").add(textBoxServiceStartGz);    
     RootPanel.get("gz_infile").add(uploadFormGz);    
    RootPanel.get("url").add(textBoxUrl);
    RootPanel.get("timezoneP").add(listBoxTimezoneP);
    RootPanel.get("timezoneS").add(listBoxTimezoneS);
    RootPanel.get("defaultroutetype").add(listBoxDefaultRouteType);
    RootPanel.get("outdir").add(labelOutdir);
    labelOutdir.setText(wikiUserName);
    RootPanel.get("user_result").add(labelResultUser);
    RootPanel.get("gz_result").add(labelResultGz);
    RootPanel.get("result").add(labelResult);
     RootPanel.get("infile").add(uploadForm);    */

    // Primary time zone (Africa, Europe, ...) selected
    listBoxTimezoneP.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            switchTimezone(listBoxTimezoneS, listBoxTimezoneP.getSelectedIndex());
        }
    });

    //----------------------------------------------------------------------------------------------
    //----------------------------------------EDJ---------------------------------------------------

}

From source file:com.kafecho.stweetmap.client.StweetMap.java

License:Apache License

private void buildUI() {
    RootPanel root = RootPanel.get();//w w  w  . ja  va2s  .c  om

    FlowPanel mainPanel = new FlowPanel();
    mainPanel.addStyleName("mainPanel");
    root.add(mainPanel);

    FlowPanel title = new FlowPanel();
    title.addStyleName("title");

    title.add(new HTML(
            "<span id='applicationName'>sTweetMap</span><span id='applicationDescription'>Put tweets on the map</span>"));

    searchInputPanel = new SearchInputPanel();
    searchResultsPanel = new FlowPanel();
    searchResultsPanel.addStyleName("searchResultsPanel");

    searchInputPanel.getQuery().addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                if (!searchInputPanel.getQuery().getText().isEmpty()) {
                    doSearch();
                }
            }
        }
    });

    searchInputPanel.getSearch().addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            doSearch();
        }
    });

    mainPanel.add(title);

    TabPanel tabPanel = new TabPanel();
    mainPanel.add(searchInputPanel);
    mainPanel.add(tabPanel);

    FlowPanel bottomPanel = new FlowPanel();

    HTML stweetMapOnGitHub = new HTML(
            "<a target = '_blank' href='http://github.com/kafecho/StweetMap'>Get the code from GitHub</a>");
    stweetMapOnGitHub.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    mainPanel.add(bottomPanel);
    bottomPanel.add(stweetMapOnGitHub);
    bottomPanel.addStyleName("bottomPanel");

    tabPanel.setWidth("100%");

    googleMapView = new GoogleMapPopupPanel(400, 400, 8);

    FlowPanel googleMapPanelContainer = new FlowPanel();
    tabPanel.add(googleMapPanelContainer, "map");
    tabPanel.add(searchResultsPanel, "tweets");

    googleMapPanel = new GoogleMapPanel(googleMapPanelContainer, 800, 400, 2);
    tabPanel.selectTab(0);
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Shows a popup to select a color for the background or the stroke.
 * The popup contains a TabPanel with 3 tab, a <code>ColorChooser</code>,
 *  a <code>Slider</code> to change the opacity of the <code>Color</code>,
 *  some <code>Pattern</code> to apply
 *///ww  w .jav a2 s  .co  m
private void showPopupColor(Widget sender) {

    final PopupPanel popupColor = new PopupPanel(true);
    popupColor.addStyleName("GfxDemo-popupColor");
    TabPanel tabPanel = new TabPanel();
    FlowPanel colPanel = new FlowPanel();

    final CheckBox checkFill = new CheckBox("Background");
    checkFill.setChecked(true);
    colPanel.add(checkFill);

    final ColorChooser colorChooser = new ColorChooser();

    colPanel.add(colorChooser);

    tabPanel.add(colPanel, new Label("Color"));

    ChangeListener colorChange = new ChangeListener() {
        public void onChange(Widget sender) {
            String color = colorChooser.getColor();
            Color colorSelected = Color.getColor(color);
            if (checkFill.isChecked()) {
                currentFillColor = colorSelected;
                DOM.setStyleAttribute(fill.getElement(), "backgroundColor", color);
                //currentFillColor.setAlpha(opacity.getValue());
                if (current != null) {
                    current.setFillColor(currentFillColor);
                }
            } else {
                currentStrokeColor = colorSelected;
                lastStrokeColor = currentStrokeColor;
                DOM.setStyleAttribute(fill.getElement(), "borderColor", color);
                if (current != null) {

                    current.setStroke(currentStrokeColor, 1);
                }
            }
        }
    };
    colorChooser.addChangeListener(colorChange);

    FlowPanel patternContainer = new FlowPanel();

    patternContainer.add(createImagePattern("gfx/none.gif"));
    patternContainer.add(createImagePattern("littleNero.png"));
    patternContainer.add(createImagePattern("littleTrajan.png"));
    patternContainer.add(createImagePattern("cubic.jpg"));
    patternContainer.add(createImagePattern("logo_ft.gif"));
    patternContainer.add(createImagePattern("od-logo.jpg"));
    tabPanel.add(patternContainer, new Label("Pattern"));
    tabPanel.add(this.opacity, new Label("Opacity"));

    tabPanel.selectTab(0);
    popupColor.add(tabPanel);
    popupColor.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
    popupColor.show();
}

From source file:com.ponysdk.ui.terminal.ui.PTTabPanel.java

License:Apache License

@Override
public void add(final PTInstruction add, final UIService uiService) {

    final Widget w = asWidget(add.getObjectID(), uiService);
    final TabPanel tabPanel = uiObject;

    final int beforeIndex = add.getInt(PROPERTY.BEFORE_INDEX);

    if (add.containsKey(PROPERTY.TAB_TEXT)) {
        tabPanel.insert(w, add.getString(PROPERTY.TAB_TEXT), beforeIndex);
    } else if (add.containsKey(PROPERTY.TAB_WIDGET)) {
        final PTWidget<?> ptWidget = (PTWidget<?>) uiService.getPTObject(add.getLong(PROPERTY.TAB_WIDGET));
        tabPanel.insert(w, ptWidget.cast(), beforeIndex);
    }//from  www. ja  va2s  . c  o  m

    if (tabPanel.getWidgetCount() == 1) {
        tabPanel.selectTab(0);
    }
}

From source file:com.qualogy.qafe.gwt.client.factory.MainFactory.java

License:Apache License

public static void createTryMeWindow(String subwindow) {

    final WindowPanel w = new WindowPanel("Try me!");

    w.setResizable(true);//  w  w  w  .  j a  v a  2  s .c o m

    w.setAnimationEnabled(true);
    w.setSize("800px", "500px");

    VerticalPanel verticalPanel = new VerticalPanel();
    final ScrollLayoutPanel vp = new ScrollLayoutPanel();
    vp.setAlwaysShowScrollBars(false);
    vp.setWidth("800px");
    vp.setHeight("500px");
    w.setWidget(verticalPanel);
    // vp.setSpacing(5);
    // vp.setWidth("100%");
    final TabPanel tabPanel = new TabPanel();
    tabPanel.setAnimationEnabled(true);
    tabPanel.setWidth("580px");
    tabPanel.setHeight("500px");

    DockPanel dockPanel = new DockPanel();
    dockPanel.setWidth("580px");
    dockPanel.setHeight("500px");
    tabPanel.add(dockPanel, "Insert code!");
    final TextArea textArea = new TextArea();
    textArea.setVisibleLines(30);
    textArea.setHeight("auto");
    textArea.setWidth("580px");
    DOM.setElementAttribute(textArea.getElement(), "font-size", "10pt");

    dockPanel.add(textArea, DockPanel.CENTER);
    final MenuBar menu = new MenuBar();
    MenuBar renderMenu = new MenuBar(true);
    w.addResizeHandler(new ResizeHandler() {

        public void onResize(ResizeEvent event) {
            int height = event.getHeight();
            int width = event.getWidth();

            if (w.getWidget() != null) {
                w.setHeight((height) + "px");
                w.setWidth((width) + "px");
                vp.setHeight((height - 20) + "px");
                vp.setWidth((width - 20) + "px");
                tabPanel.setHeight((height - 20) + "px");
                tabPanel.setWidth((width - 20) + "px");
                menu.setWidth((width) + "px");
                textArea.setWidth((width - 20) + "px");
            }

        }
    });

    MenuItem gwtMenuItem = new MenuItem("GWT output", new Command() {

        public void execute() {
            String xml = textArea.getText();
            if (xml == null || xml.length() == 0) {
                MessageBox.error("Try me:Error", "There is no input");
            } else {
                MainFactoryActions.processUIXml(xml);
            }

        }
    });
    MenuItem flexMenuItem = new MenuItem("Flex output", new Command() {

        public void execute() {
            String xml = textArea.getText();
            if (xml == null || xml.length() == 0) {
                MessageBox.error("Try me:Error", "There is no input");
            } else {
                MainFactoryActions.processUIXmlFlex(xml);
            }

        }
    });

    renderMenu.addItem(gwtMenuItem);
    renderMenu.addItem(flexMenuItem);

    MenuBar codeMenu = new MenuBar(true);

    MenuItem clearXmlInput = new MenuItem("Clear", new Command() {

        public void execute() {
            textArea.setText("");

        }
    });

    MenuItem createHeaderButton = new MenuItem("Create Header", new Command() {

        public void execute() {
            final String headerText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                    + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n"
                    + "  <!-- PLEASE ENTER YOUR CODE HERE --> \n" + "</application-mapping> \n";

            textArea.setText(headerText);

        }
    });

    MenuItem createSampleAppButton = new MenuItem("Create Sample Application", new Command() {

        public void execute() {
            final String sampleText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                    + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n"
                    + "<presentation-tier>\n" + "  <view>\n"
                    + "    <window id=\"window1\" displayname=\"Hello World\" width=\"200\" height=\"200\">\n"
                    + "      <rootpanel id=\"myRootPanel\">   \n" + "        <verticallayout>\n\n"
                    + "          <!-- PLEASE ENTER HERE YOUR CODE -->\n\n"
                    + "          <label id=\"mylabel\" displayname=\"Hello World\" />\n\n"
                    + "        </verticallayout>\n" + "      </rootpanel>\n" + "    </window>\n" + " </view>\n"
                    + "</presentation-tier>\n" +

                    "</application-mapping> \n";

            textArea.setText(sampleText);

        }
    });

    codeMenu.addItem(clearXmlInput);
    codeMenu.addItem(createHeaderButton);
    codeMenu.addItem(createSampleAppButton);

    menu.addItem("Render", renderMenu);
    menu.addItem("Code", codeMenu);

    if (menu != null) {
        verticalPanel.add(menu);
    }
    verticalPanel.add(vp);

    // w.setWidget(tabPanel);

    /*
     * FMB Upload
     */
    final FormPanel fmbForm = new FormPanel();
    fmbForm.setAction(GWT.getModuleBaseURL() + "/rpc.fmbupload");

    // Because we're going to add a FileUpload widget, we'll need to set the
    // form to use the POST method, and multipart MIME encoding.
    fmbForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    fmbForm.setMethod(FormPanel.METHOD_POST);
    // Create a panel to hold all of the form widgets.
    VerticalPanel panelFmbUpload = new VerticalPanel();
    panelFmbUpload.setWidth("580px");
    panelFmbUpload.setHeight("500px");
    // panelFmbUpload.setHeight("100%");

    final FileUpload fmbFile = new FileUpload();
    final TextBox emailBox = new TextBox();
    final TextBox phoneBox = new TextBox();
    fmbFile.setName("fmbUploadElement");

    // Add an event handler to the form.
    fmbForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {

            if (event.getResults() != null) {
                if (event.getResults().startsWith("Conversion failed")) {
                    ClientApplicationContext.getInstance().log("Conversion failed",
                            "The file doesn't seem to be a valid Oracle Forms file. If you still want it to be converted for demo purpose, you can also send it to info@qafe.com",
                            true);

                } else if (event.getResults().startsWith("UUID")) {

                    String[] split = event.getResults().split("=");
                    if (split.length == 2) {
                        String uuid = split[1];
                        MainFactoryActions.processUIByUUID(uuid, textArea);
                        MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]",
                                "The message was sent by " + emailBox.getText() + " with optional phonenr: "
                                        + phoneBox.getText());
                        tabPanel.selectTab(0);
                    }
                } else {
                    // firefox workaround
                    String[] split = event.getResults().split("=");
                    if (split.length == 2) {
                        String uuid = split[1];

                        uuid = uuid.replaceAll("</pre>", "");
                        MainFactoryActions.processUIByUUID(uuid, textArea);
                        MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]",
                                "The message was sent by " + emailBox.getText() + " with optional phonenr: "
                                        + phoneBox.getText());
                        tabPanel.selectTab(0);
                    } else {
                        ClientApplicationContext.getInstance().log(event.getResults());
                    }
                }

            } else {
                ClientApplicationContext.getInstance().log(
                        "The Forms Conversion process could not handle this file. Please check the file.",
                        "Check whether or not this file is an FMB (not an FMX)", true);
            }
        }
    });

    FlexTable tempFmbPanel = new FlexTable();
    tempFmbPanel.setWidget(0, 1, fmbFile);
    tempFmbPanel.setWidget(0, 0, new Label("Input for FMB"));

    tempFmbPanel.setWidget(1, 0, new HTML(
            "<p>Note: the FMB you are uploading is only for <span style=\"color:red;\">demo</span> purpose.</p>"
                    + "<p>FMB's can have external dependencies like <span style=\"color:red;\">PLL, OLB's, images</span>,etc. Since they are <span style=\"color:red;\">not</span> included in the upload, the output might not appear correct.</p>"
                    + "<p>For a more detailed conversion of your FMB's please contact us at <span style=\"color:red;\">info@qafe.com </span></p> <p/>"
                    + "<p>Please fill in the information below, so that we can contact you for more information</p> "));
    tempFmbPanel.getFlexCellFormatter().setColSpan(1, 0, 2);

    tempFmbPanel.setWidget(2, 0, new Label("E-mail: (required)"));

    emailBox.setName("fmbEmail");
    emailBox.addBlurHandler(new BlurHandler() {

        public void onBlur(BlurEvent event) {
            String textValue = ((TextBoxBase) event.getSource()).getText();
            if (textValue != null) {
                if (textValue.replaceFirst(TextFieldGVO.REGEXP_TYPE_EMAIL_VALUE, "").length() > 0) {
                    ClientApplicationContext.getInstance().log("Email validation error",
                            TextFieldGVO.TYPE_EMAIL_DEFAULT_MESSAGE, true);
                }
            }

        }
    });
    tempFmbPanel.setWidget(2, 1, emailBox);

    tempFmbPanel.setWidget(3, 0, new Label("Phonenr:"));

    phoneBox.setName("fmbPhone");
    phoneBox.addBlurHandler(new BlurHandler() {

        public void onBlur(BlurEvent event) {

        }
    });
    tempFmbPanel.setWidget(3, 1, phoneBox);

    fmbForm.add(tempFmbPanel);

    panelFmbUpload.add(fmbForm);
    // Add a 'submit' button.
    panelFmbUpload.add(new Button("Generate", new ClickHandler() {

        public void onClick(ClickEvent event) {
            fmbForm.submit();

        }
    }));
    // Add an event handler to the form.
    fmbForm.addSubmitHandler(new FormPanel.SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            // This event is fired just before the form is submitted. We can take
            // this opportunity to perform validation.
            if (emailBox.getText().length() == 0) {
                ClientApplicationContext.getInstance().log("Email validation error",
                        "Please fill in your email address", true);
                event.cancel();
            } else if (fmbFile.getFilename() == null || fmbFile.getFilename().length() == 0) {
                ClientApplicationContext.getInstance().log("Uploaded file validation error",
                        "There is no file selected. Please select one to continue", true);
                event.cancel();
            }
        }
    });

    tabPanel.add(panelFmbUpload, "Forms Conversion");

    vp.add(tabPanel);
    w.center();
    if (QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME_FORMS.equals(subwindow)) {
        tabPanel.selectTab(1);

    } else {
        tabPanel.selectTab(0);
    }
}

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

License:Apache License

public UIObject render(ComponentGVO component, String uuid, String parent, String context) {
    TabPanel uiObject = null;
    if (component != null) {
        if (component instanceof TabPanelGVO) {
            TabPanelGVO gvo = (TabPanelGVO) component;
            if (gvo.getMenu() != null) {
                final ComponentGVO finalComponentGVO = component;
                final String finalUuid = uuid;
                final String finalParent = parent;
                uiObject = new TabPanel() {

                    @Override/*from  w ww . j ava2s.c o  m*/
                    public void onBrowserEvent(Event event) {
                        if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                            DOM.eventPreventDefault(event);
                            applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                        }
                        super.onBrowserEvent(event);
                    }

                    @Override
                    protected void setElement(Element elem) {
                        super.setElement(elem);
                        sinkEvents(Event.ONCONTEXTMENU);
                    }
                };
            } else {
                uiObject = new TabPanel();
            }
            uiObject.setAnimationEnabled(gvo.isAnimationEnabled());
            RendererHelper.fillIn(component, uiObject, uuid, parent, context);

            TabGVO[] tabs = gvo.getTabs();
            if (tabs != null) {
                for (int i = 0; i < tabs.length; i++) {
                    TabGVO tabGVO = tabs[i];

                    // since the panel renderer is used, the title (not null) will create a titledPanel.
                    // The tab already has the title so that is overkill
                    String title = tabGVO.getTitle();
                    tabGVO.setTitle(null);
                    UIObject tabUI = renderChildComponent(tabGVO, uuid, parent, context);
                    tabGVO.setTitle(title);

                    if (tabUI instanceof Widget) {
                        uiObject.add((Widget) tabUI, title);
                        setTabVisibility(uiObject, i, tabGVO.getVisible(), tabUI);

                        int tabCount = uiObject.getTabBar().getTabCount();
                        UIObject tabComponent = (UIObject) uiObject.getTabBar().getTab(tabCount - 1);
                        RendererHelper.addAttributesRequiredByEventHandling(tabGVO, tabComponent, uuid, parent,
                                context);
                        RendererHelper.addEvents(tabGVO, tabComponent, uuid);
                    }
                }
            }

            if (uiObject.getWidgetCount() > 0) {
                uiObject.selectTab(0);
            }
        }
    }
    return uiObject;
}

From source file:com.qualogy.qafe.gwt.client.vo.handlers.FocusHandler.java

License:Apache License

private void makeParentVisible(Widget widget) {
    if (widget == null) {
        return;/*from ww w  .j ava2  s  . c o m*/
    }
    Widget parent = widget.getParent();
    if (parent == null) {
        return;
    }
    makeParentVisible(parent);
    if (parent instanceof DeckPanel) {
        DeckPanel deckPanel = (DeckPanel) parent;
        int widgetIndex = deckPanel.getWidgetIndex(widget);
        deckPanel.showWidget(widgetIndex);
        TabPanel tabPanel = (TabPanel) deckPanel.getParent().getParent();
        tabPanel.selectTab(widgetIndex);
    }
}

From source file:com.sciencegadgets.client.NavigationPanelEntry.java

License:Open Source License

@Override
public void onModuleLoad() {

    scrollInTabAbout.setWidth("60em");
    scrollInTabGetIt.setWidth("60em");
    scrollInTabRoadMap.setWidth("60em");
    scrollInTabContact.setWidth("60em");

    scrollInTabAbout.setHeight("20em");
    scrollInTabGetIt.setHeight("20em");
    scrollInTabRoadMap.setHeight("20em");
    scrollInTabContact.setHeight("20em");

    TabPanel tp = new TabPanel();
    tp.add(makeAbout(), "About");
    tp.add(makeGetIt(), "Get it");
    tp.add(makeRoadmap(), "Roadmap");
    tp.add(makeContacts(), "Contact");

    // Show the 'bar' tab initially.
    tp.selectTab(0);

    // Add it to the root panel.
    RootPanel.get("navigationArea").add(tp);
}

From source file:com.xpn.xwiki.cbdf.client.CBDF.java

License:Open Source License

private void showPopUpStroke() {
    final PopupPanel popupStroke = new PopupPanel(true);
    popupStroke.addStyleName("color_Pop-up");

    TabPanel tabPanel = new TabPanel();

    tabPanel.add(this.currentStrokeSize, new Label("Stroke"));
    tabPanel.selectTab(0);

    popupStroke.add(tabPanel);/*w  w  w .j a  v  a  2 s . co m*/
    popupStroke.setPopupPosition(this.strokeButton.getAbsoluteLeft(), this.strokeButton.getAbsoluteTop());
    popupStroke.show();
}